Files
aqhomecontrol/aqhome/msg/node/m_sysstats.c

72 lines
2.1 KiB
C

/****************************************************************************
* 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_sysstats.h"
#include "aqhome/msg/node/m_node.h"
#include <gwenhywfar/debug.h>
#define AQH_MSG_OFFS_SYSSTATS_SECONDS 0 /* 4 bytes */
#define AQH_MSG_OFFS_SYSSTATS_UID 4 /* 4 bytes */
#define AQH_MSG_OFFS_SYSSTATS_COMIRQS 8 /* 2 bytes */
#define AQH_MSG_OFFS_SYSSTATS_TIMERIRQS 10 /* 2 bytes */
uint32_t AQH_SysStatsMessage_GetUid(const AQH_MESSAGE *msg)
{
return AQH_Message_ReadUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_UID, 0);
}
uint32_t AQH_SysStatsMessage_GetSeconds(const AQH_MESSAGE *msg)
{
return AQH_Message_ReadUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_SECONDS, 0);
}
uint16_t AQH_SysStatsMessage_GetComInterrupts(const AQH_MESSAGE *msg)
{
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_COMIRQS, 0);
}
uint16_t AQH_SysStatsMessage_GetTimerInterrupts(const AQH_MESSAGE *msg)
{
return AQH_Message_ReadUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SYSSTATS_TIMERIRQS, 0);
}
void AQH_SysStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText)
{
GWEN_Buffer_AppendArgs(dbuf,
"0x%02x->0x%02x: SYSSTATS(%s) %s (uid=0x%08x, uptime=%d, com irqs=%d, timer irqs=%d)\n",
AQH_NodeMessage_GetSourceAddress(msg),
AQH_NodeMessage_GetDestAddress(msg),
AQH_NodeMessage_MsgTypeToChar(AQH_NodeMessage_GetMsgType(msg)),
sText,
(unsigned int) AQH_SysStatsMessage_GetUid(msg),
AQH_SysStatsMessage_GetSeconds(msg),
AQH_SysStatsMessage_GetComInterrupts(msg),
AQH_SysStatsMessage_GetTimerInterrupts(msg));
}