[mythtv-users] HOWTO: Using an IR Blaster with MythTV

Robert W2 rwraithr at cox.net
Fri Nov 21 16:57:06 EST 2003


The Long and Hopefully Definitive IR BLASTER HOWTO for LIRC / MYTHTV

By Robert Wamble (rwraithr at cox.net)
0311.21 11:43 v1.0

Download link:  http://members.cox.net/rwraithr

The mission was to get MythTV to use my Actisys IR-200L blaster to change
channels on my Scientific Atlanta Explorer 2000.  Since MythTV uses lirc
for its remote control, and lirc hasn't (for me) easily handled two devices
simultaneously, I had to get an independent lirc running to drive the
blaster.  To do this, I followed the recommendations found in mythtv-users
postings by Sriram Balakrishnan, Gary Te Young, and Mike Smith.

This HOWTO and accompanying scripts comprise my attempt to steamline the
process for others.  While I can only say that this works for my setup,
hopefully it will be helpful with other hardware combinations.

I have MythTV built on a RedHat 9 box, using MythTV's native lirc support
with a Hauppauge PVR 350.  As stated, my IR Blaster is the Actisys IR-200L,
and I got it from http://store.snapstream.com/index.html under Cable Packs.


Summary of sections:

1.  Get lirc-0.7.0pre2.tar.bz2
2.  Use lirc2remote.sh to convert to remote-0.7.0pre2
3.  Configure and build remote-0.7.0pre2
4.  Edit /etc/modules.conf
5.  Edit /etc/rc.d/rc.local
6.  Install /etc/remoted.conf for your tuner box
7.  Check BIOS settings for serial port
8.  Boot and test
9.  Related Scripts (change_channel.csh, channel.pl, lirc2remote.sh)

Installation:

1.  Get lirc-0.7.0pre2.tar.bz2.  Follow the instructions in Section 22.2
"Hauppauge PVR-250 remote and MythTV's native LIRC support" in the MythTV
Documentation.  In essence, do:

wget http://lirc.sourceforge.net/software/snapshots/lirc-0.7.0pre2.tar.bz2

Extract it with:

tar xjf lirc-0.7.0pre2.tar.bz2


2.  Use lirc2remote.sh to convert lirc-0.7.0pre2 to remote-0.7.0pre2.  This
step renames the directories, files, and variables in the files that have
"lirc" to "remote", changes the device major number from 61 to 72, and changes
the port from 8765 to 8768.   It's still lirc, it'll just be able to run along
side the standard lirc.

Put lirc2remote.sh in the current directory.  The lirc-0.7.0pre2 directory
should be in the current directory, too.

The script will move the lirc-0.7.0pre2 dir to remote-0.7.0pre2, rename the
lirc* dirs to remote*, rename the lirc* files to remote*, then change all
occurrences of "lirc" and "LIRC" to "remote" and "REMOTE".  

The script will then open vi on each file, one at a time, that you need to
MANUALLY check for and change each occurrence of the device major number
from 61 to 72.  Use /61 to search for 61, change it to 72, hit n to go to the
next occurrence of 61, etc.  When done, use :wq to write and quit that file
to go to the next.  Note that you're only changing the 61 for the device major
number, ie. char-major 61.  Some of them don't refer to the device major
number, so leave those at 61.  You can :q past the remote control
configuration scripts toward the end.  Don't change lines that have hex,
ie. 0x61 doesn't refer to the device major number.

Then you'll do the same thing to change port 8765 to 8768.  After than, it'll
fix some permissions and run mknod for the /dev/remote device.


As root, run the script:

./lirc2remote.sh


3.  Setup, configure, and build remote-0.7.0pre2:

The build requirements are the same as the normal lirc package.  Do the
following:

cd remote-0.7.0pre2
./setup.sh

Select 1 Driver configuration
Select 6 IrDA hardware
Select 4 Actisys Act200L SIR driver support     (in my case)
Select 2 COM2 (0x2f8, 3)         (in my case)
Select 3 Save configuration & run configure

After configure finishes, run make, but not make install yet.  Make
appears to run through configure again to find aclocal, autoconf, etc.
Just let it run, and it'll do the build.

Before you make install, note that the tools will overwrite the normal lirc
tools.  You should do the following, as root, to keep both versions:

cd /usr/local/bin
mkdir orig
cp ircat irexec irpty irrecord irsend irw irxevent mode2 xmode2 orig

