I'm new to libusb and USB in general, so I'm not sure if this is correct, but by looking at the output of a USB analyzer such as USBlyzer and setting up a few things, I come up with the following protocol elements:
usb_claim_interface
When I used the usb_claim_interface interface ( usb_claim_interface ) and then canceled my application, I was inoperable on subsequent launches. I tried various usb_reset ( usb_reset and usb_resetep ), but I still could not get the correct use from usb_control_msg .
SetReport / GetReport
USBlyzer showed that the corresponding packages include Get Descriptor , Select Configuration , Set Report and Get Report . Get Descriptor and Select Configuration explicitly associated with usb_get_descriptor and usb_set_configuration respectively.
Some Get Report packages contained Feature Id and others Input Id . I was able to map them to usb_control_msg with the following parameters ( libusb.c helped me figure this out):
requesttype = USB_ENDPOINT_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE value = 0x01 (for GetReport) index = id | (0x03 << 8) (for FeatureId)
Set Report packages also used Feature Id but Output Id . From consideration of the details, it became clear that Input Id same (0x01 << 8) and Output Id same (0x02 << 8). Therefore, to get the Set Report I called usb_control_msg with these adjusted parameters:
requesttype = USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE value = 0x09 (for SetReport) index = id | (0x03 << 8) (for FeatureId)
This may not be the βrightβ way to do all this, and I would certainly appreciate a deeper understanding of what happens with the various API functions. But this was able to make my host capture all the relevant data from the device.
source share