/**************************************************************************** * This file is part of the project AqHome. * AqHome (c) by 2023 Martin Preuss, all rights reserved. * * The license for this file can be found in the file COPYING which you * should have received along with this file. ****************************************************************************/ #ifdef HAVE_CONFIG_H # include #endif #include "aqhome/msg/msg_recvstats.h" #include #include #include #include #define AQH_MSG_OFFS_RECVSTATS_UID 0 /* 4 bytes */ #define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_IOERRORS 8 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 10 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_HANDLED 12 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_MISSED 14 /* 2 bytes */ #define AQH_MSG_RECVSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS+2) uint32_t AQH_RecvStatsMsg_GetUid(const GWEN_MSG *msg) { return GWEN_Msg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_UID, 0); } uint16_t AQH_RecvStatsMsg_GetPacketsIn(const GWEN_MSG *msg) { return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_PACKETSIN, 0); } uint16_t AQH_RecvStatsMsg_GetCrcErrors(const GWEN_MSG *msg) { return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_CRCERRORS, 0); } uint16_t AQH_RecvStatsMsg_GetIoErrors(const GWEN_MSG *msg) { return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS, 0); } uint16_t AQH_RecvStatsMsg_GetNoBufferErrors(const GWEN_MSG *msg) { return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_NOBUFFER, 0); } uint16_t AQH_RecvStatsMsg_GetHandled(const GWEN_MSG *msg) { return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_HANDLED, 0); } uint16_t AQH_RecvStatsMsg_GetMissed(const GWEN_MSG *msg) { return GWEN_Msg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_MISSED, 0); } void AQH_RecvStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText) { 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 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_GetNoBufferErrors(msg), AQH_RecvStatsMsg_GetHandled(msg), AQH_RecvStatsMsg_GetMissed(msg)); } }