[libhid-discuss] libhid with python: help appreciated

Charles Lepple clepple at ghz.cc
Fri Sep 9 02:22:57 UTC 2011


BTW, please subscribe to the list:

http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/libhid-discuss

Thanks!

On Sep 8, 2011, at 6:45 AM, JamesPK wrote:

> Hi,
>
> Apologies for what might be a basic libhid question.
>
> I'm running Ubuntu, and using libhid via Python to communicate with  
> a HID device (and have used 'lsusb' to glean all the details of the  
> device).
>
> I've started out with the example code here: http://anonscm.debian.org/viewvc/libhid/trunk/swig/test_libhid.py 
>  .I added  the vendor and product ID and the example code itself  
> worked FINE.
>
> I then added some code to the example. From the 'snooping' on the  
> communication with the device under Windows it needs a control  
> message with an initialisation string to initialise the device,  
> which I thought would be:

Not to sound too nit-picky, but is it an actual USB control transfer,  
or is it just a message that is being sent to the device?

USB has the notion of Control endpoints (EP0 IN and OUT), and also  
Interrupt endpoints. Not all devices have interrupt endpoints, but if  
you post the output of 'lsusb -v' (run as root, preferably after  
something like libhid has detached the kernel HID driver), we can see  
which endpoints are available.

> INIT_SEQ='0x20 0x00 0x08 0x01 0x00 0x00 0x00 0x00'
> ret = hid_interrupt_write(hid, 0, INIT_SEQ, 8)
> if ret != HID_RET_SUCCESS:
>        log_error("hid_set_output_report", ret)
>
> But when I added the above spinet to the example and run it I get:
> (ALL messages fine up to here)
> ---------------------
> NOTICE: hid_force_open(): successfully opened USB device 006/002[0].
>  TRACE: hid_reset_parser(): resetting the HID parser for USB device  
> 006/002[0]...
>  TRACE: hid_dump_tree(): iterating the parse tree for USB device  
> 006/002[0]...
>  TRACE: hid_reset_parser(): resetting the HID parser for USB device  
> 006/002[0]...
>  TRACE: hid_interrupt_write(): writing interrupt report to device  
> 006/002[0] ...
> WARNING: hid_interrupt_write(): failed to perform interrupt write to  
> device 006/002[0]: error submitting URB: No such file or directory
> ---------------------

Ah, I think I see what's going on: you passed endpoint 0 to  
hid_interrupt_write() - it should be 1 or higher. Again, lsusb output  
will pin this down.

> Any ideas/pointers would be much appreciated.
>
> Thanks
>
> James
>
> _______________________________________________
> libhid-discuss mailing list
> libhid-discuss at lists.alioth.debian.org
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/libhid-discuss
> http://libhid.alioth.debian.org/




More information about the libhid-discuss mailing list