I recently built myself a new HTPC. It’s controlled with a Medion X10 remote control using LIRC. For some reason, LIRC doesn’t realize when the USB dongle for my remote control is reconnected (unplug USB, plug it back in). This blog posts demonstrates how to easily fix this using a udev rule. I originally posted this on the XBMC forum.
Contents
1. Problem
When disconnecting the remote control USB dongle, LIRC removes the corresponding device. Unfortunately, it does not recognize when the device is reconnected to the computer. Only after LIRC is restarted with “/etc/init.d/lirc restart”, the remote works again. The syslog entry should look like this:
1 2 |
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 |
2. Quick and Dirty Fix
This fix simply restarts LIRC whenever the remote is (re-)connected. The software “udev” can be used to react on the USB dongle connection. Here’s how to do it:
2.1. Identify remote control
First, identify the identification numbers for your remote control. You can do that by looking for the device in /var/log/syslog. Simply look for a string like this (when USB dongle of remote is connected). Hit Ctrl+C to stop monitoring syslog.
1 2 3 4 |
tail -f /var/log/syslog ... Dec 29 16:33:10 mtp-probe: checking bus 3, device 3: "/sys/devices/pci0000:00/0000:00:1a.0/usb3/3-1" ... |
2.2. Figure out idProduct and idVendor
Take the device listed in syslog, and check for idProduct and idVendor. These two numbers can then be used to create a rule in udev.
1 2 3 4 |
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 |
2.3. Create a udev rule for
The udev system allows creating rules that are interpreted when connecting/disconnecting devices. In this case, we’d like to create a rule to restart LIRC when the USB dongle of remote control is connected.
Create a file in /etc/udev/rules.d/ with the suffix “.rules” that contains the following line. Simply replace 0006 and 0bc7 with the idProduct/idVendor numbers you identified above.
1 |
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idProduct}=="0006", ATTRS{idVendor}=="0bc7", RUN+="/etc/init.d/lirc restart" |
Note that the contents of the file are just one line — so no line breaks.
3. That’s it
That’s it. If you reconnect, LIRC should be restarting.
It should now look like this:
1 2 3 4 5 6 7 8 9 |
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 |
Recent Comments