LIRC

From MythTV Official Wiki
Revision as of 16:03, 31 March 2007 by Dagmar d'Surreal (talk | contribs) (IR Reception (to MythTV): More infographics, and grammatical cleanups)

Jump to: navigation, search

LIRC stands for Linux Infrared Remote Control.

So you want to control MythTV with your remote from the couch, eh? Well LIRC will help...

LIRC is a program that gives your computer the ability to send and receive infrared remote signals. Most distributions include LIRC packages, but you may have to compile your own version of the program to use certain features that the packagers did not include.

Basics

IR Reception (to MythTV)

In it's most basic concept, you press the 'play' button on your remote control which sends an infrared signal to an infrared receiver connected to your computer. This infrared receiver sends a signal to LIRC, which identifies that you hit the 'play' key on your remote and then generates a keystroke on your computer that instructs MythTV to play.

For the infrared receiver, you have 2 choices about how you set it up to work with mythtv:

  • Using irxevent which is an external program that can send key presses to Mythtv as if you were pressing keys on the keyboard. irxevent reads ~/.lircrc (note the dot at the start of the filename)
  • Use mythtv native LIRC support, where mythtv reads ~/.mythtv/lircrc for its own key configuration (note no dot at the start of the filename) (Note: As of 0.21 Mythtv will read ~/.lircrc if ~/.mythtv/lircrc does not exist).

In simple terms, this is what happens to the infrared (IR) signal and how it gets to mythtv:

  • A remote control (A) is emits pulses of infra-red light signals that are seen by an IR receiver (B) that is connected to your computer. The receiver may be connected to the computer via a serial port, over USB, or by a dedicated chip built into a TV tuner card. Each different type of physical IR receiver has its own type of kernel module.
Rect32603.png
  • The kernel module (C) uses /dev/lirc (typically) to emit the pulse-length information, which is then parsed by the lircd process. The LIRC daemon (D) then uses the information from /etc/lircd.conf (E) to convert the pulse-lengths into button press information.
Rect32606.png
  • irexec gets the button name and translate it into a key press to be passed on to mythtv or other software, or mythtv runs its own IR client process to do the translation. In this case CH+ might be passed on to mythtv as Up.
  • Note that the button names in /etc/lircd.conf must match the "button" configuration names you use in your lircrc file, but are otherwise completely up to you. The translations between the button names and the mythtv's internal names is done in the .lircrc or lircrc file, in the "config" line for a button. The "config" names must match what mythtv is expecting, and for the mythtv native LIRC support the "prog" line must say "prog = mythtv".

IR Transmission (from MythTV)

The concept of a transmitter is a little more complex. You might want to use a transmitter if, for instance, you want MythTV to control a cable/satellite box so it can record the right shows on the right channels. Let's say LIRC just sent 'Channel +' keystroke to MythTV (like detailed above). MythTV then sends a signal back to LIRC instructing it to transmit a 'Channel +' command to the cable box. The infrared transmitter on your computer then emits an infrared signal to your cable box instructing it to change the channel + (just as if you had pressed the channel + key on the original cable remote). http://mythblasterz.gotdns.com/ Mythblasterz has some for sale.

The transmitter and receiver mentioned above are two separate devices (sometimes packaged into a single box). You cannot transmit through a receiver or receive through a transmitter.

Controlling a digital cable/satellite box using Fedora, MythTV, an IR Blaster and one instance of LIRC

LIRC with Multiple External Tuners

If you are using a system with multiple external tuners, you can use LIRC to control each one independently. The proper irsend command for each tuner can be placed in a separate channel changing script, and then specified as an external channel changing program for the appropriate video source in the Mythtv-setup program.

Normally, only a single LIRC transmitter is required as long as each of the tuners have mutually exclusive remote codes, and the LIRC transmitter can placed in the line of site of all tuners' IR receivers. In this configuration, each tuner will need a "Remote Block" setting in the lircd.conf file and irsend simply needs the correct REMOTE argument. This is probably the simplest solution to most multiple tuner systems.

However, there are some instances where unique control codes aren't possible, or simultaneous line of site to the two receivers is not possible. In these cases, there are some options available:

  • Load multiple LIRC drivers using irsend's --device option. For some drivers, including lirc_serial (IR Blaster, etc.), this method won't work with multiple transmitters of the same type.
  • Use multiple IR emitters independently controlled by CommandIR Mini, a USB TX/RX combo device, with irsend's SET_TRANSMITTERS directive.

