Using an IR Blaster with MythTV
- 1 Introduction
- 2 Hardware
- 3 Installing the IR Blaster
- 4 Configuring Myth Backend
- 5 MyBlaster setup -- does not require LIRC
- 6 Using a USB IR Toy
- 7 LIRC settings for the USB Toy
- 8 Troubleshooting
- 9 Monitoring STB Status
- 10 IR Blaster Vendors
- 11 HOWTOs
The mission: Get MythTV to change channels on my cable provided STB (set-top box). I connected a coax cable from the STB to my capture card, but with STBs one cannot tune/change stations using the tuner built into the capture card. The capture card should remain on channel 3, and I need an infrared emitter to send signals to my set-top box when Myth needs to change channels.
N.B. In the UK you can control your Sky or Sky+ box and some of the AUS Foxtel IQ boxes using a Dusky Control
You can build your own serial port IR emitter very inexpensively or you can buy one.
- irblaster.info - $12 - $15 - inexpensive serial IR blaster similar to what you might build yourself. You stick it with included double sided tape right to the STB pointing at the STB's IR reciever. Also has FTDI based USB IR blaster. See FTDI USB IR Blaster / Transmitter using LIRC for setup.
- Microsoft MCE USB remote combo - A usb remote and blaster combo. Works very well.
- CommandIR Mini - A hardware-based USB transceiver supporting multiple IR blasters or "emitters". Can simultaneously control set top boxes and receive remote control commands. Provides a free online MythTV support Mythtv.
- See the bottom for a growing list of vendors
Installing the IR Blaster
This is the serial IR blaster from irblaster.info
Use the links at the bottom of this page for detailed instructions. You will plug one end of the IR Blaster into a serial port on the Myth backend, and the other side with the diode is pointed at the STB. Normally you put it right over the STB's IR eye as pictured below from Geoff Holden's blog. (URL gives 404 Page not found).
You have to load lirc_serial at boot. There are instructions in the HOWto links. The way I do it on Fedora is to edit modprobe.conf. Since you likely also have an IR receiver, such as on the Hauppauge cards, you need two lirc modules loaded, the lirc_i2c module for the IR receiver, and lirc_serial for the IR emitter. Again please see the details instructions in the links above.
Once the modules are loaded, you run two instances of the lirc daemon lircd. One instance uses device /dev/lircd0 and the other /dev/lircd1.
Configuring Myth Backend
Instructions in the HOWTO links show you how to make a channel change script. You need to use MythTV setup to tell Myth to use the script to change channels.
Run the mythtvsetup by opening an X window console and typeing mythtvsetup.
Once you have defined your input connection, select it and find the following setup page:
You will enter the command for changing channels here. Note the box "Preset Tuner to channel" which says 3. This is important, just as your TV has to be set to channel 3 to recieve signals from the STB, so does your PVR card. Furthermore, I found that this did not work. In order to actually tune my PVR-250 to channel 3 I used this command in my rc.local, which runs after startup:
ivtv-tune -c 3 -d /dev/video1
to change the PVR 250 to channel 3.
MyBlaster setup -- does not require LIRC
If you prefer not to have to mess around with LIRC there are alternatives. One of these is the MyBlaster serial. (See the vendor list below.) It is a commercial product but the linux drivers are GPL. The latest driver can be found on SourceForge. To set up, simply edit the perl based driver script for your port and device and call the script using the external channel change script configuration option in mythtv-setup. It is that easy.
Using a USB IR Toy
Update firmware in IRToy to v24 (even if you purchase a new one there is no easy way to check the installed firmware. I purchased one 18 months after it was released and firmware was v12)
Based on instructions from here
To compile the bootloader application (libusb-dev is required)
apt-get install libusb-dev build-tools
Create new dir to store our updated code
mkdir usbtoy_update cd usbtoy_update
Get the actual firmware file
Download USBIRToyv24.zip from here: http://dangerousprototypes.com/forum/viewtopic.php?f=29&t=7457&p=62279&hilit=lirc#p62279
Get the firmware updater
wget http://jesshaas.com/software/IRToy-fw_update.tar.gz tar xf IRToy-fw_update.tar.gz cd IRToy-fw_update LIBS=-lusb ./configure make
Activate the bootloader
Place a jumper (any piece of wire, e.g. paperclip) between the PGC and PGD pins, and then plug in the IR Toy.
The indicator LED will light when the bootloader is active.
Execute the update
sudo ./fw_update -e -w -v -m all -vid 0x04D8 -pid 0xFD0B -ix ../USBIRToyv24.hex
LIRC settings for the USB Toy
You need to install lirc-0.9.3a (or later). It includes support for the IR Toy.
Review this mythtv wiki page for LIRC
Create the file /usr/local/etc/lirc/lirc_options.conf
# These are the default options to lircd, if installed as # /etc/lirc/lirc_options.conf. See the lircd(8) and lircmd(8) # manpages for info on the different options. [lircd] nodaemon = False driver = irtoy device = /dev/ttyACM0 output = /var/run/lircd pidfile = /var/run/lircd.pid plugindir = /usr/local/lib/lirc/plugins permission = 666 allow-simulate = No repeat-max = 600 #effective-user = #listen = [address:]port #connect = host[:port] #debug = 6 debug = 6 #uinput = ... #release = ... #logfile = ... [lircmd] uinput = False nodaemon = False [modprobe] #modules = [lircd_dev, lirc_sir...]
Install Remote config file
Copy your config file to the directory /etc/lirc
This example uses cisco_hda_rf2_2.conf
Manually start lircd for testing
root@ubuntu:# lircd --nodaemon --device /dev/ttyACM0 --driver irtoy lircd-0.9.3a: Warning: Running as root lircd-0.9.3a: Info: Using remote: cisco_hda_rf2_2. lircd-0.9.3a: Notice: lircd(irtoy) ready, using /var/run/lircd
Test if it is working
After you run irw press keys on your remote, you should see output
root@ubuntu:/etc/lirc# /usr/local/bin/irw /var/run/lircd 0000000000373119 00 KEY_0 cisco_hda_rf2_2 0000000000373119 01 KEY_0 cisco_hda_rf2_2 0000000000373119 02 KEY_0 cisco_hda_rf2_2 000000000037d105 00 KEY_8 cisco_hda_rf2_2 000000000037d105 01 KEY_8 cisco_hda_rf2_2 000000000037910d 00 KEY_4 cisco_hda_rf2_2 000000000037111d 00 KEY_2 cisco_hda_rf2_2
Test if blasting works
irsend -d /var/run/lircd SEND_ONCE cisco_hda_rf2_2 key_dta
Where "cisco_hda_rf2_2" is the name of your remote file and "dta" is the power on button.
You should see your device power on
Note that MythTV sends frequency IDs to the external channel changer script and not the channel number. If you see some weird four/five digit numbers being sent through the IR blaster, you will need to go to the channel editor in setup and change the freqid for the channels to match the ones that you expect to receive through the IR blaster.
When using the script and setup at http://losdos.dyndns.org:8080/public/mythtv-info/IR-BLASTER-HOWTO.html (link times out).
- do not* be tempted to change the configure options to set COM1/IRQ4 in the pre-make configuration. Rather, follow the directions and pass those options through /etc/modules.conf or /etc/modprobe.d/aliases.
Changing the settings at the earlier stage will produce a module that conflicts with the standard lirc (and a frustrating string of errors in dmesg: ledxmit_dev: register_chrdev failed ledxmit_serial: Unknown symbol ledxmit_register_plugin).
Monitoring STB Status
As STBs are external devices, it is sometimes difficult to monitor their power state, depending on the make/model of the STB.
Refer to this page for help to setup a STB monitoring script. For best results, make your channel changer script first call this, so that it gets unhindered read access to your ivtv device.
IR Blaster Vendors
In the USA
- IRblaster offer serial port IR blasters, as do:
- IguanaWorks sells long range serial IR blaster & receiver. Also sells Linux-compatible USB IR Transceivers
- USB Infrared Toy USA, Germany and Europe stores. Works with LIRC 0.9.3a. Receives and sends IR signals.
- CommandIR Mini is a hardware-based USB multi-blaster supporting independent control of multiple devices via "emitters". Device receives & blasts simultaneously and they ship globally.
- Dvbshop.net sell IR remotes, receivers & blasters
- IRtrans sell IR transceivers (combined receiver/blaster) & LAN equipped units too
- DuskyControl This is a USB device which connects to the RF2 port on your Sky or Sky+ box. There is a version with dual outputs to allow control of two boxes.