mirror of https://github.com/nirenjan/libx52.git
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
parent
21f5440349
commit
ebf566d9be
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue