signal11 / hidapi

A Simple library for communicating with USB and Bluetooth HID devices on Linux, Mac, and Windows.
http://www.signal11.us/oss/hidapi/
Other
2.44k stars 898 forks source link

Linux: LIBUSB_TRANSFER_ERROR not handled in read callback #50

Closed jrcutler closed 12 years ago

jrcutler commented 12 years ago

The read callback will currently hang if a transfer status of LIBUSB_TRANSFER_ERROR occurs. There is a simple fix.

signal11 commented 12 years ago

Do we necessarily want to kill the entire read thread if just one input transfer fails? What is the case in which you are seeing this?

jrcutler commented 12 years ago

I have found that one process opening a device will disrupt another process that already has the device open (under Linux/libusb). If I do not terminate the thread after the error, I often find the device in an unusable state. Conversely, if I do terminate the thread and reopen, the device seems to remain functional. (The device in question is a FUNcube Dongle Pro.)

signal11 commented 12 years ago

Unfortunately, opening a device a second time causes problems. I'm working with the libusb maintainer to come up with a better solution, however LIBUSB_TRANSFER_ERROR isn't the right thing to key on because there are other situations which give this error which are recoverable. I'll let you know soon.

signal11 commented 12 years ago

Check out: 1bde0321709c8a15d5623f599dc43e

I think this will do what you're looking for.

jrcutler commented 12 years ago

This works as expected.