Monday, March 01, 2010

The endless abyss of LIRC

I built a home made Tivo out of a computer running MythBuntu (a flavor of MythTV). It installs very easily and quickly if you buy decently supported hardware. If you are using hardware with questionable Linux support, or you want it to do something a little bit custom, it can be an endless time sink to set up. I marginally justify it by thinking I am learning Linux in general along the way.

There are several ways to use a remote control with MythTV, the most common uses LIRC. LIRC is a trashy little pain in the ass program, with outdated and incomplete documentation, that generally can be forced to work if you know what you are doing, or are willing to spend tens of hours trying. I appreciate the author's time in making this program. But honestly if it wasn't free, it wouldn't be worth my time and frustration to use. LIRC needs an IR dongle to receive the remote signals. I use the serial dongle from Iguanaworks.

Set up the receiver
This assumes LIRC is installed and runs by default on your Myth distribution. This is true for most of them. Shut down the computer, plug in the serial dongle, restart the computer.

Test the receiver is working
mode2 can be used to test that the receiver is recognized and passing a remote signals to the computer
sudo mode2 -d /dev/lirc0
Now use any old remote and press some buttons, while pointing it at the receiver. You should get a bunch of pulse/pause gibberish. If you do, all is good, press ctrl+c to break out of it. If you get nothing, you need to figure out why the computer can't see the receiver, or the receiver isn't picking up any signal.

Pick and record the remote codeset
Select a set of codes on the universal remote you want to use. I'd suggest using the highest DVR codeset number, of the same brand as the universal remote, so all keys are likely to be usable. I'm going to use Sony DVR component code 3210 on their RM-VL600 remote.

If lirc is running and you want to reconfigure it, first you have to kill it
sudo killall lircd
Now let's record a new remote control configuration, first change into the recording directory.
cd /etc/lirc
Now start the recorder.
sudo irrecord -n -d /dev/lirc0 lircd.conf.new
Follow the directions onscreen. After you are done, archive your old lircd.conf and make the newly recorded conf current.
sudo mv /etc/lirc/lircd.conf /etc/lirc/lircd.conf.old
sudo mv /etc/lirc/lircd.conf.new /etc/lirc/lircd.conf

Verify the remote is being recognized
Use irw to test Lirc's interpretation of the remote keys. First restart lirc to load the new conf file.
To restart Lirc on Ubuntu 9.10 and up
sudo service lirc start|stop|restart
On older Ubuntu versions
sudo /ect/init.d/lirc start|stop|restart
Now type irw. Press buttons on the remote. You should get the name of the key, and the name of the remote echoed in the terminal. After you are satisfied, press ctrl+c to break out of irw. If you got nothing, lirc can't see the receiver, or wasn't able to load the new configuration file.

Map button names to a lirc event
Open up the lircrc file to see what remote keys are mapped to MythTV keyboard shortcuts.
nano /home/(username)/.lircrc
You should see an include statement for
/home/(username)/.lirc/mythtv
You need to open this file,
sudo nano /home/(username)/.lirc/mythtv
Verify the remote name and button names in lircd.conf are mapped to the correct MythTV keyboard shortcuts in this file. Edit lircrc as necessary. After you get done doing this, you need to restart lirc and restart MythTV frontend. Your remote should work now. MythTV no longer requires irexec or irxevent anymore, contrary to a lot of docs you will find on the intrawebs.


Other random notes
Check /etc/lirc/hardware.conf that DEVICE=/dev/lirc0

To see if lirc or irw is in the process list (ignore grep x in list)
ps aux | grep (lirc or irw)

No comments:

Post a Comment