diff --git a/transports/libhoth_usb.c b/transports/libhoth_usb.c index bee2865..6b18c6c 100644 --- a/transports/libhoth_usb.c +++ b/transports/libhoth_usb.c @@ -193,9 +193,26 @@ static int libhoth_usb_device_open( usb_dev->info = info; usb_dev->ctx = options->usb_ctx; usb_dev->claim_timeout_us = options->timeout_us; - status = libusb_open(options->usb_device, &usb_dev->handle); - if (status != LIBUSB_SUCCESS) { - goto err_out; + + uint32_t wait_time_us = 0; + while (true) { + status = libusb_open(options->usb_device, &usb_dev->handle); + + if (status == LIBUSB_SUCCESS) { + break; + } + + if (status != LIBUSB_ERROR_ACCESS) { + goto err_out; + } + + if (wait_time_us >= options->timeout_us) { + // timeout + goto err_out; + } + + usleep(1000); + wait_time_us += 1000; } dev->send = libhoth_usb_send_request;