diff options
author | Tomasz Kramkowski <tk@the-tk.com> | 2016-11-24 22:30:24 +0000 |
---|---|---|
committer | Tomasz Kramkowski <tk@the-tk.com> | 2016-11-24 22:30:24 +0000 |
commit | fad06882fe3305983292dfa34d335ec461761b61 (patch) | |
tree | a9c1f72046f235620490e3e98638b0b09c7f14f3 | |
parent | 6691e39b7762817b83c8460dbb2b4279c65255a9 (diff) | |
download | hktool-fad06882fe3305983292dfa34d335ec461761b61.tar.gz hktool-fad06882fe3305983292dfa34d335ec461761b61.tar.xz hktool-fad06882fe3305983292dfa34d335ec461761b61.zip |
halfkay.c: delay now backs off after failure
Implemented additional fix from previous commit message.
-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) |