improved output from "getdevices" command.
This commit is contained in:
@@ -58,6 +58,7 @@ static AQH_MESSAGE *_createRequestMessage(AQH_OBJECT *o, uint32_t msgId);
|
|||||||
static int _handleResponseMessage(AQH_OBJECT *o, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, int first);
|
static int _handleResponseMessage(AQH_OBJECT *o, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList, int first);
|
||||||
static void _printNode(const AQH_NODE_INFO *ni, int printAll);
|
static void _printNode(const AQH_NODE_INFO *ni, int printAll);
|
||||||
static void _printUintAsTextOrHex(uint32_t u, int bits);
|
static void _printUintAsTextOrHex(uint32_t u, int bits);
|
||||||
|
static void _printDeviceIdAsTextOrHex(uint32_t u, int version);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -163,9 +164,7 @@ void _printNode(const AQH_NODE_INFO *ni, int printAll)
|
|||||||
_printUintAsTextOrHex(u, 32);
|
_printUintAsTextOrHex(u, 32);
|
||||||
fprintf(stdout, ":");
|
fprintf(stdout, ":");
|
||||||
u=AQH_NodeInfo_GetDeviceType(ni);
|
u=AQH_NodeInfo_GetDeviceType(ni);
|
||||||
_printUintAsTextOrHex(u, 16);
|
_printDeviceIdAsTextOrHex(u, AQH_NodeInfo_GetDeviceVersion(ni));
|
||||||
u=AQH_NodeInfo_GetDeviceVersion(ni);
|
|
||||||
fprintf(stdout, " v%d.%d", (u>>8) & 0xff, u & 0xff);
|
|
||||||
u=AQH_NodeInfo_GetFirmwareVersion(ni);
|
u=AQH_NodeInfo_GetFirmwareVersion(ni);
|
||||||
fprintf(stdout, ", firmware=%d.%d.%d (%d), ",
|
fprintf(stdout, ", firmware=%d.%d.%d (%d), ",
|
||||||
(u>>16) & 0xff, (u>>8) & 0xff, u & 0xff, (u>>24) & 0xff);
|
(u>>16) & 0xff, (u>>8) & 0xff, u & 0xff, (u>>24) & 0xff);
|
||||||
@@ -189,6 +188,36 @@ void _printNode(const AQH_NODE_INFO *ni, int printAll)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void _printDeviceIdAsTextOrHex(uint32_t u, int version)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
uint8_t d;
|
||||||
|
int hasNonPrintable=0;
|
||||||
|
int hasPrintable=0;
|
||||||
|
|
||||||
|
for (i=0; i<16; i+=8) {
|
||||||
|
d=((u>>i) & 0xff);
|
||||||
|
if (d==0) { /* undecided */
|
||||||
|
}
|
||||||
|
else if (isalnum(d))
|
||||||
|
hasPrintable=1;
|
||||||
|
else
|
||||||
|
hasNonPrintable=1;
|
||||||
|
}
|
||||||
|
if (hasNonPrintable || !hasPrintable)
|
||||||
|
fprintf(stdout, "%02x v%d.%d", u, (version>>8) & 0xff, version & 0xff);
|
||||||
|
else {
|
||||||
|
for (i=0; i<16; i+=8) {
|
||||||
|
d=((u>>i) & 0xff);
|
||||||
|
|
||||||
|
fprintf(stdout, "%c", d?d:' ');
|
||||||
|
}
|
||||||
|
fprintf(stdout, "%2d (%d)", (version>>8) & 0xff, version & 0xff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _printUintAsTextOrHex(uint32_t u, int bits)
|
void _printUintAsTextOrHex(uint32_t u, int bits)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
Reference in New Issue
Block a user