Jump to content

Various LIRC failures on OrangePi Zero


DoubleHP

Recommended Posts

I have spent two days on LIRC. I am going to give up if no one can help me on this.

 

My software conf are

ARMBIAN 5.38 stable Ubuntu 16.04.3 LTS 4.14.18-sunxi

and

ARMBIAN 5.35 user-built Ubuntu 16.04.3 LTS 4.13.16-sunxi


 

# cat /etc/lirc/hardware.conf
# /etc/lirc/hardware.conf
#
#Chosen Remote Control
REMOTE="None"
REMOTE_MODULES="sunxi_cir"
REMOTE_DRIVER="default"
REMOTE_DEVICE="/dev/lirc0"
REMOTE_SOCKET=""
REMOTE_LIRCD_CONF=""
REMOTE_LIRCD_ARGS=""

#Chosen IR Transmitter
TRANSMITTER="None"
TRANSMITTER_MODULES=""
TRANSMITTER_DRIVER="audio_alsa"
TRANSMITTER_DEVICE="hw@48000,r"
TRANSMITTER_SOCKET=""
TRANSMITTER_LIRCD_CONF=""
TRANSMITTER_LIRCD_ARGS=""

#Disable kernel support.
#Typically, lirc will disable in-kernel support for ir devices in order to
#handle them internally.  Set to false to prevent lirc from disabling this
#in-kernel support.
#DISABLE_KERNEL_SUPPORT="true"

#Enable lircd
#START_LIRCD="false"
START_LIRCD="true"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD="false"

#Try to load appropriate kernel modules
LOAD_MODULES="true"

# Default configuration files for your hardware if any
LIRCMD_CONF=""

#Forcing noninteractive reconfiguration
#If lirc is to be reconfigured by an external application
#that doesn't have a debconf frontend available, the noninteractive
#frontend can be invoked and set to parse REMOTE and TRANSMITTER
#It will then populate all other variables without any user input
#If you would like to configure lirc via standard methods, be sure
#to leave this set to "false"
FORCE_NONINTERACTIVE_RECONFIGURATION="false"
START_LIRCMD=""


 

# cat /etc/lirc/lircd.conf | grep -v "^#"

begin remote

  name  ATI_Remote_Wonder_II
  bits           24
  eps            30
  aeps          100

  one             0     0
  zero            0     0
  gap          203970
  toggle_bit      0


      begin codes
          KEY_STOP                     0x000231
          KEY_PAUSE                    0x000230
          KEY_FASTFORWARD              0x000228
[...]
          KEY_B                        0x000279
          KEY_POWER                    0x00020C
      end codes

end remote

 

-1- reading internal IR probe

 

I have plugged a classic tri-leg IR receiver on IR-RX pin.

 

The correct way to get it work is to add "cir" on the overlays line of /boot/armbianEnv.txt (or use armbian-config), then reboot. Immediately after reboot you should see /dev/lirc0 available.

 

After installing lirc (aptitude install lirc), start configuring it:


 

# irrecord -d /dev/lirc0 file
[...]
Press RETURN now to start recording.
............................
irrecord: could not find gap.
irrecord: gap not found, can't continue

 

I don't know if this is related to my remote, or if there is an issue with the rpi. But I have not been able to go further using LIRC.

 

My workaround is to read lirc0 manually, and parse the timecodes with this. It's not clean, but it's good enough for me:


 

#!/bin/bash

n=1
t=1
v=400
mode2 -d /dev/lirc0 | {
while true ; do
        read -t 1 line
        [ "$line" = "" ] && {
                # timeout
                [ $n -eq 0 ] && echo "" && n=1
                t=1
                continue
        }
        n=0
        typ="$(echo "$line" | awk '{print $1}')"
        val="$(echo "$line" | awk '{print $2}')"
        z=0
        [ $val -gt $(($v/2)) ] && [ $val -lt $(($v*2)) ] && r=s && z=1
        [ $val -gt $(($v*2)) ] && [ $val -lt $(($v*4)) ] && r=m && z=1
        [ $val -gt $(($v*8)) ] && [ $val -lt $(($v*12)) ] && r=l && z=1
        [ $val -gt $(($v*12)) ] && r=x && z=1
        [ $z -ne 1 ] && {
                echo "${val} ???" >&2
                continue
        }
#       echo "$typ $r"
        [ "$typ" = "space" ] && {
                case "$r" in
                        "s")
                                echo -n "0"
                                t=0
                                ;;
                        "m")
                                echo -n "1"
                                t=0
                                ;;
                        "l")
                                echo "LARGE"
                                ;;
                        "x")
                                true
                                #echo "X"
                                ;;
                        *)
                                echo "???"
                esac
                continue
        }
        # here, we have a pulse.
        case "$r" in
                "s")
                        true
                        ;;
                "l")
                        # begin of frame
                        true
                        #echo -n ":"
                        [ $t -eq 0 ] && echo ""
                        t=1
                        ;;
                *)
                        echo "???"
        esac
done
}

 

This outputs 0s and 1s; and can later be piped to an other similar program to compare lines/strings with a home made database, or whatever.

 

-2- CPU freq issues

 

"armbianmonitor -m" shown me that CPU freq oscillates between 240MHz and 1.2GHz.  I suspect this to affect my issues, and, I have tried unsuccessfully to fix it with the following line:

 

/usr/bin/cpufreq-set -f 1200MHz ; /usr/bin/cpufreq-set -g performance

 

-3- reading audio device

 

