'How does adb find the USB port #?

When I run "adb devices -l", it is able to display the USB port info as "usb:xxxxxxx". Does anyone know how adb pulls this info? I'm trying to figure out how I may be able to do this with idb so I can get the same USB info for the attached iPhones. Thanks!

qelabadmin@DevFarm ~ % adb -P 5037 devices -l

List of devices attached

17061FDEE000BN device usb:338825984X product:raven model:Pixel_6_Pro device:raven transport_id:25

96081FFBA00052 device usb:338768384X product:coral model:Pixel_4_XL device:coral transport_id:18



Solution 1:[1]

On macOS you can use

ioreg -p IOUSB

and it lists something like

| +-o your device (2022)@14400000  <class AppleUSBDevice, id 0x0...>

and if you convert the hex to decimal

0x14400000 => 339738624

it's the number displayed by adb:

XXXXXXXX             device usb:339738624X product: blah, blah

Solution 2:[2]

you would use the command "lsusb" on Linux and MacOS

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Diego Torres Milano
Solution 2 Kunkun Liu