Don*_*agh 5 python linux ubuntu pyserial
我一直试图在过去的两天里运行以下两行Python代码,但没有取得多大成功:
import serial
ser = serial.Serial(0)
Run Code Online (Sandbox Code Playgroud)
每次运行它,我都会收到以下错误:
Traceback (most recent call last):
File "./test.py", line 4, in <module>
ser = serial.Serial(0)
File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in __init__
self.open()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 280, in open
self._reconfigurePort()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 308, in _reconfigurePort
raise SerialException("Could not configure port: %s" % msg)
serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')
Run Code Online (Sandbox Code Playgroud)
我正在运行Ubuntu 11.10 64位,Pyserial 2.5(python-serial 2.5-2.1)和Python 2.7(python 2.7.2-7ubuntu2),我的用户是拨出组的成员.
我也在运行Ubuntu 11.10 64位,使用相同版本的Python和Pyserial,并且似乎没有出现问题.欢迎任何建议 - 我很沮丧......
谢谢,多纳
如果端口不可用,则抛出此异常.在Linux上,您只需指定要使用的端口的确切名称,例如
ser = serial.Serial('/dev/ttyACM0')
Run Code Online (Sandbox Code Playgroud)