Discussion:
[libhid-discuss] HID Usage Path for an array
Steve Hawkins
2009-06-29 03:28:08 UTC
Permalink
I'm interested in using libhid to access a custom HID device that we are
developing on a PIC microcontroller. I have been able to successfully
get the test_libhid code to run, and have attempted to use the
guidelines provided in the code for reading and writing to our device.
So far, I have not been to successfully read or write to the device, and
I suspect the reason may be that the report descriptor for our devices
specifies a 64 byte array for both the input and output data reports.



I have read the details contained in the Device Class Definition for HID
section from usb.org, and I think that I understand how descriptors work
in general and how they translate to HID paths, but my attempts to read
and write data to the device have failed. We have verified that the
device works in Windows, so I believe my problem is on the Linux side.
I read in another posting that the MGE parser has problems parsing
arrays, and I'm wondering if this may be where my problems lie.



I don't think that it should matter, but I should note that I'm
currently working in a VMWare virtual machine, loaded with Ubuntu 8.04
server



Can anyone provide some guidance on how to specify he HID path for the
following report descriptor (generated from lsusb -vvv):



Report Descriptor: (length is 29)

Item(Global): Usage Page, data= [ 0x00 0xff ] 65280

(null)

Item(Local ): Usage, data= [ 0x01 ] 1

(null)

Item(Main ): Collection, data= [ 0x01 ] 1

Application

Item(Local ): Usage Minimum, data= [ 0x01 ] 1

(null)

Item(Local ): Usage Maximum, data= [ 0x40 ] 64

(null)

Item(Global): Logical Minimum, data= [ 0x00 ] 0

Item(Global): Logical Maximum, data= [ 0xff 0x00 ] 255

Item(Global): Report Size, data= [ 0x08 ] 8

Item(Global): Report Count, data= [ 0x40 ] 64

Item(Main ): Input, data= [ 0x02 ] 2

Data Variable Absolute No_Wrap Linear

Preferred_State No_Null_Position
Non_Volatile Bitfield

Item(Local ): Usage Minimum, data= [ 0x01 ] 1

(null)

Item(Local ): Usage Maximum, data= [ 0x40 ] 64

(null)

Item(Main ): Output, data= [ 0x02 ] 2

Data Variable Absolute No_Wrap Linear

Preferred_State No_Null_Position
Non_Volatile Bitfield

Item(Main ): End Collection, data=none



Also, here is the parse tree that was generated by the test_libhid
program:



parse tree of HIDInterface 001/007[0]:

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

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

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

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

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

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

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

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

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90

path: 0xff000001.0x00000000; type: 0x90



Any guidance or suggestions would be most greatly appreciated.



Thank you,



Steve Hawkins



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20090628/7e2d5e83/attachment-0001.htm>
Charles Lepple
2009-07-07 02:32:06 UTC
Permalink
I?m interested in using libhid to access a custom HID device that we
are developing on a PIC microcontroller. I have been able to
successfully get the test_libhid code to run, and have attempted to
use the guidelines provided in the code for reading and writing to
our device. So far, I have not been to successfully read or write
to the device, and I suspect the reason may be that the report
descriptor for our devices specifies a 64 byte array for both the
input and output data reports.
Do you have some example code, and the resulting error codes from
reading/writing?
I have read the details contained in the Device Class Definition for
HID section from usb.org, and I think that I understand how
descriptors work in general and how they translate to HID paths, but
my attempts to read and write data to the device have failed. We
have verified that the device works in Windows, so I believe my
problem is on the Linux side. I read in another posting that the
MGE parser has problems parsing arrays, and I?m wondering if this
may be where my problems lie.
The parser has more problems with printing the arrays than with
parsing, but if you pass in the usage code for the first array
element, things should sort of work.
I don?t think that it should matter, but I should note that I?m
currently working in a VMWare virtual machine, loaded with Ubuntu
8.04 server
Can anyone provide some guidance on how to specify he HID path for
Report Descriptor: (length is 29)
Item(Global): Usage Page, data= [ 0x00 0xff ] 65280
(null)
Item(Local ): Usage, data= [ 0x01 ] 1
(null)
Item(Main ): Collection, data= [ 0x01 ] 1
Application
Item(Local ): Usage Minimum, data= [ 0x01 ] 1
(null)
Item(Local ): Usage Maximum, data= [ 0x40 ] 64
(null)
Looks like the path should be { 0xff000001, 0xff000001 }

Also, if you have something that effectively only sends one or two
requests (in your case, you only have one array per direction), it may
be easier to use usbsnoopy and convert one of those traces to raw
libusb calls. It's not as clean, but it should get the job done.

The "value add" for libhid is when you have a number of different
report IDs, each using a standard set of usages defined by a device
class.

Loading...