]> git.zerfleddert.de Git - hmcfgusb/commitdiff
some changes in transfer-time-measurement
authorMichael Gernoth <michael@gernoth.net>
Sun, 7 Jul 2013 20:25:11 +0000 (22:25 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sun, 7 Jul 2013 20:25:11 +0000 (22:25 +0200)
hmcfgusb.c

index ce8c595268918381544c756d60f3b36d0045ae5f..5939dd61cd7ba9cc345f1aa9b74343ab72c21c3f 100644 (file)
@@ -163,9 +163,10 @@ int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len
 
        if (debug) {
                hexdump(send_data, len, "USB < ");
 
        if (debug) {
                hexdump(send_data, len, "USB < ");
-               gettimeofday(&tv_start, NULL);
        }
 
        }
 
+       gettimeofday(&tv_start, NULL);
+
        err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, send_data, len, &cnt, USB_TIMEOUT);
        if (err) {
                fprintf(stderr, "Can't send data: %s\n", usb_strerror(err));
        err = libusb_interrupt_transfer(usbdev->usb_devh, EP_OUT, send_data, len, &cnt, USB_TIMEOUT);
        if (err) {
                fprintf(stderr, "Can't send data: %s\n", usb_strerror(err));
@@ -178,10 +179,14 @@ int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len
                }
        }
 
                }
        }
 
-       if (debug) {
-               gettimeofday(&tv_end, NULL);
-               msec = ((tv_end.tv_sec-tv_start.tv_sec)*1000)+((tv_end.tv_usec-tv_start.tv_usec)/1000);
-               fprintf(stderr, "send took %dms!\n", msec);
+       gettimeofday(&tv_end, NULL);
+       msec = ((tv_end.tv_sec-tv_start.tv_sec)*1000)+((tv_end.tv_usec-tv_start.tv_usec)/1000);
+
+       if (msec > 100) {
+               if (debug)
+                       fprintf(stderr, "usb-transfer took more than 100ms (%dms), this can lead to timing problems!\n", msec);
+       } else if (debug) {
+               fprintf(stderr, "usb-transfer took %dms!\n", msec);
        }
 
        return 1;
        }
 
        return 1;
Impressum, Datenschutz