From 9997ed63aa03edee023f5766d0c11af9454f58e0 Mon Sep 17 00:00:00 2001 From: mlsvrts Date: Sat, 18 Jun 2022 10:10:20 -0400 Subject: [PATCH] Update Apple interface detection to use `bInterfaceNumber`; add a note about the reasoning. Signed-off-by: mlsvrts --- src/posix/enumerate.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/posix/enumerate.rs b/src/posix/enumerate.rs index c58d31dd..19935219 100644 --- a/src/posix/enumerate.rs +++ b/src/posix/enumerate.rs @@ -210,7 +210,13 @@ fn port_type(service: io_object_t) -> SerialPortType { serial_number: get_string_property(usb_device, "USB Serial Number"), manufacturer: get_string_property(usb_device, "USB Vendor Name"), product: get_string_property(usb_device, "USB Product Name"), - interface: get_int_property(usb_device, "iInterface", kCFNumberSInt8Type) + // Apple developer documentation indicates `bInterfaceNumber` is the supported key for + // looking up the composite usb interface id. `idVendor` and `idProduct` are included in the same tables, so + // we will lookup the interface number using the same method. See: + // + // https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_driverkit_transport_usb + // https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/USBBook/USBOverview/USBOverview.html#//apple_ref/doc/uid/TP40002644-BBCEACAJ + interface: get_int_property(usb_device, "bInterfaceNumber", kCFNumberSInt8Type) .map(|x| x as u8), }) } else if get_parent_device_by_type(service, bluetooth_device_class_name).is_some() {