-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix USB interface on macOS #193
Conversation
308d69a
to
6a633fe
Compare
Thank you for spotting this @parasyte and for preparing this PR! The After weighing this for while: Shouldn't looking up the information from |
So, again I need to be transparent that I don’t know Mac APIs. But my interpretation of the docs suggests that the Device and Interface classes should be used when you want either device or interface information. And that is going to be an application’s concern, not the library’s. So, while it does appear, at least empirically, that the Interface class gives you everything you want… I’m not sure I would rely on that. They are different things for a reason. I suspect some devices might be capable of exposing information differently about itself (e.g. through the Device class) and about all of its interfaces (Interface class). All in all, I’m in favor of just using the Interface class to simplify things. It can always be changed later if it breaks anything, right? |
USB interface number information is currently missing macOS (with feature usbportinfo-interface). The required information is not provided in IOUSBHostDevice but along with all other information of interest in IOUSBHostInterface. As it is planned to remove the feature gate for UsbPortInfo::interface with the next major release, IOUSBHostInterface is the dict to use for looking up information for USB serial ports. There is no point in using different lookups in the meanwhile.
My knowledge of the macOS APIs is limited. But as USB serial device are - to the extend of my understanding - are always accessed through the endpoints specified by an USB interface, looking up things from the perspective of an USB interface seems the right thing to do to me here.
This might be the case but as all information we are currently interested in is (also) provided through
Great! As we are not changing/breaking the public API here, we are fine to roll out a patch release if things don't work out as expected. |
When the
usbportinfo-interface
feature is enabled on macOS, theUsbPortInfo::interface
is alwaysNone
. A careful reading of https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/USBBook/USBOverview/USBOverview.html#//apple_ref/doc/uid/TP40002644-BBIDGCHB indicates that device matching or interface matching needs to be considered on a per-application basis. This PR switches the class toIOUSBHostInterface
when the feature is enabled, allowing the interface number to be returned.I am not familiar with macOS, but this seems like a fair compromise without changing the
serialport
APIs to make a distinction between searching for devices and searching for interfaces.