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

Extend USB-capable drivers and nut-scanner to detect multiple interfaces and try the one(s) with large Report Descriptor #2821

Open
jimklimov opened this issue Feb 25, 2025 · 0 comments
Labels
enhancement nut-scanner USB non-zero interface numbers Most UPSes serve USB interactions on interface 0 which is default. Recent "composite devices" differ USB
Milestone

Comments

@jimklimov
Copy link
Member

jimklimov commented Feb 25, 2025

In the few past years we see more and more devices where several USB interface numbers are implemented (not only experiments with Arduino, but also UPSes on the market like in issues #2271 and #2816), and NUT's default attempt to use interface number 0 (often with a 27-byte descriptor) is misguided and useless: the USB HID payloads are typically in 600-900 byte range or larger.

Due to this we have had a haphazard attempt to at least avoid hard-coded interface/config/descriptor and in/out endpoint numbers, allowing users to configure them (and hopefully having updated most or all drivers to honour the setting) starting with PR #2149 - for more details see issues and PRs tagged as https://github.com/networkupstools/nut/issues?q=state%3Aopen%20label%3A%22USB%20non-zero%20interface%20numbers%22

The next level of convenience would be to actually look up the amount of interfaces, their data sizes, and only walk those large enough when trying to parse USB HID information. Also check how many data points were actually extracted - if the descriptor told us nothing with some mapping table, that combo is useless anyway.

This could be useful both in drivers with auto-detection, and in nut-scanner to generate the needed settings for usb_config_index=0 usb_hid_rep_index=0 usb_hid_desc_index=0 usb_hid_ep_in=1 usb_hid_ep_out=1 (default numbers here).

Finally, some USB devices may be non-HID at all. A lack of a large HID descriptor (or any HID descriptor) can be an indication to try non-HID USB protocols (serial-over-usb - probably a Megatec dialect then; modbus; etc.)

@jimklimov jimklimov added enhancement nut-scanner USB USB non-zero interface numbers Most UPSes serve USB interactions on interface 0 which is default. Recent "composite devices" differ labels Feb 25, 2025
@jimklimov jimklimov added this to the 2.8.4 milestone Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement nut-scanner USB non-zero interface numbers Most UPSes serve USB interactions on interface 0 which is default. Recent "composite devices" differ USB
Projects
None yet
Development

No branches or pull requests

1 participant