gpt4 book ai didi

python - 求助.....串口编程

转载 作者:IT王子 更新时间:2023-10-29 00:59:15 27 4
gpt4 key购买 nike

我想用 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

关于python - 求助.....串口编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4051869/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com