Please select To the mobile version | Continue to access the desktop computer version

OrangePi

 Login            
 Register            
Search
Hot search: orangepi
1234Next
Return to list New
View: 239972|Reply: 36

[Guide] Android + InfraRed (IR) + Kodi

[Copy link]
Post time 2015-10-16 04:08:34 | Show all posts |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 the Code
3. remount /system
  1. mount -o remount,rw /system
Copy the Code
3. download files from mega to location /sdcard/Download/
4 create dir
  1. mkdir /etc/lircd
Copy the 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 the 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 the Code
7. check is module loaded
  1. lsmod | grep sunxi_ir_rx
Copy the Code
result
  1. sunxi_ir_rx 9154 0 - Live 0x00000000
Copy the Code
8. find IR event driver
  1. cat /proc/bus/input/devices
Copy the 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 the Code
9. test driver
  1. evtest /dev/input/event3
Copy the 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 the Code


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

again check again is module loaded
  1. lsmod | grep sunxi_ir_rx
Copy the Code
result
  1. sunxi_ir_rx 9154 0 - Live 0x00000000
Copy the Code
10. check again driver,
  1. cat /proc/bus/input/devices
Copy the 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 the Code
11. test event again
  1. evtest /dev/input/event3
Copy the 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 the 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 the Code
You can see allowed key names with
  1. /system/bin/irrecord -l
Copy the 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 the 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 the 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 the 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 the 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 the 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 the Code



Orange PI PC

2

Threads

36

Posts

1443

Credits

Gold member

Rank: 6Rank: 6

Credits
1443
Post time 2015-11-2 02:20:34 | Show all posts
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 the Code

0

Threads

5

Posts

74

Credits

Registered member

Rank: 2

Credits
74
Post time 2015-10-17 00:13:24 | Show all posts
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| Post time 2015-10-17 16:49:15 | Show all posts
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
Post time 2015-10-18 05:38:43 | Show all posts
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| Post time 2015-10-18 06:30:28 | Show all posts
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
Post time 2015-10-19 01:21:28 | Show all posts
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| Post time 2015-10-19 02:02:34 | Show all posts
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
Post time 2015-10-20 22:28:00 | Show all posts
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
Post time 2015-10-21 00:09:40 | Show all posts
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
Post time 2015-10-23 22:59:54 | Show all posts
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 have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2019-11-18 07:36 GMT+8 , Processed in 0.038684 second(s), 23 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list