[libhid-discuss] Announce hidmon and some questions and remarks
about libhid
Charles Lepple
clepple at ghz.cc
Tue Jan 23 14:21:21 CET 2007
On Jan 23, 2007, at 7:11 AM, drd wrote:
> Charles Lepple schrieb:
>> On Jan 22, 2007, at 7:11 PM, Frederik Reiß wrote:
>>> Is there any way to get the needed buffer size for
>>> hid_get_input_report
>>> and friends ?
>>
>> I admit that I don't know much about the MGE HIDParser code - there
>> should be a way to extract it from the parsed report structures that
>> it creates, but I am not sure the exact syntax.
>>
>> That function was meant for a device where the buffer size was known
>> ahead of time.
> that's not good, because it makes something like this necessary (at
> last
> for me):
>
>
> hid_ret=hid_get_feature_report(dev, path, c->path.size, buffer, 0);
> ...
> size_bits=dev->hid_data->Size;
> while(size_bits % 8 != 0)
> size_bits++;
> size_bytes=size_bits / 8;
If you are just trying to convert size_bits to bytes, you could do this:
size_bytes = (size_bits + 7) / 8;
> ...
> hid_ret=hid_get_feature_report(dev, path, c->path.size, buffer,
> size_bytes+1);
>
> n.b. when using the linux HID api you don't need to know the size.
I think that hiddev keeps internal tables of what size to request for
each report ID.
I really want to rewrite the HID parser, because the only people who
understand how it works have less free time than I do (and I don't
have much). But in the mean time, the code is there, and most of the
values you are looking for should be available.
Again, the hid_get_*_report() functions were not meant to cover this
case. In HID PDC UPSes, a lot of the reports are single values, and
that's all I had available to test (besides detaching the Linux input
driver from the mouse or keyboard, and doing remote debugging).
>>> hid_get_item_value does not return a proper value for me (but all/
>>> some
>>> of the other fields in HIDInterface get filled correctly).
>>
>> Please note the TODO items:
>>
>> http://www.ghz.cc/~clepple/libhid/doc/html/
>> hid__exchange_8c.html#3d57558be35776185e33c4cdce3d6b19
>>
>>
>> Do you have an idea of what the value should look like? Are you sure
>> the report descriptor is correct?
> Yes, first i wrote the programm so, that it used hid_get_input_report
> which worked (returns e.g. 200), then i just repleaced
> hid_get_input_report with hid_get_item_value, but hid_get_item_value
> returned always zero.
There appears to be a size mismatch in the requested size and the
returned size. Since USB devices are sensitive to the requested size,
you might want to double-check that 16 is a valid size - especially
if it is a low-speed device.
Once the kernel HID driver has been detached, what does 'lsusb -vvv'
say for the monitor?
>>> if hid_get_item_value is called it seems that it passes the ?
>>> parser? the
>>> size of the data in bits, but the parser wants the size in bytes,
>>> which
>>> results in an warning.
>>
>> Can you post the hex dump of the HID report descriptor, and some
>> context for this error?
> See the atachments for a sample program which triggers this
> problem, and
> a trace (which includes a hex dump) from the program
I will try to take a look at the descriptor later today.
--
Charles Lepple
clepple at ghz.cc
More information about the libhid-discuss
mailing list