Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libusb: remove the timeouts in hid_write() #190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
10 changes: 8 additions & 2 deletions linux/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,15 @@ int HID_API_EXPORT hid_write(hid_device *dev, const unsigned char *data, size_t
{
int bytes_written;

bytes_written = write(dev->device_handle, data, length);
while (1) {
bytes_written = write(dev->device_handle, data, length);
if (bytes_written < 0 &&
(errno == ETIMEDOUT || errno == EINTR)) {
continue;
}

return bytes_written;
return bytes_written;
}
}


Expand Down