]> mj.ucw.cz Git - home-hw.git/blobdiff - bsb/daemon/burrow-bsb.c
Merge branch 'master' of ssh://git.ucw.cz/home/mj/GIT/home-hw
[home-hw.git] / bsb / daemon / burrow-bsb.c
index e5304e33697d9cf34ed38e55cef37bc9cfcb2539..208056a191b159e760fb1651bf135e74d7f903b1 100644 (file)
@@ -105,19 +105,29 @@ static void show_stats(byte *resp, uint len)
 
 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]);
@@ -176,7 +186,7 @@ int main(void)
                }
 
                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);