diff options
-rw-r--r-- | pyserial/CHANGES.txt | 5 | ||||
-rw-r--r-- | pyserial/serial/tools/list_ports_osx.py | 38 |
2 files changed, 25 insertions, 18 deletions
diff --git a/pyserial/CHANGES.txt b/pyserial/CHANGES.txt index 5741b40..d31c6d2 100644 --- a/pyserial/CHANGES.txt +++ b/pyserial/CHANGES.txt @@ -485,3 +485,8 @@ Version 2.8 2014-xx-xx Bugfixes: - [Bug pyserial:166] RFC2217 connections always fail + +Bugfixes (posix): + +- [Bug pyserial:163] serial.tools.list_ports.grep() fails if it encounters None type + diff --git a/pyserial/serial/tools/list_ports_osx.py b/pyserial/serial/tools/list_ports_osx.py index c9ed615..242f468 100644 --- a/pyserial/serial/tools/list_ports_osx.py +++ b/pyserial/serial/tools/list_ports_osx.py @@ -180,24 +180,26 @@ def comports(): info = [] # First, add the callout device file. - info.append(get_string_property(service, "IOCalloutDevice")) - - # If the serial port is implemented by a - usb_device = GetParentDeviceByType(service, "IOUSBDevice") - if usb_device != None: - info.append(get_string_property(usb_device, "USB Product Name")) - - info.append( - "USB VID:PID=%x:%x SNR=%s"%( - get_int_property(usb_device, "idVendor"), - get_int_property(usb_device, "idProduct"), - get_string_property(usb_device, "USB Serial Number")) - ) - else: - info.append('n/a') - info.append('n/a') - - ports.append(info) + device = get_string_property(service, "IOCalloutDevice") + if device: + info.append(device) + + # If the serial port is implemented by a + usb_device = GetParentDeviceByType(service, "IOUSBDevice") + if usb_device is not None: + info.append(get_string_property(usb_device, "USB Product Name") or 'n/a') + + info.append( + "USB VID:PID=%x:%x SNR=%s"%( + get_int_property(usb_device, "idVendor"), + get_int_property(usb_device, "idProduct"), + get_string_property(usb_device, "USB Serial Number")) + ) + else: + info.append('n/a') + info.append('n/a') + + ports.append(info) return ports |