【发布时间】:2021-01-03 22:04:58
【问题描述】:
我尝试列出所有的 com 端口,以便可以连接到它们。我正在使用 Ubuntu 20.04。我尝试了各种在 stackoverflow 上得到解答的事情。 我尝试从命令行列表output of the command line
import serial
import serial.tools.list_ports
ports = serial.tools.list_ports.comports()
print(ports)
for port, desc, hwid in sorted(ports):
print('hello')
print("{}: {} [{}]".format(port, desc, hwid))
方法 serial.tools.list_ports.comports() 返回一个空列表。 我尝试了一切并用谷歌搜索了很多,但我无法找到解决方案。 请帮助某人,否则我的项目将停止。
【问题讨论】:
-
从终端运行
dmesg | grep -i serial会得到什么? -
[0.555970] 序列号:8250/16550 驱动程序,32 个端口,已启用 IRQ 共享 [0.562116] usb usb1:新 USB 设备字符串:Mfr=3,Product=2,SerialNumber=1 [0.562120] usb usb1: 序列号: 0000:00:14.0 [0.563893] usb usb2: 新 USB 设备字符串: Mfr=3, Product=2, SerialNumber=1 [0.563896] usb usb2: 序列号: 0000:00:14.0 [1.078359] usb 1- 1:新 USB 设备字符串:Mfr=1,Product=2,SerialNumber=0 [1.333481] usb 1-4:新 USB 设备字符串:Mfr=1,Product=2,SerialNumber=3
-
我没有看到
tty你在这台机器上实际上有一个 com 端口吗?
标签: python-3.x port pyserial ubuntu-20.04