我正在使用 Prolific 2303 串行 USB 连接到各种传感器和串行术语,如 (monoterm,coolterm) 以监视 ubuntu 18.04 中的串行输出,但似乎出了点问题,因为我无法看到输出日期,即使驱动程序和 USB 似乎工作正常。
我已经更新了 usb 端口的访问权限,并以 root 权限启动了 serialTerminal。
lsusb
的输出如下:
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 009: ID 8087:0ab6 Intel Corp.
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port
Bus 001 Device 002: ID 214b:7250
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
和
对于dmesg | grep tty
如下:
[ 0.000000] console [tty0] enabled
[ 6.724357] 8086228A:00: ttyS4 at MMIO 0x91420000 (irq = 39, base_baud = 2764800) is a 16550A
[ 6.742117] 8086228A:01: ttyS5 at MMIO 0x9141e000 (irq = 40, base_baud = 2764800) is a 16550A
[ 7.100607] usb 1-3: pl2303 converter now attached to ttyUSB0
[ 8.088988] cdc_acm 1-4:1.0: ttyACM0: USB ACM device
串口连接成功但没有返回任何输出,我知道我遗漏了什么但无法弄清楚。 根据评论中的要求,共享最小的 python 代码来读取数据。
import serial
ser = serial.Serial('/dev/ttyUSB0')
print(ser.readline())
最佳答案
通过设置传感器读取位的限制解决了这个问题,因为问题是传感器没有发送 EOL 字符,所以 readline 进入无限读取并且程序从未返回值。所以我使用字节 block 来读取数据。
关于linux - 无法在 ubuntu 18.04 中为各种串行传感器读取 USB 到串行输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56455942/