]> git.zerfleddert.de Git - hmcfgusb/commitdiff
add USB send-duration to debug output
authorMichael Gernoth <michael@gernoth.net>
Fri, 5 Jul 2013 08:22:19 +0000 (10:22 +0200)
committerMichael Gernoth <michael@gernoth.net>
Fri, 5 Jul 2013 08:22:19 +0000 (10:22 +0200)
hmcfgusb.c

index 0bcb5aeb6ebea87a1a905f6b9ce4d184fc0ba867..1ba9b2412a7b2b5b685faef7beb73f6c71def49e 100644 (file)
@@ -29,6 +29,7 @@
 #include <math.h>
 #include <poll.h>
 #include <errno.h>
+#include <sys/time.h>
 #include <libusb-1.0/libusb.h>
 
 #include "hexdump.h"
@@ -143,9 +144,14 @@ int hmcfgusb_send(struct hmcfgusb_dev *usbdev, unsigned char* send_data, int len
 {
        int err;
        int cnt;
+       struct timeval tv_start, tv_end;
+       int msec;
 
-       if (debug)
+       if (debug) {
                hexdump(send_data, len, "USB < ");
+               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));
@@ -160,6 +166,12 @@ 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);
+       }
+
        return 1;
 }
 
Impressum, Datenschutz