Discussion:
[libhid-discuss] Examples of hid_get_item_value() usage
Tom Isaacson
2009-09-21 02:13:06 UTC
Permalink
Does anyone have example code for how hid_get_item_value() can be used?
I can see how the code is implemented but not what it can be used for.



One of the things I need to do is implement a HIDInterfaceMatcher
function that matches the Usage and Usage Page of the device. I'm
assuming that I can get these values using hid_get_item_value() but I'm
not sure what parameters it requires.



Thanks for any help.



Tom



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20090921/c9921a9d/attachment.htm>
Charles Lepple
2009-09-21 02:30:08 UTC
Permalink
Post by Tom Isaacson
One of the things I need to do is implement a HIDInterfaceMatcher
function that matches the Usage and Usage Page of the device. I?m
assuming that I can get these values using hid_get_item_value() but
I?m not sure what parameters it requires.
Most of the hid_* functions are not yet available when the
HIDInterfaceMatcher function is called.

Unfortunately, reading the HID descriptor (and the ensuing Usage Page/
Usage values) is generally limited to programs or drivers which have
claimed the HID interface already, and the HIDInterfaceMatcher
function is called before a given device's interface is selected to be
claimed.
Charles Lepple
2009-09-21 03:20:38 UTC
Permalink
Post by Tom Isaacson
Does anyone have example code for how hid_get_item_value() can be
used? I can see how the code is implemented but not what it can be
used for.
Let's say you have the hex HID "path" that represents
UPS.BatterySystem.Battery.Voltage, and you don't know which report
contains that usage. hid_get_item_value() finds the report ID that
contains that usage, and fetches the whole report using a control
message. It then extracts the single value corresponding to that
usage. Unfortunately, this does not handle arrays of values, or other
compound types.

In the Network UPS Tools project, we found out that this is wasteful
of bandwidth, especially if you only have a low-speed USB device. That
project uses a precursor to this version of libhid, but the HID code
is modified to cache the retrieved reports for a certain amount of
time. So this example is based off of a different lineage code, and is
probably harder to understand.

You would use it similarly to hid_get_input_report() (which is used in
a comment in test_libhid.c), except that you would be allowing libhid
to parse the report (versus getting the raw report from
hid_get_input_report()).

Loading...