Difference between revisions of "LIRC"

From ArchWiki
Jump to: navigation, search
m (Supported hardware)
m (Undo revision 292372 by LeeDev (talk) a typo mistake)
(47 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[Category:Other hardware]]
 
[[Category:Other hardware]]
 
[[Category:Audio/Video]]
 
[[Category:Audio/Video]]
{{Article summary start}}
+
{{Related articles start}}
{{Article summary text|This article covers using LIRC with serial or USB infrared devices.}}
+
{{Related|LIRC Device Examples}}
{{Article summary end}}
+
{{Related articles end}}
  
{{Accuracy|Numerous examples of poor advice.}}
+
This article covers setup and usage of [http://lirc.org/ LIRC] "Linux Infrared Remote Control" with serial or USB infrared devices.
{{Out of date|References to out-dated init scripts and unneeded workarounds.}}
+
  
[http://lirc.org/ LIRC] stands for "Linux Infrared Remote Control", a program to use infrared devices (like your remote control from your TV) with linux.
+
==Overview==
 +
LIRC is a daemon that can translate key presses on a supported remote into program specific commands.  In this context, the term, "program specific" means that a key press can do different things depending on which program is running and taking commands from LIRC.
  
==Supported hardware==
+
=== The Central Dogma of LIRC ===
 +
The list below attempts to show the flow of information from the remote to the program using LIRC:
 +
* User hits a button on the remote causing it to transmit an IR or RF signal.
 +
* The signal is received by the receiver connected to the Linux box.
 +
* The kernel (via the correct module) uses /dev/lirc0 to characterize the pulse-length information from the receiver.
 +
* {{ic|/usr/bin/lircd}} uses the information from {{ic|/etc/lirc/lircd.conf}} convert the pulse-lengths into button press information.
 +
* Programs that use LIRC translate the button press info from {{ic|/usr/bin/lircd}} into user-defined actions according to {{ic|~/.lircrc}}.
  
Check the [http://lirc.org/html/table.html official list of supported hardware] to know, which LIRC kernel modules and lircd driver required for the infrared receiver.
+
=== Summary of Required Files ===
 +
* {{ic|/etc/lirc/lircd.conf}} - System-level config translating scancodes --> keys.  Is specific to each remote control/receiver on the system and can contain configure for multiple remotes and/or receivers if need be.
 +
* {{ic|~/.lircrc}} - File containing an '''include''' statement pointing to each program's lirc map, i.e., {{ic|~/.lirc/foo}}, {{ic|~/.lirc/bar}}, etc.
 +
* {{ic|~/.lirc/foo}} - User-level config translating of keys --> actions.  Is specific to each remote and to application foo.
  
 
==Installation==
 
==Installation==
 
 
[[pacman|Install]] the {{Pkg|lirc-utils}} package, which is available in the [[Official Repositories|official repositories]].  The most of LIRC kernel drivers are already included in the mainline kernel. Install the {{Pkg|lirc}} package only, if the hardware requires the '''lirc_wpc8769l''' module.
 
[[pacman|Install]] the {{Pkg|lirc-utils}} package, which is available in the [[Official Repositories|official repositories]].  The most of LIRC kernel drivers are already included in the mainline kernel. Install the {{Pkg|lirc}} package only, if the hardware requires the '''lirc_wpc8769l''' module.
  
==Serial receivers==
+
==Setup==
 +
Some remotes are identified as "keyboards" and function as such without LIRC.  This is problematic and can result in a doubling of commands.  Test if this is the case by opening a shell or a text editor, and by pressing buttons on the remote itself.  If letters/numbers appear, or if the up/down/left/right arrow keys behave as the up/down/left/right arrow keys on the physical keyboard, a workaround to disable this is required.  See, [[LIRC#Remote_functions_as_a_keyboard]] for a solution before continuing.
  
===Serial receivers that depend on lirc_serial===
+
=== The LIRC Config File ===
 +
Defining {{ic|/etc/lirc/lircd.conf}} which is specific to each remote/IR receiver is the first step in setting up a remote.
 +
{{Note|Common configs are provided by {{Pkg|lirc-utils}}, like those bundled with TV cards that can be installed automatically.  The primary source of config files is the LIRC homepage.  Check the [http://lirc.org/html/table.html official list of supported hardware] to know, which LIRC kernel modules and lircd driver required.}}
  
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.
+
==== Use a Prebuild Config File ====
 +
Identify which remote/receiver is to be used and see if {{ic|/usr/share/lirc}} contains a pre-built config file for it.  Once identified, create/edit {{ic|/etc/lirc/lircd.conf}} to use an '''include''' statement that points to the selected one.
  
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 [[LIRC#Building_the_LIRC_serial_module_for_another_ttySx|rebuild the LIRC module]]. If your device is connected to ttyS0, you can [[LIRC#Loading|skip this step]]
+
Example:
 +
{{hc|/etc/lirc/lircd.conf|
 +
include "/usr/share/lirc/streamzap/lircd.conf.streamzap"
 +
}}
  
To change the options for the lirc_serial module, you edit {{ic|/etc/modprobe.d/modprobe.conf}} and add this line:
+
==== Create a Config File ====
 +
Users with unsupported hardware will need to either find a config file someone else has created (i.e. google) or create one.  Creating one is fairly straightforward using the included {{ic|/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
  
  options lirc_serial io=0x2f8 irq=3
+
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 {{ic|/etc/lirc/lircd.conf}} and proceed.
  
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:
+
{{Note|Consider sending the finished config file to the email address mentioned in the program so it can be made available to others.}}
  
$ dmesg | grep ttyS
+
== Testing the Remote ==
  
===Other serial receivers===
+
Start the LIRC daemon:
 +
# systemctl start lirc
  
See [[LIRC#Other_receivers]]
+
Test the remote using {{ic|/usr/bin/irw}}, which simply echos anything received by LIRC when users push buttons on the remote to stdout.
  
===Building the lirc_serial module for another ttySx===
+
Example:
 +
$ irw
 +
000000037ff07bfe 00 One mceusb
 +
000000037ff07bfd 00 Two mceusb
 +
000000037ff07bfd 01 Two mceusb
 +
000000037ff07bf2 00 Home mceusb
 +
000000037ff07bf2 01 Home mceusb
  
Update abs
+
==Program Specific Configuration ==
 +
LIRC has the ability to allow for different programs to use the same keypress and result in unique commands.  In other words, mplayer and vlc can respond differently to a given key press.
  
  # abs
+
Decide which programs are to use LIRC commands. Common programs include: {{Pkg|mplayer}}, {{Pkg|mythtv}}, {{Pkg|totem}}, {{Pkg|vlc}}, and {{Pkg|xbmc}}.
  
Copy the LIRC files to a directory you choose yourself:
+
{{Note|XBMC implements LIRC in a non-standard way.  Users must edit {{ic|~/.xbmc/userdata/Lircmap.xml}} which is a unique xml file, rather than the LIRC standard files the rest of the programs use.  Interested users should consult the [[Xbmc#Using_a_remote_controller]] article.}}
  
  $ cp /var/abs/extra/system/lirc /some/dir
+
Users should create the expected files showing LIRC where the various program-specific maps reside:
 +
  $ mkdir ~/.lirc
 +
$ touch ~/.lircrc
  
$ cd /some/dir
+
* Populate {{ic|~/.lirc}} with the program specific config files named for each program.
  
Edit the PKGBUILD in that directory.
+
Example:
 +
$ ls ~/.lirc
 +
mplayer
 +
mythtv
 +
vlc
  
Replace the line:
+
{{Note|Providing an exhaustive listing of keymaps for each program is beyond the scope of this wiki article.  Many pre-made files unique to each remote/program are available via googling.}}
  
./configure --enable-sandboxed --prefix=/usr \
+
* Edit {{ic|~/.lircrc}} to contain an '''include''' statement pointing to {{ic|~/.lirc/foo}} and repeat for each program that is to be controlled by LIRC.
    --with-driver=all \\
+
    return 1[/code]
+
  
with:
+
Example:
 +
{{hc|~/.lircrc|
 +
include "~/.lirc/mplayer"
 +
include "~/.lirc/mythtv"
 +
include "~/.lirc/vlc"
 +
}}
  
./configure --enable-sandboxed --prefix=/usr \
+
==Troubleshooting==
    --with-driver=com2 \
+
=== Remote functions as a keyboard ===
    || return 1[/code]
+
Xorg detects some remotes, such as the Streamzap USB PC Remote, as a Human Interface Device (HID) which means some or all of the keys will show up as  key strokes as if entered from the physical keyboard.  This behavior will present problems if LIRC is to be used to manage the device. 
 +
To disable, create the following file and restart X:
  
Where you replace com2 with the com-port you need.
+
{{hc|/etc/X11/xorg.conf.d/90-streamzap.conf|
 
+
Section "InputClass"
Build and install the package:
+
  Identifier "Ignore Streamzap IR"
 
+
  MatchProduct "Streamzap"
$ makepkg
+
  MatchIsKeyboard "true"
# pacman -U lirc-version.pkg.tar.gz
+
  Option "Ignore" "true"
 
+
EndSection}}
===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
+
 
+
==USB receivers including most onboard devices==
+
This outlines the general procedure, the mceusb module which is used by many devices is used as an example.
+
 
+
# modprobe mceusb
+
 
+
Start the LIRC daemon:
+
 
+
$ /etc/rc.d/lircd start
+
 
+
Test it with irw, it will output the commands received by the IR receiver that match your {{ic|lircd.conf}} file. So start irw, point your remote and start pressing buttons.
+
 
+
$ irw
+
000000037ff07bfe 00 One mceusb
+
000000037ff07bfd 00 Two mceusb
+
000000037ff07bfd 01 Two mceusb
+
000000037ff07bf2 00 Home mceusb
+
000000037ff07bf2 01 Home mceusb
+
  
The above procedure however has been simplified and may not work that easily. One of the reasons the lircd daemon may not be working is because it expects to be run at startup and needs root permissions because it will create device nodes in {{ic|/dev}}. Try "man lircd" for more information.
+
Don't forget to alter the {{ic|MatchProduct}} property according to one shown in {{ic|Name}} from output of
 +
$ cat /proc/bus/input/devices | grep -e IR
 +
For example {{ic|WinFast}} for {{ic|<nowiki>N: Name="cx88 IR (WinFast DTV2000 H rev."</nowiki>}}
  
Continue with [[#Making a configuration file]]
+
== Legacy Info Which Needs to be Modernized and Vetted for Accuracy ==
 +
{{Accuracy|Someone with greater knowledge needs vet everything below this line for accuracy.}}
 +
{{Out of date|Parts of the following are out-of-date and need to be modernized.}}
  
 
=== Setup a HID device with LIRC ===
 
=== Setup a HID device with LIRC ===
Line 159: Line 159:
 
{{Note|LIRC 0.8.6 has changed the default socket location from {{ic|/dev/lircd}} to {{ic|/var/run/lirc/lircd}}, but many applications still look for the socket in the old location.  Since lirc-utils 0.8.6-3 the {{ic|/etc/rc.d/lircd}} script creates a symlink from {{ic|/dev/lircd}} to the {{ic|/var/run/lirc/lircd}} socket when it starts the lircd daemon and removes the link when the daemon is stopped.}}
 
{{Note|LIRC 0.8.6 has changed the default socket location from {{ic|/dev/lircd}} to {{ic|/var/run/lirc/lircd}}, but many applications still look for the socket in the old location.  Since lirc-utils 0.8.6-3 the {{ic|/etc/rc.d/lircd}} script creates a symlink from {{ic|/dev/lircd}} to the {{ic|/var/run/lirc/lircd}} socket when it starts the lircd daemon and removes the link when the daemon is stopped.}}
  
==Other receivers==
+
===Serial receivers that depend on lirc_serial===
  
There are many receivers that do not need any kernel module at all. This applies to any type of receiver, including serial receivers and usb receivers. Check the next link to see what kernel modules you need to load, if any:
+
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.
  
[http://www.lirc.org/html/table.html LIRC supported devices]
+
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 [[LIRC#Building_the_LIRC_serial_module_for_another_ttySx|rebuild the LIRC module]]. If your device is connected to ttyS0, you can [[LIRC#Loading|skip this step]]
  
==Checking module based receivers==
+
To change the options for the lirc_serial module, you edit {{ic|/etc/modprobe.d/modprobe.conf}} and add this line:
  
''NOTE: This section only applies if your device requires a lirc_[driver] kernel module.''
+
options lirc_serial io=0x2f8 irq=3
  
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.
+
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:
  
  # mode2 -d /dev/lirc0
+
  $ dmesg | grep ttyS
  
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.
+
====Building the lirc_serial module for another ttySx====
  
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.
+
Update abs
  
==LIRC daemon configuration==
+
# abs
  
The lircd configuration lives under /etc/conf.d/lircd.conf, and it is all you need to setup your device if it does not require any special kernel module.
+
Copy the LIRC files to a directory you choose yourself:
  
{{Box|IMPORTANT:|lirc-utils package on ArchLinux has a bug. You will have to create your own systemd unit or find another workaround. See [https://bugs.archlinux.org/task/31890 bug#31890] |#DF0000|#FFDFDF}}
+
$ cp /var/abs/extra/system/lirc /some/dir
  
==Making a configuration file==
+
$ cd /some/dir
  
You need a configuration file for your remote control copied or symlinked to {{ic|/etc/lirc/lircd.conf}}. A number of devices have already been included with the lirc package, they can be found in {{ic|/usr/share/lirc}}. If your specific device is not included, the LIRC site offers configuration files for a large number of extra [http://lirc.sourceforge.net/remotes/ devices].
+
Edit the PKGBUILD in that directory.
  
If your device does not already have a config file, you can create it yourself with the following command. You should avoid interference (see above) while creating the config file.
+
Replace the line:
  
  # irrecord -d /dev/lirc0 /tmp/my_remote
+
  ./configure --enable-sandboxed --prefix=/usr \
 +
    --with-driver=all \\
 +
    return 1[/code]
  
Just follow the instructions. To get a list of valid button names, refer to the output of
+
with:
# irrecord --list-namespace
+
The resulting file, {{ic|/tmp/my_remote}}, should then be copied to {{ic|/etc/lirc/lircd.conf}}. If you want to use several remotes, you repeat the irrecord step with each remote and different filenames, and then concatenate all the resulting files into {{ic|/etc/lirc/lircd.conf}}:
+
  
  # cat /tmp/my_remote /tmp/my_remote2 /tmp/my_remote3 > /etc/lirc/lircd.conf
+
  ./configure --enable-sandboxed --prefix=/usr \
 +
    --with-driver=com2 \
 +
    || return 1[/code]
  
{{Note|As of lirc-0.8.6 the default location of lircd, lircmd and lircrcd config files was moved to {{ic|/etc/lirc/lircd.conf}}, {{ic|/etc/lirc/lircmd.conf}} and {{ic|/etc/lirc/lircrc}}. If the config files are not found in that location, they are still searched at the old location in {{ic|/etc/.}}}}
+
Where you replace com2 with the com-port you need.
  
===Testing===
+
Build and install the package:
  
First start the lircd daemon:
+
$ makepkg
 +
# pacman -U lirc-version.pkg.tar.gz
  
# /etc/rc.d/lircd start
+
====Loading====
  
A good way to see if LIRC is running is to run irw.
+
Now try to load the serial module:
  
  $ irw
+
  # modprobe lirc_serial
  
When you press a button, you should see something like this:
+
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)
  
0000000000000001 00 play sony2
+
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)
0000000000000001 01 play sony2
+
0000000000000001 02 play sony2
+
0000000000000001 03 play sony2
+
  
In this case the remote is called sony2, the button is called play, and LIRC has seen it 4 times.
+
You will have to release the serial port:
  
==Run LIRC at bootup==
+
# setserial /dev/ttySx uart none
  
Remember if you had to execute the setserial command while [[LIRC#Loading|loading]] the module?
+
(Replace x with your port number)
  
If so, [[LIRC#Your serial port support is compiled into the kernel|your serial port support is compiled into the kernel]]
+
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===
 
===Your serial port support is compiled as a module in the kernel===
Line 229: Line 245:
  
 
===Your serial port support is compiled into the kernel===
 
===Your serial port support is compiled into the kernel===
 +
 +
{{Out of date|[[initscripts]] is deprecated}}
  
 
This is more complicated, you cannot just add the lirc_serial to the modules list in {{ic|/etc/rc.conf}}, as the serial port should be released first.
 
This is more complicated, you cannot just add the lirc_serial to the modules list in {{ic|/etc/rc.conf}}, as the serial port should be released first.
Line 267: Line 285:
 
Now load the daemons: add "start_lirc" and "lircd" to the daemons list in {{ic|/etc/rc.conf}}
 
Now load the daemons: add "start_lirc" and "lircd" to the daemons list in {{ic|/etc/rc.conf}}
  
==Program specific configuration==
+
== See also ==
 
+
===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 {{ic|lircd.conf}} handy prior to running. It will then produce a sane {{ic|.lircrc}} for the current user.
+
 
+
[https://aur.archlinux.org/packages.php?ID=33849 Mythbuntu's Lirc/Lircrc Generator is available on AUR]<br/>
+
[http://manpages.ubuntu.com/manpages/intrepid/man1/mythbuntu-lirc-generator.1.html 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 [https://wiki.archlinux.org/index.php/Arch_Build_System ABS].
+
 
+
Add " --enable-lirc" to the {{ic|./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 {{ic|.lircrc}} file.  In your home directory, type:
+
+
$ xine --keymap=lirc>.lircrc
+
 
+
Now, in order to have a functioning xine+lirc, edit the {{ic|.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 {{ic|.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.
+
 
+
{{hc|~/.lircrc|2=##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.
+
 
+
{{hc|~/.lircrc|2=##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:
+
 
+
{{hc|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===
+
 
+
{{hc|~/.lircrc|2=##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:
+
{{bc|$ 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:<br>
+
 
+
1. In file {{ic|/etc/conf.d/lircd.conf}} add:<br>
+
{{bc|1=LIRC_DRIVER="dvico"}}
+
2. Reload LIRC:
+
{{bc|/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)===
+
{{Note|Xorg now auto recognizes this remote as a keybaord!}}
+
To disable this behavior, add the following to {{ic|/etc/X11/xorg.conf.d/90-streamzap.conf}}:
+
{{bc|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
+
{{hc|/etc/modules-load.d/lirc_streamzap.conf|#modules for streamzap remote
+
lirc_dev
+
streamzap
+
}}
+
#Create your {{ic|/etc/lirc/lircd.conf}} (for this remote, copy {{ic|/usr/share/lirc/streamzap/lircd.conf.streamzap}} to {{ic|/etc/lirc/lircd.conf}})
+
#Fix the broken lirc.service file:
+
 
+
{{hc|/usr/lib/systemd/system/lirc.service|[Unit]
+
Description&#61;Linux Infrared Remote Control
+
+
[Service]
+
EnvironmentFile&#61;/etc/lirc/lircd.conf
+
ExecStartPre&#61;/usr/bin/ln -sf /run/lirc/lircd /dev/lircd
+
ExecStart&#61;/usr/bin/lircd --pidfile&#61;/run/lirc/lircd.pid -d /dev/lirc0
+
Type&#61;forking
+
PIDFile&#61;/run/lirc/lircd.pid
+
+
[Install]
+
WantedBy&#61;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 {{ic|lircd -d /dev/...}} to start lircd with a certain device. Run {{ic|irw}} and test it out. When you find the right device, modify {{ic|/usr/lib/systemd/system/lirc.service}} accordingly.
+
 
+
#Start lircd via {{ic|# systemctl start lirc}} to survive a reboot use {{ic|# 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
+
 
+
{{Note|When the batteries in this remote are low, it may stop working even though the red LED on the received still flashes when you hit buttons!}}
+
 
+
=== 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.
+
{{hc|/etc/udev/rules.d/z98-serial.rules|
+
# For serial port ttyS0 and LIRC
+
KERNEL&#61;&#61;"ttyS0",SUBSYSTEM&#61;&#61;"tty",DRIVERS&#61;&#61;"serial",MODE&#61;"0666"}}
+
 
+
2. Create the needed modprobe configs
+
{{hc|/etc/modules-load.d/lirc_serial.conf|lirc_serial}}
+
{{hc|/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&#61;0
+
remove lirc_serial /sbin/modprobe -r --first-time --ignore-remove lirc_serial && /sbin/modprobe -r lirc_dev}}
+
{{Note|Using [[udev]] rules to run the setserial command does not work in my experience because lirc_serial gets loaded before the serial port rules are applied.}}
+
 
+
3. Install your systemd service file.
+
{{hc|/etc/systemd/system/lirc.service|[Unit]
+
Description&#61;Linux Infrared Remote Control
+
After&#61;network.target
+
 
+
[Service]
+
Type&#61;simple
+
PIDFile&#61;/run/lirc/lircd.pid
+
ExecStartPre&#61;/bin/rm -f /dev/lirc /dev/lircd /var/run/lirc/lircd
+
ExecStart&#61;/usr/sbin/lircd -n -r -P /run/lirc/lircd.pid -d /dev/lirc0 -o /run/lirc/lircd
+
ExecStartPost&#61;/usr/bin/ln -sf /run/lirc/lircd /dev/lircd
+
ExecStartPost&#61;/usr/bin/ln -sf /dev/lirc0 /dev/lirc
+
ExecReload&#61;/bin/kill -SIGHUP $MAINPID
+
 
+
[Install]
+
WantedBy&#61;multi-user.target}}
+
 
+
4. We still need the default tmpfiles to be created, so copy that config file to {{ic|/etc/tmpfiles.d/lirc.conf}}.
+
{{bc|# cp -a /usr/lib/tmpfiles.d/lirc.conf /etc/tmpfiles.d/lirc.conf}}
+
 
+
5. Create a {{ic|.lircrc}} file in your home directory for your user or a {{ic|/etc/lirc/lircrc}} file for system wide use.
+
 
+
6. Have your service start at boot and then test with a reboot
+
{{bc|1=# systemctl enable lirc.service
+
# systemctl reboot}}
+
 
+
or load the module and start the lirc.service.
+
{{bc|# 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:
+
 
+
{{hc|/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 {{ic|/etc/rc.local}}:
+
{{hc|/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 {{ic|rc.local}}. It is possible to use tmpfiles.d (read "man tmpfiles.d") to run the command {{ic|echo lirc > /sys/class/rc/rc0/protocols}}. Create the file {{ic|/etc/tmpfiles.d/lirc-protocols.conf}}:
+
{{hc|/etc/tmpfiles.d/lirc-protocols.conf|<nowiki>
+
w /sys/class/rc/rc0/protocols - - - - lirc
+
</nowiki>}}
+
 
+
{{Note|It is also a good idea to remove the old LIRC kernel module from your MODULES array in {{ic|/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 {{bug|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 -- {{ic|/var/log/lirc}} shows error finding {{ic|/dev/lirc}}:
+
{{bc|lircd: could not get file information for /dev/lirc}}
+
 
+
Workaround: make a symbolic link for {{ic|/dev/lirc}} that points to {{ic|/dev/lirc0}} with file {{hc|/etc/tmpfiles.d/lirc-dev.conf|<nowiki>
+
L /dev/lirc - - - - /dev/lirc0
+
</nowiki>}}
+
 
+
==== Replacing/overriding the existing service file ====
+
 
+
{{hc|/etc/systemd/system/multi-user.target.wants/lirc.service|<nowiki>
+
 
+
[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</nowiki>}}
+
 
+
{{hc|/etc/conf.d/lircd.conf|<nowiki>
+
 
+
#
+
# Parameters for lirc daemon
+
#
+
LIRC_DEVICE="YOUR DEVICE"
+
LIRC_DRIVER="YOUR DRIVER"
+
LIRC_EXTRAOPTS=""
+
LIRC_CONFIGFILE="/etc/lircd.conf"</nowiki>}}
+
 
+
With these you can start the daemon with preferred parameters from the config file.
+
 
+
{{ic|<nowiki>EnvironmentFile=</nowiki> }} in the service file specifies the file with service parameters.
+
{{ic|<nowiki>–device=${LIRC_DEVICE} –driver=${LIRC_DRIVER} $LIRC_EXTRAOPTS ${LIRC_CONFIG}</nowiki> }}
+
uses the created variables from file as parameters to the daemon.
+
  
==See also==
+
* [http://www.mythtv.org/wiki/Category:Remote_Controls MythTV Wiki:Remotes article]
* http://www.mythtv.org/wiki/Category:Remote_Controls -- MythTV wiki main LIRC article
+
* [http://lirc.org/html/table.html Official list of supported hardware]
* http://www.mythtv.org/wiki/MCE_Remote -- MythTV wiki on MCE remotes
+
* http://en.gentoo-wiki.com/wiki/LIRC -- Gentoo wiki LIRC how-to
+
* https://aur.archlinux.org/packages.php?ID=33849 -- Lirc/Lircrc Configuration Generator
+

Revision as of 09:50, 11 January 2014

Related articles

This article covers setup and usage of LIRC "Linux Infrared Remote Control" with serial or USB infrared devices.

Overview

LIRC is a daemon that can translate key presses on a supported remote into program specific commands. In this context, the term, "program specific" means that a key press can do different things depending on which program is running and taking commands from LIRC.

The Central Dogma of LIRC

The list below attempts to show the flow of information from the remote to the program using LIRC:

  • User hits a button on the remote causing it to transmit an IR or RF signal.
  • The signal is received by the receiver connected to the Linux box.
  • The kernel (via the correct module) uses /dev/lirc0 to characterize the pulse-length information from the receiver.
  • /usr/bin/lircd uses the information from /etc/lirc/lircd.conf convert the pulse-lengths into button press information.
  • Programs that use LIRC translate the button press info from /usr/bin/lircd into user-defined actions according to ~/.lircrc.

Summary of Required Files

  • /etc/lirc/lircd.conf - System-level config translating scancodes --> keys. Is specific to each remote control/receiver on the system and can contain configure for multiple remotes and/or receivers if need be.
  • ~/.lircrc - File containing an include statement pointing to each program's lirc map, i.e., ~/.lirc/foo, ~/.lirc/bar, etc.
  • ~/.lirc/foo - User-level config translating of keys --> actions. Is specific to each remote and to application foo.

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

Some remotes are identified as "keyboards" and function as such without LIRC. This is problematic and can result in a doubling of commands. Test if this is the case by opening a shell or a text editor, and by pressing buttons on the remote itself. If letters/numbers appear, or if the up/down/left/right arrow keys behave as the up/down/left/right arrow keys on the physical keyboard, a workaround to disable this is required. See, LIRC#Remote_functions_as_a_keyboard for a solution before continuing.

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.

Note: Common configs are provided by lirc-utils, like those bundled with TV cards that can be installed automatically. The primary source of config files is the LIRC homepage. Check the official list of supported hardware to know, which LIRC kernel modules and lircd driver required.

Use a Prebuild Config File

Identify which remote/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 created (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.

Note: Consider sending the finished config file to the email address mentioned in the program so it can be made available to others.

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

Program Specific Configuration

LIRC has the ability to allow for different programs to use the same keypress and result in unique commands. In other words, mplayer and vlc can respond differently to a given key press.

Decide which programs are to use LIRC commands. Common programs include: mplayer, mythtv, totem, vlc, and xbmc.

Note: XBMC implements LIRC in a non-standard way. Users must edit ~/.xbmc/userdata/Lircmap.xml which is a unique xml file, rather than the LIRC standard files the rest of the programs use. Interested users should consult the Xbmc#Using_a_remote_controller article.

Users should create the expected files showing LIRC where the various program-specific maps reside:

$ mkdir ~/.lirc
$ touch ~/.lircrc
  • Populate ~/.lirc with the program specific config files named for each program.

Example:

$ ls ~/.lirc
mplayer
mythtv
vlc
Note: Providing an exhaustive listing of keymaps for each program is beyond the scope of this wiki article. Many pre-made files unique to each remote/program are available via googling.
  • Edit ~/.lircrc to contain an include statement pointing to ~/.lirc/foo and repeat for each program that is to be controlled by LIRC.

Example:

~/.lircrc
include "~/.lirc/mplayer"
include "~/.lirc/mythtv"
include "~/.lirc/vlc"

Troubleshooting

Remote functions as a keyboard

Xorg detects some remotes, such as the Streamzap USB PC Remote, as a Human Interface Device (HID) which means some or all of the keys will show up as key strokes as if entered from the physical keyboard. This behavior will present problems if LIRC is to be used to manage the device. To disable, create the following file and restart X:

/etc/X11/xorg.conf.d/90-streamzap.conf
Section "InputClass"
  Identifier "Ignore Streamzap IR"
  MatchProduct "Streamzap"
  MatchIsKeyboard "true"
  Option "Ignore" "true"
EndSection

Don't forget to alter the MatchProduct property according to one shown in Name from output of

$ cat /proc/bus/input/devices | grep -e IR

For example WinFast for N: Name="cx88 IR (WinFast DTV2000 H rev."

Legacy Info Which Needs to be Modernized and Vetted for Accuracy

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Someone with greater knowledge needs vet everything below this line for accuracy. (Discuss in Talk:LIRC#)

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Parts of the following are out-of-date and need to be modernized. (Discuss in Talk: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 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.

Note: If you have more than one ir device then there may be multiple directories under /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"
Note: Here we set up a LIRC device with the id 3353_3713, you should replace it with your own device input event name, whatever it is.

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
Note: LIRC 0.8.6 has changed the default socket location from /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

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: initscripts is deprecated (Discuss in Talk:LIRC#)

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

See also