FreeHIL
Loading...
Searching...
No Matches
FH_AI_GetStatus_C.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_AI</b> (Analog Input), <b>Cmd</b> (Command), <b>GetStatus</b>, <b>GetStatus_C</b> (GetStatus Call)\n
6 * Functions in this file, Call the related function in <b>FH_Functions</b>, Section <b>FH_AI</b> (Analog Input) according to the first parameter of the Data in the message frame
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_AI/Cmd/GetStatus/GetStatus_C/FH_AI_GetStatus_C.h"
35
36#include "../../../../../../../FH_Embedded/FH_Root/FH_General/FH_GeneralFunctions/FH_GeneralFunctions.h"
38
39#if FH_AI_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
40
41/**
42 * @brief This function calls the related function in <b>FH_Functions</b>, Section <b>FH_AI</b> (Analog Input) according to the first parameter of the Data in the message frame
43 *
44 * @param fh_RFCommunication_Message
45 * The message frame set by <b>RobotFramework</b>
46 * @param fH_AI_Data
47 * *fH_AI_Data will be set with the value of the related <b>Analog Input</b>
48 * @param fH_AI_GetStatus_FuncPtr
49 * The array of function pointers
50 *
51 * @verbatim
52 ==============================================================================
53 ##### RobotFramework Example #####
54 ==============================================================================
55 @{MessageData} = Create List ${AI01}
56 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_AI} Command=${AI_Commands_GetStatus} Data=@{MessageData}
57 ${Result} SendMessage &{Message}
58
59 Comments:
60
61 AI01 => It indicates the Analog Input 01
62 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
63 Function_AI => It is the function in the message frame
64 AI_Commands_GetStatus => It is the command of the function in the message frame
65 @endverbatim
66 *
67 *
68 * @return FH_ErrorInfo is returned
69 *
70
71*/
72FH_ErrorInfo FH_AI_GetStatus_C (FH_RFCommunication_Message* fh_RFCommunication_Message, uint32_t* fH_AI_Data, FH_AI_GetStatus_FuncPtrModel *fH_AI_GetStatus_FuncPtr)
73{
74 FH_ErrorInfo fh_ErrorInfo; // Error Information
75 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
76
77 for (uint8_t i = 1; i <= FH_AI_MaxPeripheralNumber; i++) // Iteration through all defined peripherals
78 {
79 if (i == fh_RFCommunication_Message -> Data[AI_GetStatus_PeripheralNumber]) // If the PeripheralNumber in the message frame is met
80 {
81 if (fH_AI_GetStatus_FuncPtr[i-1] != NULL_PTR) // If the address of the function is truly assigned
82 {
83 fh_ErrorInfo = fH_AI_GetStatus_FuncPtr[i-1](fh_RFCommunication_Message, fH_AI_Data); // Call the related function
84 }
85 else
86 {
87 fh_ErrorInfo.error_code = FH_ERROR_Root; // There is Root error
88 }
89 return fh_ErrorInfo;
90 }
91 }
92 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
93 return fh_ErrorInfo;
94}
95
96#endif