Consumer InfraRed Receiver (CIR) - monkeymia/orangepizero GitHub Wiki

Consumer InfraRed Receiver (CIR)

CPU H3 Datasheet

  • Full physical layer implementation; In short: The input signal is sampled with a programmable frequency and stores the pulse-width in Run-Length Code
  • Support CIR for remote control
  • 64x8 bits FIFO data buffer (MSbit indicates polarity, 7bit length)
  • Programmable FIFO thresholds (to reduce noise)
  • Note:Consumer Infrared != Serial Infrared (SIR like UART)
  • Typically Remote frequenzy 38kHz: The frequency is a fraction (1, 64, 128, 256, 512) of ir_clk.

Hardware

Pin exposed at 13 pin connector (IR-RX PL11)

Software

sudo apt install lirc
sudo apt install lirc-compat-remotes
sudo apt install ir-keytable

Overlay:

cir
Activates CIR (Infrared remote) receiver

CIR pin: PL11

from Kernel point of view a consumer infrared is like a keyboard. The lirc driver maps scan-codes to keys.

After reboot the kernel module "sunxi_cir" is loaded (double check with lsmod). It seems, lirc is installed per default.

find the input device :

demonstrator@orangepizero:~$ cat /proc/bus/input/devices
I: Bus=0019 Vendor=0001 Product=0001 Version=0100
N: Name="sunxi-ir"
P: Phys=sunxi-ir/input0
S: Sysfs=/devices/platform/soc/1f02000.ir/rc/rc0/input0
U: Uniq=
H: Handlers=kbd event0
B: PROP=0
B: EV=100013
B: KEY=1000000 0 0 0 0
B: MSC=10
demonstrator@orangepizero:~$ dmesg | grep IR
[    6.752698] lirc_dev: IR Remote Control driver registered, major 243
[    6.767893] IR LIRC bridge handler initialized
[    6.769268] Registered IR keymap rc-empty
[    6.779671] sunxi-ir 1f02000.ir: initialized sunXi IR driver

Depending on whether lirc is used or not application will get data either from the input layer (/dev/input/event0) or from LIRC (/var/run/lirc/lircd).

The device should also be available in /sys/class/rc/, usually as rc0:

cat /sys/class/rc/rc0/protocols
rc-5 nec rc-6 jvc sony rc-5-sz sanyo sharp mce_kbd xmp [lirc]
demonstrator@orangepizero:~$

It seems ir-keytable print a lot helpful information:

demonstrator@orangepizero:~$ ir-keytable
Found /sys/class/rc/rc0/ (/dev/input/event0) with:
      Driver: sunxi-ir, table: rc-empty
      lirc device: /dev/lirc0
      Supported protocols: lirc rc-5 rc-5-sz jvc sony nec sanyo mce_kbd rc-6 sharp xmp
      Enabled protocols: lirc
      Name: sunxi-ir
      bus: 25, vendor/product: 0001:0001, version: 0x0100
      Repeat delay = 500 ms, repeat period = 125 ms
demonstrator@orangepizero:~$

Note: It seems kernel creates device /dev/lirc0 The tool "mode2" show kernel output available for LIRC drivers:

ls /dev/lirc0
# if the above command runs and waits then press any key in your IR remote pointing it to the OPi IR Receiver
mode2 -d /dev/lirc0
Using driver devinput on device /dev/lirc0
code: 0x0c775300500300014003000090060001
code: 0x40030000500300014003000048030001
code: 0x40030000480300014003000050030001

This line actually makes no sense:

Using driver devinput on device /dev/lirc0

The devinput driver requires a device in the /dev/input directory, whereas the default driveruses a /dev/lirc* device like /dev/lirc0.

Changing to default provides expected output:

demonstrator@orangepizero:~$ mode2 -d /dev/lirc0
Using driver default on device /dev/lirc0
Trying device: /dev/lirc0
Using device: /dev/lirc0
space 16777215
pulse 9032
space 4416
pulse 640
space 1608
pulse 632
space 488

demonstrator@orangepizero:~$ mode2 -d /dev/lirc0 --raw
Using raw access on device /dev/lirc0
Using device: /dev/lirc/0
code: 0xffffff00
code: 0x48230001
code: 0x40110000
code: 0x78020001
code: 0x48060000
code: 0x80020001
code: 0xe8010000

The general solution is to capture the codes of your remote :

irrecord /dev/lirc0
cp *.conf /etc/lirc/lircd.conf.d/

Note: Syntax errors are ignored fail silent. It seems irrecord writes two intead of one value - remove it manually.

Test:

sudo irw /run/lirc/lircd

If it does not work read debug/log/status output of lirc deamon :

sudo /etc/init.d/lircd status

Misc

⚠️ **GitHub.com Fallback** ⚠️