SCOM Serial Communication Protocol
0.5.2
|
SCOM frame definition. More...
Go to the source code of this file.
Macros | |
#define | HAL_LOG_CHANNEL SCOM |
#define | HAL_LOG_SUBCHANNEL FRAME |
Functions | |
uint16_t | SCOMFrame_GetTotalFrameSize (const SCOMFrame *const frame) |
bool | SCOMFrame_SetType (SCOMFrame *const frame, const uint8_t type) |
uint8_t | SCOMFrame_GetType (const SCOMFrame *const frame) |
bool | SCOMFrame_SetPriority (SCOMFrame *const frame, const uint8_t priority) |
uint8_t | SCOMFrame_GetPriority (const SCOMFrame *const frame) |
bool | SCOMFrame_SetFrameNumber (SCOMFrame *const frame, const uint8_t number) |
uint8_t | SCOMFrame_GetFrameNumber (const SCOMFrame *const frame) |
bool | SCOMFrame_SetPayloadSize (SCOMFrame *const frame, const uint8_t size) |
uint8_t | SCOMFrame_GetPayloadSize (const SCOMFrame *const frame) |
uint8_t * | SCOMFrame_GetPayloadPtr (const SCOMFrame *const frame) |
uint32_t | SCOMFrame_GetTotalPayloadSize (const SCOMFrame *const frame) |
uint32_t | SCOMFrame_GetMultiId (const SCOMFrame *const frame) |
uint32_t | SCOMFrame_GetMultiOffset (const SCOMFrame *const frame) |
bool | SCOMFrame_SetAcknowledgement (SCOMFrame *const frame, const bool ack) |
bool | SCOMFrame_IsMultiframe (const SCOMFrame *const frame) |
bool | SCOMFrame_IsAcknowledged (const SCOMFrame *const frame) |
uint16_t | SCOMFrame_CalculateCRC (const SCOMFrame *const frame) |
SCOM frame definition.
Definition in file scom_frame.c.
#define HAL_LOG_CHANNEL SCOM |
Definition at line 11 of file scom_frame.c.
#define HAL_LOG_SUBCHANNEL FRAME |
Definition at line 12 of file scom_frame.c.
uint16_t SCOMFrame_CalculateCRC | ( | const SCOMFrame *const | frame | ) |
Calculates CRC for the given frame.
[in] | frame | SCOMFrame |
Definition at line 234 of file scom_frame.c.
References CRC16_InitCRC, CRC16_UpdateCRC_Byte, HAL_PACKED::ctrl, HAL_PACKED::payload, HAL_PACKED::singleframe, HAL_PACKED::size, and HAL_PACKED::type.
uint8_t SCOMFrame_GetFrameNumber | ( | const SCOMFrame *const | frame | ) |
Gets frame number.
[in] | frame | SCOMFrame |
Definition at line 108 of file scom_frame.c.
References HAL_PACKED::ctrl, and SCOM_FRAME_CTRL_FRAME_NUMBER_MASK.
uint32_t SCOMFrame_GetMultiId | ( | const SCOMFrame *const | frame | ) |
Gets the multiId associated with a multi-frame.
[in] | frame | SCOMFrame |
multiId | if the frame is a multi-frame |
0 | if NULL frame was passed or frame is not a multi-frame |
Definition at line 166 of file scom_frame.c.
References HAL_PACKED::ctrl, HAL_PACKED::multiframe, HAL_PACKED::payload, and SCOM_FRAME_CTRL_MULTI_ID_MASK.
uint32_t SCOMFrame_GetMultiOffset | ( | const SCOMFrame *const | frame | ) |
Gets the payload offset of a multi-frame.
[in] | frame | SCOMFrame |
payload | offset if the frame is a multi-frame |
0 | if NULL frame was passed or frame is not a multi-frame |
Definition at line 179 of file scom_frame.c.
References HAL_PACKED::ctrl, HAL_PACKED::multiframe, HAL_PACKED::payload, and SCOM_FRAME_CTRL_MULTI_ID_MASK.
uint8_t* SCOMFrame_GetPayloadPtr | ( | const SCOMFrame *const | frame | ) |
Gets the pointer to the frame payload.
[in] | frame | SCOMFrame |
Definition at line 144 of file scom_frame.c.
References HAL_PACKED::ctrl, HAL_PACKED::multiframe, HAL_PACKED::payload, SCOM_FRAME_CTRL_MULTI_ID_MASK, and HAL_PACKED::singleframe.
uint8_t SCOMFrame_GetPayloadSize | ( | const SCOMFrame *const | frame | ) |
Gets frame payload size.
[in] | frame | SCOMFrame |
0.. | SCOM_MAX_DATA_LENGTH - frame payload size in bytes |
0 | if NULL frame was passed |
Definition at line 133 of file scom_frame.c.
References HAL_PACKED::size.
uint8_t SCOMFrame_GetPriority | ( | const SCOMFrame *const | frame | ) |
Gets frame priority.
[in] | frame | SCOMFrame |
0..6 | - frame priority |
7 | indication that this frame was retransmitted |
0xff | if NULL frame was passed |
Definition at line 82 of file scom_frame.c.
References HAL_PACKED::ctrl, and SCOM_FRAME_CTRL_FRAME_PRIORITY_MASK.
Referenced by SCOMFrameQueue_Insert().
uint16_t SCOMFrame_GetTotalFrameSize | ( | const SCOMFrame *const | frame | ) |
Returns the total size in bytes of the SCOMFrame including all its fields.
[in] | frame | SCOMFrame |
Definition at line 20 of file scom_frame.c.
References HAL_PACKED::multiframe, HAL_PACKED::payload, SCOMFrame_IsMultiframe(), HAL_PACKED::size, HAL_PACKED::sof, and HAL_PACKED::sync.
uint32_t SCOMFrame_GetTotalPayloadSize | ( | const SCOMFrame *const | frame | ) |
Gets total frame payload size. For single-frames this is equal to the SCOMFrame_GetPayloadSize. For multi-frames the total size of the payload is returned.
[in] | frame | SCOMFrame |
total | frame payload size in bytes |
0 | if NULL frame was passed |
Definition at line 155 of file scom_frame.c.
References HAL_PACKED::ctrl, HAL_PACKED::multiframe, HAL_PACKED::payload, SCOM_FRAME_CTRL_MULTI_ID_MASK, and HAL_PACKED::size.
uint8_t SCOMFrame_GetType | ( | const SCOMFrame *const | frame | ) |
Gets frame type.
[in] | frame | SCOMFrame |
0..240 | - frame type |
0xff | if NULL frame was passed |
Definition at line 56 of file scom_frame.c.
References HAL_PACKED::type.
bool SCOMFrame_IsAcknowledged | ( | const SCOMFrame *const | frame | ) |
Checks if the frame should be acknowledged or not.
[in] | frame | SCOMFrame |
true | if the frame should be acknowledged, false otherwise |
Definition at line 221 of file scom_frame.c.
References HAL_PACKED::ctrl, and SCOM_FRAME_CTRL_NOACK_MASK.
Referenced by SCOM_Proc().
bool SCOMFrame_IsMultiframe | ( | const SCOMFrame *const | frame | ) |
Checks if the frame is a multiframe of singleframe.
[in] | frame | SCOMFrame |
true | if frame is |
Definition at line 208 of file scom_frame.c.
References HAL_PACKED::ctrl, and SCOM_FRAME_CTRL_MULTI_ID_MASK.
Referenced by SCOMFrame_GetTotalFrameSize().
bool SCOMFrame_SetAcknowledgement | ( | SCOMFrame *const | frame, |
const bool | ack | ||
) |
Sets acknowledgment generation for the given frame.
[in,out] | frame | SCOMFrame |
[in] | ack | true if acknowledgment should be generated in response to this frame, false otherwise |
true | if acknowledgment was successfully set |
false | if NULL frame was passed |
Definition at line 192 of file scom_frame.c.
References HAL_PACKED::ctrl, and SCOM_FRAME_CTRL_NOACK_MASK.
Referenced by SCOM_SendAllocatedFrameWithoutACK(), and SCOM_SendFrameWithoutAck().
bool SCOMFrame_SetFrameNumber | ( | SCOMFrame *const | frame, |
const uint8_t | number | ||
) |
Sets frame number.
[in,out] | frame | SCOMFrame |
number | frame number (0..15) |
true | if frame number was successfully set |
false | if bad frame number or NULL frame was passed |
Definition at line 93 of file scom_frame.c.
References HAL_PACKED::ctrl, and SCOM_FRAME_CTRL_FRAME_NUMBER_MASK.
Referenced by SCOM_Proc().
bool SCOMFrame_SetPayloadSize | ( | SCOMFrame *const | frame, |
const uint8_t | size | ||
) |
Sets frame payload size.
[in,out] | frame | SCOMFrame |
[in] | type | frame payload size in bytes (0..SCOM_MAX_DATA_LENGTH) |
true | if size was successfully set |
false | if bad size or NULL frame was passed |
Definition at line 119 of file scom_frame.c.
References SCOM_MAX_DATA_LENGTH, and HAL_PACKED::size.
bool SCOMFrame_SetPriority | ( | SCOMFrame *const | frame, |
const uint8_t | priority | ||
) |
Sets frame priority.
[in,out] | frame | SCOMFrame |
[in] | priority | frame priority (0 - lowest, 6 - highest) |
true | if priority was successfully set |
false | if bad priority or NULL frame was passed |
Definition at line 67 of file scom_frame.c.
References HAL_PACKED::ctrl, and SCOM_FRAME_CTRL_FRAME_PRIORITY_MASK.
Referenced by SCOM_SendFrame(), SCOM_SendFrameWithoutAck(), SCOM_SendMultiFrame(), SCOM_SendServiceFrame(), and SCOM_SendServiceMultiFrame().
bool SCOMFrame_SetType | ( | SCOMFrame *const | frame, |
const uint8_t | type | ||
) |
Sets frame type.
[in,out] | frame | SCOMFrame |
[in] | type | frame type (0..240) |
true | if type was successfully set |
false | if bad type or NULL frame was passed |
Definition at line 42 of file scom_frame.c.
References HAL_PACKED::type.