LIRC: Difference between revisions
(adding testing) |
(cut out redundant and out-dated sections) |
||
Line 48: | Line 48: | ||
000000037ff07bf2 01 Home mceusb | 000000037ff07bf2 01 Home mceusb | ||
== (Temp placeholder for content to sort) == | |||
=== Setup a HID device with LIRC === | === Setup a HID device with LIRC === | ||
Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{ic|lirc.conf}} files become standard HID devices. | Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own {{ic|lirc.conf}} files become standard HID devices. | ||
Line 172: | Line 173: | ||
If you can't make out where the interference is coming from, you can try to put a cardboard roll right in front of the receiving diode, so that it only gets light from a specific direction. Invoke mode2 as above. Then point at different locations till you receive IR noise. | If you can't make out where the interference is coming from, you can try to put a cardboard roll right in front of the receiving diode, so that it only gets light from a specific direction. Invoke mode2 as above. Then point at different locations till you receive IR noise. | ||
===Your serial port support is compiled as a module in the kernel=== | ===Your serial port support is compiled as a module in the kernel=== |
Revision as of 16:14, 7 December 2013
Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary link Template:Article summary link Template:Article summary end
Installation
Install the lirc-utils package, which is available in the official repositories. The most of LIRC kernel drivers are already included in the mainline kernel. Install the lirc package only, if the hardware requires the lirc_wpc8769l module.
Setup
The LIRC Config File
Defining /etc/lirc/lircd.conf
which is specific to each remote/IR receiver is the first step in setting up a remote.
Use a Prebuild Config File
Identify which remote/IR receiver is to be used and see if /usr/share/lirc
contains a pre-built config file for it. Once identified, create/edit /etc/lirc/lircd.conf
to use an include statement that points to the selected one.
Example:
/etc/lirc/lircd.conf
include "/usr/share/lirc/streamzap/lircd.conf.streamzap"
Create a Config File
Users with unsupported hardware will need to either find a config file someone else has create (i.e. google) or create one. Creating one is fairly straightforward using the included /usr/bin/irrecord
program which guides users along the needed process. If using a detected remote, invoke it like so:
irrecord --device=/dev/lirc0 MyRemote
The program will ask users to begin hitting keys on the remote in an attempt to learn it. If all goes well, the user will be prompted to map out each key press to a specific scancode LIRC uses to identify that specific key press. The process should take no more than 10 minutes. When finished, save the resulting file to /etc/lirc/lircd.conf
and proceed.
Testing the Remote
Start the LIRC daemon:
# systemctl start lirc
Test the remote using /usr/bin/irw
, which simply echos anything received by LIRC when users push buttons on the remote to stdout.
Example:
$ irw 000000037ff07bfe 00 One mceusb 000000037ff07bfd 00 Two mceusb 000000037ff07bfd 01 Two mceusb 000000037ff07bf2 00 Home mceusb 000000037ff07bf2 01 Home mceusb
(Temp placeholder for content to sort)
Setup a HID device with LIRC
Some remotes are supported in the kernel where they are treated as a keyboard and mouse. Every button on the device is recognized as keyboard or mouse events which can be used even without LIRC. LIRC can still be used with these devices to gain greater control over the events raised and integrate with programs that expect a LIRC remote rather than a keyboard. As drivers are migrated to the kernel, devices which use to only be useable through LIRC with their own lirc.conf
files become standard HID devices.
Some HID remotes actually simulate a USB infrared keyboard and mouse. These remotes show up as two devices so you need to add two LIRC devices to lircd.conf
.
First we need the /dev/input
device for our remote:
$ ls /sys/class/rc/rc0
One of the files should be input#, where the number matches the event# of the device. (To clarify you can check that directory, it will have an event# file.
/sys/class/rc
. Under event# cat name
to verify which device you are looking at.then go to /dev/input/by-id
$ ls -l /dev/input/by-id
You should find a file that symlinks to the input# above, and possibly others with a similar names for mouse events.
lrwxrwxrwx 1 root root 9 10月 14 06:43 usb-3353_3713-event-if00 -> ../event9 lrwxrwxrwx 1 root root 10 10月 14 06:43 usb-3353_3713-event-if01 -> ../event10
Here 'usb-3353_3713-event-if00' and 'usb-3353_3713-event-if01' are the Linux input device event for our HID device, one for the keyboard, another for the mouse.
Then, we need to edit /etc/conf.d/lircd.conf
. This file contains the parameters for LIRC daemon
# #Parameters for daemon # LIRC_DEVICE="/dev/input/by-id/usb-3353_3713-event-if00" LIRC_DRIVER="devinput" LIRC_EXTRAOPS="" LIRC_CONFIGFILE="/etc/lirc/lircd.conf"
The latest version of the config file for HID remotes exists in the LIRC git repository [1]. Simply save it as /etc/lirc/lircd.conf
.
In order to launch the LIRC daemon for HID remote, You must enable evdev module first
# modprobe evdev
/dev/lircd
to /var/run/lirc/lircd
, but many applications still look for the socket in the old location. Since lirc-utils 0.8.6-3 the /etc/rc.d/lircd
script creates a symlink from /dev/lircd
to the /var/run/lirc/lircd
socket when it starts the lircd daemon and removes the link when the daemon is stopped.Serial receivers that depend on lirc_serial
Make sure that your serial port is activated in the BIOS. There you can also set and lookup I/O address and IRQ settings of your ports.
Now there might be a problem: the module lirc_serial is build to use ttyS0 (COM1), if your device is not connected to ttyS0, you will have to either change the module-options or rebuild the LIRC module. If your device is connected to ttyS0, you can skip this step
To change the options for the lirc_serial module, you edit /etc/modprobe.d/modprobe.conf
and add this line:
options lirc_serial io=0x2f8 irq=3
You should change the values after io and irq to reflect you serial port settings, the values above may work for you if you are using ttyS1 (COM2) to connect your IR-device. But you will find the correct values by checking dmesg:
$ dmesg | grep ttyS
Building the lirc_serial module for another ttySx
Update abs
# abs
Copy the LIRC files to a directory you choose yourself:
$ cp /var/abs/extra/system/lirc /some/dir
$ cd /some/dir
Edit the PKGBUILD in that directory.
Replace the line:
./configure --enable-sandboxed --prefix=/usr \ --with-driver=all \\ return 1[/code]
with:
./configure --enable-sandboxed --prefix=/usr \ --with-driver=com2 \ || return 1[/code]
Where you replace com2 with the com-port you need.
Build and install the package:
$ makepkg # pacman -U lirc-version.pkg.tar.gz
Loading
Now try to load the serial module:
# modprobe lirc_serial
If this produces an error which says your serial port is not ready, you have the problem that your serial port support is build into the kernel and not as a module (in the default arch kernel it is build into the kernel)
If it is built into the kernel you will have to do the following (remember that it is built into the kernel, you will need to make some changes later too)
You will have to release the serial port:
# setserial /dev/ttySx uart none
(Replace x with your port number)
Load the module again:
# modprobe lirc_serial
Now it should not show any errors, and the modules lirc_serial should be listed in lsmod
Checking module based receivers
NOTE: This section only applies if your device requires a lirc_[driver] kernel module.
Before you start using lirc, you should check if your receiver is working, and if there is IR interference. Possible sources of interference include monitors/televisions (especially plasma displays), fluorescent lamps and direct or ambient sunlight. Start the following command to display raw receiver input.
# mode2 -d /dev/lirc0
If you press buttons on any IR remote, you should see a series of pulses and spaces. If there is very frequent output without pressing buttons on your remote, your receiver suffers from interference. You want to avoid such interference, e.g. by placing the receiver behind or under your plasma tv.
If you can't make out where the interference is coming from, you can try to put a cardboard roll right in front of the receiving diode, so that it only gets light from a specific direction. Invoke mode2 as above. Then point at different locations till you receive IR noise.
Your serial port support is compiled as a module in the kernel
This is rather easy: you will just have to add lirc_serial to the modules list and lircd to the daemons list in /etc/rc.conf
Your serial port support is compiled into the kernel
This is more complicated, you cannot just add the lirc_serial to the modules list in /etc/rc.conf
, as the serial port should be released first.
So I created a custom startup script to fix this problem.
/etc/rc.d/start_lirc
#!/bin/bash #/etc/rc.d/start_lirc #releases ttySx and loads lirc_serial module . /etc/rc.conf . /etc/rc.d/functions case "$1" in start) stat_busy "release ttySx" setserial /dev/ttySx uart none #load lirc module modprobe lirc_serial stat_done ;; stop) stat_busy "unload lirc module" rmmod lirc_serial stat_done ;; restart) $0 stop $0 start ;; *) echo "usage: $0 {start|stop|restart}" esac exit 0
Now load the daemons: add "start_lirc" and "lircd" to the daemons list in /etc/rc.conf
Program specific configuration
Generate your own lircrc with Mythbuntu's lircrc-generator
mythbuntu-lircrc-generator is intended to be started from a system with LIRC installed. It requires that you choose a remote via the LIRC package or have a lircd.conf
handy prior to running. It will then produce a sane .lircrc
for the current user.
Mythbuntu's Lirc/Lircrc Generator is available on AUR
Man page
Enable LIRC support in xine
Now LIRC works, but you have no program that can communicate with LIRC. This section will explain how to make xine work, but you can use xmms and mplayer (and probably a lot of other programs too) to work with LIRC.
Compile xine with LIRC support
Download the xine-ui PKGBUILD with ABS.
Add " --enable-lirc" to the ./configure
line
Compile:
$ makepkg
Uninstall old xine-ui and install the new one
# pacman -R xine-ui # pacman -U xine-filename.pkg.tar.gz
Configure xine to use LIRC
Let xine produce a default .lircrc
file. In your home directory, type:
$ xine --keymap=lirc>.lircrc
Now, in order to have a functioning xine+lirc, edit the .lircrc
file to your preferences.
However, you may choose to configure LIRC to control more than just xine. If this is the case, you will need to manually edit the .lircrc
file, and add elements.
Xine-ui Mplayer Totem Vlc Rhythmbox
All work with LIRC, but you must enable LIRC support in the program in some cases, such as VLC. Simply copy the vlc packagebuild and edit it so that "--enable-lirc" is one of the compile options for VLC not FFMPEG!
Configure Amarok2 to use LIRC
Depending on your controller model, the following configuration works with Amarok2-svn. This configuration file will work with the MCEUSB controller.
~/.lircrc
##amarok2 begin button = Play prog = irexec repeat = 0 config = qdbus org.mpris.amarok /Player Play end begin button = Pause prog = irexec repeat = 0 config = qdbus org.mpris.amarok /Player Pause end begin button = Stop prog = irexec repeat = 0 config = qdbus org.mpris.amarok /Player Stop end begin button = Skip prog = irexec repeat = 0 config = qdbus org.mpris.amarok /Player Next end begin button = Replay prog = irexec repeat = 0 config = qdbus org.mpris.amarok /Player Prev end
Configure Audacious(2) to use LIRC
Depending on your controller model, the following configuration works with all versions of Audacious, including the mercurial builds. This configuration file will work with the MCEUSB controller.
~/.lircrc
##audacious begin prog = audacious button = Play config = PLAY repeat = 0 end begin prog = audacious button = Pause config = PAUSE repeat = 0 end begin prog = audacious button = Stop config = STOP repeat = 0 end begin prog = audacious button = Skip config = NEXT repeat = 0 end begin prog = audacious button = Replay config = PREV repeat = 0 end begin prog = audacious button = VolUp config = VOL_UP repeat = 1 end begin prog = audacious button = VolDown config = VOL_DOWN repeat = 1 end
Additionally, there are other values that may be set according to the model set forth above. This was taken from the lirc.c file from audacious-plugins source code:
lirc.c
PLAY STOP PAUSE PLAYPAUSE NEXT PREV SHUFFLE REPEAT FWD BWD VOL_UP VOL_DOWN QUIT MUTE BAL_LEFT BAL_RIGHT BAL_CENTER LIST PLAYLIST_CLEAR PLAYLIST_ADD
Configure Mplayer to use LIRC
~/.lircrc
##mplayer begin button = PLAY/PAUSE prog = mplayer config = pause repeat = 1 end begin button = FWD prog = mplayer config = seek 5 end begin button = REV prog = mplayer config = seek -5 end begin button = MAXIMIZE prog = mplayer config = vo_fullscreen end
only change PLAY/PAUSE, FWD etc. on keys from your /etc/lircd.conf
Device Specific Examples
X10
There is a dedicated wiki page with information about X10
Asus DH Deluxe series motherboard
Check the output of:
$ cat /dev/usb/hiddevX
where X is 0,1 or bigger, and press some buttons on remote.
If you can see reply, device works fine, follow steps:
1. In file /etc/conf.d/lircd.conf
add:
LIRC_DRIVER="dvico"
2. Reload LIRC:
/etc/rc.d/lircd restart
ASRock ION series (Nuvoton) quickstart
$ ln -s /usr/share/lirc/remotes/lirc_wb677/lircd.conf.wb677 /etc/lirc/lircd.conf $ /etc/rc.d/lircd restart
Streamzap PC Remote (USB)
To disable this behavior, add the following to /etc/X11/xorg.conf.d/90-streamzap.conf
:
Section "InputClass" Identifier "Ignore Streamzap IR" MatchProduct "Streamzap" MatchIsKeyboard "true" Option "Ignore" "true" EndSection
- Install both packages (lirc lirc-utils)
- Modprobe both kernel mods (lirc_dev and streamzap). To have modules autoload at boot create the following file
/etc/modules-load.d/lirc_streamzap.conf
#modules for streamzap remote lirc_dev streamzap
- Create your
/etc/lirc/lircd.conf
(for this remote, copy/usr/share/lirc/streamzap/lircd.conf.streamzap
to/etc/lirc/lircd.conf
) - Fix the broken lirc.service file:
/usr/lib/systemd/system/lirc.service
[Unit] Description=Linux Infrared Remote Control [Service] EnvironmentFile=/etc/lirc/lircd.conf ExecStartPre=/usr/bin/ln -sf /run/lirc/lircd /dev/lircd ExecStart=/usr/bin/lircd --pidfile=/run/lirc/lircd.pid -d /dev/lirc0 Type=forking PIDFile=/run/lirc/lircd.pid [Install] WantedBy=multi-user.target
You might have to play around with lircd and irw to find your remote. In the above example, it's /dev/lirc0.
Use lircd -d /dev/...
to start lircd with a certain device. Run irw
and test it out. When you find the right device, modify /usr/lib/systemd/system/lirc.service
accordingly.
- Start lircd via
# systemctl start lirc
to survive a reboot use# systemctl enable lirc
- Test the remote/lirc with irw
$ irw 00000000000028cc 00 CH_UP Streamzap_PC_Remote 00000000000028ce 00 CH_DOWN Streamzap_PC_Remote 00000000000028c8 00 8 Streamzap_PC_Remote 00000000000028c5 00 5 Streamzap_PC_Remote 00000000000028d2 00 OK Streamzap_PC_Remote 00000000000028d1 00 LEFT Streamzap_PC_Remote 00000000000028d1 01 LEFT Streamzap_PC_Remote 00000000000028d1 00 LEFT Streamzap_PC_Remote 00000000000028d3 00 RIGHT Streamzap_PC_Remote 00000000000028d3 00 RIGHT Streamzap_PC_Remote 00000000000028d3 00 RIGHT Streamzap_PC_Remote 00000000000028d3 00 RIGHT Streamzap_PC_Remote 00000000000028d4 00 DOWN Streamzap_PC_Remote 00000000000028d4 00 DOWN Streamzap_PC_Remote 00000000000028d4 00 DOWN Streamzap_PC_Remote
Serial Port "Home Brew" IR Receiver
Here's how to get a "Home Brew" serial port IR receiver working:
1. Create a udev rule to give non-privleged users read/write access to the serial port. I will be using ttyS0 in my example.
/etc/udev/rules.d/z98-serial.rules
# For serial port ttyS0 and LIRC KERNEL=="ttyS0",SUBSYSTEM=="tty",DRIVERS=="serial",MODE="0666"
2. Create the needed modprobe configs
/etc/modules-load.d/lirc_serial.conf
lirc_serial
/etc/modprobe.d/lirc_serial.conf
install lirc_serial /usr/bin/setserial /dev/ttyS0 uart none && /sbin/modprobe --first-time --ignore-install lirc_serial options lirc_serial type=0 remove lirc_serial /sbin/modprobe -r --first-time --ignore-remove lirc_serial && /sbin/modprobe -r lirc_dev
3. Install your systemd service file.
/etc/systemd/system/lirc.service
[Unit] Description=Linux Infrared Remote Control After=network.target [Service] Type=simple PIDFile=/run/lirc/lircd.pid ExecStartPre=/bin/rm -f /dev/lirc /dev/lircd /var/run/lirc/lircd ExecStart=/usr/sbin/lircd -n -r -P /run/lirc/lircd.pid -d /dev/lirc0 -o /run/lirc/lircd ExecStartPost=/usr/bin/ln -sf /run/lirc/lircd /dev/lircd ExecStartPost=/usr/bin/ln -sf /dev/lirc0 /dev/lirc ExecReload=/bin/kill -SIGHUP $MAINPID [Install] WantedBy=multi-user.target
4. We still need the default tmpfiles to be created, so copy that config file to /etc/tmpfiles.d/lirc.conf
.
# cp -a /usr/lib/tmpfiles.d/lirc.conf /etc/tmpfiles.d/lirc.conf
5. Create a .lircrc
file in your home directory for your user or a /etc/lirc/lircrc
file for system wide use.
6. Have your service start at boot and then test with a reboot
# systemctl enable lirc.service # systemctl reboot
or load the module and start the lirc.service.
# modprobe lirc_serial # systemctl start lirc.service
Receivers that do not depend on a kernel module
Usually, you only need to specify your the device where the receiver is plugged in and the lirc driver. This is an example for pinnacle or miro serial receivers):
LIRC_DEVICE="/dev/ttySX" LIRC_DRIVER="pinsys"
Then, start lircd daemon and create the remote/s configuration (/etc/lirc/lircd.conf), either by copying one of the configured defaults that comes with lirc-utils or by using irrecord. Even if you find your remote in the list of preconfigured remotes it might not work so you will have to use irrecord anyway.
After this you can use irw to check the remote, create your ~/.lircrc to assign remote buttons to actions and start irexec if you need to run arbitrary commands.
Troubleshooting
Buttons processed several times when pressed
Problem in module ir_core which processes IR commands with LIRC at the same time. Simply blacklist it by creating the following file:
/etc/modprobe.d/remote_blacklist.conf
# Prevent processing button several times when pressed blacklist ir_core
After upgrading or installing Arch, an existing configuration stopped working
Kernel module change
As of kernel 2.6.36, LIRC modules have been included in the kernel. Arch's lirc package has included the older kernel modules, which work with lircd without any additional configuration. However, a recent update removed those older modules, which results in the stock kernel modules being used. Unfortunately, these kernel modules treat the remote as a keyboard by default, which is incompatible for lircd. To correct this, put the following line to /etc/rc.local
:
/etc/rc.local
echo lirc > /sys/class/rc/rc0/protocols
You may also run that command as root to enable LIRC for your current session.
Systemd has moved away from rc.local
. It is possible to use tmpfiles.d (read "man tmpfiles.d") to run the command echo lirc > /sys/class/rc/rc0/protocols
. Create the file /etc/tmpfiles.d/lirc-protocols.conf
:
/etc/tmpfiles.d/lirc-protocols.conf
w /sys/class/rc/rc0/protocols - - - - lirc
/etc/rc.conf
, as it is no longer present.Problems using default systemd lirc.service file
The lirc service used to use a conf.d file for configuring command-line parameters, but the functionality was removed for systemd since the default configuration tends to work for the majority of use cases after kernel support for lirc was introduced. See FS#31890.
As the bug report states, the "correct" way to fix this issue is to use a drop-in service file; however, the workaround below can be a quick fix for a particular common problem.
Workaround
How to know you might need the workaround -- /var/log/lirc
shows error finding /dev/lirc
:
lircd: could not get file information for /dev/lirc
Workaround: make a symbolic link for /dev/lirc
that points to /dev/lirc0
with file
/etc/tmpfiles.d/lirc-dev.conf
L /dev/lirc - - - - /dev/lirc0
Replacing/overriding the existing service file
/etc/systemd/system/multi-user.target.wants/lirc.service
[Unit] Description=Linux Infrared Remote Control [Service] EnvironmentFile=/etc/conf.d/lircd.conf ExecStartPre=/usr/bin/ln -sf /run/lirc/lircd /dev/lircd ExecStart=/usr/bin/lircd --pidfile=/run/lirc/lircd.pid --device=${LIRC_DEVICE} --driver=${LIRC_DRIVER} $LIRC_EXTRAOPTS ${LIRC_CONFIGFILE} Type=forking PIDFile=/run/lirc/lircd.pid [Install] WantedBy=multi-user.target
/etc/conf.d/lircd.conf
# # Parameters for lirc daemon # LIRC_DEVICE="YOUR DEVICE" LIRC_DRIVER="YOUR DRIVER" LIRC_EXTRAOPTS="" LIRC_CONFIGFILE="/etc/lircd.conf"
With these you can start the daemon with preferred parameters from the config file.
EnvironmentFile=
in the service file specifies the file with service parameters.
–device=${LIRC_DEVICE} –driver=${LIRC_DRIVER} $LIRC_EXTRAOPTS ${LIRC_CONFIG}
uses the created variables from file as parameters to the daemon.
See also
- http://www.mythtv.org/wiki/Category:Remote_Controls -- MythTV wiki main LIRC article