永久的USB端口名称? (Linux) [英] permanent USB port names? (Linux)
本文介绍了永久的USB端口名称? (Linux)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的程序现在使用了两个Arduino. 因为我在Linux上并且是Linux的新手,所以端口不是静态的,例如"com3"和"com6",我认为第一个连接的是Arduino的"ttyUSB0",第二个连接的是"ttyUSB1",等等.在.但是,由于在操作系统启动时两者都已连接,因此我可以确定端口名称将保持不变吗?还是有其他方法可以通过名称访问端口?
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?
推荐答案
使用udev!
udevadm info -a -n /dev/ttyUSB1 | grep '{serial}' | head -n1
应该给您USB接口的序列号.
should give you the USB interfaces serial number.
然后您可以编写udev规则:
then you can write udev rules:
示例
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"
这篇关于永久的USB端口名称? (Linux)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文