Title: udev rule to identify specific device Subject: #------------------------------------------------------------------------------ # Identify the device when you plug it in #------------------------------------------------------------------------------ sudo udevadm monitor # Plug in the device, and note the output. Ctrl-c #------------------------------------------------------------------------------ # List the udev device, and get the vendor and product id #------------------------------------------------------------------------------ lsusb -v #------------------------------------------------------------------------------ # Make a udev rule for this device, # such that it creates a link when this device is found #------------------------------------------------------------------------------ sudo cat > /etc/udev/rules.d/51-at91sam_cdc_acm.rules << 'EOF' # # Create symlink to what ever usb device matches our target # #ACTION=="add", SUBSYSTEM=="usb", ATTR{idProduct}=="6124", ATTR{isdVendor}=="03eb", RUN+="/usr/bin/logger 'Found sam-ba'" #ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idProduct}=="6124", ATTRS{idVendor}=="03eb", MODE="0600", GROUP="steveg" KERNEL=="ttyACM*", ATTRS{idProduct}=="6124", ATTRS{idVendor}=="03eb", SYMLINK+="ttyUSB-AT91SAMBA%n", ENV{ID_MM_DEVICE_IGNORE}="1" EOF #------------------------------------------------------------------------------ # reload udev rules #------------------------------------------------------------------------------ sudo udevadm control --reload-rules sudo udevadm monitor #------------------------------------------------------------------------------ # replug the device and watch #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # Make script to tell you which device the link points to #------------------------------------------------------------------------------ echo > find_my_device.bash <<'EOF' echo "Determine where the link points..." serial_interface="/dev/ttyUSB-AT91SAMBA0" # Check if link exists, set by udev rule. if [[ -h "${serial_interface}" ]]; then serial_port="/dev/$(readlink ${serial_interface})" echo "Found serial device for AT91SAMBA: ${serial_interface}" else echo "Link not found." exit 1 fi # Check if link points to valid serial device file if [[ -c "${serial_port}" ]]; then echo "Driver linked to serial port: ${serial_port}" else echo "Driver not linked to vaild serial port: ${serial_port}" echo "Exiting!" exit 1 fi EOF