cd -  (back to the remote-0.7.0pre2 directory)
make install
cd -  (back to /usr/local/bin)

mv ircat remote_ircat
mv irexec remote_irexec
mv irpty remote_irpty
mv irrecord remote_irrecord
mv irsend remote_irsend
mv irw remote_irw
mv irxevent remote_irxevent
mv mode2 remote_mode2
mv xmode2 remote_xmode2

mv orig/* .
rmdir orig


4.  Edit /etc/modules.conf.  Add the following:

alias char-major-72 remote_sir
below remote_sir remote_dev
options remote_sir irq=3 io=0x2f8

Your options may be different.  My blaster is on COM2, irq=3, io=0x2f8

Also in /etc/modules.conf, add the following to the top:

path[toplevel]=/lib/modules/`uname -r`/misc


5.  Edit /etc/rc.d/rc.local for auto-starting the daemon:

Add to rc.local:

echo "Starting remoted..."
setserial /dev/ttyS1 uart none
/sbin/modprobe remote_sir
/usr/local/sbin/remoted


6.  Put in the receiving device's config file.  Check http://www.lirc.org/
for remotes.tar.bz2.  I found my Cox box in remotes/scientific_atlanta, the
Explorer_2000 file.  I just copied that file to /etc/remoted.conf.


7.  Check BIOS setting for your serial port.  On my box, I had to use COM2,
and I had to have it set to NORMAL, *not* IrDA or ASKIR.


8.  Boot and test.  The change_channel.csh and channel.pl scripts are below.
Put them in /usr/local/bin, and don't forget to chmod +x both of them.

Note that the command to change the channel in channel.pl is remote_irsend.

You can use  remote_irrecord --device=/dev/remote filename  just to see if the
blaster is receiving signals from the remote it's supposed to know how to act
like.  I saw dots while hitting buttons, but it didn't detect something it
needed, so it didn't actually create a file.  I didn't need a file, since my
Explorer 2000 is in the remotes database.

If it's working, you should be able to aim the blaster at the tuner and type
change_channel.csh 13 and it'll send 1 and 3 to your tuner.  Then you can
set up MythTV to use change_channel.csh as the external channel changing
command.  It was quite a joy when I finally saw it happen for the first
time.  Mine works from five feet away, though I won't need it that far back.

Well, hopefully this Howto and script come in handy to users of IR Blasters
and MythTV.  Feel free to email me questions, corrections, or comments at
rwraithr at cox.net.


9. Related Scripts:

The change_channel.csh script (set MythTV to use this script):

----cut below this line for change_channel.csh, don't include this line----
#!/bin/csh
echo "changing to $1"
/usr/local/bin/channel.pl $1 &
----cut above this line for change_channel.csh, don't include this line----





The channel.pl script (edit your $remote_name):

----cut below this line for channel.pl, don't include this line----
#!/usr/bin/perl

# make sure to set this string to
# the corresponding remote in /etc/lircd.conf
$remote_name = "SA2000";

sub change_channel {
        my($channel_digit) = @_;
        system ("remote_irsend SEND_ONCE $remote_name $channel_digit");
        sleep 1;
}

$channel=$ARGV[0];
sleep 1;
if (length($channel) > 2) {
        change_channel(substr($channel,0,1));
        change_channel(substr($channel,1,1));
        change_channel(substr($channel,2,1));
} elsif (length($channel) > 1) {
        change_channel(substr($channel,0,1));
        change_channel(substr($channel,1,1));
} else {
        change_channel(substr($channel,0,1));
}
system ("remote_irsend SEND_ONCE $remote_name SELECT");
----cut above this line for channel.pl, don't include this line----




The Main Script:   lirc2remote.sh

----cut below this line for lirc2remote.sh, don't include this line----
#!/bin/bash
#
# lirc2remote.sh -- Convert lirc dirs/files/vars to remote for IR Blaster.
# version 1.0
# 11/21/2003  No rights reserved.  Deploy and use as desired.  YMMV.
#
# Download link:  http://members.cox.net/rwraithr
#
# The idea is to run an independent version of lirc to handle the IR
# Blaster, so that conflicts with the lirc running for MythTV are avoided.
#
# This script and Howto created by Robert Wamble (rwraithr at cox.net) because
# I just had to get my Actisys IR Blaster working with MythTV and
# my Cox Cable issued Scientific Atlanta Explorer 2000 digital tuner.
#
# Special thanks to Sriram Balakrishnan, Gary Te Young, and Mike Smith
# whose mythtv-users list inputs on the subject pointed me in the right
# direction and provided valuable information.
 

# Rename main lirc dir

echo ""
echo "Moving main dir"

if [ ! -d lirc-0.7.0pre2 ] ; then
	echo ""
	echo "lirc-0.7.0pre2 not found"
	exit
fi

if [ -d lirc-0.7.0pre2 ] ; then
	mv lirc-0.7.0pre2 remote-0.7.0pre2
fi


# Rename the lirc directories

echo ""
echo "Moving lirc directories"

mv remote-0.7.0pre2/drivers/lirc_atiusb remote-0.7.0pre2/drivers/remote_atiusb
mv remote-0.7.0pre2/drivers/lirc_bt829 remote-0.7.0pre2/drivers/remote_bt829
mv remote-0.7.0pre2/drivers/lirc_dev remote-0.7.0pre2/drivers/remote_dev
mv remote-0.7.0pre2/drivers/lirc_gpio remote-0.7.0pre2/drivers/remote_gpio
mv remote-0.7.0pre2/drivers/lirc_i2c remote-0.7.0pre2/drivers/remote_i2c
mv remote-0.7.0pre2/drivers/lirc_it87 remote-0.7.0pre2/drivers/remote_it87
mv remote-0.7.0pre2/drivers/lirc_parallel remote-0.7.0pre2/drivers/remote_parallel
mv remote-0.7.0pre2/drivers/lirc_serial remote-0.7.0pre2/drivers/remote_serial
mv remote-0.7.0pre2/drivers/lirc_sir remote-0.7.0pre2/drivers/remote_sir


# Rename the lirc files

echo ""
echo "Moving lirc files"

find remote-0.7.0pre2 -name '*lirc*' -print > lircfiles.txt

for i in `cat lircfiles.txt`
do
	if [ -f $i ] ; then
		NewFileName=`echo $i | sed 's/lirc/remote/'`
		mv $i $NewFileName
	fi
done


# Rename lirc occurrences in the files

echo ""
echo "Renaming lirc vars in files"

find remote-0.7.0pre2 | xargs grep -l lirc > lircvars.txt

for i in `cat lircvars.txt`
do
	if [ -f $i ] ; then
		cat $i | sed 's/lirc/remote/g' > $i.newfile
		mv $i.newfile $i
	fi
done


# Rename LIRC occurrences in the files

echo ""
echo "Renaming LIRC vars in files"

find remote-0.7.0pre2 | xargs grep -l LIRC > LIRCvars.txt

for i in `cat LIRCvars.txt`
do
	if [ -f $i ] ; then
		cat $i | sed 's/LIRC/REMOTE/g' > $i.newfile
		mv $i.newfile $i
	fi
done


# Check for device number 61, manually change to 72.  Then :wq the file to
# check the following file.

echo ""
echo "Manually change device number 61 to 72, then :wq for next file."
echo "Note that not every 61 refers to the device number."
echo "You can :q to skip the remote control config files."
echo "Use /61 to search for 61, and hit n for next occurrence."
echo "(15 second pause)"

sleep 15

find remote-0.7.0pre2 | xargs grep -l 61 > device61.txt

for i in `cat device61.txt`
do
	vi $i
done


# Check for port number 8765, manually change to 8768.  Then :wq the file to
# check the following file.

echo ""
echo "Manually change port number 8765 to 8768, then :wq for next file."
echo "Use /8765 to search for 8765, and hit n for next occurrence."
echo "(15 second pause)"

sleep 15

find remote-0.7.0pre2 | xargs grep -l 8765 > port8765.txt

for i in `cat port8765.txt`
do
	vi $i
done


# Restore exec permissions

echo ""
echo "Restoring exec permissions"

chmod +x remote-0.7.0pre2/configure remote-0.7.0pre2/*.sh


# Make the remote device

echo ""
echo "Mknod remote device /dev/remote"

/bin/mknod /dev/remote c 72 0

echo ""
echo "Conversion done.  Refer to the Howto for build, install, and"
echo "configuration."
echo ""
----cut above this line for lirc2remote.sh, don't include this line----



More information about the mythtv-users mailing list