added message MEMSTATS.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
104
aqhome/msg/msg_memstats.c
Normal 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
37
aqhome/msg/msg_memstats.h
Normal 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
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -84,6 +84,7 @@ comDataBegin:
|
||||
comRecvBuffersReadPos: .byte 1
|
||||
comRecvBuffersWritePos: .byte 1
|
||||
comRecvBuffersUsed: .byte 1
|
||||
comMaxBuffersUsed: .byte 1
|
||||
comRecvBuffers: .byte (COM_BUFFER_SIZE*COM_BUFFER_NUM)
|
||||
comDataEnd:
|
||||
|
||||
|
||||
@@ -65,6 +65,11 @@ COM_BufferAlloc:
|
||||
brcc COM_AllocBuffer_error ; no buffer available
|
||||
inc r17 ; increment number of buffers used
|
||||
sts comRecvBuffersUsed, r17 ; store new value
|
||||
lds r16, comMaxBuffersUsed ; calc max buffers used
|
||||
cp r16, r17
|
||||
brcc COM_AllocBuffer_l0
|
||||
sts comMaxBuffersUsed, r17
|
||||
COM_AllocBuffer_l0:
|
||||
lds r16, comRecvBuffersWritePos ; get current write pos
|
||||
mov r17, r16 ; increment for next call
|
||||
inc r17
|
||||
|
||||
@@ -34,7 +34,7 @@ CPRO_EnqueueMemStats:
|
||||
push xh
|
||||
push xl
|
||||
mov r16, r6
|
||||
ldi r17, CPRO_PAYLOAD_FLAGS_UID | CPRO_PAYLOAD_FLAGS_SECONDS | (7<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||
ldi r17, CPRO_PAYLOAD_FLAGS_UID | CPRO_PAYLOAD_FLAGS_SECONDS | (8<<CPRO_PAYLOAD_FLAGS_SHIFT_NUM)
|
||||
ldi r18, CPRO_CMD_MEMSTATS
|
||||
rcall cproBeginMsgWithVariablePayload ; (R3, R4, R16, R17, R18, R19, R20, R21, X)
|
||||
; payload
|
||||
@@ -44,6 +44,8 @@ CPRO_EnqueueMemStats:
|
||||
st X+, r17
|
||||
lds r17, comRecvBuffersUsed
|
||||
st X+, r17 ; used buffers
|
||||
lds r17, comMaxBuffersUsed
|
||||
st X+, r17 ; max used buffers
|
||||
lds r17, comStatsSendNoBuffer
|
||||
st X+, r17 ; sendNoBuffer
|
||||
lds r17, comStatsSendNoBuffer+1
|
||||
|
||||
Reference in New Issue
Block a user