diff options
-rw-r--r-- | halfkay.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -40,7 +40,7 @@ enum { HK_USB_VAL = 0x200, TIMEOUT = 2000, TIMEOUT_FIRST = 3000, - TRANS_DELAY = 10000, + TRANS_DELAY = 4000, TRANS_ATTEMPTS = 10, }; @@ -80,11 +80,13 @@ static void usbsendcmd(void *data, size_t size, bool firstxfer) { unsigned int timeout = firstxfer ? TIMEOUT_FIRST : TIMEOUT; int rc, attempt = 0; + useconds_t delay = TRANS_DELAY; do { rc = libusb_control_transfer(hk_usb_hnd, HK_USB_REQTYP, HK_USB_REQ, HK_USB_VAL, 0, data, size, timeout); - usleep(TRANS_DELAY); + usleep(delay); + delay *= 2; } while (rc == LIBUSB_ERROR_PIPE && ++attempt < TRANS_ATTEMPTS); if (rc < 0) |