Repository navigation
hid_device_info->interface_number zero on macOS 13.3 #531
Copy link
Copy link
Closed
BitBoxSwiss/bitbox02-firmware
#1073Labels
macOSRelated to macOS backendRelated to macOS backend
Description
Discussed in #527
Originally posted by dingsijie-nreal April 11, 2023
I've noticed comment here: https://github.com/libusb/hidapi/blob/master/mac/hid.c#L543
The interesting thing is: macOS Monterey(12.6.3) works perfectly with my usb gadget, I got expected interface numbers.
the output of test.c is shown below:
hidapi test/example tool. Compiled with hidapi version 0.14.0, runtime ve
Compile-time version matches runtime version of hidapi.
Device Found
type: 3318 0424
path: DevSrvsID:4298350859
serial_number: A00016:33:33
Manufacturer: xxxx
Product: xxxx
Release: 1
Interface: 3
Usage (page): 0x0 (0x41)
Bus type: 1
Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff,
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02,
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0,
Device Found
type: 3318 0424
path: DevSrvsID:4298350872
serial_number: A00016:33:33
Manufacturer: xxxx
Product: xxxxx
Release: 1
Interface: 5
Usage (page): 0x0 (0x41)
Bus type: 1
Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff,
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02,
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0,
Device Found
type: 3318 0424
path: DevSrvsID:4298350862
serial_number: A00016:33:33
Manufacturer: xxxx
Product: xxxxx
Release: 1
Interface: 4
Usage (page): 0x0 (0x41)
Bus type: 1
Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff,
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02,
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0,
But, after upgrading to macOS 13.3 the result changes to flowing:
hidapi test/example tool. Compiled with hidapi version 0.14.0, runtime version 0.14.0.
Compile-time version matches runtime version of hidapi.
Device Found
type: 3318 0424
path: DevSrvsID:4294984005
serial_number: A00016:33:33
Manufacturer: xxxxx
Product: xxxxx
Release: 1
Interface: 0
Usage (page): 0x0 (0x41)
Bus type: 1
Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff,
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02,
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0,
Device Found
type: 3318 0424
path: DevSrvsID:4294984010
serial_number: A00016:33:33
Manufacturer: xxxxx
Product: xxxxx
Release: 1
Interface: 0
Usage (page): 0x0 (0x41)
Bus type: 1
Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff,
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02,
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0,
Device Found
type: 3318 0424
path: DevSrvsID:4294984008
serial_number: A00016:33:33
Manufacturer: xxxxx
Product: xxxxx
Release: 1
Interface: 0
Usage (page): 0x0 (0x41)
Bus type: 1
Report Descriptor: (27 bytes)
0x05, 0x41, 0x09, 0x00, 0xa1, 0x01, 0x15, 0x00, 0x25, 0xff,
0x19, 0x01, 0x29, 0x08, 0x95, 0x40, 0x75, 0x08, 0x81, 0x02,
0x19, 0x01, 0x29, 0x08, 0x91, 0x02, 0xc0,
My mission it to discriminate 3 different components on my USB gadget, and the interface number was the key that I rely on.
But with 0 interfaces numbers, I don't know how to do my job.
Any one get any ideas? Thanks a lot.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
macOSRelated to macOS backendRelated to macOS backend
Activity
mcuee commentedon Apr 15, 2023
I think this is a real issue.
Last time I can get proper interface number on my Mac Mini M1.
#249 (comment)
With the latest macOS Ventura 13.3.1 on my Mac Mini M1, interface number becomes 0 for the Logitech USB receiver (046d:c52b).
mcuee commentedon Apr 15, 2023
From @dingsijie-nreal
mcuee commentedon Apr 15, 2023
@Youw @dingsijie-nreal @pengxianheng-nreal
Somehow libusb is able to print the interface number.
mcuee commentedon Apr 15, 2023
PR #530 is a workaround and it seems to work. However, I believe there is a better solution.
mcuee commentedon Apr 15, 2023
Just a quick test using my mod hidapi-libusb under macOS.
#319 (comment)
mcuee commentedon Apr 15, 2023
@Youw
I am thinking that libusb codes may be of some reference to sort out the issue here.[
https://github.com/libusb/libusb/blob/master/libusb/os/darwin_usb.c#L1342-L1377
Youw commentedon Apr 15, 2023
Yeah, libusb and HIDAPI using different API/subsystems to get the information about USB device.
libusb gets it directly from USB subsystem, which would be broken all at once if the interface number wasn't availale.
HIDAPI uses HidManager macOS API which is either changed or broken in the latest macOS 13.3.1.
BTW: I'm still using 12.6 so I'm unable to debug/fix it localy as of yet...
dingsijie-nreal commentedon Apr 16, 2023
Yeah, I've noticed that libusb is able to fetch the correct interface number, but as @Youw has pointed out, hidapi doesn't use libusb on mac. Our app code currently uses hidapi API because it is easier and nicer to use than libusb. Maybe it is a real bug on macOS 13.3?
Now what I'm thinking more about is that shouldn't apple already received reports about this issue? Is @mcuee 's logitech USB receiver working fine on macOS 13.3? Or, maybe a usb device with none zero interface number itself is a less common design?
mcuee commentedon Apr 16, 2023
The USB receiver works fine (together with the mouse and keyboard). In fact yesterday I tried hidpp macOS fork and it works fine.
It is probably just the paticual macOS API is broken. Sometimes Apple will fix it in the future updates. Sometimes it may take time. Let's see if you will get some reply here. Better way is to submit a bug report to Apple.
Ref: https://developer.apple.com/forums/thread/728001
mcuee commentedon Apr 16, 2023
@dingsijie-nreal
It will be good to file a feedback to Apple.
https://developer.apple.com/bug-reporting/
You can see from the following libusb issue that Apple fixed the issue pretty fast in the paticular case. But sometimes it takes time.
Ref: libusb/libusb#1156
dingsijie-nreal commentedon Apr 17, 2023
feedback posted. https://feedbackassistant.apple.com/feedback/12125162
Youw commentedon Apr 17, 2023
Is there some kind of visibility configuration for the feedback? I'm unable to open/see it.
mcuee commentedon Apr 17, 2023
Same here. Probably it is not visible for unconfirmed issue.
dingsijie-nreal commentedon Apr 17, 2023
Only apple can see it according to:
https://developer.apple.com/forums/thread/700518
Also, I didn't notice any visibility setting when I was posting the feedback.
Youw commentedon Apr 30, 2023
After digging deeper into the problem in the context of #534 - I'm starting to think that this is not a bug in macOS.
It looks like HIDAPI used an undocumented property of the
IOHIDDeviceregistry entry, and Apple finally cleaned (some?/all?) undocumented properties from the IOHIDDevice registry.But it is still a clear statement that
IOHIDDeviceentry in the registry is one of the child entries of theIOUSBHostInterfaceentry for USB HID devices, which definitely has the InterfaceNumber property (otherwise at least libusb would break completely).Youw commentedon Apr 30, 2023
@dingsijie-nreal see if you (or you colleague?) could check the #534 fix.
mcuee commentedon May 1, 2023
PR #534 works fine for me.
py: require hidapi>=0.14.0
py: require hidapi>=0.14.0
bitbox02: update to 6.2.0
bitbox02: update to 6.2.0
deps: switch back to the karalabe/hid USB library
deps: switch back to the karalabe/hid USB library
bitbox02: update to 6.2.0