FreeHIL
Loading...
Searching...
No Matches
FH_RFCommunication_Configs.h File Reference

File Map:
FH_Setup, Section FH_RFCommunication
The micro-controller on which FH source code is ported, could be simply utilized in a RS485 network
In other word, multiple devices or multiple cards could be simply utilized where every device or every card has its own address
Address of the device (or card) for every device (or card) is set by FH user in FH_DeviceAddress.h
An interested UART (called Communication Dedicated UART) by the FH user for the communication between RobotFramework and the micro-controller on which FH source code is ported, shall be dedicated
Different configuration on the communication between RobotFramework and the micro-controller are defined here More...

Go to the source code of this file.

Macros

#define FH_RFCommunication_MinCommandSize   5
#define FH_RFCommunication_ReceiveBufLength   255 + FH_RFCommunication_MinCommandSize
#define FH_RFCommunication_ReceiveBufMaxTimeout   100
#define FH_RFCommunication_SendBufLength   255 + FH_RFCommunication_MinCommandSize

Enumerations

enum  FH_RFCommunication_Commandelements {
  RFCommunication_DeviceAddress = 0 , RFCommunication_Function = 1 , RFCommunication_Command = 2 , RFCommunication_DataLength = 3 ,
  RFCommunication_Data = 4
}
enum  FH_RFCommunication_Function {
  RFCommunication_Function_DO = 0 , RFCommunication_Function_DI = 1 , RFCommunication_Function_AO = 2 , RFCommunication_Function_AI = 3 ,
  RFCommunication_Function_PWMO = 4 , RFCommunication_Function_PWMI = 5 , RFCommunication_Function_UART = 6 , RFCommunication_Function_CAN = 7
}
enum  FH_RFCommunication_State {
  RFCommunication_STATE_IDLE = 0 , RFCommunication_STATE_DeviceAddress , RFCommunication_STATE_Function , RFCommunication_STATE_Command ,
  RFCommunication_STATE_DataLength , RFCommunication_STATE_Data , RFCommunication_STATE_Checksum , RFCommunication_STATE_MessageReceived
}

Detailed Description

File Map:
FH_Setup, Section FH_RFCommunication
The micro-controller on which FH source code is ported, could be simply utilized in a RS485 network
In other word, multiple devices or multiple cards could be simply utilized where every device or every card has its own address
Address of the device (or card) for every device (or card) is set by FH user in FH_DeviceAddress.h
An interested UART (called Communication Dedicated UART) by the FH user for the communication between RobotFramework and the micro-controller on which FH source code is ported, shall be dedicated
Different configuration on the communication between RobotFramework and the micro-controller are defined here

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_RFCommunication_Configs.h.

Macro Definition Documentation

◆ FH_RFCommunication_MinCommandSize

#define FH_RFCommunication_MinCommandSize   5

FH_RFCommunication_MinCommandSize is the minimum size of the message frame (FH_RFCommunication_Message) from RobotFramework (When DataLength is zero and there is no Data)
The minimum size includes the following items: 1 - DeviceAddress (1 byte) 2 - Function (1 byte) 3 - Command (1 byte) 4 - DataLength (1 byte) which is 0 for minimum size message 5 - Data (0 byte) which is not available for minimum size message 6 - Checksum (1 byte) => Total 5 bytes of data

Definition at line 55 of file FH_RFCommunication_Configs.h.

Referenced by FH_RFCommunication_Receive().

◆ FH_RFCommunication_ReceiveBufLength

#define FH_RFCommunication_ReceiveBufLength   255 + FH_RFCommunication_MinCommandSize

FH_RFCommunication_ReceiveBufLength is the receive buffer length of the buffer which is filled in the ISR (Interrupt Service Routine) Communication Dedicated UART
255 is added to FH_RFCommunication_MinCommandSize to guarantee the maximum possible Data Length of 255 bytes in the Data part of the message

Definition at line 61 of file FH_RFCommunication_Configs.h.

◆ FH_RFCommunication_ReceiveBufMaxTimeout

#define FH_RFCommunication_ReceiveBufMaxTimeout   100

