Skip to content

Commit b4c03d1

Browse files
committed
Merge pull request #16 from bridadan/check-all-mac-usb-controllers
Check all possible Apple USB Host Controllers
2 parents be6a0c2 + fe73ee8 commit b4c03d1

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

mbed_lstools/lstools_darwin.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,26 @@ def get_mbed_volumes(self):
9696
''' returns a map {volume_id: {serial:, vendor_id:, product_id:, tty:}'''
9797

9898
# to find all the possible mbed volumes, we look for registry entries
99-
# under the USB bus which have a "BSD Name" that starts with "disk"
99+
# under all possible USB bus which have a "BSD Name" that starts with "disk"
100100
# (i.e. this is a USB disk), and have a IORegistryEntryName that
101101
# matches /\cmbed/
102102
# Once we've found a disk, we can search up for a parent with a valid
103103
# serial number, and then search down again to find a tty that's part
104104
# of the same composite device
105-
# ioreg -a -r -n "AppleUSBXHCI" -l
106-
ioreg_usb = subprocess.Popen(['ioreg', '-a', '-r', '-n', 'AppleUSBXHCI', '-l'], stdout=subprocess.PIPE)
107-
usb_bus = plistlib.readPlist(ioreg_usb.stdout)
108-
ioreg_usb.wait()
105+
# ioreg -a -r -n <usb_controller_name> -l
106+
usb_controllers = ['AppleUSBXHCI', 'AppleUSBUHCI', 'AppleUSBEHCI', 'AppleUSBOHCI']
107+
usb_bus = []
108+
109+
for usb_controller in usb_controllers:
110+
ioreg_usb = subprocess.Popen(['ioreg', '-a', '-r', '-n', usb_controller, '-l'], stdout=subprocess.PIPE)
111+
112+
try:
113+
usb_bus = usb_bus + plistlib.readPlist(ioreg_usb.stdout)
114+
except:
115+
# Catch when no output is returned from ioreg command
116+
pass
117+
118+
ioreg_usb.wait()
109119

110120
r = {}
111121

0 commit comments

Comments
 (0)