Add retry to libx52_vendor_command

Sometimes the vendor control request failes with LIBUSB_PIPE_ERROR. Most
of the time a retry fixes it right away. To allow for a transient
failure, make the function retry the control transfer up to 3 times
before failing.
pull/7/head
nirenjan 2015-12-04 16:44:41 -08:00
parent 21f5440349
commit ebf566d9be
1 changed files with 13 additions and 1 deletions

View File

@ -21,9 +21,21 @@
static int libx52_vendor_command(libx52_device *x52, uint16_t index, uint16_t value)
{
return libusb_control_transfer(x52->hdl,
int j;
int rc;
/* Allow retry in case of failure */
for (j = 0; j < 3; j++) {
rc = libusb_control_transfer(x52->hdl,
LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT,
X52_VENDOR_REQUEST, value, index, NULL, 0, 5000);
if (rc == 0) {
break;
}
}
return rc;
}
static int libx52_write_line(libx52_device *x52, uint8_t line_index)