我正在开发珊瑚开发板。我正在尝试在开发板上的 40 针接头上使用 UART1_TXD/RXD、UART3_TXD/RXD。我正在按照教程连接到 GPIO 引脚。
[serial_test.py]
from periphery import Serial
serial = Serial("/dev/ttyS0", 115200)
serial.write(b"Hello World!")
buf = serial.read(128, 0.5)
print("read %d bytes: _%s_" % (len(buf), buf))
serial.close()
当我测试电路板时:
$ python3 serial_test.py
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 166, in _open
termios.tcsetattr(self._fd, termios.TCSANOW, [iflag, oflag, cflag, lflag, ispeed, ospeed, cc])
termios.error: (5, 'Input/output error')
在处理上述异常的过程中,又出现了一个异常:
Traceback (most recent call last):
File "serial.py", line 5, in <module>
serial = Serial("/dev/ttyS0", 115200)
File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 60, in __init__
self._open(devpath, baudrate, databits, parity, stopbits, xonxoff, rtscts)
File "/usr/local/lib/python3.5/dist-packages/periphery/serial.py", line 168, in _open
raise SerialError(e.errno, "Setting serial port attributes: " + e.strerror)
AttributeError: 'error' object has no attribute 'errno'
$ stty -F /dev/ttyS0
stty: /dev/ttyS0: Input/output error
其余的 ttyS1~3 也有同样的结果。
正确的设备路径是什么?