From d200d8ca4e666defd3609ab2a8e058a20c419607 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Sun, 7 Jul 2013 22:25:11 +0200 Subject: [PATCH] some changes in transfer-time-measurement --- hmcfgusb.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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; -- 2.39.5