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:
@@ -19,10 +19,13 @@
|
||||
|
||||
|
||||
|
||||
#define AQH_MSG_OFFS_RECVSTATS_UID 0
|
||||
#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4
|
||||
#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6
|
||||
#define AQH_MSG_OFFS_RECVSTATS_UID 0
|
||||
#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4
|
||||
#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6
|
||||
#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 8
|
||||
#define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 10
|
||||
#define AQH_MSG_OFFS_RECVSTATS_HANDLED 12
|
||||
#define AQH_MSG_OFFS_RECVSTATS_MISSED 14
|
||||
|
||||
#define AQH_MSG_RECVSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS+2)
|
||||
|
||||
@@ -30,52 +33,49 @@
|
||||
|
||||
uint32_t AQH_RecvStatsMsg_GetUid(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_UID;
|
||||
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_RECVSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetPacketsIn(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_PACKETSIN;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_PACKETSIN, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetCrcErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_CRCERRORS;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_CRCERRORS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetIoErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) {
|
||||
const uint8_t *ptr;
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS, 0);
|
||||
}
|
||||
|
||||
ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS;
|
||||
return (uint16_t)(ptr[0])+(ptr[1]<<8);
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_NOBUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetHandled(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_HANDLED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMsg_GetMissed(const GWEN_MSG *msg)
|
||||
{
|
||||
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_MISSED, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,14 +85,17 @@ void AQH_RecvStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const
|
||||
if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMRECVSTATS) &&
|
||||
(GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE)) {
|
||||
GWEN_Buffer_AppendArgs(dbuf,
|
||||
"0x%02x->0x%02x: RECVSTATS %s (uid=0x%08x, in=%d, crc errors=%d, io errors=%d)\n",
|
||||
"0x%02x->0x%02x: RECVSTATS %s (uid=0x%08x, in=%d, crc errs=%d, io errs=%d, nobuf errs=%d, handled=%d, missed=%d)\n",
|
||||
AQH_NodeMsg_GetSourceAddress(msg),
|
||||
AQH_NodeMsg_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_RecvStatsMsg_GetUid(msg),
|
||||
AQH_RecvStatsMsg_GetPacketsIn(msg),
|
||||
AQH_RecvStatsMsg_GetCrcErrors(msg),
|
||||
AQH_RecvStatsMsg_GetIoErrors(msg));
|
||||
AQH_RecvStatsMsg_GetIoErrors(msg),
|
||||
AQH_RecvStatsMsg_GetNoBufferErrors(msg),
|
||||
AQH_RecvStatsMsg_GetHandled(msg),
|
||||
AQH_RecvStatsMsg_GetMissed(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user