[libhid-discuss] HID Usage Path for an array

Charles Lepple clepple at ghz.cc
Tue Jul 7 02:32:06 UTC 2009


On Jun 28, 2009, at 11:28 PM, Steve Hawkins wrote:

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

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.


More information about the libhid-discuss mailing list