FreeHIL
Loading...
Searching...
No Matches
FH_DO.c File Reference

File Map:
FH_Root, Section FH_Perif, FH_DO (Digital Output)
Functions in this file, handle RFCommunication (RobotFramework Communication) for all commands related to DO (Digital Output) More...

Go to the source code of this file.

Functions

FH_ErrorInfo FH_DO_RFCommunication (FH_RFCommunication_Message *fh_RFCommunication_Message)
 This function is the basic function of handling RFCommunication (RobotFramework Communication) for all the Commands related to the Function DO (Digital Output)
This function is called from FH_RFCommunication().
FH_ErrorInfo FH_DO_ProcessCommand_Init (FH_RFCommunication_Message *fh_RFCommunication_Message)
 This function handles FH_DO_Commands_Init command
There are 3 main items handled in this function as following:
1 - Verifying the health of the received message
2 - Setting the addresses of the functions in FH_Functions, Section FH_DO (Digital Output) to an array of function pointer
3 - Calling the related function in FH_Functions, Section FH_DO (Digital Output) according to the first parameter of the Data in the message frame.
FH_ErrorInfo FH_DO_ProcessCommand_SetStatus (FH_RFCommunication_Message *fh_RFCommunication_Message)
 This function handles FH_DO_Commands_SetStatus command
There are 3 main items handled in this function as following:
1 - Verifying the health of the received message
2 - Setting the addresses of the functions in FH_Functions, Section FH_DO (Digital Output) to an array of function pointer
3 - Calling the related function in FH_Functions, Section FH_DO (Digital Output) according to the first parameter of the Data in the message frame (The second parameter resemble the digital data to be set as 1 or 0).
FH_ErrorInfo FH_DO_ProcessCommand_InitMULTI (FH_RFCommunication_Message *fh_RFCommunication_Message)
 This function handles FH_DO_ProcessCommand_InitMULTI command
With this function, mass initialization of up to 64 DO (Digital Output) is possible instead of just 1 DO (Digital Output)
There are 3 main items handled in this function as following:
1 - Verifying the health of the received message
2 - Setting the addresses of the functions in FH_Functions, Section FH_DO (Digital Output) to an array of function pointer
3 - Calling the related function(s) in FH_Functions, Section FH_DO (Digital Output) according to the 8 first parameters of the Data in the message frame (The first 8 bytes resemble 64 bits and each bit resembles 1 DO (Digital Output) and if the bit is 1, the related DO (Digital Output) function will be called).
FH_ErrorInfo FH_DO_ProcessCommand_SetStatusMULTI (FH_RFCommunication_Message *fh_RFCommunication_Message)
 This function handles FH_DO_ProcessCommand_SetStatusMULTI command
With this function, mass status set of up to 64 DO (Digital Output) is possible instead of just 1 DO (Digital Output)
There are 3 main items handled in this function as following:
1 - Verifying the health of the received message
2 - Setting the addresses of the functions in FH_Functions, Section FH_DO (Digital Output) to an array of function pointer
3 - Calling the related function in FH_Functions, Section FH_DO (Digital Output) according to the 16 first parameters of the Data in the message frame
(The first 8 bytes as mask resemble 64 bits and each bit resembles 1 DO (Digital Output) and if the bit is 1, the related DO (Digital Output) function will be called)
(The second 8 bytes as data resemble 64 bits and each bit resembles status of 1 DO (Digital Output) as 1 or 0 of the corresponding bit in the first 8 bytes).

Detailed Description

File Map:
FH_Root, Section FH_Perif, FH_DO (Digital Output)
Functions in this file, handle RFCommunication (RobotFramework Communication) for all commands related to DO (Digital Output)

Attention
FH user could left this file intact

SPDX-License-Identifier: Apache-2.0

Copyright 2026 Vahid Hasirchi

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

For more information refer to FreeHIL.com

Definition in file FH_DO.c.

Function Documentation

◆ FH_DO_ProcessCommand_Init()

FH_ErrorInfo FH_DO_ProcessCommand_Init ( FH_RFCommunication_Message * fh_RFCommunication_Message)

This function handles FH_DO_Commands_Init command
There are 3 main items handled in this function as following:
1 - Verifying the health of the received message
2 - Setting the addresses of the functions in FH_Functions, Section FH_DO (Digital Output) to an array of function pointer
3 - Calling the related function in FH_Functions, Section FH_DO (Digital Output) according to the first parameter of the Data in the message frame.

