[libhid-discuss] Examples of hid_get_item_value() usage

Charles Lepple clepple at ghz.cc
Mon Sep 21 03:20:38 UTC 2009


On Sep 20, 2009, at 10:13 PM, Tom Isaacson wrote:

> 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()).



More information about the libhid-discuss mailing list