Reputation: 45
I'm using libusb on windows to work with multiple usb devices using default context. For hot-plugin support I'm registering for the windows events not libusb. I'm running infinite while loop in a separate thread function and inside the while loop i'm calling libusb_handle_events_timeout. And i'm sleeping this thread for 5 seconds when libusb_handle_events_timeout returns anything less than LIBUSB_SUCCESS and continuing the while loop. If any device is disconnected when any transfer in progress libusb_handle_events_timeout function continuously returns LIBUSB_ERROR_NOT_FOUND. Even after releasing interface and closing handle this issue is seen. I'm not able to work with that device even after reconnecting. How to resolve this issue ?
while (1)
{
struct timeval tv = { 5, 0 };
r = libusb_handle_events_timeout(NULL, &tv);
if (r < LIBUSB_SUCCESS)
{
DDEBUG("ERROR: In Device Communication Thread. r = " << libusb_error_name(r));
}
}
Upvotes: 0
Views: 35