libtest: Parse "value" packets.
This commit is contained in:
@@ -109,7 +109,7 @@ void _packetReceived(AQH_SERIAL *sr, const uint8_t *ptr, uint8_t len)
|
||||
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||
ti=GWEN_CurrentTime();
|
||||
GWEN_Time_toString(ti, "YYYY-MM-DD hh:mm:ss", dbuf);
|
||||
fprintf(stdout, "- %s: Received:\n", GWEN_Buffer_GetStart(dbuf));
|
||||
fprintf(stdout, " %s: Received:\n", GWEN_Buffer_GetStart(dbuf));
|
||||
GWEN_Text_DumpString(ptr, len, 6);
|
||||
GWEN_Time_free(ti);
|
||||
GWEN_Buffer_free(dbuf);
|
||||
@@ -148,6 +148,33 @@ void _packetReceived(AQH_SERIAL *sr, const uint8_t *ptr, uint8_t len)
|
||||
param2=ptr[5];
|
||||
fprintf(stdout, "-> Debug param1=%02x, param2=%02x\n", param1, param2);
|
||||
}
|
||||
else if (ptr[2]==6) {
|
||||
uint32_t secs;
|
||||
int valueId;
|
||||
int valueType;
|
||||
double value;
|
||||
double denom;
|
||||
double calcValue;
|
||||
int intDenom;
|
||||
const char *tn;
|
||||
|
||||
/* send error stats */
|
||||
secs=(ptr[4])+(ptr[5]<<8)+(ptr[6]<<16)+(ptr[7]<<24);
|
||||
valueId=ptr[8];
|
||||
valueType=ptr[9];
|
||||
value=(double)((ptr[10])+(ptr[11]<<8));
|
||||
intDenom=(ptr[12])+(ptr[13]<<8);
|
||||
denom=(double)(intDenom);
|
||||
if (intDenom==0)
|
||||
denom=1.0;
|
||||
calcValue=value/denom;
|
||||
switch(valueType) {
|
||||
case 1: tn="temperature"; break;
|
||||
case 2: tn="humidity"; break;
|
||||
default: tn="unknown"; break;
|
||||
}
|
||||
fprintf(stdout, "-> VALUE: %08x %d=%.2f (%s)\n", (unsigned int) secs, valueId, calcValue, tn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -158,8 +185,8 @@ int testLoop()
|
||||
int rv;
|
||||
int i;
|
||||
GWEN_BUFFER *dbuf;
|
||||
uint8_t sendBuf[5]={0x01, 0x02, 0xdb, 0x00, 0xd8 };
|
||||
uint8_t sendBuf2[2]={0x02, 0xdb };
|
||||
// uint8_t sendBuf[5]={0x01, 0x02, 0xdb, 0x00, 0xd8 };
|
||||
uint8_t sendBuf[5]={0x01, 0x02, 0x01, 0xdb, 0xd9 };
|
||||
time_t tLast;
|
||||
|
||||
fprintf(stdout, "Opening device...\n");
|
||||
|
||||
Reference in New Issue
Block a user