How to identify multiple USB-serial adapters under Ubuntu 10.1

后端 未结 7 1399
无人共我
无人共我 2020-12-29 13:54

I am reading data from multiple identical USB-serial adapters under Ubuntu 10.1.

On occasion, their /dev/tty path changes (eg if other USB devices are connected on s

7条回答
  •  长发绾君心
    2020-12-29 14:14

    Much like Ilya Matvejchikov's answer, a good solution is to add udev rules to do what you want with the device. Like you, I was having a similar problem. I had a UPS on a USB-to-multi-serial adapter and occasionally the system would switch around the /dev/tty numbers.

    My solution was to create a rule to match the type of device by driver and port, then create a symbolic link to the port to which my UPS was attached. I used NUT to monitor the UPS, which was always plugged into the same physical port.

    # File contents of /etc/udev/rules.d/75-nut-ups.rules
    # Create /dev/nut-ups0 to use as a persistent serial device that can be used
    # reliably by nut to communicate with a UPS attached to the system.
    # The UPS is attached to the first port of a MosSemiconductor dual USB
    # serial adapter.
    KERNELS=="ttyUSB*", SUBSYSTEMS=="usb-serial", DRIVERS=="moschip7720", ATTRS{port_number}=="0", SYMLINK+="nut-ups0"
    

    Now I configure NUT to always use a constant /dev/nut-ups0, as the serial port and the rule takes care of mapping properly when the usb-serial device is recognized.

    You can use the lsusb command to find out the actual device name to use in the rule when it's plugged in.

提交回复
热议问题