FreeHIL
Loading...
Searching...
No Matches
FH_CAN_SSD16_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_CAN</b>, <b>Cmd</b> (Command), <b>SSD16</b>, <b>SSD16_H</b> (Set Shared Data 16 Health)\n
6 * Functions in this file, verify the health of the different message frames related to <b>CAN</b>
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_CAN/Cmd/SSD16/SSD16_H/FH_CAN_SSD16_H.h"
35
36#include "../../../../../../../FH_Embedded/FH_Root/FH_General/FH_GeneralFunctions/FH_GeneralFunctions.h"
38
39#if FH_CAN_MaxPeripheralNumber > 0 // It is configurable in FH_DevicePeripherals.h
40
41/**
42 * @brief This function verifies the health of <b>FH_CAN_Commands_SSD16</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 ${CAN01} 02 AA BB CC DD
52 &{Message} = Create Dictionary DeviceAddress=${DeviceAddress_01} Function=${Function_CAN} Command=${CAN_Commands_SSD16} Data=@{MessageData}
53 ${Result} SendMessage &{Message}
54
55 Comments:
56
57 CAN01 => It indicates the CAN 01
58 02 => Example interested length of the 16 bit data to be set
59 AA BB CC DD => Example data (0xAABB and 0xCCDD) to be set in <b>FH_CAN01_SharedDataBuf_16Bits</b>
60 DeviceAddress_01 => It shall be equal to the address of the device: FH_RFCommunication_DeviceAddress
61 Function_CAN => It is the function in the message frame
62 CAN_Commands_SSD16 => It is the command of the function in the message frame
63 @endverbatim
64 *
65 * @return FH_ErrorInfo is returned
66 *
67
68*/
70{
71 FH_ErrorInfo fh_ErrorInfo; // Error Information
72 FH_ResetErrorInfo(&fh_ErrorInfo); // Reset Error Information to default
73
74 uint8_t FH_MessageDataLength; // It temporarily stores the DataLength in the message frame
75 uint8_t FH_PeripheralNumber; // It temporarily stores the PeripheralNumber (Data[0]) in the message frame
76 uint8_t FH_SharedDataLength; // It temporarily stores the SharedDataLength (Data[1]) of the 16 bit data to be set
77
78 // Verifying the minimum possible length in the message frame
79 FH_MessageDataLength = fh_RFCommunication_Message -> DataLength;
80 if (FH_MessageDataLength < FH_CAN_MinCommandSize_SSD16) // If the length is less than expected value
81 {
82 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
83 return fh_ErrorInfo;
84 }
85
86 // Verifying the possible PeripheralNumber in the message frame
87 FH_PeripheralNumber = fh_RFCommunication_Message -> Data[CAN_SSD16_PeripheralNumber] ;
88 if (FH_PeripheralNumber == 0 || FH_PeripheralNumber > FH_CAN_MaxPeripheralNumber) // If the PeripheralNumber is not within the expected value
89 {
90 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
91 return fh_ErrorInfo;
92 }
93
94 // Verifying the possible SharedDataLength in the message frame
95 FH_SharedDataLength = fh_RFCommunication_Message -> Data[CAN_SSD16_SharedDataLength];
96 if (FH_SharedDataLength == 0) // If SharedDataLength is 0
97 {
98 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
99 return fh_ErrorInfo;
100 }
101
102 if ((FH_SharedDataLength * 2) != (FH_MessageDataLength - 2)) // If SharedDataLength is not matched with the length of the message frame
103 {
104 fh_ErrorInfo.error_code = FH_ERROR_MessageFrame; // There is message frame error
105 return fh_ErrorInfo;
106 }
107
108 fh_ErrorInfo.error_code = FH_ERROR_OK; // There is no error
109 return fh_ErrorInfo;
110}
111
112#endif