If at least one byte of data is received through the ISR (Interrupt Service Routine) of the Communication Dedicated UART by the FH user, a complete message shall be received in a maximum defined timeout
The received data in the ISR (Interrupt Service Routine) will be ignored if the complete message will not be received within the defined timeout\nFor this to happen, FH_GlobalTimeCounter is utilized to calculate the maximum timeout
FH_RFCommunication_ReceiveBufMaxTimeout is the defined maximum timeout for every byte
In the ISR (Interrupt Service Routine) of the Communication Dedicated UART by the FH user, FH_GlobalTimeCounter shall be reset after receiving every byte of data
For example, 100 is set to have 100ms timeout (When the heart beat of the system is 1 mili-second) to receive a complete message when there is no longer any data being received

Definition at line 70 of file FH_RFCommunication_Configs.h.

Referenced by FH_RFCommunication_Receive().

◆ FH_RFCommunication_SendBufLength

#define FH_RFCommunication_SendBufLength   255 + FH_RFCommunication_MinCommandSize

Definition at line 72 of file FH_RFCommunication_Configs.h.

Referenced by FH_CAN_RFCommunication(), and FH_UART_RFCommunication().

Enumeration Type Documentation

◆ FH_RFCommunication_Commandelements

FH_RFCommunication_Commandelements includes the position of different parts of the message in the message frame (FH_RFCommunication_Message) Since the Data part may have different sizes, the checksum position may be different

Enumerator
RFCommunication_DeviceAddress 

The 1st data in the message frame is the DeviceAddress
If a message (from RobotFramework) with a different DeviceAddress than the one set in FH_DeviceAddress.h is received, it will be ignored and not processed

RFCommunication_Function 

The 2nd data in the message frame is the Function
Function could be DO (Digital Output), DI (Digital Input), AO (Anolog Output), AI (Analog Input), UART, CAN , ... in FH_RFCommunication_Function

RFCommunication_Command 

The 3rd data in the message frame is the Command
There are different commands for DO (Digital Output), DI (Digital Input), AO (Anolog Output), AI (Analog Input), UART, CAN , ...
For example for DO (Digital Output), different commands are available in FH_DO_Configs.h

RFCommunication_DataLength 

The 4th data in the message frame is the DataLength
It is the length of the Data in the message frame
Since DataLength is just one byte, Data bytes can't be more than 255

RFCommunication_Data 

The Data could be from 0 byte to up to (FH_RFCommunication_ReceiveBufLength - FH_RFCommunication_MinCommandSize) bytes
Since DataLength is just one byte, Data bytes can't be more than 255
FH_RFCommunication_ReceiveBufLength and FH_RFCommunication_MinCommandSize are configurable in this file (FH_RFCommunication_Configs.h)

Definition at line 78 of file FH_RFCommunication_Configs.h.

◆ FH_RFCommunication_Function

FH_RFCommunication_Function includes different possible functions of the message in the message frame (FH_RFCommunication_Message)

Enumerator
RFCommunication_Function_DO 

DO (Digital Output)

RFCommunication_Function_DI 

DI (Digital Input)

RFCommunication_Function_AO 

AO (Analog Output)

RFCommunication_Function_AI 

AI (Analog Input)

RFCommunication_Function_PWMO 

PWMO (PWM Output)

RFCommunication_Function_PWMI 

PWMI (PWM Input)

RFCommunication_Function_UART 

UART

RFCommunication_Function_CAN 

CAN

Definition at line 117 of file FH_RFCommunication_Configs.h.

◆ FH_RFCommunication_State

FH_RFCommunication_Message is the structure for receiving the message frame from RobotFramework
FH_RFCommunication_State is the enumeration utilized as state machine to collect the different blocks of the message frame from RobotFramework
It is initialized with RFCommunication_STATE_IDLE to be ready to collect a new message from RobotFramework

Enumerator
RFCommunication_STATE_IDLE 

State to receive a new message

RFCommunication_STATE_DeviceAddress 

State to receive DeviceAddress

RFCommunication_STATE_Function 

State to receive Function

RFCommunication_STATE_Command 

State to receive Command

RFCommunication_STATE_DataLength 

State to receive DataLength

RFCommunication_STATE_Data 

State to receive Data

RFCommunication_STATE_Checksum 

State to receive Checksum

RFCommunication_STATE_MessageReceived 

State to indicate a complete message is already received

Definition at line 158 of file FH_RFCommunication_Configs.h.