FreeHIL
Loading...
Searching...
No Matches
FH_DO_SetStatus_H.c
Go to the documentation of this file.
1/**
2 * @file
3 * @brief
4 * <b>File Map:</b>\n
5 * <b>FH_Root</b>, Section <b>FH_Perif</b>, <b>FH_DO</b> (Digital Output), <b>Cmd</b> (Command), <b>SetStatus</b>, <b>SetStatus_H</b> (SetStatus Health)\n
6 * Functions in this file, verify the health of the different message frames related to <b>DO</b> (Digital Output)
7 *
8 * @attention <b>FH</b> user could left this file intact
9 *
10 *******************************************************************************
11 * SPDX-License-Identifier: Apache-2.0
12 *
13 * Copyright 2026 Vahid Hasirchi
14 *
15 * Licensed under the Apache License, Version 2.0 (the "License");
16 * you may not use this file except in compliance with the License.
17 * You may obtain a copy of the License at
18 *
19 * http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing, software
22 * distributed under the License is distributed on an "AS IS" BASIS,
23 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24 * See the License for the specific language governing permissions and
25 * limitations under the License.
26 ********************************************************************************
27
28 *
29 * <b>For more information refer to FreeHIL.com</b>
30 *
31*/
32
33/* Includes ------------------------------------------------------------------*/
34#include "../../../../../../../FH_Embedded/FH_Root/FH_Perif/FH_DO/Cmd/SetStatus/SetStatus_H/FH_DO_SetStatus_H.h"
35
36#include "../../../../../../../FH_Embedded/FH_Root/FH_General/FH_GeneralFunctions/FH_GeneralFunctions.h"
38
39#if FH_DO_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
40
41/**
42 * @brief This function verifies the health of <b>FH_DO_Commands_SetStatus</b> command
43 *
44 * @param fh_RFCommunication_Message
45 * The message frame set by <b>RobotFramework</b>
46 *
47 * @verbatim
48 ==============================================================================
49 ##### RobotFramework Example #####
50 ==============================================================================
51 @{MessageData} = Create List ${DO01} ${DO_Set}
52 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_DO} Command=${DO_Commands_SetStatus} Data=@{MessageData}
53 ${Result} SendMessage &{Message}
54
55 Comments:
56
57 DO01 => It indicates the Digital Output 01
58 DO_Set => It indicates the Digital Output 01 shall be Set (DO_Reset indicates the Digital Output 01 shall be Reset)
59 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
60 Function_DO => It is the function in the message frame
61 DO_Commands_SetStatus => It is the command of the function in the message frame
62 @endverbatim
63 *
64 * @return FH_ErrorInfo is returned
65 *
66
67*/
69{
70 FH_ErrorInfo fh_ErrorInfo; // Error Information
71 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
72
73 uint8_t FH_MessageDataLength; // It temporarily stores the DataLength in the message frame
74 uint8_t FH_PeripheralNumber; // It temporarily stores the PeripheralNumber (Data[0]) in the message frame
75 uint8_t FH_Status; // It temporarily stores the Status (Data[1]) in the message frame
76
77 // Verifying the minimum possible length in the message frame
78 FH_MessageDataLength = fh_RFCommunication_Message -> DataLength;
79 if (FH_MessageDataLength < FH_DO_MinCommandSize_SetStatus) // If the length is less than expected value
80 {
81 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
82 return fh_ErrorInfo;
83 }
84
85 // Verifying the possible PeripheralNumber in the message frame
86 FH_PeripheralNumber = fh_RFCommunication_Message -> Data[0];
87 if (FH_PeripheralNumber == 0 || FH_PeripheralNumber > FH_DO_MaxPeripheralNumber) // If the PeripheralNumber is not within the expected value
88 {
89 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
90 return fh_ErrorInfo;
91 }
92
93 // Verifying the possible Status in the message frame
94 FH_Status = fh_RFCommunication_Message -> Data[1];
95 if (FH_Status != 0 && FH_Status != 1) // If the Status is not within the expected value
96 {
97 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
98 return fh_ErrorInfo;
99 }
100
101 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no error
102 return fh_ErrorInfo;
103}
104
105/**
106 * @brief This function verifies the health of <b>FH_DO_Commands_SetStatusMULTI</b> command
107 *
108 * @param fh_RFCommunication_Message
109 * The message frame set by <b>RobotFramework</b>
110 *
111 * @verbatim
112 ==============================================================================
113 ##### RobotFramework Example #####
114 ==============================================================================
115 @{MessageData} = Create List FF FF FF FF FF FF FF FF 01 02 03 04 05 06 07 08
116 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_DO} Command=${DO_Commands_SetStatusMULTI} Data=@{MessageData}
117 ${Result} SendMessage &{Message}
118
119 Comments:
120
121 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
122 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)
123 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
124 Function_DO => It is the function in the message frame
125 DO_Commands_SetStatusMULTI => It is the command of the function in the message frame
126 @endverbatim
127 *
128 * @return FH_ErrorInfo is returned
129 *
130
131*/
133{
134 FH_ErrorInfo fh_ErrorInfo; // Error Information
135 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
136
137 uint8_t FH_MessageDataLength; // It temporarily stores the DataLength in the message frame
138
139 // Verifying the minimum possible length in the message frame
140 FH_MessageDataLength = fh_RFCommunication_Message -> DataLength;
141 if (FH_MessageDataLength < FH_DO_MinCommandSize_SetStatusMULTI) // If the length is less than expected value
142 {
143 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
144 return fh_ErrorInfo;
145 }
146
147 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no error
148 return fh_ErrorInfo;
149}
150
151#endif