MythTV Upgrade - Part 2

Configuring lirc (Remote control daemon)

Getting the remote control to work has been on my to-do list for as long as I've been using MythTV. Early on I decided to go with a wireless mouse/keyboard combo instead. I have been using the Ione Scorpius P-20 for quite a while and it has served me well.





Every 6 months or so I would try to get the remote working, and every time I would fail... until this weekend. I couldn’t have done it without the following two sites:

1) http://www.mythtv.org/wiki/index.php/MCE_Remote
2) http://www.hauppauge.co.uk/board/showthread.php?t=8048


I have a Hauppauge PVR-150 Tuner card which came with the Remote and the IR receiver. I would say my biggest stumbling point along the way was that until this weekend I never knew exactly which remote I had. Apparently the PVR-150 has come with a whole bunch of different remotes over its lifetime.



As it turns out, I have a MCE USB2, Version 2, Hauppauge PVR-Kit remote. How I was supposed to know that without luckily finding that first link, I have no idea. A picture truly is worth a thousand words sometimes. The only identifying number on the back was "RC 6" ir.

So now on to the configuration:

MythDora4 comes with lircd version 0.8.2-CVS:

[root@mythtv mythtv]# /usr/sbin/lircd -v
lircd 0.8.2-CVS


After reading a bunch of caveats on the MythTV.org wiki link above, I decided to use CVS and go right to the latest version.

I following the wiki instructions exactly:

407 cd /usr/src
408 cvs -d:pserver:anonymous@lirc.cvs.sourceforge.net:/cvsroot/lirc login
409 cvs -z8 -d:pserver:anonymous@lirc.cvs.sourceforge.net:/cvsroot/lirc co lirc
410 cd lirc
411 ls
412 ./autogen.sh
413 ./setup.sh

Menu Option # (1) - Driver Configuration (enter)
Menu Option # (8) - USB Devices (enter)
Menu Option # (t) - Windows Media Center Remotes (new version, Philips et al.) (enter)
Menu Option # (3) - Save your configuration and run configure (enter)
418 make && make install
419 modprobe lirc_mceusb2


This installed lircd in /usr/local/sbin/lircd (This will be important later). First I used mode2 to see if the IR receiver was working:


[root@mythtv lirc]# mode2
(I then pressed the up arrow on the remote)
space 100000
pulse 2750
space 750
pulse 500
space 400
pulse 500
space 350


- That output means it was catching the signals

Unfortunately when I started lircd, ran irw, and then pressed the same buttons, nothing showed up:

[root@mythtv lirc]# /usr/local/sbin/lircd /etc/lircd.conf
[root@mythtv lirc]# irw

I tried a few pre-made lircd.conf files online, but the one from that second link is what finally worked. The lircd.conf file is what maps the IR code to a button on your remote. It looks something like this:

Power 0x00007bf3 # no e2,e3
MyTV 0x00007bb9 # starts at af
MyMusic 0x00007bb8 # starts at af
MyPictures 0x00007bb6 # starts at af
MyVideos 0x00007bb5 # starts at af
Record 0x00007be8 # no e2,e3
Stop 0x00007be6 # no e2,e3
Pause 0x00007be7 # no e2,e3


This time, when I run irw i see the following output:

[root@mythtv lirc]# lircd /etc/lircd.conf
[root@mythtv lirc]# irw
000000037ff07be1 00 Up mceusb
000000037ff07be0 00 Down mceusb
000000037ff07bdf 00 Left mceusb
000000037ff07bde 00 Right mceusb
000000037ff07bfa 00 Five mceusb
000000037ff07bf9 01 Six mceusb

That is farther then I have ever been before. Now the last part is the .lircrc file. This file maps the named button to the program and action (or keystroke) and is located in the users home directory. (ex: /home/mythtv/.lircrc)

To review:

Lircd.conf -> Maps IR code to a button name on remote
.lircrc -> Maps the button on the remote to a corresponding keystroke (application dependent).

An excerpt of the .lircrc file looks something like this:

# Down = Scroll/Channel Down.
begin
prog = mythtv
button = Down
config = Down
repeat = 2
end

This tells us that when (according to lircd.conf) the down button is pressed, if we are in mythtv, this should be equivalent to the down arrow.

I then started lircd with my new lircd.conf and .lircrc files in place:
[root@mythtv lirc]# lircd /etc/lircd.conf

And with that my remote control worked with MythTV for the first time ever.

The last thing I did was to change the /etc/rc.d/init.d/lircd file so that the service script starts my newly compiled lircd .0.8.3-CVS rather than the stock lircd.

Just to reiterate which version is which:

[root@mythtv mythtv]# /usr/sbin/lircd -v
lircd 0.8.2-CVS
[root@mythtv lirc]#/usr/local/sbin/lircd -v
lircd 0.8.3-CVS

I added the text in red to the following file: /etc/rc.d/init.d/lircd

[ -x /usr/local/sbin/lircd ] exit 1
[ -x /usr/local/sbin/lircmd ] exit 1

start(){
if [ -f /etc/lircd.conf ]; then
echo -n $"Starting infrared remote control daemon: "
daemon /usr/local/sbin/lircd $LIRCD_OPTIONS
RETVAL=$?
echo
fi


Troubleshooting:

The licrd binary that came with MythDora4 wrote debug information to /var/log/messages. On the lircd I complied myself, it wrote message to /var/log/lircd. Tailing (with a -f) whichever log file lirc is writing to can be a really good way to troubleshoot.

Comments

Popular posts from this blog

Exploiting Python Code Injection in Web Applications

Exploiting Server Side Request Forgery on a Node/Express Application (hosted on Amazon EC2)

Pentest Home Lab - 0x3 - Kerberoasting: Creating SPNs so you can roast them