Discussion:
[libhid-discuss] how to select Report ID?
Christopher Boger
2010-03-11 23:32:29 UTC
Permalink
I have a device with multiple Report IDs. Each of the Report IDs is
associated with the same Usage Page and Usage number. So, basically I
have one path. How exactly do I select the Report ID? It looks like when
I write a report using the path, it shows a report ID in the TRACE
printout, but basically it's choosing the first report ID that matches
this path. How do I select others? Is this a limitation of libhid? Or,
am I not getting something?



Thanks.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20100311/b1670425/attachment.htm>
Charles Lepple
2010-03-12 03:15:51 UTC
Permalink
Post by Christopher Boger
I have a device with multiple Report IDs. Each of the Report IDs is
associated with the same Usage Page and Usage number. So, basically
I have one path. How exactly do I select the Report ID? It looks
like when I write a report using the path, it shows a report ID in
the TRACE printout, but basically it?s choosing the first report ID
that matches this path. How do I select others? Is this a limitation
of libhid? Or, am I not getting something?
Can you post a dump of the descriptor?

It is probably a limitation of the library, but all of the HID class
devices I have seen use different paths. The whole point of the Usage
numbers is to uniquely identify values in a collection. In the case of
multiple identical Usage values that exist in different collections,
the Usage of the parent collection (in libhid, the preceding
element(s) of the "usage path") is used to disambiguate the Usages.
Christopher Boger
2010-03-12 16:17:55 UTC
Permalink
Thanks Charles. I was able to run that script successfully (very
useful). It describes things as I had expected. I have several reports,
each one referring the same Usage. They only differ in the length of the
report ("Report Count"). So, I have been toying around with the code and
instead of using the path to send reports, have sent my Report ID as the
first byte in the report. I'm now seeing signs of life from my device.
Seems like the path, if it is to be used to determine the Report ID,
won't work for a device like mine with several reports associated with
the same Usage. Am I right?

Here's an excerpt of the descriptor dump:

[0x0000] 0x06 0x00 0xff (value: 0xff00 / 65280)
bSize = 2 byte(s)
bType = 0x01 (Global)
bTag = 0x00 (Usage page)

[0x0003] 0x09 0x01 (value: 0x1 / 1)
bSize = 1 byte(s)
bType = 0x02 (Local)
bTag = 0x00 (Usage)

[0x0005] 0xa1 0x01 (value: 0x1 / 1)
bSize = 1 byte(s)
bType = 0x00 (Main)
bTag = 0x0a (Collection) (Application)

[0x0007] 0x75 0x08 (value: 0x8 / 8)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x07 (Report Size)

[0x0009] 0x26 0x80 0x00 (value: 0x80 / 128)
bSize = 2 byte(s)
bType = 0x01 (Global)
bTag = 0x02 (Logical Maximum)

[0x000c] 0x15 0x00 (value: 0x0 / 0)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x01 (Logical Minimum)

[0x000e] 0x09 0x01 (value: 0x1 / 1)
bSize = 1 byte(s)
bType = 0x02 (Local)
bTag = 0x00 (Usage)

[0x0010] 0x85 0x01 (value: 0x1 / 1)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x08 (Report ID)

[0x0012] 0x95 0x05 (value: 0x5 / 5)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x09 (Report Count)

[0x0014] 0x82 0x02 0x01 (value: 0x102 / 258)
bSize = 2 byte(s)
bType = 0x00 (Main)
bTag = 0x08 (Input)

[0x0017] 0x09 0x01 (value: 0x1 / 1)
bSize = 1 byte(s)
bType = 0x02 (Local)
bTag = 0x00 (Usage)

[0x0019] 0x85 0x02 (value: 0x2 / 2)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x08 (Report ID)

[0x001b] 0x95 0x09 (value: 0x9 / 9)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x09 (Report Count)

[0x001d] 0x82 0x02 0x01 (value: 0x102 / 258)
bSize = 2 byte(s)
bType = 0x00 (Main)
bTag = 0x08 (Input)

[0x0020] 0x09 0x01 (value: 0x1 / 1)
bSize = 1 byte(s)
bType = 0x02 (Local)
bTag = 0x00 (Usage)

[0x0022] 0x85 0x03 (value: 0x3 / 3)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x08 (Report ID)

[0x0024] 0x95 0x0d (value: 0xd / 13)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x09 (Report Count)

[0x0026] 0x82 0x02 0x01 (value: 0x102 / 258)
bSize = 2 byte(s)
bType = 0x00 (Main)
bTag = 0x08 (Input)

[0x0029] 0x09 0x01 (value: 0x1 / 1)
bSize = 1 byte(s)
bType = 0x02 (Local)
bTag = 0x00 (Usage)

[0x002b] 0x85 0x04 (value: 0x4 / 4)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x08 (Report ID)

[0x002d] 0x95 0x11 (value: 0x11 / 17)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x09 (Report Count)

[0x002f] 0x82 0x02 0x01 (value: 0x102 / 258)
bSize = 2 byte(s)
bType = 0x00 (Main)
bTag = 0x08 (Input)

[0x0032] 0x09 0x01 (value: 0x1 / 1)
bSize = 1 byte(s)
bType = 0x02 (Local)
bTag = 0x00 (Usage)

[0x0034] 0x85 0x05 (value: 0x5 / 5)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x08 (Report ID)

[0x0036] 0x95 0x19 (value: 0x19 / 25)
bSize = 1 byte(s)
bType = 0x01 (Global)
bTag = 0x09 (Report Count)

[0x0038] 0x82 0x02 0x01 (value: 0x102 / 258)
bSize = 2 byte(s)
bType = 0x00 (Main)
bTag = 0x08 (Input)

...
Charles Lepple
2010-03-13 13:52:15 UTC
Permalink
Post by Christopher Boger
Seems like the path, if it is to be used to determine the Report ID,
won't work for a device like mine with several reports associated with
the same Usage. Am I right?
I guess the assumption in libhid was that we wouldn't see a device
where a single usage would have multiple allowable sizes (via the
Count tag). In a keyboard or mouse, each Usage code refers to a
specific value, and the size of that value is generally kept constant.
Same deal with an UPS.

Charles Lepple
2010-03-12 03:26:25 UTC
Permalink
Post by Christopher Boger
I have a device with multiple Report IDs. Each of the Report IDs is
associated with the same Usage Page and Usage number. So, basically
I have one path. How exactly do I select the Report ID? It looks
like when I write a report using the path, it shows a report ID in
the TRACE printout, but basically it?s choosing the first report ID
that matches this path. How do I select others? Is this a limitation
of libhid? Or, am I not getting something?
Ah, I see what happened. libhid has a bug in which the Usages for
ranges are not printed properly.

[I think I accidentally dropped that message, but the list has a limit
of 40KB including attachments. I would recommend against sending HTML,
as it tends to hit that limit quickly.]

Here's an excerpt of the dump you sent:

parse tree of HIDInterface 002/037[2]:
path: 0xff000001.0xff000001; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0xff000001; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80
path: 0xff000001.0x00000000; type: 0x80

If a path ends in 0x00000000, it is probably being printed
incorrectly. There is a script in SVN which decodes a hex dump of the
HID report descriptor. Not sure if I have described how that script
works on the list, but if you have trouble, send the descriptor hex
dump from the test_libhid program.
Loading...