Ubuntu Serial Lirc Install

From MythTV Official Wiki
Revision as of 16:58, 26 February 2012 by Wagnerrp (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

About

This Guide is the 'official' way to install Lirc remote control drivers in Ubuntu Linux

This guide is for a serial device

There are similar instructions at the Ubuntu Community site https://help.ubuntu.com/community/Install_Lirc_Feisty

An alternate method using ledxmit (lirc) is located here: http://ubuntuforums.org/showthread.php?t=550068 (This method works well with homebrew serial irblasters)


Important.png Note: lirc_serial.ko has a serious bug in a number of distributions including Ubuntu 10.10 that my prevent it from working. A quick fix is here: http://www.gossamer-threads.com/lists/mythtv/users/477915#477915

Install

Note: For Intrepid, this procedure has changed somewhat. After installing the lirc packages, edit /usr/src/lirc-0.8*/lirc-modules-source.conf as directed below. Then sudo dpkg-reconfigure lirc-modules-source. This will not present the configuration screens as noted below but it will build the lirc kernel modules automagically using DKMS.

  • Install Lirc
sudo apt-get install lirc lirc-modules-source module-assistant
  • Configure lirc-modules-source
sudo dpkg-reconfigure lirc-modules-source 
A Configuration should appear
Choose the OK button and press enter (tab key to move across)
Make sure only the serial module is selected, use the space bar to select, and then press enter on OK
You will be given an option to build the modules. Be sure not to build the modules here
You may be given an option to replace with a new version. Be sure to choose to Install the package maintainer's version
  • Modify /etc/lirc/lirc-modules-source.conf
sudo nano /etc/lirc/lirc-modules-source.conf
LIRC_MODULES="serial"

For Intrepid do not edit the LIRC_MODULES entry. The DKMS build fails if certain modules are removed and it is easiest to just leave this line as is and build them all.

LIRC_SERIAL_PORT="0x03f8"
LIRC_SERIAL_IRQ="4"
LIRC_SERIAL_CFLAGS=" -DLIRC_SERIAL_TRANSMITTER -DLIRC_SERIAL_SOFTCARRIER"
LIRC_SERIAL_PORT needs the address of your serial port, this is usually shown in the bios, 0x03f8 is usually serial port 1
LIRC_SERIAL_IRQ is also shown in the bios, 4 is usually serial port 1

If your serial device is a receiver, leave LIRC_SERIAL_CFLAGS empty.

  • Modify /etc/lirc/hardware.conf
sudo nano /etc/lirc/hardware.conf
Make sure LOAD_MODULES is =true. Also, edit your modules to MODULES="lirc_dev lirc_serial".
On Feisty the device created was /dev/lirc0. If this is the case you should add DEVICE="/dev/lirc0"

Your files should match the documentation here at this point Ubuntu_lirc_configuration_files#lirc_serial

  • Remove Old Drivers and Build Lirc Modules (Don't worry about file not found errors).
sudo m-a update,prepare
sudo rm /usr/src/lirc*deb
sudo m-a clean lirc
sudo m-a a-i -f lirc
sudo depmod -a
  • Install setserial to allow lirc to take control of your serial device
sudo apt-get install setserial
  • Disable Ubuntu's control of your serial port
sudo setserial /dev/ttyS0 uart none
sudo setserial /dev/ttyS1 uart none
  • Load Module
sudo modprobe lirc_serial

This should now complete without an error

  • Restart Lirc
sudo /etc/init.d/lirc restart
  • Startup Configuration

To ensure that lirc starts up correctly on reboot, add the appropriate setserial line (without the sudo) to the top of your hardware.conf file. There are two other methods for this given in https://help.ubuntu.com/community/Install_Lirc_Feisty

Remote Configuration

You can get a remote configuration file at sourceforge http://lirc.sourceforge.net/remotes/

If your remote is not listed there, or their remote codes dont work for you, you will have to reccord your own For this you will need a IR Reciever, a serial one will work with the above guide I managed to record using the mceusb2 reciever, however you will need to recompile lirc to use it

Lets assume you have a 3M MP8640 remote

mkdir ~/lirc
cd ~/lirc
wget http://lirc.sourceforge.net/remotes/3m/MP8640
sudo cp MP8640 /etc/lirc/lircd.conf

Testing Your IRBlaster

Assuming you managed to get a lircd.conf that worked

sudo nano /etc/lirc/lircd.conf
At the top there will be somthing written next to name

lets assume it says

name  MP8640

now to test a code

irsend send_once MP8640 1

You should now see a 1 appear on your set top box (or if you have an LED irblaster it should blink)

Testing your IR Reciever

Open a terminal and type

irw

now start pressing buttons on your remote, you should see lines appear in your window If its working ok, press Ctrl+C to quit irw

Recording your Remote

Firstly you need to stop lirc

sudo /etc/init.d/lirc stop

Then run irrecord

irrecord -d /dev/lirc lircd.conf
/dev/lirc is your lirc device, for me this was lirc0

irrecord will ask you to press buttons, this is to determine how your remote works If it is picking up your remote, full stops will scroll accross the screen It will then ask you to enter a name for each button, and then to press it, this will record your remote When you are done, press enter without putting anything in the name field This will write your remote control codes to lircd.conf in the directory your in

  • Move lircd.conf to the correct dirrectory
sudo cp lircd.conf /etc/lirc

Troubleshooting

If you are having problems, like IRW dropping back to the console a good way to diagnose is to launch lircd in the foreground

sudo lircd -n

now if you do IRW you will see why lircd is dieing, or any other errors