Configuring multiple serial IR Blasters

Author(s)

Bill Giannikos (bill2 at giannikos.com.au)

Introduction

This guide is to help you run two ir blasters from the same system. This is useful when you have two or more Foxtel (or similar) set top boxes connect to your mythtv system. You may first like to read the Configuring Lirc for Foxtel and Building a IR Blaster guides. This guide assumes that both have already been done and lirc is currently working with one serial ir blaster.

Here we will cover running just two IR blasters but the process of adding more is the same.

Guide

As standard, Lirc is only able to control one serial port. If you would like to use two or more ports for your IR blaster you will need to modify the Lirc source code to achieve this. Unfortunately you will need to do some compiling to get this working.

I made things (relatively) simple for you guys by preparing a patch which applies against lirc 0.8.1. You can download it here. What this patch does is rename all occurrences of lirc_serial in the code to lirc_serial2 and renames the lirc_serial folder and the lirc_serial/lirc_serial.c file to lirc_serial2 and lirc_serial2/lirc_serial2.c respectively. You can apply the patch by typing:

patch -p1 < lirc.patch

You can then compile lirc with:

./configure
(configure lirc to the settings of your second serial port)
cd drivers
make
make install

Notice the 'cd drivers' line which causes lirc to only compile and install the serial drivers, not the extra tools. These tools should have already been installed by the previous lirc installation (for the first serial port).

You should now have a new module called lirc_serial2. You will now need to ensure this module is loaded on startup of your system. This varies depending on your Linux distribution. Under Fedora, I put these lines in /etc/rc.modules:

setserial /dev/ttyS1 uart none
mknod /dev/lirc2 c 61 1
cp -a /dev/lircd /dev/lircd2
modprobe lirc-serial2

Notice that my second serial port is called ttyS1. This may not always be the case if you use a add-in PCI card so check in 'dmesg' first.

Next, we need to run a second instance of the lircd daemon. This can be done with the following command.

/usr/sbin/lircd –driver=default –device=/dev/lirc2 –output=/dev/lircd2 –pidfile=/var/run/lircd2.pid –listen=8766

Of course, this also needs to be run on every system start, so I added the command into my /etc/init.d/lircd file just under the command for the first daemon.

Finally you will need to tell the 'irsend' command to use the second lircd daemon rather than the first. To do this you need to add –device=/dev/lircd2 to the command line. In my scripts it will look like:

irsend –device=/dev/lircd2 SEND_ONCE sky 1

Like my script for the Configuring Lirc for Foxtel guide, I have attached scripts which you can use for the second IR blaster. Download the changechannel2 and changefoxtel2 files. Copy these files into your /usr/local/bin folder and use the '/usr/local/bin/changefoxtel2' command in mythtv (as in the previous guide).

And that will just about do it. Not the easiest thing in the world to setup, but once working it works reliably.

Notes and Tips

USB to Serial Converters do not work, you need to use the onboard serial ports or a PCI add-in card.

You can use PCI cards with two or more serial ports. Unfortunately these cards will likely assign the same IRQ to both ports which causes lirc to crash when both serial ports are activated at the same time. It is best to avoid this situations but if you must use both serial ports on such a card you will need to write come extra code which ensures both IR blasters are not triggered at the same time.

There are some guides explaining how to control 2 STUs with the one serial port. These guides wont work here because the two STU we will be using both use the same IR codes.



Discussion

Enter your comment (wiki syntax is allowed):
RRSWK
configuring+multiple+serial+ir+blasters.txt · Last modified: Monday 01 of December, 2008 [03:19:11] by 124.168.71.99
Contact Us Sister Sites Privacy Policy Terms of Use
Copyright © 2007-2008 ozmyth.com