ruabmbua / hidapi-rs

Rust bindings for the hidapi C library
MIT License
172 stars 81 forks source link

Descriptors? #31

Closed Geobert closed 6 years ago

Geobert commented 6 years ago

Hi,

First, thank you for this crate, it's really useful!

I was wondering if it's possible to get the Hid descriptors?

The device I work on report the maximum size accepted for a usb message in a "Hid descriptor" and I'd like to access it.

Regards

ruabmbua commented 6 years ago

Hi @Geobert ,

Hidapi does not implement report descriptor parsing, so it can't help you with getting the maximum size of a report.

You can however try to discovery the size with other measures, and then just assume a static size.

Geobert commented 6 years ago

I see, thank you for your answer. I'll need to rely on libusb as well then :)

ruabmbua commented 6 years ago

If your on linux, then do cat /sys/kernel/debug/hid/0018\:06CB\:7A13.0001/rdesc

ruabmbua commented 6 years ago

Or maybe use lsusb.

Geobert commented 6 years ago

Unfortunately, Windows here

ruabmbua commented 6 years ago

I think the device manager might even print the report of a device somehow. Check it out :smile:

Geobert commented 6 years ago

Maybe, but I need to adapt my packet size according to the device I'm talking to (similar devices, 2 different generations)

thank you anyway :D

ruabmbua commented 6 years ago

Oh okay. Maybe my rust library will support this in the future. I am currently spending some time on redoing everything in pure rust (and of course cross platform compatible). The goal is to have a rust library, which you can use to develop any kind of hid based userspace driver.

jleni commented 6 years ago

I know you asked about Windows, but maybe this helps.. I am also trying to get a descriptor in native Rust. Unfortunately something is not working. I can get the descriptor size but not the content.

https://stackoverflow.com/questions/51898034/how-to-use-ioctl-nix-macros-to-get-a-variable-size-buffer