From: Ernst B. <e.b...@xe...> - 2006-09-12 12:07:46
|
On Tuesday 12 September 2006 13:43, tasos wrote: > Hello ernst. > Until now i'm using this rule in udev in order to > recognise my devices. > BUS=="usb",SYSFS{interface}=="Crystalfontz CFA-635 USB > LCD", KERNEL=="ttyUSB*", > SYMLINK+="lcd1/%k",MODE="0666" > > I will use more than one devices.So my question is. > I will launch lcd4linux -f foo,lcd4linux -f bar etc. > Will those processes killed automatically if i use > udev.i mean when foo which uses ttyUSB6,is > disconnected will udev recognise the correct lcd4linux > process? > If so can you help me a little bit. Well, unfortunatly the name and location of the PIDFILE written by lcd4linux is hardcoded, to run multiple instances this needs to be fixed first (e.g. make lcd4linux accept a command-line parameter specifing the pidfile location) Then, for each device in question, write a little shellscript (forking lcd4linux, and killing it), add it to your udev rule: ...MODE="0666",RUN+="/path/my_lcd_1_script" ...MODE="0666",RUN+="/path/my_lcd_2_script" for the second lcd and so on. the script would be something like: --- /path/my_lcd_1_script --- #!/bin/sh if [ "$ACTION" = remove ]; then # Kill running lcd4linux kill `cat /var/run/lcd4linux_1.pid` else # start new lcd4linux process, assert $ACTION==add lcd4linux -f /etc/my_lcd_1_config.cfg --pidfile=/var/run/lcd4linux_1.pid fi ----------------------------- (With more sanity checks added, like checking for the pidfile, check if the pid belongs to lcd4linux, etc. maybe use a distro tool like "start-stop-deamon" for this, they usually contain most of those checks already...) have a look at the udev manpage for more info, esp. how to pass the location of the devicenode to your script etc. > BTW is it so difficult to add some code which will > disconnect it automatically? > Thank you in advance! Well, in that case, it is. The kernel only presents a virtual comport to lcd4linux, and lcd4linux only notices its gone when it tries to use it. Devices/Drivers that work directly with usb (libusb) have it easier here, they can notice the disconnect, but AFAIK don't shutdown then. Some drivers (lcd2usb for example) even try to wait for an eventual reconnect of the device, they keep running on purpose. /Ernst |