From: Michael Gernoth Date: Sun, 7 Jul 2013 20:25:11 +0000 (+0200) Subject: some changes in transfer-time-measurement X-Git-Tag: v0.100~75 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/hmcfgusb/commitdiff_plain/d200d8ca4e666defd3609ab2a8e058a20c419607 some changes in transfer-time-measurement --- diff --git a/hmcfgusb.c b/hmcfgusb.c index ce8c595..5939dd6 100644 --- a/hmcfgusb.c +++ b/hmcfgusb.c @@ -163,9 +163,10 @@ int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len 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)); @@ -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;