LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Udev rules triggers multiple times (https://www.linuxquestions.org/questions/linux-software-2/udev-rules-triggers-multiple-times-4175571932/)

utomsig 02-10-2016 06:47 PM

Udev rules triggers multiple times
 
Hi!
I'm trying to start a SNES emulator on my Raspberry Pi 2 when I connect my USB joystick. So I don't have to use the keyboard at all. The thing itself is not important, obviesly. I don't even use the emulator, but my girlfriend does. And more importantly, it's irritating not understanding what is happening.
So, my udev rule looks like this:
Code:

ACTION=="add", KERNELS=="1-1.4", SUBSYSTEMS=="usb", DRIVERS=="usb", ATTRS{idVendor}=="0079", ATTRS{idProduct}=="0011", ATTRS{product}=="USB Gamepad ", RUN+="/home/pi/bin/udevrunsnes.sh"
I have tried to put more ATTRS (30 or so) and using different parent devices. The result is more or less the same. The udev rule gets triggered several times. With the current setup, 7 times. Is udev broken on my machine or have I missed something?

Heres what I'm running (Noobs/Raspbian):
Code:

$ uname -a
Linux raspberrypi 4.1.17-v7+ #838 SMP Tue Feb 9 13:15:09 GMT 2016 armv7l GNU/Linux

I haven't used udev before and I'm not a expert at linux, but I have used it at home for some years now. Thanks!

ferrari 02-12-2016 03:52 PM

Perhaps worth monitoring udev to see what events are occurring when the device is attached
Code:

udevadm monitor
Maybe the re-triggering just exposes how the device itself is behaving eg disconnecting and connecting multiple times? To expand on that - is it continuously re-triggering, or just a burst of activity when first connected?

The only workaround I can think of is to invoke a wrapper script that only runs your desired script once, and sets a flag accordingly.


All times are GMT -5. The time now is 10:02 AM.