Because I need to irsend things, and, after 6h of google, it seems impossible to do it on OrangePi/Armbian (pigpio is unusable on OrangePi/Armbian; Armbian does not include any equivalent of lirc-rpi; it should be possible to write a DTO to handle this, but I don't know how to do it; did not find any real time interface able to produce apropriate signals; still, it should be possible to do it at the very least on the MOSI pin, the same way as for SPI LCD and 1Wire), I have switched to LIRC-ALSA.

 

In short ...
 

irrecord --driver=audio_alsa -d hw@48000,r file
[...]
Press RETURN now to start recording..
.............irrecord: no data for 10 secs, aborting
irrecord: gap not found, can't continue

 

I have tried to run this inside "time"; irrecord can have two extreme reactions:

- freese and never give prompt back ... for a full minute (until ^C) (if I don't press my remote at all, or, once every 5s)

- give hand back after printing 1 to 10 dots, pretending "timeout after 10s", after a duration as short as "1.3s" (I am not showing here my tons of attempts), if I press my remote very fast.

 

As said, fixing the CPU freq did not help.

 

I have cheked 5 times I was working on the good input. IR data line can be plugged on pins MIC1P or MIC1N; then, use alsamixer to enable capture (F4 menu) on MIC1. MIC1_boost and ADC_gain affect the behaviour of irrecord. Best results are obtained with 54% and 57%. Other columns do not affect LIRC.

 

-4- Sending IR frames

 

Not having able to record any conf the proper way, I was unable to fire-send-transmit any stream. So I downloaded a random lircd.conf file, just to have a random "remove" in my conf, to dig irsend.


 

# tail /var/log/syslog
Feb 11 18:54:16 localhost systemd[1]: Starting LSB: Starts LIRC daemon....
Feb 11 18:54:16 localhost lirc[26693]:  * Loading LIRC modules
Feb 11 18:54:16 localhost lirc[26693]:    ...done.
Feb 11 18:54:16 localhost lirc[26693]:  * Starting remote control daemon(s) :
Feb 11 18:54:16 localhost lircd-0.9.0[26704]: lircd(audio_alsa) ready, using /run/lirc/lircd1
Feb 11 18:54:16 localhost lircd-0.9.0[26706]: lircd(default) ready, using /run/lirc/lircd
Feb 11 18:54:16 localhost lircd-0.9.0[26706]: connected to localhost
Feb 11 18:54:16 localhost lirc[26693]:    ...done.
Feb 11 18:54:16 localhost lircd-0.9.0[26704]: accepted new client from 127.0.0.1
Feb 11 18:54:16 localhost systemd[1]: Started LSB: Starts LIRC daemon..
[...]
Feb 11 18:55:03 localhost lircd-0.9.0[26704]: accepted new client on /run/lirc/lircd1
Feb 11 18:55:03 localhost lircd-0.9.0[26704]: error processing command: SEND_ONCE ATI_Remote_Wonder_II KEY_STOP
Feb 11 18:55:03 localhost lircd-0.9.0[26704]: hardware does not support sending
Feb 11 18:55:03 localhost lircd-0.9.0[26704]: removed client

...

# irsend -d /var/run/lirc/lircd1 SEND_ONCE ATI_Remote_Wonder_II KEY_STOP
irsend: command failed: SEND_ONCE ATI_Remote_Wonder_II KEY_STOP
irsend: hardware does not support sending

 

So, I am trying to send data over /var/run/lirc/lircd1, which is confirmed by syslog to be the audio_alsa device. And it complains "hardware does not support sending". Also spent 2h in googling this; no help.

 

Some people mention, /usr/share/lirc/lirc-old2new , but it's not available in my Armbian.

 

-5- External USB-sound dongle

 

Trying to use a USB-sound dongle gave similar (identical ?) results.

 

-6- my need

 

ATM, I am able to input the bits; my real urgent need is to find any way to send frames. Either via GPIO, or ALSA, I don't care. As long as it remains cheap.

 

NB: do not talk about what happen over the air; I am stuck on a software issue; the frames I need to send are never to be converted in actual infra red light; I am working directly on IR data lines inside a device, after optical-electrical conversion.

 

OrangePi hardly can receive IR; and not send any at all. Very sad. I have put too big hope in this cheap machine. I have also given-up on using Opi0 as USB-gadget gateway; opi0 can do only storage gadget; I need HID, and no tutorial explain how to do it with a recent Armban (all tutorial were written in 2015-2016, and fail on Armbian 5.35 or + ).

Link to comment
Share on other sites

Only one important remark. Kernel 4.14.y is the first modern stable to be for H3 boards and it is the best what exists ATM. Some features are not yet developed and are certainly badly tested. Bugs are possible to be hidden. Even there is a "stable" in the build name, we consider and label all those images testing (at best). Subsequently, there are not many real cases or manuals with this kernel around. Until few weeks, there was only some half-working development builds.


I personally don't deal much with IR so I am not aware of the details. This will be also a good source: http://linux-sunxi.org/LIRC

Link to comment
Share on other sites

I have found one bug in LIRC: mode2 is telling me about the last bit (pulse timing) of the first received frame only when receiving the second frame. For subsequent frames, the last bit (pulse timing) is obtained immediately.

 

I have written my own frame decoder, and IR transmitter tools. I will publish them later, when everything works.

 

Spent 3 days in re-inventing the wheel.

 

Why didn't I receive email notification for your message ?

Link to comment
Share on other sites

I have given up on the classic use of LIRC. It's definitely broken.

 

mode2 have a bug, and drops the last bit of the last frame.

 

My script reads the output of mode2, and works out the timing to compute the frame.

 

Transmission is done on GPIO using home made code.

 

All details are given in here:

 

http://www.orangepi.org/orangepibbsen/forum.php?mod=viewthread&tid=3388&page=1&extra=#pid22196

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines