Linux LIRC USB-UIRT HOWTO
Posted: Mon Oct 17, 2005 7:43 pm
I've just received a usb-uirt in the mail, and have had some luck getting it going for reception under gentoo gnu/linux. Here's what I did:
- enable ftdi_sio support in kernel (only required on older or manually compiled kernels)
And reboot. If installing as modules, be sure to load modules (usbserial,ftdi_sio) at boot by editing /etc/modules.autoload.d/kernel-2.6 or similar.
- after reboot or loading modules, verify usb-uirt is being found by tailing the logs and plugging in the device
If you don't see similar, verify kernel configuration and module loading (if applicable)
- if under ubuntu ensure you have the build dependencies by
- download lirc 0.7.1 lirc-0.7.1.tar.bz2 from lirc.org
- download the patch (an update of neveld's patch to prevent the debug and repeat bugs)
- do the following
- edit configure.sh as follows:
Note the changed --with-tty line and --prefix line (to install to /usr, instead of /usr/local) and the --with-syslog for logging to syslog
- run
make install needs to be run as root.
- if under gentoo: create/edit /etc/modules.d/lirc to contain
and run update-modules
- otherwise: edit /etc/modules.conf, add the above alias and run
- background watching the logs:
- run lircd which should trigger log message:
- run irrecord
and record remote keypresses. Remote has to be held within inches of front center of usb-uirt. -l puts it into learn mode, which dumps the frequency. Might be a good idea to record a power button if you want to try transmitting. Continue thru irrecord process.
- edit the test.conf and replace
with a better name (ie the name of the remote, etc):
This name (ie NAD above) is the remote name and will be used with irssend and other apps.
- in the conf file will be lines containing the frequency. Such as:
Take a look a the numbers within the frequency lines. Copy the line to the top and round the number to something close to all numbers:
Without this step, you may not be able to transmit.
- move test.conf to default and restart lircd
- run irw and hit recorded buttons... button id should show as you press it.
- you can try transmit, if you wish. Record a button which controls the device you'd like the uirt to control. Power button is the easiest. Point the uirt at the device and send the button:
[REMOTE] should be the name of the remote as in the lircd.conf file and [BUTTON] the name of the button to send. If sending power, the device should come on or off. Putting the command in a loop might be useful when testing:
Hit ^c to exit. Hopefully it should turn the device on or off every 3 seconds.
- (optional) You might want a channel changing script which could be used to change the channel before recording. Here's one:
Save it somewhere (/usr/bin/chchan, perhaps) and chmod it: chmod a+x /usr/bin/chchan. Call it with the name of the remote and the channel:
- lirc should now be verified to be working, but it's only ever been started manually. To have lirc start on boot, you'll need to add a file to /etc/init.d. In the lirc source directory, do
As lirc was installed to /usr, you'll have to edit the new /etc/init.d/lirc and change all references from /usr/local to /usr.
For gentoo, the debian startup script should work, or, if want to be fancy, you use the lirc startup scripts which are packaged with the ebuild:
- (optional) lircmd is a program to use a remote to control the X mouse pointer. It can be somewhat funky with an appropriately configured X display on tv out... browsing for files through nautilus, etc. Check out doc/html/lircmd.html in lirc source distribution for installation instructions.
---
EDIT
- added transmission steps as derived from nathan.
- changed patch link to reflect lirc0.7.1, instead of 0.7.0pre7, should patch fine now.
- further modified patch to fix debug and repeat bugs (as noted in MM's post and others) and removed the link to the original.
- updated build process to include libtoolize workaround
- added ubuntu build dep instructions
Any suggestions for improving this howto are welcome!
- enable ftdi_sio support in kernel (only required on older or manually compiled kernels)
- Code: Select all
# cd /usr/src/linux
# make menuconfig
select Device Drivers -> USB Support -> <*> USB Serial Converter Support
select Device Drivers -> USB Support -> <*> USB Serial Converter Support -> <*> USB FTDI Single Port Serial Driver (EXPERIMENTAL)
And reboot. If installing as modules, be sure to load modules (usbserial,ftdi_sio) at boot by editing /etc/modules.autoload.d/kernel-2.6 or similar.
- after reboot or loading modules, verify usb-uirt is being found by tailing the logs and plugging in the device
- Code: Select all
# tail -f /var/log/everything/current
(for metalog, or tail -f /var/log/messages if syslog)
Plug in the USB-UIRT and you should see:
[kernel] usb 2-3: new full speed USB device using ohci_hcd and address 8
[kernel] ftdi_sio 2-3:1.0: USB-UIRT Infrared Tranceiver converter detected
[kernel] usb 2-3: USB-UIRT Infrared Tranceiver converter now attached to ttyUSB0
If you don't see similar, verify kernel configuration and module loading (if applicable)
- if under ubuntu ensure you have the build dependencies by
- Code: Select all
sudo apt-get build-dep lirc
- download lirc 0.7.1 lirc-0.7.1.tar.bz2 from lirc.org
- download the patch (an update of neveld's patch to prevent the debug and repeat bugs)
- do the following
- Code: Select all
# tar xvfj lirc-0.7.1.tar.bz2
# cd lirc-0.7.1
# bzcat ../lirc-0.7.1-usb_uirt.patch.bz2 | patch -p1
# libtoolize --force
# ./setup.sh
choose Driver Configuration->USB Devices->USB-UIRT2 (receive and transmit)
choose Save Configuration & Exit
- edit configure.sh as follows:
- Code: Select all
#!/bin/bash
./configure \
--with-moduledir=/lib/modules/2.6.12-gentoo-r9/misc \
--with-x \
--with-syslog \
--with-driver=usb-uirt2_raw \
--with-major=61 \
--with-port=none \
--with-irq=none \
--prefix=/usr \
"$@"
Note the changed --with-tty line and --prefix line (to install to /usr, instead of /usr/local) and the --with-syslog for logging to syslog
- run
- Code: Select all
# sh ./configure.sh && make && make install
make install needs to be run as root.
- if under gentoo: create/edit /etc/modules.d/lirc to contain
- Code: Select all
alias char-major-61 lirc_usb-uirt2_raw
and run update-modules
- otherwise: edit /etc/modules.conf, add the above alias and run
- Code: Select all
# depmod -a
- background watching the logs:
- Code: Select all
metalog: # tail -f /var/log/everything/current&
syslog: # tail -f /var/log/messages&
- run lircd which should trigger log message:
- Code: Select all
# lircd
[lircd-0.7.1] lircd(usb-uirt2_raw) ready
- run irrecord
- Code: Select all
# irrecord -l test.conf
and record remote keypresses. Remote has to be held within inches of front center of usb-uirt. -l puts it into learn mode, which dumps the frequency. Might be a good idea to record a power button if you want to try transmitting. Continue thru irrecord process.
- edit the test.conf and replace
- Code: Select all
name /some/path/test.conf
with a better name (ie the name of the remote, etc):
- Code: Select all
name NAD
This name (ie NAD above) is the remote name and will be used with irssend and other apps.
- in the conf file will be lines containing the frequency. Such as:
- Code: Select all
:
name sat_rew
# frequency 39466
2422 632 646 636 648 632
648 636 646 636 1255 622
:
Take a look a the numbers within the frequency lines. Copy the line to the top and round the number to something close to all numbers:
- Code: Select all
:
begin remote
name nad
flags CONST_LENGTH|RAW_CODES
eps 30
aeps 100
frequency 39200
:
Without this step, you may not be able to transmit.
- move test.conf to default and restart lircd
- Code: Select all
# mv test.conf /etc/lircd.conf
# killall lircd && lircd
- run irw and hit recorded buttons... button id should show as you press it.
- you can try transmit, if you wish. Record a button which controls the device you'd like the uirt to control. Power button is the easiest. Point the uirt at the device and send the button:
- Code: Select all
irsend [REMOTE] SEND_ONCE [BUTTON]
ie: irsend nad SEND_ONCE sat_pwr
[REMOTE] should be the name of the remote as in the lircd.conf file and [BUTTON] the name of the button to send. If sending power, the device should come on or off. Putting the command in a loop might be useful when testing:
- Code: Select all
while [ true ]; do irsend nad SEND_ONCE sat_pwr; sleep 3s; done;
Hit ^c to exit. Hopefully it should turn the device on or off every 3 seconds.
- (optional) You might want a channel changing script which could be used to change the channel before recording. Here's one:
- Code: Select all
#!/bin/sh
REMOTE_NAME=$1
cmd=$2
echo $cmd | grep -q -e '^[0-9]'
ret=$?
if [ $ret -eq 0 ];then
for digit in $(echo $cmd | sed -e 's/./& /g'); do
irsend SEND_ONCE $REMOTE_NAME sat_$digit
# sleep 1
# If things work OK with sleep 1, try this for faster channel changes:
sleep 0.5
done
else
irsend SEND_ONCE $REMOTE_NAME $cmd
fi
Save it somewhere (/usr/bin/chchan, perhaps) and chmod it: chmod a+x /usr/bin/chchan. Call it with the name of the remote and the channel:
- Code: Select all
/usr/bin/chchan nad 551
- lirc should now be verified to be working, but it's only ever been started manually. To have lirc start on boot, you'll need to add a file to /etc/init.d. In the lirc source directory, do
- Code: Select all
# copy contrib/lirc.<dist> /etc/init.d/lirc
where <dist> is your distribution. ie:
# copy contrib/lirc.debian /etc/init.d/lirc
As lirc was installed to /usr, you'll have to edit the new /etc/init.d/lirc and change all references from /usr/local to /usr.
For gentoo, the debian startup script should work, or, if want to be fancy, you use the lirc startup scripts which are packaged with the ebuild:
- Code: Select all
# copy /usr/portage/app-misc/lirc/files/lircd /usr/portage/app-misc/lirc/files/lircmd /etc/init.d/
# rc-update add lircd default
# rc-update add lircmd default
- (optional) lircmd is a program to use a remote to control the X mouse pointer. It can be somewhat funky with an appropriately configured X display on tv out... browsing for files through nautilus, etc. Check out doc/html/lircmd.html in lirc source distribution for installation instructions.
---
EDIT
- added transmission steps as derived from nathan.
- changed patch link to reflect lirc0.7.1, instead of 0.7.0pre7, should patch fine now.
- further modified patch to fix debug and repeat bugs (as noted in MM's post and others) and removed the link to the original.
- updated build process to include libtoolize workaround
- added ubuntu build dep instructions
Any suggestions for improving this howto are welcome!