Parameters
fh_RFCommunication_MessageThe message frame set by RobotFramework
  ==============================================================================
                        ##### RobotFramework Example #####
  ==============================================================================
  @{MessageData} =    Create List    ${DO01}
  &{Message}     =    Create Dictionary    DeviceAddress=${DeviceAddress_01}    Function=${Function_DO}    Command=${DO_Commands_Init}    Data=@{MessageData}
  ${Result}    SendMessage    &{Message}

  Comments:

  DO01 => It indicates the Digital Output 01
  DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
  Function_DO => It is the function in the message frame
  DO_Commands_Init => It is the command of the function in the message frame
Returns
FH_ErrorInfo is returned

Definition at line 125 of file FH_DO.c.

References FH_ErrorInfo::error_code, FH_DO_Init_C(), FH_DO_Init_H(), FH_DO_Init_S(), FH_DO_MaxPeripheralNumber, FH_ERROR_OK, FH_ResetErrorInfo(), and fh_RFCommunication_Message.

Referenced by FH_DO_RFCommunication().

◆ FH_DO_ProcessCommand_InitMULTI()

FH_ErrorInfo FH_DO_ProcessCommand_InitMULTI ( FH_RFCommunication_Message * fh_RFCommunication_Message)

This function handles FH_DO_ProcessCommand_InitMULTI command
With this function, mass initialization of up to 64 DO (Digital Output) is possible instead of just 1 DO (Digital Output)
There are 3 main items handled in this function as following:
1 - Verifying the health of the received message
2 - Setting the addresses of the functions in FH_Functions, Section FH_DO (Digital Output) to an array of function pointer
3 - Calling the related function(s) in FH_Functions, Section FH_DO (Digital Output) according to the 8 first parameters of the Data in the message frame (The first 8 bytes resemble 64 bits and each bit resembles 1 DO (Digital Output) and if the bit is 1, the related DO (Digital Output) function will be called).

Parameters
fh_RFCommunication_MessageThe message frame set by RobotFramework
  ==============================================================================
                        ##### RobotFramework Example #####
  ==============================================================================
  @{MessageData} =    Create List    FF    FF    FF    FF    FF    FF    FF    FF
  &{Message}     =    Create Dictionary    DeviceAddress=${DeviceAddress_01}    Function=${Function_DO}    Command=${DO_Commands_InitMULTI}    Data=@{MessageData}
  ${Result}    SendMessage    &{Message}

  Comments:

  FF    FF    FF    FF    FF    FF    FF    FF => Example data as the first 8 parameters of the Data in the message frame utilized as mask (In this example it means all 64 digital outputs shall be initialized)
  DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
  Function_DO => It is the function in the message frame
  DO_Commands_InitMULTI => It is the command of the function in the message frame
Returns
FH_ErrorInfo is returned

Definition at line 234 of file FH_DO.c.

References FH_ErrorInfo::error_code, FH_DO_Init_S(), FH_DO_InitMULTI_C(), FH_DO_InitMULTI_H(), FH_DO_MaxPeripheralNumber, FH_ERROR_OK, FH_ResetErrorInfo(), and fh_RFCommunication_Message.

Referenced by FH_DO_RFCommunication().

◆ FH_DO_ProcessCommand_SetStatus()

FH_ErrorInfo FH_DO_ProcessCommand_SetStatus ( FH_RFCommunication_Message * fh_RFCommunication_Message)

This function handles FH_DO_Commands_SetStatus command
There are 3 main items handled in this function as following:
1 - Verifying the health of the received message
2 - Setting the addresses of the functions in FH_Functions, Section FH_DO (Digital Output) to an array of function pointer
3 - Calling the related function in FH_Functions, Section FH_DO (Digital Output) according to the first parameter of the Data in the message frame (The second parameter resemble the digital data to be set as 1 or 0).

