[libhid-discuss] usb_control_msg

Jorgen Lundman lundman at lundman.net
Tue Jun 26 05:30:50 UTC 2007


To sum up;

I have the official driver that just works, and also an Open Source Unix 
driver using libusb. But since it is a HID device, the OS will take it, 
and libusb can not claim it.

Looking at libhid, I can get further, in that I can call 
usb_control_msg() (or rather equivalent hid_control_msg()). But, the 
method that the Unix driver uses to communicate will most likely not 
succeed. I can not call hid_interrupt_read() because I do not have 
exclusive access, so enumerating the end points will fail.

I can use HID explorer in OsX to view/set values in the device, so this 
would indicate that it is the right way to go.

Reading the sources to libhid-0.2.16, there really is not a lot of OsX 
magic in there - mostly just libusb calls, and might need some work done 
before I can use it to communicate with my device. At a guess, I should 
be using the HIDAPI to get/set HIDGetItemValue() etc.

Then finally, I need to translate the usb_control_msg() numbers I have 
into the HID equivalent.

Does that sound about right? I feel it is worth doing, and libusb, 
libhid and libptp would all benefit most likely. (I tried libptp with my 
camera for kicks, but I get EACCESS, not exclusive access as HID has it, 
sigh).

I know I can make a codeless kext and just use the Unix driver, but that 
feels like cheating, and you'd have to reboot. The official driver does 
not need to do this, and gdb/decompile confirms it also uses libusb, but 
clearly some extra love to handle the HID issue.

Lund

Jorgen Lundman wrote:
> 
> Charles Lepple wrote:
> 
>> It depends what you want to accomplish - if you just want to make it 
>> work, then feel free to dereference it. I can't guarantee that it will 
>> stay that way forever, but I will try not to change it unnecessarily.
>>
>> In an ideal world, the libhid functions would do everything you need 
>> them to, but the HID devices people are trying to use with libhid are 
>> way more diverse than we expected back when this project was started.
>>
> 
> 
> That is fine for now. You are clearly not screaming in terror at using 
> it that way so maybe it should work that way.
> 
> When just using libusb I can not even use usb_control_msg so it feels 
> like there is some progress. But it seems it can not get the endpoints, 
> and thusly can"t find 0x81.
> 
> 
>    TRACE: hid_compare_usb_device(): comparing match specifications to 
> USB device.
> ..
>    TRACE: hid_compare_usb_device(): inspecting vendor ID...
>    TRACE: hid_compare_usb_device(): match on vendor ID: 0x6993.
>    TRACE: hid_compare_usb_device(): inspecting product ID...
>    TRACE: hid_compare_usb_device(): match on product ID: 0xb001.
>    TRACE: hid_compare_usb_device(): no custom matching function supplied.
>   NOTICE: hid_find_usb_device(): found a matching USB device 
> 005/006-6993-b001-00-00[0].
>    TRACE: hid_force_open(): claiming USB device 005/006-6993-b001-00-00[0].
> WARNING: hid_os_force_claim(): code not tested on the Darwin platform!
>    TRACE: hid_os_force_claim(): claiming USB device 
> 005/006-6993-b001-00-00[0]...
> usb_claim_interface: called for interface 0
> Interface 0 of device is 0x00001c73
> claim_interface: Interface 0 of device from QueryInterface is 0x3033f0
> libusb/darwin.c get_endpoints: building table of endpoints.
> libusb/darwin.c get_endpoints: complete.
>   NOTICE: hid_force_open(): successfully claimed USB device 
> 005/006-6993-b001-00-
> 00[0].
>    TRACE: hid_init_parser(): initialising the HID parser for USB Device 
> 005/006-6993-b001-00-00[0]...
> 
> 
> 
> usb_control_msg: 33 9 512 3 0xbffff8ec 16 1600
> hid_set_output_report failed with return code 16
>    TRACE: hid_interrupt_read(): retrieving interrupt report from device 
> 005/006-6
> 993-b001-00-00[0] ...
> libusb/darwin.c get_endpoints: building table of endpoints.
> libusb/darwin.c get_endpoints: complete.
> endponts 0, num 0
> libusb/darwin.c ep_to_pipeRef: Converting ep address to pipeRef.
> libusb/darwin.c ep_to_pipeRef:: No pipeRef found with endpoint address 0x81.
> USB error: libusb/darwin.c usb_bulk_transfer: Invalid pipe reference
> USB error: usb_bulk_read: An error occured during read (see messages above)
> WARNING: hid_interrupt_read(): failed to get interrupt read from device 
> 005/006-
> 6993-b001-00-00[0]: usb_bulk_read: An error occured during read (see 
> messages ab
> ove)
> hid_interrupt_read() => 21:libhid: interrupt read failed
> 
> 

-- 
Jorgen Lundman       | <lundman at lundman.net>
Unix Administrator   | +81 (0)3 -5456-2687 ext 1017 (work)
Shibuya-ku, Tokyo    | +81 (0)90-5578-8500          (cell)
Japan                | +81 (0)3 -3375-1767          (home)



More information about the libhid-discuss mailing list