Skip to content

Commit 7e480da

Browse files
Merge pull request #115 from bulislaw/master
Fix listing connected mbeds on OS X El Captain
2 parents 05ba6c1 + 4c4a015 commit 7e480da

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

mbed_lstools/lstools_darwin.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import re
1919
import subprocess
2020
import plistlib
21+
import platform
2122

2223
from lstools_base import MbedLsToolsBase
2324

@@ -110,11 +111,17 @@ def get_mbed_volumes(self):
110111
# serial number, and then search down again to find a tty that's part
111112
# of the same composite device
112113
# ioreg -a -r -n <usb_controller_name> -l
113-
usb_controllers = ['AppleUSBXHCI', 'AppleUSBUHCI', 'AppleUSBEHCI', 'AppleUSBOHCI']
114+
usb_controllers = ['AppleUSBXHCI', 'AppleUSBUHCI', 'AppleUSBEHCI', 'AppleUSBOHCI', 'IOUSBHostDevice']
114115
usb_bus = []
115116

117+
cmp_par = '-n'
118+
# For El Captain we need to list all the instances of (-c) rather than compare names (-n)
119+
mac_ver = float('.'.join(platform.mac_ver()[0].split('.')[:2])) # Returns mac version as float XX.YY
120+
if mac_ver >= 10.11:
121+
cmp_par = '-c'
122+
116123
for usb_controller in usb_controllers:
117-
ioreg_usb = subprocess.Popen(['ioreg', '-a', '-r', '-n', usb_controller, '-l'], stdout=subprocess.PIPE)
124+
ioreg_usb = subprocess.Popen(['ioreg', '-a', '-r', cmp_par, usb_controller, '-l'], stdout=subprocess.PIPE)
118125

119126
try:
120127
usb_bus = usb_bus + plistlib.readPlist(ioreg_usb.stdout)

0 commit comments

Comments
 (0)