aboutsummaryrefslogtreecommitdiffstats
path: root/src/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/usb.c')
-rw-r--r--src/usb.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/usb.c b/src/usb.c
index 5742d7b..95bf14a 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -18,6 +18,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <unistd.h>
#include <sys/types.h>
#include <libusb.h>
@@ -39,8 +40,15 @@ int usb_open(struct context *context)
return -1;
}
- handle = libusb_open_device_with_vid_pid(NULL, USB_VENDOR_LG, USB_DEVICE_DOWNLOAD);
- if (handle == NULL) {
+ do {
+ handle = libusb_open_device_with_vid_pid(NULL, USB_VENDOR_LG, USB_DEVICE_DOWNLOAD);
+ if (handle != NULL)
+ break;
+
+ usleep(300000);
+ } while (context->wait);
+
+ if (handle == NULL) {
fprintf(stderr, "Finding and opening USB device failed\n");
fprintf(stderr, "\nDevice might be missing or you may not have the rights to do this\n");
goto error;