aqhome: started rewriting message code, start using new event2 lib.
This commit is contained in:
97
aqhome/msg/node/m_recvstats.c
Normal file
97
aqhome/msg/node/m_recvstats.c
Normal file
@@ -0,0 +1,97 @@
|
||||
/****************************************************************************
|
||||
* 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 <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#include "aqhome/msg/node/m_recvstats.h"
|
||||
#include "aqhome/msg/node/m_node.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
#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 */
|
||||
|
||||
|
||||
|
||||
uint32_t AQH_RecvStatsMessage_GetUid(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_UID, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMessage_GetPacketsIn(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_PACKETSIN, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMessage_GetCrcErrors(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_CRCERRORS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMessage_GetIoErrors(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMessage_GetNoBufferErrors(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_NOBUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMessage_GetHandled(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_HANDLED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t AQH_RecvStatsMessage_GetMissed(const AQH_MESSAGE *msg)
|
||||
{
|
||||
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_MISSED, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_RecvStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText)
|
||||
{
|
||||
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_NodeMessage_GetSourceAddress(msg),
|
||||
AQH_NodeMessage_GetDestAddress(msg),
|
||||
sText,
|
||||
(unsigned int) AQH_RecvStatsMessage_GetUid(msg),
|
||||
AQH_RecvStatsMessage_GetPacketsIn(msg),
|
||||
AQH_RecvStatsMessage_GetCrcErrors(msg),
|
||||
AQH_RecvStatsMessage_GetIoErrors(msg),
|
||||
AQH_RecvStatsMessage_GetNoBufferErrors(msg),
|
||||
AQH_RecvStatsMessage_GetHandled(msg),
|
||||
AQH_RecvStatsMessage_GetMissed(msg));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user