FreeHIL
Loading...
Searching...
No Matches
FH_DI_GetStatus_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_DI</b> (Digital Input), <b>Cmd</b> (Command), <b>GetStatus</b>, <b>GetStatus_H</b> (GetStatus Health)\n
6
* Functions in this file, verify the health of the different message frames related to <b>DI</b> (Digital Input)
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_DI/Cmd/GetStatus/GetStatus_H/FH_DI_GetStatus_H.h"
35
36
#include "../../../../../../../FH_Embedded/FH_Root/FH_General/FH_GeneralFunctions/FH_GeneralFunctions.h"
37
#include "
../../../../../../../FH_Embedded/FH_Setup/FH_DeviceAddress/FH_DeviceAddress.h
"
38
39
#if FH_DI_MaxPeripheralNumber > 0
// It is configurable in FH_DevicePeripherals.h
40
41
/**
42
* @brief This function verifies the health of <b>FH_DI_Commands_GetStatus</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 ${DI01}
52
&{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_DI} Command=${DI_Commands_GetStatus} Data=@{MessageData}
53
${Result} SendMessage &{Message}
54
55
Comments:
56
57
DI01 => It indicates the Digital Input 01
58
DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
59
Function_DI => It is the function in the message frame
60
DI_Commands_GetStatus => It is the command of the function in the message frame
61
@endverbatim
62
*
63
* @return FH_ErrorInfo is returned
64
*
65
66
*/
67
FH_ErrorInfo
FH_DI_GetStatus_H(
FH_RFCommunication_Message
*
fh_RFCommunication_Message
)
68
{
69
FH_ErrorInfo
fh_ErrorInfo;
// Error Information
70
FH_ResetErrorInfo
(&fh_ErrorInfo);
// Reset Error Information to default
71
72
uint8_t FH_MessageDataLength;
// It temporarily stores the DataLength in the message frame
73
uint8_t FH_PeripheralNumber;
// It temporarily stores the PeripheralNumber (Data[0]) in the message frame
74
75
// Verifying the minimum possible length in the message frame
76
FH_MessageDataLength =
fh_RFCommunication_Message
-> DataLength;
77
if
(FH_MessageDataLength <
FH_DI_MinCommandSize_GetStatus
)
// If the length is less than expected value
78
{
79
fh_ErrorInfo.
error_code
=
FH_ERROR_MessageFrame
;
// There is message frame error
80
return
fh_ErrorInfo;
81
}
82
83
// Verifying the possible PeripheralNumber in the message frame
84
FH_PeripheralNumber =
fh_RFCommunication_Message
-> Data[0];
85
if
(FH_PeripheralNumber == 0 || FH_PeripheralNumber >
FH_DI_MaxPeripheralNumber
)
// If the PeripheralNumber is not within the expected value
86
{
87
fh_ErrorInfo.
error_code
=
FH_ERROR_MessageFrame
;
// There is message frame error
88
return
fh_ErrorInfo;
89
}
90
91
fh_ErrorInfo.
error_code
=
FH_ERROR_OK
;
// There is no error
92
return
fh_ErrorInfo;
93
}
94
95
/**
96
* @brief This function verifies the health of <b>FH_DI_Commands_GetStatusMULTI</b> command
97
*
98
* @param fh_RFCommunication_Message
99
* The message frame set by <b>RobotFramework</b>
100
*
101
* @verbatim
102
==============================================================================
103
##### RobotFramework Example #####
104
==============================================================================
105
@{MessageData} = Create List FF FF FF FF FF FF FF FF
106
&{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_DI} Command=${DI_Commands_GetStatusMULTI} Data=@{MessageData}
107
${Result} SendMessage &{Message}
108
109
Comments:
110
111
FF FF FF FF FF FF FF FF => Example data as the first 8 parameters
112
DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
113
Function_DI => It is the function in the message frame
114
DI_Commands_GetStatusMULTI => It is the command of the function in the message frame
115
@endverbatim
116
*
117
* @return FH_ErrorInfo is returned
118
*
119
120
*/
121
FH_ErrorInfo
FH_DI_GetStatusMULTI_H(
FH_RFCommunication_Message
*
fh_RFCommunication_Message
)
122
{
123
FH_ErrorInfo
fh_ErrorInfo;
// Error Information
124
FH_ResetErrorInfo
(&fh_ErrorInfo);
// Reset Error Information to default
125
126
uint8_t FH_MessageDataLength;
// It temporarily stores the DataLength in the message frame
127
128
// Verifying the minimum possible length in the message frame
129
FH_MessageDataLength =
fh_RFCommunication_Message
-> DataLength;
130
if
(FH_MessageDataLength <
FH_DI_MinCommandSize_GetStatusMULTI
)
// If the length is less than expected value
131
{
132
fh_ErrorInfo.
error_code
=
FH_ERROR_MessageFrame
;
// There is message frame error
133
return
fh_ErrorInfo;
134
}
135
136
fh_ErrorInfo.
error_code
=
FH_ERROR_OK
;
// There is no error
137
return
fh_ErrorInfo;
138
}
139
140
#endif
Core
FH_Embedded
FH_Root
FH_Perif
FH_DI
Cmd
GetStatus
GetStatus_H
FH_DI_GetStatus_H.c
Generated by
1.15.0