From 8847d051c163776870a9b6434e979f4c3d933410 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 24 Apr 2023 20:36:13 +0200 Subject: [PATCH] aqhome-tool: more work on getdevices. --- apps/aqhome-tool/getdevices.c | 11 +++- aqhome/ipc/msg_ipc_getdevices_rsp.c | 86 ++++++++++++++++++++++++++--- aqhome/ipc/msg_ipc_getdevices_rsp.h | 8 +++ 3 files changed, 96 insertions(+), 9 deletions(-) diff --git a/apps/aqhome-tool/getdevices.c b/apps/aqhome-tool/getdevices.c index f6f02f9..7d6499e 100644 --- a/apps/aqhome-tool/getdevices.c +++ b/apps/aqhome-tool/getdevices.c @@ -174,13 +174,20 @@ int _doGetDevices(GWEN_DB_NODE *dbArgs) ts64=AQH_GetDevicesResponseIpcMsg_GetTimestamp(msg); ts=GWEN_Timestamp_fromInt64(ts64); /* TODO: fix timestamp */ - fprintf(stdout, "- node: %02x (uid=%04x, firmware type=%02x, firmware version=%d.%d, timeStamp: %016lx)\n", + fprintf(stdout, "- node: %02x (uid=%04x, fw type=%02x, fw version=%d.%d, timeStamp: %016lx" + ", pkg out: %d, pkg in: %d, collisions: %d, busy: %d, crc: %d, io: %d)\n", AQH_GetDevicesResponseIpcMsg_GetBusAddress(msg), AQH_GetDevicesResponseIpcMsg_GetUid(msg), AQH_GetDevicesResponseIpcMsg_GetFirmwareType(msg), (fwVersion>>8) & 0xff, fwVersion & 0xff, - (unsigned long int)ts64); + (unsigned long int)ts64, + AQH_GetDevicesResponseIpcMsg_GetPkgOut(msg), + AQH_GetDevicesResponseIpcMsg_GetPkgIn(msg), + AQH_GetDevicesResponseIpcMsg_GetCollisions(msg), + AQH_GetDevicesResponseIpcMsg_GetBusy(msg), + AQH_GetDevicesResponseIpcMsg_GetCrcErrors(msg), + AQH_GetDevicesResponseIpcMsg_GetIoErrors(msg)); GWEN_Timestamp_free(ts); GWEN_Msg_free(msg); if (flags & AQH_MSGIPC_GETDEVICES_RSP_FLAGS_LAST) { diff --git a/aqhome/ipc/msg_ipc_getdevices_rsp.c b/aqhome/ipc/msg_ipc_getdevices_rsp.c index 7845b44..bd96be1 100644 --- a/aqhome/ipc/msg_ipc_getdevices_rsp.c +++ b/aqhome/ipc/msg_ipc_getdevices_rsp.c @@ -23,13 +23,19 @@ #include -#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FLAGS 0 /* 1 bytes */ -#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSADDR 1 /* 1 bytes */ -#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_UID 2 /* 4 bytes */ -#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWTYPE 6 /* 2 bytes */ -#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWVER 8 /* 2 bytes */ -#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_MODULES 10 /* 2 bytes */ -#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG 12 /* 8 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FLAGS 0 /* 1 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSADDR 1 /* 1 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_UID 2 /* 4 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWTYPE 6 /* 2 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_FWVER 8 /* 2 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_MODULES 10 /* 2 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG 12 /* 8 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGOUT 20 /* 2 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGIN 22 /* 2 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_COLLISIONS 24 /* 2 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSY 26 /* 2 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_CRC 28 /* 2 bytes */ +#define AQH_MSGIPC_GETDEVICES_RSP_OFFS_IO 30 /* 2 bytes */ #define AQH_MSGIPC_GETDEVICES_RSP_MINSIZE (GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_LASTCHG+8) @@ -82,6 +88,30 @@ GWEN_MSG *AQH_GetDevicesResponseIpcMsg_new(uint16_t code, uint8_t flags, const A *(ptr++)=(u64>>48) & 0xff; *(ptr++)=(u64>>56) & 0xff; + u32=AQH_NodeInfo_GetStatsPacketsOut(ni); + *(ptr++)=u32 & 0xff; + *(ptr++)=(u32>>8) & 0xff; + + u32=AQH_NodeInfo_GetStatsPacketsIn(ni); + *(ptr++)=u32 & 0xff; + *(ptr++)=(u32>>8) & 0xff; + + u32=AQH_NodeInfo_GetStatsCollisions(ni); + *(ptr++)=u32 & 0xff; + *(ptr++)=(u32>>8) & 0xff; + + u32=AQH_NodeInfo_GetStatsBusy(ni); + *(ptr++)=u32 & 0xff; + *(ptr++)=(u32>>8) & 0xff; + + u32=AQH_NodeInfo_GetStatsCrcErrors(ni); + *(ptr++)=u32 & 0xff; + *(ptr++)=(u32>>8) & 0xff; + + u32=AQH_NodeInfo_GetStatsIoErrors(ni); + *(ptr++)=u32 & 0xff; + *(ptr++)=(u32>>8) & 0xff; + return msg; } @@ -140,6 +170,48 @@ int64_t AQH_GetDevicesResponseIpcMsg_GetTimestamp(const GWEN_MSG *msg) +uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgOut(const GWEN_MSG *msg) +{ + return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGOUT, 0); +} + + + +uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgIn(const GWEN_MSG *msg) +{ + return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_PKGIN, 0); +} + + + +uint16_t AQH_GetDevicesResponseIpcMsg_GetCollisions(const GWEN_MSG *msg) +{ + return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_COLLISIONS, 0); +} + + + +uint16_t AQH_GetDevicesResponseIpcMsg_GetBusy(const GWEN_MSG *msg) +{ + return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_BUSY, 0); +} + + + +uint16_t AQH_GetDevicesResponseIpcMsg_GetCrcErrors(const GWEN_MSG *msg) +{ + return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_CRC, 0); +} + + + +uint16_t AQH_GetDevicesResponseIpcMsg_GetIoErrors(const GWEN_MSG *msg) +{ + return GWEN_Msg_GetUint16At(msg, GWEN_MSGIPC_OFFS_PAYLOAD+AQH_MSGIPC_GETDEVICES_RSP_OFFS_IO, 0); +} + + + void AQH_GetDevicesResponseIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText) { if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSGIPC_GETDEVICES_RSP_MINSIZE) { diff --git a/aqhome/ipc/msg_ipc_getdevices_rsp.h b/aqhome/ipc/msg_ipc_getdevices_rsp.h index bf1a8fd..77c70c8 100644 --- a/aqhome/ipc/msg_ipc_getdevices_rsp.h +++ b/aqhome/ipc/msg_ipc_getdevices_rsp.h @@ -32,6 +32,14 @@ AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetFirmwareVersion(const GWEN_M AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetModules(const GWEN_MSG *msg); AQHOME_API int64_t AQH_GetDevicesResponseIpcMsg_GetTimestamp(const GWEN_MSG *msg); +AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgOut(const GWEN_MSG *msg); +AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetPkgIn(const GWEN_MSG *msg); +AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetCollisions(const GWEN_MSG *msg); +AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetBusy(const GWEN_MSG *msg); +AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetCrcErrors(const GWEN_MSG *msg); +AQHOME_API uint16_t AQH_GetDevicesResponseIpcMsg_GetIoErrors(const GWEN_MSG *msg); + + AQHOME_API void AQH_GetDevicesResponseIpcMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText);