Change default names for USB virtual serial ports in Linux

匆匆过客 提交于 2019-12-18 09:27:19

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/40673043/change-default-names-for-usb-virtual-serial-ports-in-linux

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