通过 UART 在 RPi3 上使用 Python 时遇到了一些问题。我的 Python 2.7 脚本:
import time
import serial
ser = serial.Serial(
port='/dev/ttyS0',
baudrate=115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
while 1:
ser.write('hello')
time.sleep(1)
终端中的输出是:
hellohello`??p?nnn?`??p?nnn?`??p?nnn?`??p?nnn?`??p?nnn?`??p?nnn?`??p?nnn?
有时是“你好”两次,有时是五次。标准 RPi3 控制台输出已关闭(在 raspi-config 中)。UART转换器是3V3逻辑。
你可以帮帮我吗?非常感谢!
瓦尔迪