Linux -  Restart LIRC if remote control is (re-)connected (udev rule)
#1
For some reason, LIRC doesn't realize when the USB dongle for my remote control (Medion X10) is reconnected (unplug USB, plug it back in). Only after I restart lirc with /etc/init.d/lirc restart, the remote works again. In syslog, that looks like this:

Code:
Dec 29 16:33:00 kernel: [20216.136118] usb 3-1: USB disconnect, device number 2
Dec 29 16:33:00 lircd-0.9.0[23295]: can't read from USB device: No such device



QUICK AND DIRTY FIX: Restart lirc whenever the remote is (re-)connected
I use udev to automatically restart LIRC when the remote is connected via USB

1) Find idProduct/idVendor by monitoring /var/log/syslog for a string like this (when USB dongle of remote is connected)
$ tail -f /var/log/syslog
Code:
...
Dec 29 16:33:10 mtp-probe: checking bus 3, device 3: "/sys/devices/pci0000:00/0000:00:1a.0/usb3/3-1"
...

2) Now figure out idProduct and idVendor
$ cat /sys/devices/pci0000:00/0000:00:1d.0/usb6/6-2/idProduct
0006

$ cat /sys/devices/pci0000:00/0000:00:1d.0/usb6/6-2/idVendor
0bc7

3) Create a udev rule for: restart lirc when USB dongle of remote control is connected
$ vi /etc/udev/rules.d/80-lirc-restart-on-x10-connect.rules
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idProduct}=="0006", ATTRS{idVendor}=="0bc7", RUN+="/etc/init.d/lirc restart"

That's it. If you reconnect, it should now look like this:
Code:
Dec 29 16:33:10 kernel: [20226.544088] usb 3-1: new low speed USB device number 3 using uhci_hcd
Dec 29 16:33:10 mtp-probe: checking bus 3, device 3: "/sys/devices/pci0000:00/0000:00:1a.0/usb3/3-1"
Dec 29 16:33:11 mtp-probe: bus: 3, device: 3 was not an MTP device
Dec 29 16:33:11 lircd-0.9.0[23343]: lircd(atilibusb) ready, using /var/run/lirc/lircd
Dec 29 16:33:11 lircd-0.9.0[23343]: accepted new client on /var/run/lirc/lircd
Dec 29 16:33:11 lircd-0.9.0[23343]: removed client
Dec 29 16:33:11 lircd-0.9.0[23343]: caught signal
Dec 29 16:33:11 lircd-0.9.0[23371]: lircd(atilibusb) ready, using /var/run/lirc/lircd
Dec 29 16:33:11 lircd-0.9.0[23371]: accepted new client on /var/run/lirc/lircd
Fanless Linux HTPC/NAS: Streacom FC10, ASUS P8H77-M PRO, i3-3225, Corsair LP White DDR3-1600, picoPSU-150-XT, 1x SSD 840, 2x HDD WD Red 3TB
Stats: 29W idle, 55W load, CPU 38-43°C idle, CPU 55-60°C load, HDD 42-43°C idle, HDD 47°C load

Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Restart LIRC if remote control is (re-)connected (udev rule)00