Skip to content

Commit

Permalink
libusb: remove the timeouts in hid_write()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jsquyres committed Sep 30, 2014
1 parent d17db57 commit 0d4cf6c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libusb/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 0d4cf6c

Please sign in to comment.