Here's what I have for an FPGA programming dongle. It runs the script RUN whenever the device is connected (since ACTION="")
ATTRS{idVendor}=="1443", MODE="666" ACTION="" ATTRS{idVendor}=="0403", ATTRS{manufacturer}=="Digilent", MODE="666", RUN+="/usr/local/sbin/dftdrvdtch %s{busnum} %s{devnum}"
You can have ATTRS{serial}=="xxxxxxxxx" qualifiers in rules to perform actions for a particular device. Here's an example I found on the net for a printer: SUBSYSTEM=="usb", ATTRS{serial}=="L72010011070626380", SYMLINK+="epson_680"
Here's the page with the above example -- I found it very helpful
Folks,
I have a couple of questions about how to automatically set up USB serial devices on Linux. I have a Newport motor controller which is a USB device, but is actually a "serial" device. I can configure it fine on Linux by plugging it in and executing the following 2 commands as root:
modprobe ftdi_sio vendor=0x104d product=0x3000 chmod o+rw /dev/ttyUSB0
The first command loads the ftdi_sio driver with the vendor and product codes for this device. Those codes can be determined from the lsusb command:
Colorado:motor/iocBoot/iocWithAsyn>/usr/sbin/lsusb Bus 002 Device 003: ID 104d:3000 Newport Corporation
The second command sets the permissions on the device so any user can read and write it.
After doing those commands my EPICS IOC can access the device, set the baud rate, data bits, stop bits, etc. I now have a motor record driver to talk to it.
My question is how to have those 2 commands executed automatically so I don't need to manually do it. My first thought was to create a udev entry for the device. I created the following file and put it in /etc/udev/rules.d
Colorado:motor/iocBoot/iocWithAsyn>more ~/81-Agilis.rules SYSFS{idVendor}=="104d", ATTRS{idProduct}=="3000", MODE="0666"
If this file is present after the Linux system is booted and after I have issued the "modprobe" command then it works correctly. Each time I unplug the device /dev/ttyUSB0 disappears, and each time I plug it in it reappears with the correct permissions. If the udev file is not present then when I plug it in the device is missing read/write permission for others.
However, if that udev file is present when the system boots, before I issue the "modprobe" command then the "modprobe" command does not work in the sense that no /dev/ttyUSBn device appears. I think this could be because the udev file is causing some other driver to load, and so it won't load the ftdi_sio driver. Is there a way to specify which driver to load in the udev file?
Does anyone know how to do this?
I have a related question. An EPICS user at NIH has 18 of these devices which he wants to use at the same time. Is there a way to assign a specific device (based upon its serial number for example) to a specific /dev/ttyUSBn port? If not, how does one figure out which motor is connected to which /dev/ttyUSBn port?
Thanks, Mark
|