Controlling a digital cable/satellite box using Fedora, MythTV, an IR Blaster and one instance of LIRC
This site best viewed in FireFox

andymyth@gmail.com

Return to main site


Contents:
Section 1. Procedure
    -Step 1: Make sure you have all the necessary LIRC components installed
    -Step 2: Get the necessary config files for your cable/satellite box
    -Step 3: Setting up an alias for LIRC
    -Step 4: Making a shell script to handle channel changes
    -Step 5: Make /usr/local/bin/change_chan.sh executable
    -Step 6: Reboot your PC
    -Step 7: Test!
    -Step 8: Add your channel changing powers to MythTV
Section 2. Troubleshooting
Section 3. My Files
Section 4. Changelog

Section 1. Procedure


Below are the colors used to highlight information that you will need to enter as command line input, receive as command line output, or enter into a configuration or shell file. This will hopefully make it easier to distinguish between what different commands do in this guide.

Command line input .
Command line output .
Entry for a file .


**Note: I followed Jarod's guide when I set up MythTV. This LIRC guide is written with users who followed Jarod's guide in mind, though anyone running Fedora (and maybe other distros) should be able to use it too.

**Another Note: I am using the following:

  • Fedora Core 3
  • Kernel 2.6.10-1.741_FC3
  • MythTV v0.16 (not CVS)
  • LIRC v0.7.0
  • All of the above (except Fedora) were installed via apt. Additionally, just for reference, I am using the following hardware:

  • Hauppauge PVR-250
  • Radio Shack 15-2116 Universal Remote
  • AMD Athlon XP 2500+
  • Abit VA-10 motherboard (VIA chipset, using the onboard sound and NIC as well)
  • AOpen GeForce4 MX440
  • IR Blaster from http://www.irblaster.info

    Step 1: Make sure you have all the necessary LIRC components installed
    You will need the following 5 items installed:

  • lirc-devices-0.7.0-1
  • lirc-0.7.0-43
  • lirc-kmdl-[YOURKERNEL]
  • lirc-lib-0.7.0-43
  • lirc-lib-devel-0.7.0-43
  • (If you don't have any of the above installed...see near the bottom of this step about installing RPMs for what to do.)

    The versions listed above may have changed since the writing of this guide. Regardless, you will need the 5 packages listed there, whatever version they might be. If you followed Jarod's guide for the LIRC install (see here), you should already have 4 of them installed. If you have used Jarod's guide to do your LIRC install, or installed them from RPM's, you can see which LIRC components are already installed. To check which ones are installed, run the following command:

    $ rpm -qa lirc*

    This will give you a listing of what LIRC packages have been installed from RPMs. For me, I got the following output:

    lirc-devices-0.7.0-1.rhfc3.at
    lirc-0.7.0-43.rhfc3.at
    lirc-kmdl-2.6.10-1.741_FC3-0.7.0-43.rhfc3.at
    lirc-lib-0.7.0-43.rhfc3.at

    In my case, I have lirc-devices, lirc, the lirc kernel modules for my kernel, and lirc-lib. The one missing is lirc-lib-devel for my version of lirc. To get it, type

    # apt-get install lirc-lib-devel-0.7.0-43

    This installs the missing component, and now I'm ready to go. You will need to change the above to match your installed version of LIRC. You could also just type

    # apt-get install lirc-lib-devel
    and have it work, as apt-get should grab the right version. Just repeat the instructions above for any other parts of LIRC you are missing.

    After installing I can confirm everything is now there by typing

    $ rpm -qa lirc*
    again and seeing that I now have 5 things listed.

    lirc-devices-0.7.0-1.rhfc3.at
    lirc-0.7.0-43.rhfc3.at
    lirc-kmdl-2.6.10-1.741_FC3-0.7.0-43.rhfc3.at
    lirc-lib-0.7.0-43.rhfc3.at
    lirc-lib-devel-0.7.0-43.rhfc3.at

    If you have those 5 things listed, you can now proceed to Step 2.

    If you don't have any of the LIRC components installed (or are missing components other than the one I described), you can either use apt to get them, or download the necessary RPMs as follows (note, the versions may have changed. BE SURE TO GET THE KERNEL MODULES THAT MATCH YOUR KERNEL VERSION!!!!!).

    # rpm -Uvh http://download.atrpms.net/production/packages/fedora-3-i386/atrpms/lirc-0.7.0-43.rhfc3.at.i386.rpm
    # rpm -Uvh http://download.atrpms.net/production/packages/fedora-3-i386/atrpms/lirc-lib-0.7.0-43.rhfc3.at.i386.rpm
    # rpm -Uvh http://download.atrpms.net/production/packages/fedora-3-i386/atrpms/lirc-lib-devel-0.7.0-43.rhfc3.at.i386.rpm
    # rpm -Uvh http://download.atrpms.net/production/packages/fedora-3-i386/atrpms/lirc-devices-0.7.0-1.rhfc3.at.noarch.rpm
    # rpm -Uvh http://download.atrpms.net/production/packages/fedora-3-i386/atrpms/lirc-kmdl-2.6.9-1.681_FC3-0.7.0-43.rhfc3.at.i686.rpm

    Again, the versions and URL path will change depending on your version of LIRC. I would recommend checking http://atrpms.net for your distro under the LIRC section to see what versions of LIRC are available for download.

    ***An important note: if you decide not to use RPMs or apt to get the LIRC file and want to compile it yourself, make sure you use the "--with-driver=any" and "--with-transmitter" options.

    Example:
    ./configure --with-port=0x3f8 --with-irq=4 --with-transmitter --enable-sandboxed --with-driver=any

    Pete says, "That should build with ALL drivers and serial transmit enabled on com1. You should not have to build again even if you add a new device(unless of course it wasn't supported at the time of build)."

    Step 2: Get the necessary config files for your cable/satellite box

    You will need to get the necessary configuration file for your set top box. I have a Motorola DCT2000 box (It's actually a DCT 2554, but the DCT2000 config file will control any Motorola DCT2xxx box). To get the Motorola DCT2000 config file, run this command from your home directory (which for me is /home/mythtv):

    $ wget http://lirc.sourceforge.net/remotes/motorola/DCT2000

    IF YOU ARE NOT USING A MOTOROLA DCT2000 CABLE BOX:
    There are literally dozens of other config files already available. To find yours, go to http://lirc.sourceforge.net/remotes/ and look for a config file for your particular cable/satellite box. Then, simply replace "DCT2000" with whatever your file is called for all of the directions in this step. If the config file for your cable/satellite box isn't there, be sure to try the config files for other models within your brand. Often, companies making cable/satellite boxes only use one or two signaling protocols that will cover every model of box they have. Motorola is one example. Scientific Atlanta is another (The SA Explorer 8000 config will work with the SA Explorer 3200).

    Now, you have to add the contents of the DCT2000 file you just downloaded into your current /etc/lircd.conf file. There are multiple ways to do this, but for me, I'm still a person who likes to use the GUI for this type of stuff. So, I just fired up OpenOffice, opened the /home/mythtv/DCT2000 file and copied all of its contents. Then, I ran

    # vi /etc/lircd.conf

    I scrolled down to the bottom of the file, and hit Shift+Insert on the keyboard. This pasted all of the copied contents from /home/mythtv/DCT2000 into the bottom of /etc/lircd.conf. Thus, I now have configuration information for 2 "remotes" in my /etc/lircd.conf file (the top one is my RadioShack remote I use to control the Myth, the other is the DCT2000 info I use to control my cable box).

    While you're looking at the info for your remote that you just pasted, notice near the top of the info for your cable/satellite box what the remote name is. For example, you should see something like this:

    begin remote
    name DCT2000
    bits 16

    The part that says "name DCT2000" is what we're interested in. This name changes depending on what type of device you're trying to control, varying from config file to config file (though you could potentially rename it to whatever you like). For me, it was DCT2000. If you're using a DISH Network Receiver, it will probably say JVC_RAW. For now, just note this name, because we will need it later.

    Save the changes you made to /etc/lircd.conf and exit vi.

    Step 3: Setting up an alias for LIRC

    You will need to make changes to the files listed below. You can pretty much just copy/paste this stuff in. You will need to do the following as root user

    Make a copy of your /etc/rc.d/rc.local file as follows:

    # cp /etc/rc.d/rc.local /etc/rc.d/rc.local.sav

    This will insure that you have a backup of your rc.local just in case something goes wrong.

    Now open for editing /etc/rc.d/rc.local as follows:

    # vi /etc/rc.d/rc.local

    Add the following lines of information near the top.

    /sbin/modprobe lirc_i2c
    /sbin/modprobe lirc_serial
    /usr/sbin/lircd --device=/dev/lirc0 --output=/dev/lircd
    /usr/sbin/lircd --driver=default --device=/dev/lirc1 --output=/dev/lircd1 --pidfile=/var/run/lircd1.pid

    If there is a line already in there saying something like "touch /var/lock/subsys/local", put the above commands below that line.

    After you have added that information, save the file and exit vi.

    This next part might be the trickiest. If you followed Jarod's guide, you have probably already made some changes to your /etc/modprobe.conf file. We are going to have to edit some of these, so just to be safe, make a backup of your modprobe.conf (just in case). You can do so as follows:

    # cp /etc/modprobe.conf /etc/modprobe.conf.sav

    Now open for editing /etc/modprobe.conf as follows:

    # vi /etc/modprobe.conf

    If you followed Jarod's guide, somewhere near the top of this file you should have a line reading one of the following:

    For the PVR-x50:
    alias char-major-61 lirc_i2c

    For the AverMedia M179 or bttv/Brooktree card:
    alias char-major-61 lirc_gpio

    You will either need to comment this line out (you can do that by putting a "#" at the beginning of it), or just delete it (remember that we have your original one backed up). If you have a PVR-x50, you will also need to comment out or delete the line reading

    install lirc_i2c /sbin/modprobe ivtv; /sbin/modprobe --ignore-install lirc_i2c

    Jarod's guide has you put in both of those, but you won't need them for this guide (or at least I didn't). If, after you do the remaining steps your remote control won't control the mythbox (I'm just talking about being able to navigate MythTV, not change the cable/satellite box), then you may need to re-add that last line we just commented out. If nothing else, restore the modprobe.conf.sav file and make sure that LIRC was working for you to being with.

    After you have commented out/deleted the lines mentioned above, you will need to add the following lines to your /etc/modprobe.conf file. I added mine near the top right below where it said "alias eth0 via-rhine" and right above the lines for my sound card. Your modprobe.conf file might say something a little different, but just put it close to the top of the file and you should be fine. These lines will differ depending on if your IR Blaster is on COM1 or COM2 (for me, it was COM2 because my IR receiver for my PVR-250 was on COM1.) You may have to try both just to see which one works for your IR Blaster (you can also set the IRQ for the serial port on some motherboards so there will be no question).

    For COM1, copy/paste the following into /etc/modprobe.conf near the top:

    alias char-major-61-0 lirc_i2c
    alias char-major-61-1 lirc_serial
    options lirc_serial irq=4 io=0x3f8
    ####IR setup####
    install lirc_i2c /sbin/modprobe ivtv; /sbin/modprobe --ignore-install lirc_i2c
    install lirc_serial setserial /dev/ttyS0 uart none; /sbin/modprobe --ignore-install lirc_serial

    For COM2, copy/paste the following into /etc/modprobe.conf near the top:

    alias char-major-61-0 lirc_i2c
    alias char-major-61-1 lirc_serial
    options lirc_serial irq=3 io=0x2f8
    ####IR setup####
    install lirc_i2c /sbin/modprobe ivtv; /sbin/modprobe --ignore-install lirc_i2c
    install lirc_serial setserial /dev/ttyS1 uart none; /sbin/modprobe --ignore-install lirc_serial

    ***IMPORTANT NOTE*** If you use an Avermedia M179 or bttv/Brooktree card, replace the line that says "alias char-major-61-0 lirc_i2c" with "alias char-major-61-0 lirc_gpio" (minus the quote marks). You should also exclude the line that begins with "install lirc_i2c" (it's the second one from the bottom).

    Now save your /etc/modprobe.conf file and exit out of vi.

    ------------Begin brief discussion about commands above (you can skip this if you want)-------------------------
    First, in your /etc/modprobe.conf file, you can alias as many devices as you wish. The example files above list only two (lirc_i2c and lirc_serial), but by incrementing the number in the "alias-char-major-61" statement, you can add other LIRC components. So, you could add "alias-char-major-61-2 lirc_gpio" to the file above to load the LIRC module to run an Avermedia remote.

    Second, in your /etc/rc.d/rc.local file, examine the last line we added. Notice where it says "--output=/dev/lircd1". This is the name of the device that will need to be referenced whenever you send an IR signal via LIRC's irsend module. It might seem a little complicated. Basically, "/dev/lirc0" or "/dev/lirc1" is what the actual device name is (if you had other devices, they would be called "/dev/lirc2" "/dev/lirc3" and so on). For the IR Blaster, you are sending output to that device called "/dev/lircd1", which is what you specified in the "--output" option. As Pete says, "it's confusing, but that's how it works". I will point this out again a little later when we make a script to change the channels.

    Third, if you decide to add more than two devices, also be sure to change the pid in /etc/rc.d/rc.local as appropriate.
    For example, if you added "--device=/dev/lirc2" you'd need to specify "--pidfile=/var/run/lircd2.pid",
    and for "--device=/dev/lirc3" you'd need "--pidfile=/var/run/lircd3.pid", and so on.

    You'd end up with something like: /usr/sbin/lircd --driver=default --device=/dev/lirc2 --output=/dev/lircd2 --pidfile=/var/run/lircd2.pid
    ------------End brief discussion-----------------------------------------------------------------------------------------

    Step 4: Making a shell script to handle channel changes

    There are lots of ways you can make scripts to handle this. There are example scripts you can use at the losdos.dyndns.org site and at the iwamble.net site. You might check those if you need something more tricky. For me though, the one below works great. It will accept 3 numbers (or less, or more), and then input the "Enter" key as well. Please read the comments discussed below this script, as they are quite important to get it running.

    Type the following:

    # vi /usr/local/bin/change_chan.sh

    This will open up a new sh script in "/usr/local/bin" that's called "change_chan.sh". You will point MythTV towards this later when setting it up to change your channels.

    Copy and paste the following into your /usr/local/bin/change_chan.sh file:

    #!/bin/sh
    REMOTE_NAME=DCT2000
    for digit in $(echo $1 | sed -e 's/./& /g'); do
    irsend --device=/dev/lircd1 SEND_ONCE $REMOTE_NAME $digit
    sleep 0.4 # note, you may have to tweak the interdigit delay up a bit
    done
    irsend --device=/dev/lircd1 SEND_ONCE $REMOTE_NAME OK

    There are several important parts that might need to be changed depending on your cable/satellite box.

  • The part that says "REMOTE_NAME=DCT2000" will need to be changed to your particular cable box. Remember at the end of Step 2 when I told you to note the name of the second "remote" in your /etc/lircd.conf file? (JVC_RAW was the other one mentioned). You will need to change "REMOTE_NAME=DCT2000" to whatever your remote name is. So, if it were JVC_RAW, you would have "REMOTE_NAME=JVC_RAW" (minus the quote marks).

  • Notice that in the fourth line, irsend is sending the signal to the device specified by the "--output" option that was specified in your /etc/rc.d/rc.local file (which, in this case is /dev/lircd1). See the brief discussion at the bottom of Step 3 for further explanation on this.

  • The line that begins with "sleep 0.4" can be altered. Right now, this puts a 0.4 second delay between transmitting each key to the cable box. This may need to be raised if you find too many keystrokes are getting dropped. For DISH Receivers though, you can maybe go as low as 0.2. However, 0.4 is pretty reliable for Motorola Cable boxes. Play with this to find what works best for you.

  • For the last line, I have my IR Blaster send an "OK" keypress to my cable box. The "OK" may be different for your remote. For example, for DISH Receivers, instead of saying "OK" at the end, it would say "select" (again, all this is minus the quotes). To find out for sure what yours would be, you'll have to open up your /etc/lircd.conf file and see what your "OK" or "select" or "enter" key is called within that file, and then change the "OK" in this sh script to whatever is appropriate. Additionally, you can delete the last line entirely, as it isn't really necessary. But, having it there sends a command to your cable/satellite box telling it to change channels right now, so it's a handy line to have as it speeds up channel changing.

    As an example, a DISH receiver would have the following for the last line:

    irsend --device=/dev/lircd1 SEND_ONCE $REMOTE_NAME select

    After you have configured your /usr/local/bin/change_chan.sh file as specified above, save it and exit vi.

    Step 5: Make /usr/local/bin/change_chan.sh executable

    This is a seemingly trivial yet amazingly important step. If your script isn't executable, it will probably (definitely) not run. To make it executable, type the following (and make sure you're root user when you do it):

    # chmod 755 /usr/local/bin/change_chan.sh

    You can verify it is now executable by typing:

    # ls -sl /usr/local/bin/change_chan.sh

    You should get something like the following as output:

    4 -rwxr-xr-x 1 root root 266 Jan 18 17:56 /usr/local/bin/change_chan.sh

    You should see 3 "x's" in that part with the -'s, r's, w's, and x's (it shows you the file permissions).

    Step 6: Reboot your PC

    Do this just to be safe and to make sure that everything we've changed gets loaded. I struggled thinking my setup had failed until I rebooted, then it worked fine. Duh! At this point, make sure you have your IR Blaster hooked up to your PC and the transmitter end of the IR Blaster on your cable/satellite box over the cable/satellite box's IR receiver eye.

    Since some of you just hate to reboot, you can try the commands below. However, a reboot is the most sure-fire way to ensure that everything is loaded properly. Don't make me say "I told you so."

    # depmod -a
    # /sbin/modprobe lirc_i2c
    # /sbin/modprobe lirc_serial
    # /usr/sbin/lircd --device=/dev/lirc0 --output=/dev/lircd
    # /usr/sbin/lircd --driver=default --device=/dev/lirc1 --output=/dev/lircd1 --pidfile=/var/run/lircd1.pid

    The above would be different for users of Avermedia/bttv/Brooktree cards. I'm not sure of the exact syntax, so please just reboot it and save yourself the hassles.

    Step 7: Test!

    After your PC reboots, first make sure your remote is still working. Do this by typing:

    $ /usr/bin/irw

    Point your remote at your IR receiver, and you should see stuff appearing in the console. If not, you may have broken LIRC. Restore your /etc/modprobe.conf.sav file and try again to see if you made errors or typos anywhere. If I made an error, let me know.

    Presuming the remote works, let's test your IR Blaster. To do that, you'll pass an argument to your change_chan.sh script. Try changing it to channel 12. To do so, type

    $ /usr/local/bin/change_chan.sh 12

    Your cable/satellite box should change to that channel. You can pass any number as an argument if you want to try further testing. But, if it changed channels, you've got it working.

    If your cable/satellite box did not change channels, see the troubleshooting section and try some of the suggestions listed there.

    Be sure to note any output errors that are displaying in the console whenever you run the script. You may try restoring your /etc/rc.d/rc.local.sav and /etc/modprobe.conf.sav files, rebooting and starting from scratch now that you have had a run at doing it. Things are often easier (and work right) the second time.

    Step 8: Add your channel changing powers to MythTV

    MythTV will automagically handle the channel changing on your cable box for you, as long as it knows where the channel changing script you created is located. To let it know, run mythtvsetup as follows:

    $ mythtvsetup

    Say No to clearing capture card or channel info.

    Under "Input Connections," look for the part called "External Channel Change Command." Navigate to this, and enter "/usr/local/bin/change_chan.sh" (without the quotation marks). Be sure to hit the "Finish" button (if you just Esc out, it won't save). After that's done, exit mythtvsetup, kill mythfrontend (if it's running) and restart mythbackend. Or, just reboot the PC (again, it's the easiest way to make sure everything goes down and comes back up again. Now, whenever you change channels in Myth, it should change your cable/satellite box for you.

    I know this looks long, but, for Fedora at least, I can almost guarantee it's easier than compiling a second instance of LIRC. Please feel free to contact me at the address listed up top or the mythtv-users mailing list [mythtv-users !at! mythtv.org] with any questions.

    Section 2. Troubleshooting

    Due to length, the Troubleshooting Section has been moved to its own seperate page.

    Main troubleshooting page

    Section 3. My Files

    Here are the links to the files that I used in my setup. Since they are specific to my particular hardware, you probably can't use them verbatim, but they should give you a pretty good idea of how the setup looks.

    /etc/lircd.conf
    /etc/rc.d/rc.local
    /etc/modprobe.conf
    /usr/local/bin/change_chan.sh

    Section 4. Changelog

    v1.0.2 (03/01/05)
    -Corrected link pointing to an old version of Jarod's site
    -Changed up the color table a bit

    Older changelog entries can be found here



    v1.0.2
    Updated 03/01/2005

    Return to main site



    Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'eggshell'@'localhost' (using password: NO) in /home/eggshell/public_html/lirc/blaster/index.php on line 754

    Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in /home/eggshell/public_html/lirc/blaster/index.php on line 754

    Warning: mysql_query() [function.mysql-query]: Access denied for user 'eggshell'@'localhost' (using password: NO) in /home/eggshell/public_html/lirc/blaster/index.php on line 757

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/eggshell/public_html/lirc/blaster/index.php on line 757

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/eggshell/public_html/lirc/blaster/index.php on line 758

    Warning: mysql_query() [function.mysql-query]: Access denied for user 'eggshell'@'localhost' (using password: NO) in /home/eggshell/public_html/lirc/blaster/index.php on line 787

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/eggshell/public_html/lirc/blaster/index.php on line 787

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/eggshell/public_html/lirc/blaster/index.php on line 788
    Number of unique hits to www.lircsetup.com since Feb 20, 2005: 0
    Number of hits to this page since Feb 20, 2005: 0

    L10 Web Stats Reporter 3.15 LevelTen Hit Counter - Free PHP Web Analytics Script
    LevelTen dallas web development firm - website design, flash, graphics & marketing