[libhid-discuss] usb_control_msg

Charles Lepple clepple at ghz.cc
Fri Jun 22 12:39:05 UTC 2007


On Jun 22, 2007, at 8:00 AM, Jorgen Lundman wrote:

> Or perhaps I do not need the Usage Path.. if the code I am porting has
> the calls like:
>
>  ret=usb_control_msg(dev_h,USB_MSG_OUT, 
> 0x9,0x200,0x03,PACKET,length,TIME_OUT);
> and
>  ret=usb_interrupt_read(dev_h,0x00000081,data,URB_LENGTH,TIME_OUT);
>
>
> I would need to replace these calls with a libhid equivalent. It would
> seem to me that the latter should be compatible with;
>
>  ret=hid_interrupt_read(hid,0x00000081,data,URB_LENGTH,TIME_OUT);

That looks about right. Since the only "backend" to libhid is libusb  
(at the moment), it's just a thin layer on top - not much translation  
of parameters, as you can see in the code (src/hid_exchange.c).

> But what do I do about usb_control_msg() ? I tried doing something
> naughty like:
>
>  ret=usb_control_msg(hid->dev_handle,USB_MSG_OUT, 
> 0x9,0x200,0x03,PACKET,length,TIME_OUT);
>
> Which claims to send 16 bytes (length is 16), but the
> hid_interrupt_read() always return -22. And I'm not sure the device is
> entirely happy afterwards (had to powercycle the device at least once)

Not sure what to tell you here. (BTW, you can use hid_strerror() to  
map the return code to a real error message - beats counting lines in  
hid.h)

Can you generate any debug output on a platform where the code you're  
porting actually runs properly? There's a new USB trace feature in  
recent Linux kernels, if you can get the device to a Linux box.

-- 
Charles Lepple





More information about the libhid-discuss mailing list