-
Notifications
You must be signed in to change notification settings - Fork 34
udev
趙 漠居(Zhao, Moju) edited this page Jun 3, 2021
·
3 revisions
- create a symbolic link to port (e.g., /dev/ttyUSB0) that may change after re-plug
- configure settings about the port, such as badurate, latency
X
is your device's number. An example is following:
$ sudo udevadm info -a /dev/ttyUSB0
Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.
looking at device '/devices/3610000.xhci/usb1/1-4/1-4:1.0/ttyUSB0/tty/ttyUSB0':
KERNEL=="ttyUSB0"
SUBSYSTEM=="tty"
DRIVER==""
looking at parent device '/devices/3610000.xhci/usb1/1-4/1-4:1.0/ttyUSB0':
KERNELS=="ttyUSB0"
SUBSYSTEMS=="usb-serial"
DRIVERS=="ftdi_sio"
ATTRS{latency_timer}=="1"
ATTRS{port_number}=="0"
looking at parent device '/devices/3610000.xhci/usb1/1-4/1-4:1.0':
KERNELS=="1-4:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="ftdi_sio"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 0"
ATTRS{bInterfaceClass}=="ff"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceProtocol}=="ff"
ATTRS{bInterfaceSubClass}=="ff"
ATTRS{bNumEndpoints}=="02"
ATTRS{interface}=="FT232R USB UART"
ATTRS{supports_autosuspend}=="1"
looking at parent device '/devices/3610000.xhci/usb1/1-4':
KERNELS=="1-4"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="8"
ATTRS{bMaxPower}=="90mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0600"
ATTRS{bmAttributes}=="a0"
ATTRS{busnum}=="1"
ATTRS{configuration}==""
ATTRS{devnum}=="5"
ATTRS{devpath}=="4"
ATTRS{idProduct}=="6001"
ATTRS{idVendor}=="0403"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="FTDI"
ATTRS{maxchild}=="0"
ATTRS{product}=="FT232R USB UART"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="unknown"
ATTRS{serial}=="A907HR6F"
ATTRS{speed}=="12"
ATTRS{urbnum}=="24761"
ATTRS{version}==" 2.00"
looking at parent device '/devices/3610000.xhci/usb1':
KERNELS=="usb1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{authorized_default}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="09"
ATTRS{bDeviceProtocol}=="01"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="0mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0409"
ATTRS{bmAttributes}=="e0"
ATTRS{busnum}=="1"
ATTRS{configuration}==""
ATTRS{devnum}=="1"
ATTRS{devpath}=="0"
ATTRS{idProduct}=="0002"
ATTRS{idVendor}=="1d6b"
ATTRS{interface_authorized_default}=="1"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Linux 4.9.108-tegra xhci-hcd"
ATTRS{maxchild}=="4"
ATTRS{product}=="xHCI Host Controller"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="unknown"
ATTRS{serial}=="3610000.xhci"
ATTRS{speed}=="480"
ATTRS{urbnum}=="73"
ATTRS{version}==" 2.00"
looking at parent device '/devices/3610000.xhci':
KERNELS=="3610000.xhci"
SUBSYSTEMS=="platform"
DRIVERS=="tegra-xusb"
ATTRS{driver_override}=="(null)"
ATTRS{hsic_power}=="0"
- The two-digit number like 99 indicate the priority of this rule file to be loaded. 99 means the highest priority
- Template rule file
99-aerial-robot-dev.rules
for serial USB device:
KERNEL=="ttyUSB*", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="A907HR6F", SYMLINK+="flight_controller"
ACTION=="add", SUBSYSTEM=="usb-serial", DRIVER=="ftdi_sio", ATTR{latency_timer}="1"
- Line1: numbers of
idVendor
,idProduct
andserial
should be modified correctly referring to the result of 1. - Line2: configure the latency: minimum latency of 1. Very Important. Otherwise the arrival of rosserial message from spinal would be very unstable.
$ sudo udevadm control --reload-rules && udevadm trigger
you must see the symbolic link under /dev
, such as /dev/flight_controller
in the above udev rule file.
If you don't have permission to use /dev/ttyUSB*
, do $ sudo adduser [username] dialout