From 0d4cf6c143452177f9ba2982521b6a28f8752070 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 29 Sep 2014 22:40:21 -0400 Subject: [PATCH] libusb: remove the timeouts in hid_write() The libusb/hid.c:hid_write() has timeouts in its calls to libusb_interrupt_transfer and libusb_control_transfer(). This timeout can sometimes be tripped (e.g., if the underlying hardware is slow), and no sensible error code is returned -- you just get a -1. Hence, the caller can't know that it could just try again because the only error that occurred was a timeout (or that the message may have actually gotten through). Additionally, the other hid.c:hid_write() implementations -- linux, mac, and windows -- are all blocking and do not timeout. This makes the behavior of the libusb hid_write() different than the others, which seems weird. This commit simply sets the libusb timeouts to 0 (i.e., infinite) to make the libusb hid_write() behave like the others. --- libusb/hid.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libusb/hid.c b/libusb/hid.c index a23bf461..e17db66b 100644 --- a/libusb/hid.c +++ b/libusb/hid.c @@ -1021,7 +1021,7 @@ int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t (2/*HID output*/ << 8) | report_number, dev->interface, (unsigned char *)data, length, - 1000/*timeout millis*/); + 0/*timeout millis*/); if (res < 0) return -1; @@ -1038,7 +1038,7 @@ int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t dev->output_endpoint, (unsigned char*)data, length, - &actual_length, 1000); + &actual_length, 0); if (res < 0) return -1;