我想用 python 与我的串口进行通信。我为linux安装了pyserial和uspp。尽管如此,当我运行以下代码时:
import serial
ser = serial.Serial('/dev/pts/1', 19200, timeout=1)
print ser.portstr #check which port was really used
ser.write("hello") #write a string
ser.close() #
它给出以下错误:
Traceback (most recent call last):
File "poi.py", line 5, in ser.open()
File "/usr/local/lib/python2.6/dist-packages/pyserial-2.5-py2.6.egg/serial/serialposix.py",
line 276,
in open raise SerialException("could not open port %s: %s" % (self._port, msg)) serial.serialutil.SerialException:
could not open port /dev/tyUSB1: [Errno 2] No such file or directory: '/dev/tyUSB1'
我应该怎么办?
/dev/tyUSB1
看起来像一个错字。设备节点通常称为/dev/ttyXXX
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)