[libhid-discuss] help with usage path

Charles Lepple clepple at ghz.cc
Fri Jul 6 03:13:50 UTC 2007


On Jul 5, 2007, at 7:11 PM, Washington Trindade wrote:

> To read from the device is the same process, but I want to read  
> more than 8
> bytes, which is the max length of the packet. Then, I think I would  
> to do
> many reads in a loop and concatenate the result in a buffer,  but I  
> don't
> know how to stop that loop? the hid_interrupt_read says when there  
> is no
> more data?

The usual advice on the libusb lists is to request as many bytes as  
you want, and the kernel will break that up into individual requests  
of 8 bytes each. Then, you will get one buffer back with all of the  
bytes.

However, I think that you will have to increase the timeout to  
account for this.

hid_interrupt_read() will return HID_RET_FAIL_INT_READ if you request  
8 bytes, and fewer than 8 are returned. This is not strictly an error  
in USB terms, but for actual USB HID requests, the interpretation of  
a short report is not defined. If the chip returns only 8-byte  
packets, then you can just loop until you get an error code.

-- 
Charles Lepple






More information about the libhid-discuss mailing list