Difference between revisions of "LIRC Device Examples"

From ArchWiki
Jump to: navigation, search
(split out this section from LIRC on 08-Dec-2013 6:41 EST)
(No difference)

Revision as of 11:41, 8 December 2013

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)

Note: Xorg now auto recognizes this remote as a keybaord!

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
  1. Install both packages (lirc lirc-utils)
  2. 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
  1. Create your /etc/lirc/lircd.conf (for this remote, copy /usr/share/lirc/streamzap/lircd.conf.streamzap to /etc/lirc/lircd.conf)
  2. 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.

  1. Start lircd via # systemctl start lirc to survive a reboot use # systemctl enable lirc
  2. 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.

/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
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.

/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.