From: Michael B. <mic...@gm...> - 2019-11-20 20:59:43
|
lOn Wed, Nov 20, 2019 at 11:49 AM Tim Roberts <ti...@pr...> wrote: > Michael Bacarella wrote: > > > > I'm on Linux. I connected a USB device. I added it to udev rules to > > gain permissions. I got resource busy on set_configuration, so I did > > 'usb-devices' and found Driver= lines that correspond to the device > > and rmmod'd them. > > > > I probe for and unload any attached kernel driver in code. > > Your device has four audio interfaces, which you have rendered > unusable. They had drivers, which is why you couldn't set the > configuration. Your device only has one configuration, so you do not > need libusb_set_configuration at all. If you had skipped that, then > libusb_detach_kernel_driver on your HID interface would have been > sufficient. > Thank you, I did indeed not want to render them unusable. I tried this out of desperation. If I skip the set_configuration call it works properly as you observed. Out of curiosity, if a device has more than one configuration, how would a programmer know which one to pick to set? Is the answer to this too hard to generalize? > Now I can successfully connect to the device, but doing an > > interrupting receive (the first one), with any number of bytes, > > returns an Input/output error. > > ... > > I: If#= 0 Alt= 0 #EPs= 0 Cls=01(audio) Sub=01 Prot=20 Driver=(none) > > I: If#= 1 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=20 Driver=(none) > > I: If#= 2 Alt= 0 #EPs= 0 Cls=01(audio) Sub=02 Prot=20 Driver=(none) > > I: If#= 3 Alt= 0 #EPs= 2 Cls=01(audio) Sub=03 Prot=00 Driver=(none) > > I: If#= 4 Alt= 0 #EPs= 2 Cls=03(HID ) Sub=00 Prot=00 Driver=(none) > > I: If#= 5 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none) > > I: If#= 6 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=f0 Prot=00 Driver=(none) > > Is the HID interface you're actually want? Have you checked the report > descriptors to make sure the HID layout is the same as what you expect? > Is it possible there's some new vendor command you have to send to > enable the HID endpoint? (Although that would be unusual.) Is the max > packet size the same? Is the interval the same? > I think I do want the HID interface (what would the alternative be?). At least, that's what I used to successfully decode packets from the other controller from this same company. So, I think I figured this out. My problem was that I'm too ignorant of USB and didn't call recv with the endpoint address that corresponds to interface 4. I had hard-coded endpoint address to 1 in my code and forgotten about it. Not sure why I didn't notice that sooner; I guess my coffee had worn off. I searched through the active config descriptor for the device and found that, for interface 4, there are two endpoint addresses, 132 and 3. Choosing the first one seems to work now. I get back packets when I move knobs on the controller that look similar to the packets for the other model controller from the same company. So I suspect my issue is solved. I'm a little unclear on what the second endpoint address is for. (I'm wondering aloud, I don't expect anyone besides the manufacturer to know the answer). Thank you for the hand-holding! |