udev Rules
udev 规则AdvancedLinux rules that set device permissions and give devices fixed names, so port numbers don't shuffle after replugging.
udev is Linux's device manager. The kernel names devices such as /dev/ttyUSB0 or /dev/video0 in the order it discovers them, so after replugging or rebooting two arms or two cameras can swap names — an easy way to send commands to the wrong arm. Regular users also often lack permission to open these devices. udev rules are text files ending in .rules placed in /etc/udev/rules.d/. Each line first matches a device by conditions such as ATTRS{idVendor} or ATTRS{serial}, then sets permissions with MODE and GROUP, adds a stable name with SYMLINK, and can even change device settings with ATTR (a serial port's latency, for example). udev never renames the original device node; it only adds a link that points to it. Identical devices have to be told apart by serial number, which udevadm info will show you. After editing, run udevadm control --reload and udevadm trigger to apply the rules. The setup_udev_rules.sh script in RealSense's installation steps simply installs udev rules that give users access to the cameras.
ExampleALOHA's setup guide has you look up the right master arm's serial number with udevadm info, then add one line to a rules file under /etc/udev/rules.d/ that matches that serial with ATTRS{serial}, names the device with SYMLINK+="ttyDXL_master_right", and sets latency_timer to 1. After reloading, that arm is always /dev/ttyDXL_master_right no matter which USB port it is plugged into.
- Also called
- udev, udev rule files
- Related
- Ubuntu Linux · Serial Port (UART / USB-to-Serial) · Driver (Device Driver) · RealSense Depth Camera (D435i / D405) · ALOHA · ROBOTIS Dynamixel Servo
- Sources
- udev(7) - Linux manual page
tonyzhaozh/aloha README: Hardware installation (fixed udev symlinks for arms and cameras)
librealsense: Linux installation guide (setup_udev_rules.sh)