Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions mbed_lstools/lstools_darwin.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,26 @@ def get_mbed_volumes(self):
''' returns a map {volume_id: {serial:, vendor_id:, product_id:, tty:}'''

# to find all the possible mbed volumes, we look for registry entries
# under the USB bus which have a "BSD Name" that starts with "disk"
# under all possible USB bus which have a "BSD Name" that starts with "disk"
# (i.e. this is a USB disk), and have a IORegistryEntryName that
# matches /\cmbed/
# Once we've found a disk, we can search up for a parent with a valid
# serial number, and then search down again to find a tty that's part
# of the same composite device
# ioreg -a -r -n "AppleUSBXHCI" -l
ioreg_usb = subprocess.Popen(['ioreg', '-a', '-r', '-n', 'AppleUSBXHCI', '-l'], stdout=subprocess.PIPE)
usb_bus = plistlib.readPlist(ioreg_usb.stdout)
ioreg_usb.wait()
# ioreg -a -r -n <usb_controller_name> -l
usb_controllers = ['AppleUSBXHCI', 'AppleUSBUHCI', 'AppleUSBEHCI', 'AppleUSBOHCI']
usb_bus = []

for usb_controller in usb_controllers:
ioreg_usb = subprocess.Popen(['ioreg', '-a', '-r', '-n', usb_controller, '-l'], stdout=subprocess.PIPE)

try:
usb_bus = usb_bus + plistlib.readPlist(ioreg_usb.stdout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usb_bus.extend(plistlib.readPlist(ioreg_usb.stdout))

except:
# Catch when no output is returned from ioreg command
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is like a small indent issue here.


ioreg_usb.wait()

r = {}

Expand Down