diff --git a/src/hidapi/linux/hid.c b/src/hidapi/linux/hid.c index e3b200eddf..e742b13aa6 100644 --- a/src/hidapi/linux/hid.c +++ b/src/hidapi/linux/hid.c @@ -1176,14 +1176,23 @@ int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) int HID_API_EXPORT hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length) { + static const int MAX_RETRIES = 50; + int retry; int res; register_device_error(dev, NULL); - res = ioctl(dev->device_handle, HIDIOCSFEATURE(length), data); - if (res < 0) - register_device_error_format(dev, "ioctl (SFEATURE): %s", strerror(errno)); + for (retry = 0; retry < MAX_RETRIES; ++retry) { + res = ioctl(dev->device_handle, HIDIOCSFEATURE(length), data); + if (res < 0 && errno == EPIPE) { + /* Try again... */ + continue; + } + if (res < 0) + register_device_error_format(dev, "ioctl (SFEATURE): %s", strerror(errno)); + break; + } return res; }