added message MEMSTATS.

This commit is contained in:
Martin Preuss
2023-04-10 01:01:48 +02:00
parent 84f11398b8
commit 04ab31ca3d
9 changed files with 156 additions and 1 deletions

View File

@@ -58,6 +58,7 @@
msg_needaddr.h
msg_sendstats.h
msg_recvstats.h
msg_memstats.h
msg_value.h
msg_value2.h
msg_device.h
@@ -89,6 +90,7 @@
msg_needaddr.c
msg_sendstats.c
msg_recvstats.c
msg_memstats.c
msg_value.c
msg_value2.c
msg_device.c

View File

@@ -18,6 +18,7 @@
#include "aqhome/msg/msg_value2.h"
#include "aqhome/msg/msg_sendstats.h"
#include "aqhome/msg/msg_recvstats.h"
#include "aqhome/msg/msg_memstats.h"
#include "aqhome/msg/msg_ping.h"
#include "aqhome/msg/msg_pong.h"
#include "aqhome/msg/msg_needaddr.h"
@@ -134,6 +135,7 @@ void _logMessage(GWEN_MSG_ENDPOINT *ep, const GWEN_MSG *msg)
case AQH_MSG_TYPE_HAVE_ADDRESS: AQH_HaveAddrMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_DENY_ADDRESS: AQH_DenyAddrMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_DEVICE: AQH_DeviceMsg_DumpToBuffer(msg, dbuf, "received"); break;
case AQH_MSG_TYPE_MEMSTATS: AQH_MemStatsMsg_DumpToBuffer(msg, dbuf, "received"); break;
default: AQH_NodeMsg_DumpToBuffer(msg, dbuf, "received"); break;
}
}

104
aqhome/msg/msg_memstats.c Normal file
View File

@@ -0,0 +1,104 @@
/****************************************************************************
* 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/msg_memstats.h"
#include <gwenhywfar/misc.h>
#include <gwenhywfar/list.h>
#include <gwenhywfar/error.h>
#include <gwenhywfar/debug.h>
#define AQH_MSG_OFFS_MEMSTATS_SECONDS 0 /* 4 bytes */
#define AQH_MSG_OFFS_MEMSTATS_UID 4 /* 4 bytes */
#define AQH_MSG_OFFS_MEMSTATS_STACKPTR 8 /* 2 bytes */
#define AQH_MSG_OFFS_MEMSTATS_BUFFERSUSED 10 /* 1 byte */
#define AQH_MSG_OFFS_MEMSTATS_MAXBUFFERSUSED 11 /* 1 byte */
#define AQH_MSG_OFFS_MEMSTATS_SENDNOBUFFER 12 /* 2 bytes */
#define AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER 14 /* 2 bytes */
#define AQH_MSG_MEMSTATS_MINSIZE (AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER+2)
uint32_t AQH_MemStatsMsg_GetUid(const GWEN_MSG *msg)
{
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_UID, 0);
}
uint32_t AQH_MemStatsMsg_GetSeconds(const GWEN_MSG *msg)
{
return AQH_NodeMsg_GetUint32At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_SECONDS, 0);
}
uint16_t AQH_MemStatsMsg_GetStackPtr(const GWEN_MSG *msg)
{
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_STACKPTR, 0);
}
uint8_t AQH_MemStatsMsg_GetBuffersUsed(const GWEN_MSG *msg)
{
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_BUFFERSUSED, 0);
}
uint8_t AQH_MemStatsMsg_GetMaxBuffersUsed(const GWEN_MSG *msg)
{
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_MAXBUFFERSUSED, 0);
}
uint16_t AQH_MemStatsMsg_GetSendNoBufferErrors(const GWEN_MSG *msg)
{
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_SENDNOBUFFER, 0);
}
uint16_t AQH_MemStatsMsg_GetRecvNoBufferErrors(const GWEN_MSG *msg)
{
return AQH_NodeMsg_GetUint16At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_MEMSTATS_RECVNOBUFFER, 0);
}
void AQH_MemStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText)
{
GWEN_Buffer_AppendArgs(dbuf,
"0x%02x->0x%02x: MEMSTATS %s (uid=0x%08x, uptime=%d, stackptr=%d[%04x], buffers used=%d(max=%d), no sendbuf errs=%d, no recvbuf=%d)\n",
AQH_NodeMsg_GetSourceAddress(msg),
AQH_NodeMsg_GetDestAddress(msg),
sText,
(unsigned int) AQH_MemStatsMsg_GetUid(msg),
AQH_MemStatsMsg_GetSeconds(msg),
AQH_MemStatsMsg_GetStackPtr(msg),
AQH_MemStatsMsg_GetStackPtr(msg),
AQH_MemStatsMsg_GetBuffersUsed(msg),
AQH_MemStatsMsg_GetMaxBuffersUsed(msg),
AQH_MemStatsMsg_GetSendNoBufferErrors(msg),
AQH_MemStatsMsg_GetRecvNoBufferErrors(msg));
}

37
aqhome/msg/msg_memstats.h Normal file
View File

@@ -0,0 +1,37 @@
/****************************************************************************
* 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.
****************************************************************************/
#ifndef AQH_MSG_MEMSTATS_H
#define AQH_MSG_MEMSTATS_H
#include <aqhome/api.h>
#include <aqhome/msg/msg_node.h>
#include <gwenhywfar/msg.h>
#include <gwenhywfar/buffer.h>
AQHOME_API uint32_t AQH_MemStatsMsg_GetUid(const GWEN_MSG *msg);
AQHOME_API uint32_t AQH_MemStatsMsg_GetSeconds(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_MemStatsMsg_GetStackPtr(const GWEN_MSG *msg);
AQHOME_API uint8_t AQH_MemStatsMsg_GetBuffersUsed(const GWEN_MSG *msg);
AQHOME_API uint8_t AQH_MemStatsMsg_GetMaxBuffersUsed(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_MemStatsMsg_GetSendNoBufferErrors(const GWEN_MSG *msg);
AQHOME_API uint16_t AQH_MemStatsMsg_GetRecvNoBufferErrors(const GWEN_MSG *msg);
AQHOME_API void AQH_MemStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);
#endif

View File

@@ -204,6 +204,7 @@ uint32_t AQH_NodeMsg_GetMsgGroup(uint8_t msgType)
case AQH_MSG_TYPE_TWIBUSMEMBER:
case AQH_MSG_TYPE_DEBUG:
case AQH_MSG_TYPE_DEVICE:
case AQH_MSG_TYPE_MEMSTATS:
return AQH_MSG_TYPEGROUP_INFO;
case AQH_MSG_TYPE_VALUE:
case AQH_MSG_TYPE_VALUE2:

View File

@@ -42,6 +42,7 @@
#define AQH_MSG_TYPE_ADDRESS_RANGE 64
#define AQH_MSG_TYPE_DEVICE 80
#define AQH_MSG_TYPE_MEMSTATS 81
/* internal msg types via NET interface */