simplified message handling, switch from XOR checksum to CRC8 with polynomial 0x97.

0x97 allows for detection of all 1-3 bit errors in a message of up to
119 bytes
(see https://www.faa.gov/aircraft/air_cert/design_approvals/air_software/media/TC-14-49.pdf)
This commit is contained in:
Martin Preuss
2023-04-07 23:22:40 +02:00
parent 4e1f08b567
commit 7eb462173c
33 changed files with 281 additions and 367 deletions

View File

@@ -18,17 +18,15 @@
#include <gwenhywfar/debug.h>
#define AQH_MSG_OFFS_PING_TIMESTAMP 0
#define AQH_MSG_PING_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP+4)
uint32_t AQH_PingMsg_GetTimestamp(const GWEN_MSG *msg)
{
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_PING) &&
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_PING_MINSIZE)) {
const uint8_t *ptr;
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP;
return (uint32_t)(ptr[0])+(ptr[1]<<8)+(ptr[2]<<16)+(ptr[3]<<24);
}
return 0;
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_PING_TIMESTAMP, 0);
}