From fe73ee8f689e41214ea19f1fd78ff2a69b2a75f8 Mon Sep 17 00:00:00 2001 From: Brian Daniels Date: Tue, 18 Aug 2015 12:49:19 -0700 Subject: [PATCH] Checks all possible Apple USB Host Controllers, not just XHCI. Now checks XHCI, UHCI, EHCI, and OHCI --- mbed_lstools/lstools_darwin.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/mbed_lstools/lstools_darwin.py b/mbed_lstools/lstools_darwin.py index 5c179ed..1bc3412 100644 --- a/mbed_lstools/lstools_darwin.py +++ b/mbed_lstools/lstools_darwin.py @@ -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 -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) + except: + # Catch when no output is returned from ioreg command + pass + + ioreg_usb.wait() r = {}