我使用的是 Ubuntu 20.04.3 LTS
当我尝试从 arduino 上传时,我得到了
avrdude: ser_open(): can't open device "/dev/ttyUSB0": Input/output error
当我尝试打开串行监视器时
Error opening serial port '/dev/ttyUSB0'. (Port not found)
如果我使用另一种类型的 USB 转串行(pl2303),串行监视器工作正常,硬件工作正常,我在 Windows 机器上测试过,没有问题。
$ lsmod | grep usbserial
usbserial 53248 2 pl2303,ch341
dmesg 给出:
[ 451.329190] usb 10-2: new full-speed USB device number 2 using xhci_hcd
[ 451.505205] usb 10-2: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54
[ 451.505219] usb 10-2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 451.505223] usb 10-2: Product: USB2.0-Serial
[ 451.556668] usbcore: registered new interface driver usbserial_generic
[ 451.556686] usbserial: USB Serial support registered for generic
[ 451.558302] usbcore: registered new interface driver ch341
[ 451.559378] usbserial: USB Serial support registered for ch341-uart
[ 451.559976] ch341 10-2:1.0: ch341-uart converter detected
[ 451.573480] usb 10-2: ch341-uart converter now attached to ttyUSB0
[ 463.937493] usb 10-2: failed to receive control message: -110
[ 463.937504] ch341-uart ttyUSB0: failed to read modem status: -110
[ 482.625628] usb 10-2: failed to receive control message: -110
[ 482.625701] ch341-uart ttyUSB0: failed to read modem status: -110
[ 501.281699] usb 10-2: failed to receive control message: -110
[ 501.281710] ch341-uart ttyUSB0: failed to read modem status: -110
和 pl2303:
[ 1751.189867] usb 10-2: USB disconnect, device number 2
[ 1751.190187] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[ 1751.190220] ch341 10-2:1.0: device disconnected
[ 1786.822056] usb 10-2: new full-speed USB device number 3 using xhci_hcd
[ 1786.996937] usb 10-2: New USB device found, idVendor=067b, idProduct=2303, bcdDevice= 3.00
[ 1786.996946] usb 10-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 1786.996951] usb 10-2: Product: USB-Serial Controller
[ 1786.996954] usb 10-2: Manufacturer: Prolific Technology Inc.
[ 1787.046337] usbcore: registered new interface driver pl2303
[ 1787.046367] usbserial: USB Serial support registered for pl2303
[ 1787.046410] pl2303 10-2:1.0: pl2303 converter detected
[ 1787.076108] usb 10-2: pl2303 converter now attached to ttyUSB0
我尝试了很多方法,比如添加用户拨出和文件权限
可以做什么?
编辑:
ls -al /dev/ | grep ttyUSB*
crw-rw---- 1 ss dialout 188, 0 dec 19 16:58 ttyUSB0
两个设备都一样
编辑:
后
sudo usermod -a -G dialout username && sudo chmod a+rw /dev/ttyUSB0 && sudo chown root:dialout -R /dev/
ls -al /dev/ttyUSB*
crw-rw-rw- 1 root dialout 188, 0 dec 19 20:40 /dev/ttyUSB0
arduino 串行监视器出现同样的错误,dmesg 与上述相同
更新:
在另一台机器上安装了 arduino(同一台笔记本电脑,但装有 windows7,硬盘不同),只运行将用户添加到拨出组,运行正常,从 arduino 上传了一个测试草图。相同版本“Ubuntu 20.04.3 LTS”笔记本电脑是较旧的型号,只有 usb2.0,而 PC 是“较新的”(5-6 年旧)并使用 usb3.0 端口。切换到 2.0 端口,现在情况好多了,但还有另一个问题:串行监视器以随机间隔拾取随机字符:
MCbK19:kEPUqPJv0Zyq71dlX19QDFDFR
2K19:m4GjpRJ7cNnR9AxB
X19K19:M4yD0kmEvONihR79X19
DFUDK19:OVyzqIbEKK4VAUCcX19DF
??????
如果我设法在随机字符之间发送,我可以上传草图。
通过使用 USB2.0 端口,问题得到解决。