在Mac OS X和Python 3中列出串行端口

Tho*_*mas 7 macos pyserial python-3.x

我在列出可用的串口时遇到问题,我真的需要帮助调试这个.在Python 2.7.5中,正确列出了COM端口,而PySerial在Python 3.3.5中返回一个空列表.

我发现另一个孤独的灵魂在互联网上遇到同样的问题(没有答案),但这个问题似乎并不受欢迎 - 也许这是我的系统?

我正在使用Mac OS X 10.9.2并通过自制软件安装了python和python3.我刚才更新了一切.PySerial在pip和pip3都是2.7版本.

输出:

Python 2.7.5 (default, Nov  4 2013, 18:04:45) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from serial.tools import list_ports
>>> list_ports.comports()
[['/dev/cu.Bluetooth-Incoming-Port', 'n/a', 'n/a'], ['/dev/cu.Bluetooth-Modem', 'n/a', 'n/a']]

Python 3.3.5 (default, Mar 10 2014, 13:25:50) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from serial.tools import list_ports
>>> list_ports.comports()
[]
Run Code Online (Sandbox Code Playgroud)

Tho*_*mas 5

目前我正在采用以下方法.PySerial工具坏了.

>>> import glob
>>> glob.glob('/dev/tty.*')
['/dev/tty.Bluetooth-Incoming-Port', '/dev/tty.Bluetooth-Modem']
Run Code Online (Sandbox Code Playgroud)