static void show_packet(byte *pkt, uint len)
{
- if (len == 1) {
- printf("Received status %u\n", pkt[0]);
+ if (!len) {
+ printf("ERROR: Received empty frame!\n");
+ return;
+ }
+
+ byte status = *pkt++;
+ len--;
+
+ if (!len) {
+ printf("Transmit status: %u\n", status);
return;
}
#if 1
- printf(":");
+ printf(": [%d]", status);
for (uint i=0; i<len; i++)
printf(" %02x", pkt[i]);
putchar('\n');
#endif
- printf("%02x -> %02x: ", pkt[1] ^ 0x80, pkt[2]);
+ printf("%02x -> %02x: ", pkt[BF_SRC] ^ 0x80, pkt[BF_DEST]);
+ if (status)
+ printf("[REPLY] ");
switch (pkt[4]) {
case 2:
printf("INFO %04x:%04x =", (pkt[5]<<8) | pkt[6], (pkt[7]<<8) | pkt[8]);
}
if (last_query + 10 < now) {
- byte pkt[] = { 0xdc, 0xc2, 0x00, 0x0b, 0x06, 0x3d, 0x2e, 0x11, 0x25 };
+ byte pkt[] = { 0xdc, 0xc2, 0x00, 0x0b, 0x06, 0x3d, 0x2e, 0x11, 0x25, 0x00, 0x00 };
if (err = libusb_bulk_transfer(devh, 0x01, pkt, sizeof(pkt), &received, 2000)) {
printf("Send failed: error %d\n", err);
// usb_error("Receive failed: error %d", received);