CFA-635 - udev runs script 7 times on insertion

Anthony Stanley

New member
Hello,

I am running Ubuntu and using udev to detect when the CFA-635 USB LCD is plugged in or removed.

When plugged in, I want it to run a bash script to display a simple control menu for a headless PC.
When the LCD is unplugged, I want it to kil the little script and clean things up a bit.

I have been able to get udev to trigger on insertion (add) and removal (remove). The problem is that when udev triggers on (add) it runs the script 7 times.

The (remove) event triggers correctly. It runs only once as intended.

Here is the udev rule:

ACTION=="add", ATTRS{product}=="Crystalfontz CFA-635 USB LCD", RUN+="/tmp/1.sh"
ACTION=="remove", ATTRS{product}=="Crystalfontz CFA-635 USB LCD", RUN+="/tmp/2.sh"

1.sh and 2.sh are just simple scripts that echo out a line to a log file for testing:

----------------------------------------------------------

#!/bin/bash
#1.sh test script

echo "LCD Module ADD event detected "`date` >> /tmp/lcd.log

-----------------------------------------------------------

#!/bin/bash
#2.sh test script

echo "LCD Module REMOVE event detected "`date` >> /tmp/lcd.log


-----------------------------------------------------------

When I plug in the LCD, my lcd.log file shows:

LCD Module ADD event detected <Current time and date>
LCD Module ADD event detected <Current time and date>
LCD Module ADD event detected <Current time and date>
LCD Module ADD event detected <Current time and date>
LCD Module ADD event detected <Current time and date>
LCD Module ADD event detected <Current time and date>
LCD Module ADD event detected <Current time and date>
LCD Module REMOVE event detected <Current time and date>



This tells me that udev finds both the add and remove action keywords and only runs my script once on removal, but runs it 7 times on insertion.

I have studied http://www.reactivated.net/writing_udev_rules.html and the man page at length and have searched for this behavior in other fourms and on Google. I have seen two others with the same problem, but no one answered thier question, or they simply gave up and added code to thier script to abort if it had already been run within a specified cooldown interval. I could do that too if I have too. But, I would perfer it just work correctly. Any ideas?

Thank you
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.
 
I tried this today and the /tmp/1.sh script ran several times.

I think that several parent devices ( udevinfo -a -p /sys/bus/usb-serial/devices/ttyUSB0 ) also match the ATTRS{product}=="Crystalfontz CFA-635 USB LCD" rule.
I narrowed the matching rule to:
ACTION=="add", ATTRS{driver}=="ftdi_sio", KERNEL=="ttyUSB0", SUBSYSTEM=="usb-serial", RUN+="/tmp/1.sh"
and the sript runs only once.

LCD Module ADD event detected Sat Jan 24 15:49:03 PST 2009
LCD Module ADD event detected Sat Jan 24 15:49:03 PST 2009
LCD Module ADD event detected Sat Jan 24 15:49:03 PST 2009
LCD Module ADD event detected Sat Jan 24 15:49:03 PST 2009
LCD Module ADD event detected Sat Jan 24 15:49:03 PST 2009
LCD Module ADD event detected Sat Jan 24 15:50:43 PST 2009
LCD Module ADD event detected Sat Jan 24 15:50:43 PST 2009
LCD Module ADD event detected Sat Jan 24 15:52:57 PST 2009
LCD Module ADD event detected Sat Jan 24 15:52:57 PST 2009
LCD Module ADD event detected Sat Jan 24 15:54:43 PST 2009
LCD Module ADD event detected Sat Jan 24 15:54:43 PST 2009
LCD Module ADD event detected Sat Jan 24 15:56:43 PST 2009
LCD Module ADD event detected Sat Jan 24 15:56:43 PST 2009
LCD Module ADD event detected Sat Jan 24 16:00:34 PST 2009
LCD Module ADD event detected Sat Jan 24 16:00:34 PST 2009
LCD Module ADD event detected Sat Jan 24 16:01:04 PST 2009
LCD Module ADD event detected Sat Jan 24 16:01:04 PST 2009
LCD Module ADD event detected Sat Jan 24 16:03:44 PST 2009
LCD Module ADD event detected Sat Jan 24 16:05:56 PST 2009
LCD Module ADD event detected Sat Jan 24 16:06:27 PST 2009

The remove rule is not working for me.
Debian etch/stable, custom 2.6.18 kernel, udev 0.105-4, hal 0.5.8.1-9etch
 
Top