please choosego to mobile | Continue to access the PC version
View: 287240|Reply: 38

[Guide] Android + InfraRed (IR) + Kodi

[Copy link]
Published in 2015-10-16 04:08:34 | Show all floors |Read mode
Edited by darqoq at 2015-10-23 16:47

Hi!
Now, you can control your android and apps liked Kodi using IR Remote Control

1. Tested on Orange Pi PC
2. Tested on loboris images (http://www.orangepi.org/orangepi ... =363&extra=page%3D1)
3. based on https://github.com/cubieplayer/Cubian/issues/75

Scenario:
1. run Terminal Emulator app
2. run su
  1. su
Copy code
3. remount /system
  1. mount -o remount,rw /system
Copy code
3. download files from mega to location /sdcard/Download/
4 create dir
  1. mkdir /etc/lircd
Copy code
5. copy files download from mega to to /etc/lircd/
  1. cp /sdcard/Download/evtest /system/bin/
  2. cp /sdcard/Download/lircd /system/bin/lircd
  3. cp /sdcard/Download/irw /system/bin/irw
  4. cp /sdcard/Download/irrecord /system/bin/irrecord
  5. cp /sdcard/Download/start_lircd.sh /system/bin/start_lircd.sh
  6. cp /sdcard/Download/stop_lircd.sh /system/bin/stop_lircd.sh
Copy code
6. add execute attributes
  1. chmod a+x /system/bin/evtest
  2. chmod a+x /system/bin/lircd
  3. chmod a+x /system/bin/irw
  4. chmod a+x /system/bin/irrecord
  5. chmod a+x /system/bin/start_lircd.sh
Copy code
7. check is module loaded
  1. lsmod | grep sunxi_ir_rx
Copy code
result
  1. sunxi_ir_rx 9154 0 - Live 0x00000000
Copy code
8. find IR event driver
  1. cat /proc/bus/input/devices
Copy code
result
  1. I: Bus=0019 Vendor=0001 Product=0001 Version=0100
  2. N: Name="sunxi-ir"
  3. P: Phys=RemoteIR/input1
  4. S: Sysfs=/devices/virtual/input/input3
  5. U: Uniq=
  6. H: Handlers=sysrq kbd event3 cpufreq_interactive
  7. B: PROP=0
  8. B: EV=100003
  9. B: KEY=ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe
Copy code
9. test driver
  1. evtest /dev/input/event3
Copy code
8. [you can skip this step it is only information]
something wrong is with this module sunxi_ir_rx need to be reloaded
because at the first time evtest shows result and hungs (pressing any key on yout IR remote, should add last line):
  1. ...
  2.     Event code 254 (?)
  3.     Event code 255 (?)
  4.     Event type 20 (Repeat)
  5. Testing ... (interrupt to exit)
  6. Event: time 1444933051.375784, -------------- Report Sync ------------
Copy code


9. reload sunxi_ir_rx  module
  1. rmmod sunxi_ir_rx
  2. insmod /system/vendor/modules/sunxi-ir-rx.ko
Copy code

again check again is module loaded
  1. lsmod | grep sunxi_ir_rx
Copy code
result
  1. sunxi_ir_rx 9154 0 - Live 0x00000000
Copy code
10. check again driver,
  1. cat /proc/bus/input/devices
Copy code
result, ensure it still event3
  1. I: Bus=0019 Vendor=0001 Product=0001 Version=0100
  2. N: Name="sunxi-ir"
  3. P: Phys=RemoteIR/input1
  4. S: Sysfs=/devices/virtual/input/input5
  5. U: Uniq=
  6. H: Handlers=sysrq kbd event3 cpufreq_interactive
  7. B: PROP=0
  8. B: EV=100003
  9. B: KEY=ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe
Copy code
11. test event again
  1. evtest /dev/input/event3
Copy code
result (pressing any key on yout IR remote, should add line with Event)
  1. ...
  2.     Event code 255 (?)
  3.   Event type 20 (Repeat)
  4. Testing ... (interrupt to exit)
  5. Event: time 1444933164.078062, type 1 (Key), code 123 (Hanja), value 1
  6. Event: time 1444933164.078073, -------------- Report Sync ------------
  7. Event: time 1444933164.276381, type 1 (Key), code 123 (Hanja), value 0
  8. Event: time 1444933164.276389, -------------- Report Sync ------------
  9. Event: time 1444933164.477201, type 1 (Key), code 123 (Hanja), value 1
  10. Event: time 1444933164.477211, -------------- Report Sync ------------
  11. Event: time 1444933164.676388, type 1 (Key), code 123 (Hanja), value 0
  12. Event: time 1444933164.676396, -------------- Report Sync ------------
Copy code
it works, but still need some configurations ...
12. now record your IR remote,
  1. /system/bin/irrecord -H devinput -d name=sunxi-ir /etc/lircd/lircd.conf
Copy code
You can see allowed key names with
  1. /system/bin/irrecord -l
Copy code
Check /etc/lircd/lircd.conf, if your key codes are doubled like
  1. begin codes
  2.         KEY_0                    0x0100FF00000001 0x00000000000000
  3.         KEY_1                    0x01000100000001 0x00000000000000
  4.       end codes
Copy code
edit /etc/lircd/lircd.confand manually remove the second code part (0x00000000000000)
result:
  1. begin codes
  2.          KEY_0                    0x0100FF00000001
  3.          KEY_1                    0x01000100000001
  4.       end codes
Copy code
edit /etc/lircd/lircd.conf and change the 'name' from lircd.conf  to devinput or linux-input-layer (this remote names are predefined in Kodi configuration)
  1. begin remote
  2.     name  devinput
Copy code
Especially record keys like:
KEY_DOWN, KEY_UP, KEY_LEF, KEY_ENTER, KEY_BACK
13. Test
run lirc daemon
  1. /system/bin/start_lirc.sh
Copy code
run irw and press some keys (recorded, definded in/etc/lircd/lircd.conf) on your remote:
  1. /system/bin/irw /dev/lircd
  2. 000100c300000001 00 KEY_OK myremote
  3. 000100c500000001 00 KEY_DOWN myremote
  4. 000100a800000001 00 KEY_KPPLUS myremote
  5. 000100a000000001 00 KEY_POWER myremote
  6. 0001000800000001 00 KEY_8 myremote
  7. 0001000100000001 00 KEY_1 myremote
  8. 0001000600000001 00 KEY_6 myremote
Copy code
14. Enjoy - SUCCESS : LIRC is working fine !
now you can control yout android apps and especially  Kodi with yout IR remote control
15. to stop daemon:
  1. /system/bin/stop_lirc.sh
Copy code



Orange PI PC

2

threads

36

posts

1443

credits

Gold member

Rank: 6Rank: 6

credits
1443
Published in 2015-11-2 02:20:34 | Show all floors
I make script file and use Script Manager.
My script:
  1. #!/system/bin/sh
  2. mount -o remount,rw /system
  3. rmmod sunxi_ir_rx
  4. insmod /system/vendor/modules/sunxi-ir-rx.ko
  5. /system/bin/start_lircd.sh
  6. am start -n org.xbmc.kodi/org.xbmc.kodi.Splash
Copy code

0

threads

5

posts

74

credits

Registered member

Rank: 2

credits
74
Published in 2015-10-17 00:13:24 | Show all floors
Thank you for this guide, I've checked it with Elenberg DVD player IR remote, it works ok, but I tried to use Philips pfl7605 remote and "evtest /dev/input/event3" hasn't any response for remote's buttons. It will be very well to control Kodi and tv from one remote, so how make system recognize Philips tv remote signals?
 Author| Published in 2015-10-17 16:49:15 | Show all floors
Hmm, I don't know but maybe It is a problem with this module
I read that "the IR-receiver emulates keyboard input",
(especially that location of this module is ../drivers/input/keyboard/sunxi-ir-rx.*).
So maybe your Elenberg DVD player IR remote emulates keyboard keys,
and Philips remote are not.

Maybe better option is find other IR module.
Orange PI PC

0

threads

5

posts

26

credits

Novice

Rank: 1

credits
26
Published in 2015-10-18 05:38:43 | Show all floors
Hi. I got two problems. system/sbin doesnt exist i create it and copy evtest, but when I execute it says can't execute: permission denied
Thank you in advance
alex
 Author| Published in 2015-10-18 06:30:28 | Show all floors
You probably use other android disto (without /system/sbin).
Choose any other location (for example on ext4 filesystem)
and add execute attributes (chmod) then check,
also check that you have root privileges (whoami).
Orange PI PC

0

threads

5

posts

74

credits

Registered member

Rank: 2

credits
74
Published in 2015-10-19 01:21:28 | Show all floors
Is it possible to switch between "sleep" and working modes with IR remote? It seems my board doesn't go out from "sleep" (no video signal, green LED turns on) mode with IR remote. It doesn't react to remote's signals while "sleeping"
 Author| Published in 2015-10-19 02:02:34 | Show all floors
Are you talking about sleep mode in Kodi ?
or Android sleep mode ?

When android is sleeping I think that IR receiver is still working.
I suggest you to use irexec (http://www.lirc.org/html/irexec.html)
and log any button you pressed.
Then wait for sleep mode and start pressing buttons, then check log.
If receiver works, you have to use irexec (with any command you find to wake up your OS).
Orange PI PC

3

threads

165

posts

1203

credits

Gold member

Rank: 6Rank: 6

credits
1203
Published in 2015-10-20 22:28:00 | Show all floors
Edited by Dima at 2015-10-20 22:33

Good tutorial!

I tried a million remotes which didn't work. Then just took a universal remote and started a search. It found a match and all the buttons gave a command. So I assume that reprogramming would work great. Though I still need to find a better remote, because the universal remote has some bad buttons which are hard to press.

Nonetheless, it's a step in the right direction. I look forward to complete the set-up.

BTW: I did use the loboris image,though it didn't have /system/sbin, so I just created the directory. Though evtest had to be done through /system/sbin/evtest.
Also, 1 time you mention "/etc/lircd.conf" and another time you mention "/etc/lircd/lircd.conf". Which one is the correct one?

Same for "
/etc/init.d/start_lirc.sh", though the cp command went to "/system".

0

threads

5

posts

74

credits

Registered member

Rank: 2

credits
74
Published in 2015-10-21 00:09:40 | Show all floors
I talk about Android sleep mode, not Kodi. Something strange is going on with my board in sleep mode: using only onboard power button (without IR remote and lircd installed) I can't get it out from sleep mode. I need to unplug power and connect it again for reboot and there is no reaction to power button pressing. At working mode power button works OK - short pressing - sleep mode, long pressing - shutdown menu). Using IR remote is the same situation. It seems IR receiver and power button stop working in sleep mode or CPU hangs?

3

threads

165

posts

1203

credits

Gold member

Rank: 6Rank: 6

credits
1203
Published in 2015-10-23 22:59:54 | Show all floors
Found a remote, though the lircd server isn't really working. I think that another distro is needed (no /etc/init.d or /system/sbin) and the tutorial has to be corrected in some places (ie /etc/lircd.conf --> /etc/lircd/lircd.conf). Also the start_lircd.sh has to be adapted to the correct path.

Will play with it next week, and will give the necessary corrections.
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list