permanent USB port names? (Linux) [closed]

有些话、适合烂在心里 提交于 2020-01-07 04:58:25

问题


I have two Arduinos now used by my program. SInce I'm on Linux and new to Linux, the port isn't static, like "com3" and "com6", I think it's "ttyUSB0" for the first Arduino which is connected, and "ttyUSB1" for the second and so on. But since both are connected when the OS boots, can I be certain that the port names will remain the same? Or is there some other way to access ports by name?


回答1:


use udev!

udevadm info -a -n /dev/ttyUSB1 | grep '{serial}' | head -n1

should give you the USB interfaces serial number.

then you can write udev rules:

example

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A6008isP", SYMLINK+="arduino"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A7004IXj", SYMLINK+="buspirate"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="FTDIF46B", SYMLINK+="cisco.serial"


来源:https://stackoverflow.com/questions/32702885/permanent-usb-port-names-linux

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!