improve stats reporting

now again use three messages to transmit stats (much more efficient than
sending single values, also more acurate).
This commit is contained in:
Martin Preuss
2025-08-25 10:22:05 +02:00
parent 7efaf720cc
commit 6e062d3f60
13 changed files with 234 additions and 186 deletions

View File

@@ -41,6 +41,7 @@
#include <aqhome/msg/node/m_value.h> #include <aqhome/msg/node/m_value.h>
#include <aqhome/msg/node/m_recvstats.h> #include <aqhome/msg/node/m_recvstats.h>
#include <aqhome/msg/node/m_sendstats.h> #include <aqhome/msg/node/m_sendstats.h>
#include <aqhome/msg/node/m_memstats.h>
#include <aqhome/data/value.h> #include <aqhome/data/value.h>
#include <gwenhywfar/args.h> #include <gwenhywfar/args.h>
@@ -122,7 +123,10 @@ static void _forwardTtyMsgToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH
static void _forwardValueMessageToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardValueMessageToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg);
static void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg);
static void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg);
static void _forwardDataFromMemStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg);
static void _forwardTtyMsgToClients(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg); static void _forwardTtyMsgToClients(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg);
static void _publishIntWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, int v);
static void _publishDoubleWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, double v);
static void _publishInt(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v); static void _publishInt(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v);
static void _publishDouble(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, double v); static void _publishDouble(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, double v);
static void _setDeviceName(AQH_VALUE *value, uint32_t uid); static void _setDeviceName(AQH_VALUE *value, uint32_t uid);
@@ -827,9 +831,11 @@ void _forwardTtyMsgToBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAG
code=AQH_NodeMessage_GetMsgType(msg); code=AQH_NodeMessage_GetMsgType(msg);
switch(code) { switch(code) {
case AQH_MSG_TYPE_VALUE_REPORT: _forwardValueMessageToBroker(o, xo, msg); break; case AQH_MSG_TYPE_VALUE_REPORT: _forwardValueMessageToBroker(o, xo, msg); break;
case AQH_MSG_TYPE_COMSENDSTATS: _forwardDataFromSendStatsMsgToBroker(xo, msg); break; case AQH_MSG_TYPE_COMSENDSTATS: _forwardDataFromSendStatsMsgToBroker(xo, msg); break;
case AQH_MSG_TYPE_COMRECVSTATS: _forwardDataFromRecvStatsMsgToBroker(xo, msg); break; case AQH_MSG_TYPE_COMRECVSTATS: _forwardDataFromRecvStatsMsgToBroker(xo, msg); break;
case AQH_MSG_TYPE_MEMSTATS: _forwardDataFromMemStatsMsgToBroker(xo, msg); break;
default: break; default: break;
} }
} }
@@ -898,6 +904,7 @@ void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE
packetsOutInt=AQH_SendStatsMessage_GetPacketsOut(msg); packetsOutInt=AQH_SendStatsMessage_GetPacketsOut(msg);
if (packetsOutInt) { if (packetsOutInt) {
uint32_t uid; uint32_t uid;
int devNum;
double packetsOut; double packetsOut;
double collisions; double collisions;
double busy; double busy;
@@ -905,6 +912,7 @@ void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE
double busyPercentage=0.0; double busyPercentage=0.0;
uid=AQH_SendStatsMessage_GetUid(msg); uid=AQH_SendStatsMessage_GetUid(msg);
devNum=AQH_SendStatsMessage_GetInterface(msg);
packetsOut=/*(double)*/ packetsOutInt; packetsOut=/*(double)*/ packetsOutInt;
collisions=/*(double)*/ AQH_SendStatsMessage_GetCollisions(msg); collisions=/*(double)*/ AQH_SendStatsMessage_GetCollisions(msg);
busy=/*(double)*/ AQH_SendStatsMessage_GetBusyErrors(msg); busy=/*(double)*/ AQH_SendStatsMessage_GetBusyErrors(msg);
@@ -912,10 +920,10 @@ void _forwardDataFromSendStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE
collisionsPercentage=collisions*100.0/packetsOut; collisionsPercentage=collisions*100.0/packetsOut;
busyPercentage=busy*100.0/packetsOut; busyPercentage=busy*100.0/packetsOut;
_publishInt( xo, uid, "net/packetsOut", 0, NULL, packetsOutInt); _publishIntWithIdx( xo, uid, "net/packetsOut", devNum, 0, NULL, packetsOutInt);
_publishInt( xo, uid, "net/collisions", 0, NULL, (int) AQH_SendStatsMessage_GetCollisions(msg)); _publishIntWithIdx( xo, uid, "net/collisions", devNum, 0, NULL, (int) AQH_SendStatsMessage_GetCollisions(msg));
_publishDouble(xo, uid, "net/collisionsPercent", 0, "%", collisionsPercentage); _publishDoubleWithIdx(xo, uid, "net/collisionsPercent", devNum, 0, "%", collisionsPercentage);
_publishDouble(xo, uid, "net/busyPercent", 0, "%", busyPercentage); _publishDoubleWithIdx(xo, uid, "net/busyPercent", devNum, 0, "%", busyPercentage);
} }
} }
@@ -928,13 +936,15 @@ void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE
packetsInInt=AQH_RecvStatsMessage_GetPacketsIn(msg); packetsInInt=AQH_RecvStatsMessage_GetPacketsIn(msg);
if (packetsInInt) { if (packetsInInt) {
uint32_t uid; uint32_t uid;
int devNum;
double packetsIn; double packetsIn;
double crcErrors; double crcErrors;
double ioErrors; double ioErrors;
double crcErrorsPercentage=0.0; double crcErrorsPercentage=0.0;
double ioErrorsPercentage=0.0; double ioErrorsPercentage=0.0;
uid=AQH_SendStatsMessage_GetUid(msg); uid=AQH_RecvStatsMessage_GetUid(msg);
devNum=AQH_RecvStatsMessage_GetInterface(msg);
packetsIn=/*(double)*/ packetsInInt; packetsIn=/*(double)*/ packetsInInt;
crcErrors=/*(double)*/AQH_RecvStatsMessage_GetCrcErrors(msg); crcErrors=/*(double)*/AQH_RecvStatsMessage_GetCrcErrors(msg);
ioErrors=/*(double)*/AQH_RecvStatsMessage_GetIoErrors(msg); ioErrors=/*(double)*/AQH_RecvStatsMessage_GetIoErrors(msg);
@@ -942,16 +952,52 @@ void _forwardDataFromRecvStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE
crcErrorsPercentage=crcErrors*100.0/packetsIn; crcErrorsPercentage=crcErrors*100.0/packetsIn;
ioErrorsPercentage=ioErrors*100.0/packetsIn; ioErrorsPercentage=ioErrors*100.0/packetsIn;
_publishInt( xo, uid, "net/packetsIn", 0, NULL, packetsInInt); _publishIntWithIdx( xo, uid, "net/packetsIn", devNum, 0, NULL, packetsInInt);
_publishInt( xo, uid, "net/crcerrors", 0, NULL, (int) AQH_RecvStatsMessage_GetCrcErrors(msg)); _publishIntWithIdx( xo, uid, "net/crcerrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetCrcErrors(msg));
_publishInt( xo, uid, "net/ioerrors", 0, NULL, (int) AQH_RecvStatsMessage_GetIoErrors(msg)); _publishIntWithIdx( xo, uid, "net/ioerrors", devNum, 0, NULL, (int) AQH_RecvStatsMessage_GetIoErrors(msg));
_publishDouble(xo, uid, "net/crcerrorsPercent", 0, "%", crcErrorsPercentage); _publishDoubleWithIdx(xo, uid, "net/crcerrorsPercent", devNum, 0, "%", crcErrorsPercentage);
_publishDouble(xo, uid, "net/ioerrorsPercent", 0, "%", ioErrorsPercentage); _publishDoubleWithIdx(xo, uid, "net/ioerrorsPercent", devNum, 0, "%", ioErrorsPercentage);
} }
} }
void _forwardDataFromMemStatsMsgToBroker(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg)
{
uint32_t uid;
uid=AQH_MemStatsMessage_GetUid(msg);
_publishInt( xo, uid, "mem/buffersUsed", 0, NULL, AQH_MemStatsMessage_GetBuffersUsed(msg));
_publishInt( xo, uid, "mem/maxBuffersUsed", 0, NULL, AQH_MemStatsMessage_GetMaxBuffersUsed(msg));
}
void _publishIntWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, int v)
{
GWEN_BUFFER *tbuf;
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
GWEN_Buffer_AppendArgs(tbuf, "%s%d", vPath, idx);
_publishInt(xo, uid, GWEN_Buffer_GetStart(tbuf), vModality, vUnits, v);
GWEN_Buffer_free(tbuf);
}
void _publishDoubleWithIdx(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int idx, int vModality, const char *vUnits, double v)
{
GWEN_BUFFER *tbuf;
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
GWEN_Buffer_AppendArgs(tbuf, "%s%d", vPath, idx);
_publishDouble(xo, uid, GWEN_Buffer_GetStart(tbuf), vModality, vUnits, v);
GWEN_Buffer_free(tbuf);
}
void _publishInt(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v) void _publishInt(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vModality, const char *vUnits, int v)
{ {
_publishDouble(xo, uid, vPath, vModality, vUnits, /*(double)*/ v); _publishDouble(xo, uid, vPath, vModality, vUnits, /*(double)*/ v);

View File

@@ -29,8 +29,8 @@
#define AQH_MSG_TYPE_PING 10 #define AQH_MSG_TYPE_PING 10
#define AQH_MSG_TYPE_PONG 11 #define AQH_MSG_TYPE_PONG 11
#define AQH_MSG_TYPE_COMSENDSTATS 20 #define AQH_MSG_TYPE_COMSENDSTATS 22
#define AQH_MSG_TYPE_COMRECVSTATS 21 #define AQH_MSG_TYPE_COMRECVSTATS 23
#define AQH_MSG_TYPE_TWIBUSMEMBER 30 #define AQH_MSG_TYPE_TWIBUSMEMBER 30
#define AQH_MSG_TYPE_DEBUG 40 #define AQH_MSG_TYPE_DEBUG 40
#define AQH_MSG_TYPE_VALUE 50 /* deprecated */ #define AQH_MSG_TYPE_VALUE 50 /* deprecated */

View File

@@ -19,12 +19,20 @@
#define AQH_MSG_OFFS_RECVSTATS_UID 0 /* 4 bytes */ #define AQH_MSG_OFFS_RECVSTATS_UID 0 /* 4 bytes */
#define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 4 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_IFACE 4 /* 1 byte */
#define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 6 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_PACKETSIN 5 /* 2 bytes */
#define AQH_MSG_OFFS_RECVSTATS_IOERRORS 8 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_CRCERRORS 7 /* 2 bytes */
#define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 10 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_IOERRORS 9 /* 2 bytes */
#define AQH_MSG_OFFS_RECVSTATS_HANDLED 12 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_NOBUFFER 11 /* 2 bytes */
#define AQH_MSG_OFFS_RECVSTATS_MISSED 14 /* 2 bytes */ #define AQH_MSG_OFFS_RECVSTATS_HANDLED 13 /* 2 bytes */
#define AQH_MSG_OFFS_RECVSTATS_MISSED 15 /* 2 bytes */
uint8_t AQH_RecvStatsMessage_GetInterface(const AQH_MESSAGE *msg)
{
return AQH_Message_ReadUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IFACE, 0);
}
@@ -80,12 +88,13 @@ uint16_t AQH_RecvStatsMessage_GetMissed(const AQH_MESSAGE *msg)
void AQH_RecvStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText) void AQH_RecvStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf, const char *sText)
{ {
GWEN_Buffer_AppendArgs(dbuf, GWEN_Buffer_AppendArgs(dbuf,
"0x%02x->0x%02x: RECVSTATS %s " "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", "(uid=0x%08x, dev=%d, in=%d, crc errs=%d, io errs=%d, nobuf errs=%d, handled=%d, missed=%d)\n",
AQH_NodeMessage_GetSourceAddress(msg), AQH_NodeMessage_GetSourceAddress(msg),
AQH_NodeMessage_GetDestAddress(msg), AQH_NodeMessage_GetDestAddress(msg),
sText, sText,
(unsigned int) AQH_RecvStatsMessage_GetUid(msg), (unsigned int) AQH_RecvStatsMessage_GetUid(msg),
AQH_RecvStatsMessage_GetInterface(msg),
AQH_RecvStatsMessage_GetPacketsIn(msg), AQH_RecvStatsMessage_GetPacketsIn(msg),
AQH_RecvStatsMessage_GetCrcErrors(msg), AQH_RecvStatsMessage_GetCrcErrors(msg),
AQH_RecvStatsMessage_GetIoErrors(msg), AQH_RecvStatsMessage_GetIoErrors(msg),

View File

@@ -17,6 +17,7 @@
AQHOME_API uint8_t AQH_RecvStatsMessage_GetInterface(const AQH_MESSAGE *msg);
AQHOME_API uint32_t AQH_RecvStatsMessage_GetUid(const AQH_MESSAGE *msg); AQHOME_API uint32_t AQH_RecvStatsMessage_GetUid(const AQH_MESSAGE *msg);
AQHOME_API uint16_t AQH_RecvStatsMessage_GetPacketsIn(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_RecvStatsMessage_GetPacketsIn(const AQH_MESSAGE *msg);
AQHOME_API uint16_t AQH_RecvStatsMessage_GetCrcErrors(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_RecvStatsMessage_GetCrcErrors(const AQH_MESSAGE *msg);

View File

@@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
* This file is part of the project AqHome. * This file is part of the project AqHome.
* AqHome (c) by 2023 Martin Preuss, all rights reserved. * AqHome (c) by 2025 Martin Preuss, all rights reserved.
* *
* The license for this file can be found in the file COPYING which you * The license for this file can be found in the file COPYING which you
* should have received along with this file. * should have received along with this file.
@@ -19,9 +19,17 @@
#define AQH_MSG_OFFS_SENDSTATS_UID 0 /* 4 bytes */ #define AQH_MSG_OFFS_SENDSTATS_UID 0 /* 4 bytes */
#define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 4 /* 2 bytes */ #define AQH_MSG_OFFS_SENDSTATS_IFACE 4 /* 1 byte */
#define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 6 /* 2 bytes */ #define AQH_MSG_OFFS_SENDSTATS_PACKETSOUT 5 /* 2 bytes */
#define AQH_MSG_OFFS_SENDSTATS_BUSY 8 /* 2 bytes */ #define AQH_MSG_OFFS_SENDSTATS_COLLISIONS 7 /* 2 bytes */
#define AQH_MSG_OFFS_SENDSTATS_BUSY 9 /* 2 bytes */
uint8_t AQH_SendStatsMessage_GetInterface(const AQH_MESSAGE *msg)
{
return AQH_Message_ReadUint8At(msg, AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_SENDSTATS_IFACE, 0);
}
@@ -57,11 +65,12 @@ void AQH_SendStatsMessage_DumpToBuffer(const AQH_MESSAGE *msg, GWEN_BUFFER *dbuf
{ {
if (msg) if (msg)
GWEN_Buffer_AppendArgs(dbuf, GWEN_Buffer_AppendArgs(dbuf,
"0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, out=%d, collisions=%d, busy line=%d)\n", "0x%02x->0x%02x: SENDSTATS %s (uid=0x%08x, dev=%d, out=%d, collisions=%d, busy line=%d)\n",
AQH_NodeMessage_GetSourceAddress(msg), AQH_NodeMessage_GetSourceAddress(msg),
AQH_NodeMessage_GetDestAddress(msg), AQH_NodeMessage_GetDestAddress(msg),
sText, sText,
(unsigned int) AQH_SendStatsMessage_GetUid(msg), (unsigned int) AQH_SendStatsMessage_GetUid(msg),
AQH_SendStatsMessage_GetInterface(msg),
AQH_SendStatsMessage_GetPacketsOut(msg), AQH_SendStatsMessage_GetPacketsOut(msg),
AQH_SendStatsMessage_GetCollisions(msg), AQH_SendStatsMessage_GetCollisions(msg),
AQH_SendStatsMessage_GetBusyErrors(msg)); AQH_SendStatsMessage_GetBusyErrors(msg));

View File

@@ -17,6 +17,7 @@
AQHOME_API uint8_t AQH_SendStatsMessage_GetInterface(const AQH_MESSAGE *msg);
AQHOME_API uint32_t AQH_SendStatsMessage_GetUid(const AQH_MESSAGE *msg); AQHOME_API uint32_t AQH_SendStatsMessage_GetUid(const AQH_MESSAGE *msg);
AQHOME_API uint16_t AQH_SendStatsMessage_GetPacketsOut(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_SendStatsMessage_GetPacketsOut(const AQH_MESSAGE *msg);
AQHOME_API uint16_t AQH_SendStatsMessage_GetCollisions(const AQH_MESSAGE *msg); AQHOME_API uint16_t AQH_SendStatsMessage_GetCollisions(const AQH_MESSAGE *msg);

View File

@@ -25,7 +25,13 @@ AppNetwork_SendTxdStats:
bigcall NETMSG_SendStats_Write ; (R16, R17, R18, R19, R20, R21, Z) bigcall NETMSG_SendStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
sbiw xh:xl, 1 sbiw xh:xl, 1
pop r16 pop r16
bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) push yl
push yh
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
pop yh
pop yl
AppNetwork_SendTxdStats_end: AppNetwork_SendTxdStats_end:
ret ret
; @end ; @end
@@ -35,7 +41,7 @@ AppNetwork_SendTxdStats_end:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine AppNetwork_SendRxdStats ; @routine AppNetwork_SendRxdStats
; @param Y network interface to work with ; @param Y network interface whose stats to send
; @clobbers R16, X (R17, R18, R19, R20, R21, Z) ; @clobbers R16, X (R17, R18, R19, R20, R21, Z)
AppNetwork_SendRxdStats: AppNetwork_SendRxdStats:
@@ -46,7 +52,13 @@ AppNetwork_SendRxdStats:
bigcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z) bigcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
sbiw xh:xl, 1 sbiw xh:xl, 1
pop r16 pop r16
bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) push yl
push yh
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
pop yh
pop yl
AppNetwork_SendRxdStats_end: AppNetwork_SendRxdStats_end:
ret ret
; @end ; @end
@@ -54,9 +66,8 @@ AppNetwork_SendRxdStats_end:
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine AppNetwork_SendRxdStats ; @routine AppNetwork_SendMemStats
; @param Y network interface to work with
; @clobbers R16, X (R17, R18, R19, R20, R21, Z) ; @clobbers R16, X (R17, R18, R19, R20, R21, Z)
AppNetwork_SendMemStats: AppNetwork_SendMemStats:
@@ -67,7 +78,13 @@ AppNetwork_SendMemStats:
bigcall NETMSG_MemStats_Write ; (R16, R17, R18, R19, R20, R21) bigcall NETMSG_MemStats_Write ; (R16, R17, R18, R19, R20, R21)
sbiw xh:xl, 1 sbiw xh:xl, 1
pop r16 pop r16
bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) push yl
push yh
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
pop yh
pop yl
AppNetwork_SendMemStats_end: AppNetwork_SendMemStats_end:
ret ret
; @end ; @end

View File

@@ -11,7 +11,7 @@
; *************************************************************************** ; ***************************************************************************
; defines ; defines
.equ APP_STATS_INTERVAL_MINS = 31 .equ APP_STATS_INTERVAL_MINS = 10
@@ -62,10 +62,6 @@ AppStats_OnEveryMinute:
ret ret
AppStats_OnEveryMinute_noIrq: AppStats_OnEveryMinute_noIrq:
; ldi yl, LOW(netInterfaceData)
; ldi yh, HIGH(netInterfaceData)
; rcall AppNetwork_SendRxdStats ; debug
lds r16, appStatsTimer lds r16, appStatsTimer
inc r16 inc r16
cpi r16, APP_STATS_INTERVAL_MINS cpi r16, APP_STATS_INTERVAL_MINS
@@ -73,71 +69,28 @@ AppStats_OnEveryMinute_noIrq:
clr r16 clr r16
AppStats_OnEveryMinute_store: AppStats_OnEveryMinute_store:
sts appStatsTimer, r16 sts appStatsTimer, r16
ldi yl, LOW(netInterfaceData)
ldi yh, HIGH(netInterfaceData)
ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN
ldi xl, LOW(netInterfaceData)
ldi xh, HIGH(netInterfaceData)
cpi r16, 1 cpi r16, 1
breq AppStats_OnEveryMinute_sendDevice breq AppStats_OnEveryMinute_sendDevice
cpi r16, 2
breq AppStats_OnEveryMinute_sendMemStats
cpi r16, 3 cpi r16, 3
breq AppStats_OnEveryMinute_sendPacketsIn breq AppStats_OnEveryMinute_sendRecvStats1
cpi r16, 5
breq AppStats_OnEveryMinute_sendPacketsOut cpi r16, 4
cpi r16, 6 breq AppStats_OnEveryMinute_sendSendStats1
breq AppStats_OnEveryMinute_sendDevice
cpi r16, 7
breq AppStats_OnEveryMinute_sendContentErrs
cpi r16, 9
breq AppStats_OnEveryMinute_sendIoErrs
cpi r16, 10
breq AppStats_OnEveryMinute_sendDevice
cpi r16, 11
breq AppStats_OnEveryMinute_sendNoBufErrs
cpi r16, 13
breq AppStats_OnEveryMinute_sendCollisionErrs
cpi r16, 14
breq AppStats_OnEveryMinute_sendDevice
cpi r16, 15
breq AppStats_OnEveryMinute_sendBusyErrs
#ifdef APP_STATS_NETDEV2 #ifdef APP_STATS_NETDEV2
ldi r17, AQHOME_VALUEID_STATS_PACKETS_IN2 cpi r16, 5
ldi xl, LOW(netInterfaceData2) breq AppStats_OnEveryMinute_sendRecvStats2
ldi xh, HIGH(netInterfaceData2)
cpi r16, 16
breq AppStats_OnEveryMinute_sendPacketsIn
cpi r16, 17
breq AppStats_OnEveryMinute_sendPacketsOut
cpi r16, 18
breq AppStats_OnEveryMinute_sendDevice
cpi r16, 19
breq AppStats_OnEveryMinute_sendContentErrs
cpi r16, 20
breq AppStats_OnEveryMinute_sendIoErrs
cpi r16, 21
breq AppStats_OnEveryMinute_sendDevice
cpi r16, 22
breq AppStats_OnEveryMinute_sendNoBufErrs
cpi r16, 23
breq AppStats_OnEveryMinute_sendDevice
cpi r16, 24
breq AppStats_OnEveryMinute_sendCollisionErrs
cpi r16, 25
breq AppStats_OnEveryMinute_sendBusyErrs
#endif
#ifdef MODULES_HEAP cpi r16, 6
cpi r16, 26 breq AppStats_OnEveryMinute_sendSendStats2
breq AppStats_OnEveryMinute_sendHeapUsed
cpi r16, 27
breq AppStats_OnEveryMinute_sendHeapfree
#endif #endif
cpi r16, 28 ; add more here
breq AppStats_OnEveryMinute_sendDevice
ret ret
AppStats_OnEveryMinute_sendDevice: AppStats_OnEveryMinute_sendDevice:
push yl push yl
push yh push yh
@@ -152,68 +105,35 @@ AppStats_OnEveryMinute_sendDevice:
pop yh pop yh
pop yl pop yl
ret ret
AppStats_OnEveryMinute_sendPacketsIn: AppStats_OnEveryMinute_sendMemStats:
ldi r16, 0 rjmp AppNetwork_SendMemStats
rjmp appStatsSendDeviceStat
AppStats_OnEveryMinute_sendPacketsOut:
ldi r16, 1
rjmp appStatsSendDeviceStat
AppStats_OnEveryMinute_sendContentErrs:
ldi r16, 2
rjmp appStatsSendDeviceStat
AppStats_OnEveryMinute_sendIoErrs:
ldi r16, 3
rjmp appStatsSendDeviceStat
AppStats_OnEveryMinute_sendNoBufErrs:
ldi r16, 4
rjmp appStatsSendDeviceStat
AppStats_OnEveryMinute_sendCollisionErrs:
ldi r16, 5
rjmp appStatsSendDeviceStat
AppStats_OnEveryMinute_sendBusyErrs:
ldi r16, 6
rjmp appStatsSendDeviceStat
#ifdef MODULES_HEAP AppStats_OnEveryMinute_sendRecvStats1:
AppStats_OnEveryMinute_sendHeapUsed: ldi yl, LOW(netInterfaceData)
ldi r17, AQHOME_VALUEID_STATS_HEAP_USED ldi yh, HIGH(netInterfaceData)
lds r18, heapUsed rjmp AppNetwork_SendRxdStats
lds r19, heapUsed+1
rjmp appStatsSend16BitValue AppStats_OnEveryMinute_sendSendStats1:
AppStats_OnEveryMinute_sendHeapfree: ldi yl, LOW(netInterfaceData)
ldi r17, AQHOME_VALUEID_STATS_HEAP_FREE ldi yh, HIGH(netInterfaceData)
lds r18, heapFree rjmp AppNetwork_SendTxdStats
lds r19, heapFree+1
rjmp appStatsSend16BitValue #ifdef APP_STATS_NETDEV2
AppStats_OnEveryMinute_sendRecvStats2:
ldi yl, LOW(netInterfaceData2)
ldi yh, HIGH(netInterfaceData2)
rjmp AppNetwork_SendRxdStats
AppStats_OnEveryMinute_sendSendStats2:
ldi yl, LOW(netInterfaceData2)
ldi yh, HIGH(netInterfaceData2)
rjmp AppNetwork_SendTxdStats
#endif #endif
; @end ; @end
; ---------------------------------------------------------------------------
; @routine AppStats_OnEveryMinute @global
;
; @param r16 index into device table (e.g. 0 for NET_IFACE_OFFS_PACKETSIN_LOW)
; @param r17 offset to first value id (e.g. AQHOME_VALUEID_STATS_PACKETS_IN for device 0,
; AQHOME_VALUEID_STATS_PACKETS_IN2 for device 1)
; @param Y pointer to device to send data to
; @param X pointer to device to inspect
appStatsSendDeviceStat:
add r17, r16
lsl r16
adiw xh:xl, NET_IFACE_OFFS_PACKETSIN_LOW
add xl, r16
adc xh, r16
sub xh, r16
ld r18, X+
ld r19, X
rjmp appStatsSend16BitValue
; @end
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine AppStats_OnEveryMinute @global ; @routine AppStats_OnEveryMinute @global
; ;

View File

@@ -165,10 +165,11 @@ Offset Length Meaning
2 1 command code 2 1 command code
3 1 source address 3 1 source address
--------------------------------------------------------- ---------------------------------------------------------
4 4 UID of the sending node 4 1 Interface number
8 2 packets out 5 4 UID of the sending node
10 2 collisions 9 2 packets out
12 2 line busy errors 11 2 collisions
13 2 line busy errors
--------------------------------------------------------- ---------------------------------------------------------
14 1 CRC8 byte 14 1 CRC8 byte
@@ -185,15 +186,16 @@ Offset Length Meaning
2 1 command code 2 1 command code
3 1 source address 3 1 source address
--------------------------------------------------------- ---------------------------------------------------------
4 4 UID of the sending node 4 1 Interface number
8 2 packets in 5 4 UID of the sending node
10 2 content errors (invalid msg length, CRC errors) 9 2 packets in
12 2 io errors 11 2 content errors (invalid msg length, CRC errors)
14 2 no buffer errors 13 2 io errors
16 2 handled packets 15 2 no buffer errors
18 2 missed packets 17 2 handled packets
19 2 missed packets
--------------------------------------------------------- ---------------------------------------------------------
20 1 CRC8 byte 21 1 CRC8 byte

View File

@@ -14,8 +14,8 @@
.equ NETMSG_CMD_PING = 10 .equ NETMSG_CMD_PING = 10
.equ NETMSG_CMD_PONG = 11 .equ NETMSG_CMD_PONG = 11
.equ NETMSG_CMD_SENDSTATS = 20 .equ NETMSG_CMD_SENDSTATS = 22
.equ NETMSG_CMD_RECVSTATS = 21 .equ NETMSG_CMD_RECVSTATS = 23
.equ NETMSG_CMD_TWIBUSMEMBER = 30 .equ NETMSG_CMD_TWIBUSMEMBER = 30
.equ NETMSG_CMD_DEBUG = 40 .equ NETMSG_CMD_DEBUG = 40

View File

@@ -51,14 +51,10 @@ NETMSG_MemStats_Write:
st X+, r21 st X+, r21
.endif .endif
; current buffers used ; current buffers used
push xl lds r16, netBuffersUsed
push xh
bigcall NET_Buffer_CountUsed ; (r16, r17, r18, X)
pop xh
pop xl
st X+, r16 st X+, r16
; max buffers used ; max buffers used
clr r16 lds r16, netBuffersMaxUsed
st X+, r16 st X+, r16
; no buffer errors ; no buffer errors
ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW

View File

@@ -19,21 +19,52 @@
NETMSG_RecvStats_Write: NETMSG_RecvStats_Write:
ldi r16, 0xff ldi r16, 0xff
st X+, r16 ; dest address st X+, r16 ; dest address
ldi r16, 18 ; msg code+src address+10 payload bytes ldi r16, 19 ; msg code+src address+10 payload bytes
st X+, r16 ; msg len st X+, r16 ; msg len
ldi r16, NETMSG_CMD_RECVSTATS ldi r16, NETMSG_CMD_RECVSTATS
st X+, r16 ; msg code st X+, r16 ; msg code
ldd r16, Y+NET_IFACE_OFFS_ADDRESS ldd r16, Y+NET_IFACE_OFFS_ADDRESS
st X+, r16 ; src address st X+, r16 ; src address
bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
adiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW
ldi r18, 12
bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
sbiw yh:yl, NET_IFACE_OFFS_PACKETSIN_LOW+12
sbiw xh:xl, 20 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload) ; UID
bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
; interface number
ldd r16, Y+NET_IFACE_OFFS_IFACENUM
st X+, r16
; packets in
ldd r16, Y+NET_IFACE_OFFS_PACKETSIN_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_PACKETSIN_HIGH
st X+, r16
; content error
ldd r16, Y+NET_IFACE_OFFS_ERR_CONTENT_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_CONTENT_HIGH
st X+, r16
; io error
ldd r16, Y+NET_IFACE_OFFS_ERR_IO_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_IO_HIGH
st X+, r16
; nobuf error
ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_NOBUF_HIGH
st X+, r16
; msgsize error
ldd r16, Y+NET_IFACE_OFFS_ERR_MSGSIZE_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_MSGSIZE_HIGH
st X+, r16
; missed error
ldd r16, Y+NET_IFACE_OFFS_ERR_MISSED_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_MISSED_HIGH
st X+, r16
sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload)
bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
sbiw xh:xl, 21 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc) sbiw xh:xl, 22 ; go back to beginning of message (1 byte dst addr, 1 byte length, 18 bytes payload, 1 byte crc)
ret ret
; @end ; @end

View File

@@ -12,28 +12,44 @@
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine NETMSG_SendStats_Write @global ; @routine NETMSG_SendStats_Write @global
; ;
; @param Y pointer to device to write msg for and to ; @param Y pointer to device to write msg for
; @param X pointer to buffer to write to ; @param X pointer to buffer to write to
; @clobbers R16, R18 (R17, R19, R20, R21, Z) ; @clobbers R16, R18 (R17, R19, R20, R21, Z)
NETMSG_SendStats_Write: NETMSG_SendStats_Write:
ldi r16, 0xff ldi r16, 0xff
st X+, r16 ; dest address st X+, r16 ; dest address
ldi r16, 12 ; msg code+src address+10 payload bytes ldi r16, 13 ; msg code+src address+11 payload bytes
st X+, r16 ; msg len st X+, r16 ; msg len
ldi r16, NETMSG_CMD_SENDSTATS ldi r16, NETMSG_CMD_SENDSTATS
st X+, r16 ; msg code st X+, r16 ; msg code
ldd r16, Y+NET_IFACE_OFFS_ADDRESS ldd r16, Y+NET_IFACE_OFFS_ADDRESS
st X+, r16 ; src address st X+, r16 ; src address
bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
adiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW
ldi r18, 6
bigcall Utils_Copy_SDRAM ; (R17, R18, X, Y)
sbiw yh:yl, NET_IFACE_OFFS_PACKETSOUT_LOW+6
sbiw xh:xl, 14 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload) ; UID
bigcall NETMSG_Common_AddUidToBuffer ; (R16, R18, R19, R20, R21)
; interface number
ldd r16, Y+NET_IFACE_OFFS_IFACENUM
st X+, r16
; packets out
ldd r16, Y+NET_IFACE_OFFS_PACKETSOUT_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_PACKETSOUT_HIGH
st X+, r16
; collisions
ldd r16, Y+NET_IFACE_OFFS_ERR_COLLISIONS_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_COLLISIONS_HIGH
st X+, r16
; busy
ldd r16, Y+NET_IFACE_OFFS_ERR_BUSY_LOW
st X+, r16
ldd r16, Y+NET_IFACE_OFFS_ERR_BUSY_HIGH
st X+, r16
sbiw xh:xl, 15 ; go back to beginning of message (1 byte dst addr, 1 byte length, 13 bytes payload)
bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X) bigcall NETMSG_CalcAndAddChecksumByte ; (R16, R17, R18, R19, R20, X)
sbiw xh:xl, 15 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload, 1 byte crc) sbiw xh:xl, 16 ; go back to beginning of message (1 byte dst addr, 1 byte length, 12 bytes payload, 1 byte crc)
ret ret
; @end ; @end