]> mj.ucw.cz Git - home-hw.git/commitdiff
BSB: Daemon tries to send frames
authorMartin Mares <mj@ucw.cz>
Wed, 26 Feb 2020 17:34:02 +0000 (18:34 +0100)
committerMartin Mares <mj@ucw.cz>
Wed, 26 Feb 2020 17:34:02 +0000 (18:34 +0100)
bsb/daemon/Makefile
bsb/daemon/burrow-bsb.c

index 10ed6338e4ad0f99f9d127851f39db25b26a4365..8afe8d2ec2112242e553687b9beb54c4b86c76c0 100644 (file)
@@ -1,4 +1,4 @@
-PC := pkg-config
+PC := PKG_CONFIG_PATH=/home/mj/tmp/bsb/root/lib/pkgconfig pkg-config
 USB_CFLAGS := $(shell $(PC) --cflags libusb-1.0)
 USB_LDFLAGS := $(shell $(PC) --libs libusb-1.0)
 
index 714f811600ff09a5038e56280983c9cc5dc4c02e..9e02008f3ec73c48b45e3354234c9cede091680d 100644 (file)
@@ -92,6 +92,11 @@ static const char * const stat_names[] = {
        "rx_timeouts",
        "rx_bad_crc",
        "rx_ok",
+       "tx_overruns",
+       "tx_rejects",
+       "tx_timeouts",
+       "tx_collisions",
+       "tx_ok",
 };
 
 static void show_stats(byte *resp, uint len)
@@ -106,6 +111,11 @@ 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]);
+               return;
+       }
+
 #if 1
        printf(":");
        for (uint i=0; i<len; i++)
@@ -145,7 +155,9 @@ int main(void)
        // libusb_set_debug(usb_ctxt, 3);
        open_device();
 
+       time_t now = time(NULL);
        time_t last_stats = 0;
+       time_t last_query = now;
        int received;
        byte resp[64];
 
@@ -158,7 +170,7 @@ int main(void)
                        }
                }
 
-               time_t now = time(NULL);
+               now = time(NULL);
                if (last_stats + 60 < now) {
                        if ((received = libusb_control_transfer(devh, 0xc0, 0x00, 0, 0, resp, sizeof(resp), 1000)) < 0) {
                                usb_error("Receive failed: error %d", received);
@@ -169,6 +181,18 @@ int main(void)
                        last_stats = now;
                }
 
+               if (last_query + 10 < now) {
+                       byte pkt[] = { 0xdc, 0xc2, 0x00, 0x0b, 0x06, 0x3d, 0x2e, 0x11, 0x25 };
+                       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);
+                               // continue;
+                       } else {
+                               printf("Send OK: %d bytes\n", received);
+                       }
+                       last_query = now;
+               }
+
 #if 0
                if (err = libusb_bulk_transfer(devh, 0x81, resp, 64, &received, 2000)) {
                        usb_error("Receive failed: error %d", err);