【问题标题】:python serial port蟒蛇串口
【发布时间】:2010-10-28 05:48:39
【问题描述】:

我想在 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 <module>
    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'

【问题讨论】:

标签: python linux pyserial


【解决方案1】:

如果你使用的是linux,一般来说,串口命名为/dev/tty*;只需将* 替换为s 和/dev/ttyS1 之类的端口号。我使用通过 USB 串行通信的 arduino,它是 /dev/ttyUSB0。

【讨论】:

    猜你喜欢
    • 2010-10-27
    • 2010-10-21
    • 2016-05-28
    • 2014-08-01
    • 2021-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多