Set up

Setting up LIRC can range from very easy to incredibly difficult. The difficulty level is likely related to what hardware you end up using for LIRC. There are several different hardware pieces for receiving and sending LIRC commands. A few are:

  • The receiver that comes with your TV card. For example, the PVR series from Hauppauge sometimes have a receiver.
  • A Serial Port reciever you can make yourself or buy for a small fee (Often called a homebrew reciever) I have made a list of homebrew lirc receiver parts that are readily available at RadioShack.
  • A Serial Port transmitter you can make yourself or buy for a small fee (called a homebrew transmitter)
  • A commercially available USB receiver (e.g. Microsoft MCE remote control).
  • A USB receiver you can make yourself.
  • A Parallel Port transmitter and/or receiver you can make yourself.

It should be noted also that some people bypass the need for lirc altogether, and simply 'train' infrared codes from an infrared keyboard to their universal remote control. This way, pressing a key on your universal remote control would be picked up by the infrared keyboard's sensor, and pass the keystroke directly to MythTV as if you had been using an actual keyboard and not a remote at all.

For Help Setting up LIRC on your computer, follow some of these excellent resources:


lirc + 2.6.16 kernel:

As of 5/10/06 you must patch lirc-0.8 to work with the 2.6.16 kernel. Patch can be found here:

Additional info:

I have built several homebrew recievers, and it is a fun project. If you are faint-of-heart when around soldering irons and little resistors, then you might want to check out some of these sites that offer pre-built models:

-- Dave Hofstra

Troubleshooting

irw

Use the irw program to see whether LiRc and your remote are working before going any further. It shows what events are generated by your remote. This is very helpful! The irw tool connects to the lircd daemon and displays any recognized IR signals detected by the driver. If this works, then your hardware and driver is working. All that remains is your application setup.

Logging

You can enable logging for lircd with the -L option. Use this to see the results of clients connecting to lircd daemon. Compiling lircd with debugging enabled (-D option) allows you to see much more including parsing of the remote definitions.

# /usr/local/sbin/lircd --device=/dev/lirc/0 /etc/lirc/lircd.conf -L ~/lircd.log -D7
  • The log file showing "accepted new client" immediately followed by "removed client" can indicate a a ~/.lircrc or ~/.mythtv/lircrc parsing error. Check the formatting.

Key things to remember

  • If you're using a PVR-350, at least, it won't work with stock LiRc. You need 0.7.0 (as mentioned in Jarod's Guide)
  • If you're using a PVR-500MCE, please read this page: MCE_Remote
  • Set up /etc/lircd.conf to fit your remote.
  • Set up ~/.mythtv/lircrc with the keys that are needed for MythTV and MPlayer
  • Ensure MPlayer knows about LIRC (assuming you use it as the default player). If LIRC was installed AFTER MPlayer, you need to tell mplayer where to find the lircrc file in either the global config file /etc/mplayer/mplayer.conf, the local user override file ~/.mplayer/config, or on the command line in mythfrontend -> Utilities/Setup -> Setup -> Media Settings -> Video Settings -> Player Settings -> Default Player by adding -lircconf /path/to/lircrc. Note that when using all the default video players etc in myth, native control of MPlayer is only required when playing video files (like AVI's etc..) under "Watch Videos".
  • Setup ~/.lircrc for Xine. I have the ~/.mythtv/lircrc be a softlink to ~/.lircrc. See my lircrc [link void as of October 2006, and most likely since October 2004. Candidate for removal] for a MythTV + Xine lircrc suggestion using the Hauppauge Grey remote.
  • Don't try to use a lircrc file written for irxevent if you are trying to use mythtv native lirc support, instead search for mythtv/configfiles/hauppauge-lircrc-nativelirc to use as a template. Even better, use Mythtv-lircrc-Dapper as the basis for your own file.

-- Peter Morch

I use KnoppMyth and it worked out of the box for me with a Homebrew transmitter & receiver.

I use this SKY channel changer script with Sky in the UK - my sky box doesn't always change channels so it does it twice :) It also has 'locking' and works with the SKY dog remover script. I the ideas for this from a website somewhere.

-- David Greaves

LIRC 2.6

LIRC26 is how I installed Lirc (well, the lirc_serial driver) under 2.6.4 and 2.6.6

Lirc on Ubuntu Dapper is how I installed Lirc under a Ubuntu Dapper system with kernel 2.6.15