Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need longer timeout with send_feature_report() for libusb under Linux #493

Open
elfmimi opened this issue Jan 3, 2023 · 9 comments
Open
Labels
enhancement New feature or request libusb Related to libusb backend

Comments

@elfmimi
Copy link

elfmimi commented Jan 3, 2023

Some devices may require much longer timeout when submitting hid_send_feature_report() .

for such devices hid_send_feature_report() just notifies failure with return value of -1 .

I checked that internal error code libusb is reporting is LIBUSB_ERROR_TIMEOUT ( -7 ) .

Changing value here, from 1000 to, say, 5000 does make difference.

1000/*timeout millis*/);

You curious what the device is?
It is USB-HID control capable LCD monitor from EIZO . ex. FlexScan EV2670
Most requests to the monitor, for example a request to change speaker volume, work fine with short timeout .
But one specific request that is to enable or disable picture-by-picture mode only works with long timeout .

So it is better to have a measure to somehow specify custom value for timeout.

@Youw Youw added the libusb Related to libusb backend label Jan 3, 2023
@Youw
Copy link
Member

Youw commented Jan 3, 2023

I guess it was only a matter of time when that magic number would backfire at us.
On the other hand it's been years and no one complained, until now.

But we definitely need a workaround for that. I think a libusb-specific option (e.g. int hid_libusb_set_output_timeout(hid_device *dev, unsigned int timeout) to be used with hid_write and hid_send_feature_report would suffice.

P.S.: PR is welcome.

@elfmimi
Copy link
Author

elfmimi commented Jan 3, 2023

Thank you for your quick response. I'm afraid I'm not sure if I want to do a PR myself for now.
It's like I spent way too much effort into finding this out , and so I felt like leaving a short note here.

Easiest workaround is to use libhidapi-hidraw instead of libhidapi-libusb .

@Youw
Copy link
Member

Youw commented Jan 3, 2023

Easiest workaround is to use libhidapi-hidraw instead of libhidapi-libusb .

I'd say - a perfect one.

@Youw
Copy link
Member

Youw commented Jan 3, 2023

For a historical reference:
HIDRAW has this timeout hard-coded as well: https://github.com/torvalds/linux/blob/69b41ac87e4a664de78a395ff97166f0b2943210/drivers/hid/usbhid/hid-core.c#L931
And it is set to 5 seconds.

@mcuee
Copy link
Member

mcuee commented Jan 19, 2023

I think we may want to promote the use of the hidraw backend for Linux and not the libusb backend.

@Youw
Copy link
Member

Youw commented Jan 19, 2023

Totally agree. But that does not exclude having a potential fix for libusb backend.

@oistra-ah
Copy link

oistra-ah commented Mar 21, 2024

Hi,
could please someone give a hint: is it possible to increase timeout for send_feature_report() on Windows? I also have a device, which takes a more than 5 sec sometimes for response. Thanks.
@Youw

@mcuee
Copy link
Member

mcuee commented Mar 22, 2024

Hi, could please someone give a hint: is it possible to increase timeout for send_feature_report() on Windows? I also have a device, which takes a more than 5 sec sometimes for response. Thanks.

That is interesting, what is the device? The original issue only mentions Linux and only libusb backend.

@oistra-ah
Copy link

Hi, could please someone give a hint: is it possible to increase timeout for send_feature_report() on Windows? I also have a device, which takes a more than 5 sec sometimes for response. Thanks.

That is interesting, what is the device? The original issue only mentions Linux and only libusb backend.

Sorry for asking in this topic. I've just created #670. Device is a tiny USB climate sensor on the stm32f4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request libusb Related to libusb backend
Projects
None yet
Development

No branches or pull requests

4 participants