Guide: Configuring Orange PI PC+ to receive IR with LIRC


Recommended Posts

Guide: Configuring Orange PI PC to receive IR/InfraRed and fix Lirc

I also show how VNC can be used to do remote control on orangepipc+  on the example of kodi.

Should be the same on orangepipc boards.

If a USB IR receiver is used the problem ma not be present at all, but i use the on-board IR receiver. 

 

Is dirty work around, if someone knows how to fix it correctly please tell! 

(I installed the latest version of LIRC  0.9.4b from the source code and compiled it, but it din not fix the problem. So i stay with the version ARMBIAN 5.25 stable Ubuntu 16.04.1 LTS 3.4.113-sun8i comes with.)

 

If the LIRC tool irw cant be started  and reports:  (See also the doku for ubuntu and lirk https://wiki.ubuntuusers.de/Lirc/#lirc.fdi)

No such file or directory

The bug is present, and the lirc demon also want work.

The directory /var/~run is a symbolic link and somehow the lirk demon has a problem with it.

 

The proper way is to use a option for the lircd demon.

There is an option for the demon to use a different output directory as the default /var/run/lirc   --output <output socket>

If used with option --output specified make a directory that lirc demon can use:

mkdir /run/lirc

(Unfortunately the tool irexec has no option for supplying a path to the socket. The newer lirc version 9.0.4b can use an environment variable for this.)

The problem may only be present in some cases.   

--------------------------------------------------------------------------------------------------------------------------

The following description is how one can test step by step that IR remote control is working:

 

Make sure nothing is running stopping the process is needed:

 

root@orangepipcplus:~# /etc/init.d/lirc stop
[ ok ] Stopping lirc (via systemctl): lirc.service.

 

Install additional tool we use later on.

apt-get install ir-keytable

 

Start kernal modul (http://linux-sunxi.org/IR) sunix_cir

modprobe sunxi-cir
(or edit /etc/modules and aktiviere sunxi-cir and reboot.)

We need to find out some info:

cat /proc/bus/input/devices

(should list sunix-ir if not the Kernal modul is not loaded)
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="sunxi-ir"
P: Phys=sunxi-ir/input1
S: Sysfs=/devices/virtual/rc/rc0/input3
U: Uniq=
H: Handlers=kbd event3 cpufreq_interactive
B: PROP=0
B: EV=100013
B: KEY=1000000 0 0 0 0
B: MSC=10

 

lsmode should list sunix_cir
root@orangepipcplus:~# lsmod
Module                  Size  Used by
ir_lirc_codec           3650  0
lirc_dev                7834  1 ir_lirc_codec
ir_mce_kbd_decoder      2885  0
ir_sanyo_decoder        1480  0
ir_sony_decoder         1422  0
ir_jvc_decoder          1452  0
ir_rc6_decoder          1941  0
ir_rc5_decoder          1412  0
ir_nec_decoder          1556  0
sunxi_cir               1601  0
rc_core                12727  10 ir_lirc_codec,ir_rc5_decoder,ir_nec_decoder,ir_sony_decoder,sunxi_cir,ir_mce_kbd_decoder,ir_jvc_decoder,ir_rc6_decoder,ir_sanyo_decoder
mali_drm                2732  1
drm                   178255  2 mali_drm
pcf8591                 3363  0
bmp085                  3487  0
mali                  123146  0
ump                    29379  3 mali
8189fs               1050451  0
btrfs                 712409  0
root@orangepipcplus:~# ^C
root@orangepipcplus:~#

 

The two commands above can be left out because ir-ketable reports all we need! ir-keytable also may be used instead or on combination with LIRC. See more info on https://wiki.ubuntuusers.de/Kodi_Remote/  and http://www.yavdr.org/documentation/de/ch02s03.html#idp6463520.

 

root@orangepipcplus:~# ir-keytable
Found /sys/class/rc/rc0/ (/dev/input/event3) with:
        Driver sunxi-ir, table rc-empty
        Supported protocols: lirc rc-5 jvc sony nec sanyo mce-kbd rc-6
        Enabled protocols: lirc rc-5 jvc sony nec sanyo mce-kbd rc-6
        Name: sunxi-ir
        bus: 25, vendor/product: 0001:0001, version: 0x0100
        Repeat delay = 500 ms, repeat period = 125 ms
root@orangepipcplus:~#

We need to remember (/dev/input/event3)  this can be different on your system.

The following line also can be used for testing remote control functionality. lirc rc-5 jvc sony nec sanyo mce-kbd rc-6 ... are RC protocols as shown above additional or only one may be used to verify witch protocol your remote control is using. 

ir-keytable -c -p NEC,RC-5,RC-6,JVC,SONY, SANYO, MEC-KGB -t

(ir-keytable -c -p NEC -t)

(ir-keytable -c -p RC-5 -t)

Output looks like this with mine if buttons on the remote pressed:
Old keytable cleared
Protocols changed to rc-5 jvc sony nec rc-6
Testing events. Please, press CTRL-C to abort.
1493833179.145623: event type EV_MSC(0x04): scancode = 0x406
1493833179.145637: event type EV_SYN(0x00).
1493833180.683349: event type EV_MSC(0x04): scancode = 0x444
1493833180.683363: event type EV_SYN(0x00).
1493833181.529723: event type EV_MSC(0x04): scancode = 0x407
1493833181.529735: event type EV_SYN(0x00).

 

Up to now we just used the kernal Modul and not LIRC.

Reboot for safety! 

reboot

systemctl daemon-reload && /etc/init.d/lirc stop

We start the demon in a n extra terminal window with ssh and putty in my case!

root@orangepipcplus:~# lircd --nodaemon --device /dev/lirc0 --driver default --output /run/lirc/lircd 
lircd-0.9.0[4614]: lircd(default) ready, using /run/lirc/lircd

 

Don't enter other command line commends within this window is only for watching what the demon is doing.
Go back to the first terminal window and enter more commands:

 

Install additional optional tool ncat with:

( apt-get install nmap 

ncat and irw can be used for the same task.

 /usr/bin/ncat -U /run/lirc/lircd )
 /usr/bin/irw /run/lirc/lircd

root@orangepipcplus:~#  irw /run/lirc/lircd
0000000020df22dd 04 KEY_OK LG-AKB72915207
0000000020df609f 00 KEY_RIGHT LG-AKB72915207
0000000020df22dd 00 KEY_OK LG-AKB72915207
0000000020df02fd 01 KEY_UP LG-AKB72915207
0000000020dfe01f 00 KEY_LEFT LG-AKB72915207
0000000020df827d 01 KEY_DOWN LG-AKB72915207
 

if no out put is generated something is wrong with the file /etc/lirc/lircd.conf

 

The following command can be used to generate a functional /etc/lirc/lircd.conf Be aware that not all remote control's will work. Have more as one for testing.  

systemctl daemon-reload && /etc/init.d/lirc stop
irrecord -d /dev/lirc0 /etc/lirc/lircd.conf

My generated file looks like this:


# Please make this file available to others
# by sending it to <lirc@bartelmus.de>
#
# this config file was automatically generated
# using lirc-0.9.0(default) on Wed May  3 13:58:01 2017
#
# contributed by
#
# brand:                       /etc/lirc/lircd5.conf
# model no. of remote control:
# devices being controlled by this remote:
#

begin remote

  name  LG-AKB72915207
  bits           16
  flags SPACE_ENC|CONST_LENGTH
  eps            30
  aeps          100

  header       9022  4488
  one           552  1690
  zero          552   578
  ptrail        552
  repeat       9017  2252
  pre_data_bits   16
  pre_data       0x20DF
  gap          141229
  toggle_bit_mask 0xCECE

      begin codes
          KEY_OK                   0x22DD
          KEY_DOWN                 0x827D
          KEY_UP                   0x02FD
          KEY_LEFT                 0xE01F
          KEY_RIGHT                0x609F
          KEY_VOLUMEUP             0x40BF
          KEY_VOLUMEDOWN           0xC23D
      end codes

end remote

 

Output on the demon terminal window is like this:


Last login: Wed May  3 18:02:03 2017 from 192.168.178.49
root@orangepipcplus:~# modprobe sunxi-cir
root@orangepipcplus:~#  lircd --nodaemon --device /dev/lirc0 --driver default
lircd-0.9.0[2763]: lircd(default) ready, using /var/run/lirc/lircd
lircd-0.9.0[2763]: accepted new client on /var/run/lirc/lircd
lircd-0.9.0[2763]: removed client

 

Now you can close the demon window and run the demon in the background without the  --nodaemon option

lircd --device /dev/lirc0 --driver default

 

Keep in mind with this command line the demon runs without /etc/lirc/hardware.conf file!

Here is my harware.conf file:

 

REMOTE="None"
REMOTE_MODULES="sunix-cir"
REMOTE_DRIVER="default"
REMOTE_DEVICE="/dev/lirc0"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS=""
TRANSMITTER="None"
TRANSMITTER_MODULES="sunix-cir"
TRANSMITTER_DRIVER="default"
TRANSMITTER_DEVICE="/dev/lirc0"
TRANSMITTER_SOCKET=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""
START_LIRCD="true"
START_LIRCMD="false"
LOAD_MODULES="true"
LIRCMD_CONF=""
FORCE_NONINTERACTIVE_RECONFIGURATION=""

 

 

The next step is that in the ubunto or may be also in the debian setup a script  /init.d/lirc is in use to start the service in the background.  

Only this script uses the file /etc/hardware.conf.  This script is extremely suspect and may be one of the reasons way in some cases problems arise.

Finally i set the variable LOAD_MODULES="false"  and  activated the modul in the file /etc/mudules. 

echo sunix-cir | sudo tee -a /etc/modules  

reboot.

 

This led to the circumstance that the service stated at reboot.

 

Have a look at /var/log/syslog to find out if the demon starts as it should.

 

USING with kodi:

 

If sunix-cir and lircd is working popper what it was not in may case and the hardware.conf is as it was from a clean install:

 

sed -i s/'#DISABLE_KERNEL_SUPPORT="true"'/'DISABLE_KERNEL_SUPPORT="false"'/ /etc/lirc/hardware.conf;
sed -i s/'START_LIRCD="false"'/'START_LIRCD="true"'/ /etc/lirc/hardware.conf;
 

apt-get install kodi #install kodi

systemctl daemon-reload && /etc/init.d/lirc stop

rm -rf /etc/lirc/lircd.conf
irrecord -H default -d /dev/lirc0 /etc/lirc/lircd.conf  # Record your remote or use a config-file you already have. Keep in mind the names for keys are limited and must correspond to the names used in ~/.kodi/userdata/Lircmap.xml

systemctl daemon-reload && /etc/init.d/lirc start

(Now logged in as normal user that was set up when first time Armbian was booted!)

(find / -name Lircmap.xml  #find the location of a template-file that makes the final key mapping for kodi) 
cp /usr/share/kodi/system/Lircmap.xml ~/.kodi/userdata/Lircmap.xml  #copy the template to your user directory
sudo sed -i s#'</etc/lirc/lircd.config>'#'<SAMSUNG>'# /etc/lirc/lircd.config # Replace the Name of your remote  in lircd.config to "SAMSUNG" or what you want.
sudo sed -i s#'<remote device="mceusb">'#'<remote device="SAMSUNG">'# ~/.kodi/userdata/Lircmap.xml # Also adapt the NAME to the same in Lircmap.xml 
reboot

----------------------------------------------------------------------------------------------------------------

If the demon does not do the loading of the modul sunix-cir as in my case i removed the file:

rm /etc/init.d/lirc # leads to the case that the demon is not started at boot time, etc/hardware.conf is not in use any more ether.

 

I added the following three lines to /etc/rc.local before the final exit 0

if [ -d "/run/lirc" ]; then rm -Rf  /run/lirc; fi 
mkdir -pv /run/lirc
/usr/sbin/lircd --driver=default --device=/dev/lirc0 --uinput --output=/var/run/lirc/lircd --pidfile=/var/run/lirc/lircd.pid /etc/lirc/lircd.conf 

And edited the file /etc/modules by removing the # in front of sunix-cir

to start sunix-cir modul at boot time.

Or invoke this line to add an additional line.

echo sunix-cir | sudo tee -a /etc/modules

reboot

You also can use an add-on in kodi to edit the keys in use. -> progamms -> add-ons -> Keymap Editor

(install it first in kodi:  system -> add-on -> install from repository -> Keymap Editor)

Kodi Sound:

Needs a additional file in /etc/asound.conf  #See  http://alpha6.ru/blog/2016/10/09/orange-pi-armbian-kodi/

 

pcm.snd_card { type hw card 1 device 0 }

ctl.snd_card { type hw card 1 device 0 }

pcm.dmixer { type dmix ipc_key 1024 ipc_perm 0666 slave.pcm "snd_card" slave { period_time 0 period_size 1024 buffer_size 4096 rate 48000 format S32_LE channels 2 } bindings { 0 0 1 1 } }

 

It is also possible to use VNC Client on the PC and server on orange pipc+ to get the Screen of codi to the PC. http://www.tightvnc.com/download/2.8.3/tvnjviewer-2.8.3-bin-gnugpl.zip

extract the file tightvnc-viewer.jar and put it on the desktop or elsewhere to klick on it for starting.

TightVNC is just a single java executable, needs java to be installed on the PC.

 

On orange pi:

 

sudo apt-get -y install x11vnc vnc4server xinetd vnc-java xfonts-base
sudo x11vnc -storepasswd yourpassword /etc/x11vnc.pass

This two lines are for starting, can but done also via etc/rc.local so VNC starts ever time the Linux is rebooted.  

vncserver # first time use a password has to be setup as well, just follow the Questions presented after invoking
x11vnc -display :0 & 

 

I also installed kodi with lirkd on OPENelec lirkd is there installed a bit different. The socket directory is not on a linked path. /var/run/ the path /run/ is used instead.

This lead to the case that irw has not problem when it is invoked without explicit added path. I don't know why armbian must use this linked directory but insider may know why. 

 

Kernel modul also has to be loaded at startup by adding modeprobe sunix-cir to /storage/.config/autostart.sh.

See also:

 

 

 

 

 

 

 

 

 

 

    


 
Link to post
Share on other sites
Armbian is a community driven open source project. Do you like to contribute your code?

Guest
This topic is now closed to further replies.