Skip to content

Commit

Permalink
Update Apple interface detection to use bInterfaceNumber; add a
Browse files Browse the repository at this point in the history
note about the reasoning.

Signed-off-by: mlsvrts <[email protected]>
  • Loading branch information
mlsvrts authored and jessebraham committed Jun 28, 2022
1 parent 0e64109 commit 9997ed6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/posix/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 9997ed6

Please sign in to comment.