reworked com stack.

- prepared for use of CRC8
- organized code in more files
- recv stats message now contains crc errors and io errors
This commit is contained in:
Martin Preuss
2023-04-07 19:13:54 +02:00
parent 3bb867ed21
commit 4e1f08b567
22 changed files with 1326 additions and 1161 deletions

View File

@@ -21,10 +21,10 @@
#define AQH_MSG_OFFS_RECVSTATS_UID 0
#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4
#define AQH_MSG_OFFS_RECVSTATS_ERRORS 6
#define AQH_MSG_OFFS_RECVSTATS_HANDLED 8
#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6
#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 8
#define AQH_MSG_RECVSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_HANDLED+2)
#define AQH_MSG_RECVSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS+2)
@@ -54,12 +54,12 @@ uint16_t AQH_RecvStatsMsg_GetPacketsIn(const GWEN_MSG *msg)
uint16_t AQH_RecvStatsMsg_GetErrors(const GWEN_MSG *msg)
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_ERRORS;
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;
@@ -67,12 +67,12 @@ uint16_t AQH_RecvStatsMsg_GetErrors(const GWEN_MSG *msg)
uint16_t AQH_RecvStatsMsg_GetHandled(const GWEN_MSG *msg)
uint16_t AQH_RecvStatsMsg_GetIoErrors(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_HANDLED;
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;
@@ -85,14 +85,14 @@ 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, errors=%d, handled=%d)\n",
"0x%02x->0x%02x: RECVSTATS %s (uid=0x%08x, in=%d, crc errors=%d, io errors=%d)\n",
AQH_NodeMsg_GetSourceAddress(msg),
AQH_NodeMsg_GetDestAddress(msg),
sText,
(unsigned int) AQH_RecvStatsMsg_GetUid(msg),
AQH_RecvStatsMsg_GetPacketsIn(msg),
AQH_RecvStatsMsg_GetErrors(msg),
AQH_RecvStatsMsg_GetHandled(msg));
AQH_RecvStatsMsg_GetCrcErrors(msg),
AQH_RecvStatsMsg_GetIoErrors(msg));
}
}