在Linux中更改USB虚拟串行端口的默认名称 [英] Change default names for USB virtual serial ports in Linux
问题描述
我正在使用C开发嵌入式解决方案,并且正在使用两个USB传感器.如果我单独连接每个传感器,它们将使用以下名称:
设备1 (我不知道为什么要使用6个名称...)
- /dev/ttyACM0
- /dev/ttyACM1
- /dev/ttyACM2
- /dev/ttyACM3
- /dev/ttyACM4
- /dev/ttyACM5
- /dev/ttyACM6
设备2
- /dev/ttyACM0
因此,当我开始作为嵌入式系统并连接两个传感器时,最快的传感器为/dev/ACM0,但并不总是相同.因此,当我尝试读取设备2时,我可能正在读取设备1 ...
我认为最好更改传感器的默认名称.我想这将是可能的,但我什么也没找到.
您应该尝试使用/dev/serial/by-id
中的名称,因为这些名称包括设备的名称,并且不取决于连接顺序.>
顺便说一句,还可以编写udev规则,这些规则根据串行端口所属的设备为串行端口建立符号链接.我不确定这对于具有6个串行端口的复合设备将如何工作,但是可能有一种使其起作用的方法.
I am developing an embedded solution using C and I am working with two USB sensors. If I connect each sensor alone they take this names:
Device 1 (I do not know why it takes 6 names...)
- /dev/ttyACM0
- /dev/ttyACM1
- /dev/ttyACM2
- /dev/ttyACM3
- /dev/ttyACM4
- /dev/ttyACM5
- /dev/ttyACM6
Device 2
- /dev/ttyACM0
So when I start as an embedded system and both sensors are connected, the fastest one takes /dev/ACM0 but it not always the same. So, when I try to read device 2 I could be reading device 1...
I think that It would be great to change the default names of the sensors. I guess that it is going to be possible but I do not find anything.
You should try using the names in /dev/serial/by-id
instead, since those names include the name of the device and should not depend on the order of connection.
By the way, it is also possible to write udev rules that make symbolic links for the serial ports depending on what device they belong to. I am not sure how that would work for a composite device with 6 serial ports, but there probably is a way to make it work.
这篇关于在Linux中更改USB虚拟串行端口的默认名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!