Parameters
fh_RFCommunication_MessageThe message frame set by RobotFramework
  ==============================================================================
                        ##### RobotFramework Example #####
  ==============================================================================
  @{MessageData} =    Create List    ${DO01}    ${DO_Set}
  &{Message}     =    Create Dictionary    DeviceAddress=${DeviceAddress_01}    Function=${Function_DO}    Command=${DO_Commands_SetStatus}    Data=@{MessageData}
  ${Result}    SendMessage    &{Message}

  Comments:

  DO01 => It indicates the Digital Output 01
  DO_Set => It indicates the Digital Output 01 shall be Set (DO_Reset indicates the Digital Output 01 shall be Reset)
  DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
  Function_DO => It is the function in the message frame
  DO_Commands_SetStatus => It is the command of the function in the message frame
Returns
FH_ErrorInfo is returned

Definition at line 180 of file FH_DO.c.

References FH_ErrorInfo::error_code, FH_DO_MaxPeripheralNumber, FH_ERROR_OK, FH_ResetErrorInfo(), and fh_RFCommunication_Message.

Referenced by FH_DO_RFCommunication().

◆ FH_DO_ProcessCommand_SetStatusMULTI()

FH_ErrorInfo FH_DO_ProcessCommand_SetStatusMULTI ( FH_RFCommunication_Message * fh_RFCommunication_Message)

This function handles FH_DO_ProcessCommand_SetStatusMULTI command
With this function, mass status set of up to 64 DO (Digital Output) is possible instead of just 1 DO (Digital Output)
There are 3 main items handled in this function as following:
1 - Verifying the health of the received message
2 - Setting the addresses of the functions in FH_Functions, Section FH_DO (Digital Output) to an array of function pointer
3 - Calling the related function in FH_Functions, Section FH_DO (Digital Output) according to the 16 first parameters of the Data in the message frame
(The first 8 bytes as mask resemble 64 bits and each bit resembles 1 DO (Digital Output) and if the bit is 1, the related DO (Digital Output) function will be called)
(The second 8 bytes as data resemble 64 bits and each bit resembles status of 1 DO (Digital Output) as 1 or 0 of the corresponding bit in the first 8 bytes).

Parameters
fh_RFCommunication_MessageThe message frame set by RobotFramework
  ==============================================================================
                        ##### RobotFramework Example #####
  ==============================================================================
  @{MessageData} =    Create List    FF    FF    FF    FF    FF    FF    FF    FF    01    02    03    04    05    06    07    08
  &{Message}     =    Create Dictionary    DeviceAddress=${DeviceAddress_01}    Function=${Function_DO}    Command=${DO_Commands_SetStatusMULTI}    Data=@{MessageData}
  ${Result}    SendMessage    &{Message}

  Comments:

  FF    FF    FF    FF    FF    FF    FF    FF => Example data as the first 8 parameters of the Data in the message frame utilized as mask (In this example it means all 64 digital outputs shall set status)
  01    02    03    04    05    06    07    08 => Example data as the second 8 parameters of the Data in the message frame as data value of 1 or 0, corresponding to the first 8 bytes)
  DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
  Function_DO => It is the function in the message frame
  DO_Commands_SetStatusMULTI => It is the command of the function in the message frame
Returns
FH_ErrorInfo is returned

Definition at line 291 of file FH_DO.c.

References FH_ErrorInfo::error_code, FH_DO_MaxPeripheralNumber, FH_ERROR_OK, FH_ResetErrorInfo(), and fh_RFCommunication_Message.

Referenced by FH_DO_RFCommunication().

◆ FH_DO_RFCommunication()

FH_ErrorInfo FH_DO_RFCommunication ( FH_RFCommunication_Message * fh_RFCommunication_Message)

This function is the basic function of handling RFCommunication (RobotFramework Communication) for all the Commands related to the Function DO (Digital Output)
This function is called from FH_RFCommunication().

Parameters
fh_RFCommunication_MessageThe message frame set by RobotFramework
Returns
FH_ErrorInfo is returned

Definition at line 61 of file FH_DO.c.

References FH_ErrorInfo::error_code, FH_DO_Commands_Init, FH_DO_Commands_InitMULTI, FH_DO_Commands_SetStatus, FH_DO_Commands_SetStatusMULTI, FH_DO_ProcessCommand_Init(), FH_DO_ProcessCommand_InitMULTI(), FH_DO_ProcessCommand_SetStatus(), FH_DO_ProcessCommand_SetStatusMULTI(), FH_ResetErrorInfo(), FH_RFCommunication_DeviceAddress, fh_RFCommunication_Message, FH_RFCommunication_Send(), and FH_RFCommunication_SendBuf.

Referenced by FH_RFCommunication().