Re: How to catch raw codes ?
Benoît-Pierre DEMAINE <[email protected]> Sun, 11 Feb 2018 12:56:53 +0100
| Newsgroups | gmane.comp.hardware.lirc |
|---|---|
| Message-ID | <[email protected]> |
On 10/02/18 23:35, Benoît-Pierre DEMAINE wrote:
> Hello.
>
> I want to perform manual decoding of air cooler device. The remote control
> can send a huge variety of commands; and I am not going to record every
> single of them in my lirc conf.
>
> I would like LIRC to call my app (bash shell script, possible via irexec),
> and pass me as argument the binary value received after timings decoding.
> I want to leave LIRC convert the timings sequence into a serie of 0s and
> 1s. And then, I handle the myself.
>
> This is performed here using pigpio, without LIRC:
> http://blog.bschwind.com/2016/05/29/sending-infrared-commands-from-a-raspberry-pi-without-lirc/
>
> but I would like to try using LIRC. I have a working /dev/lirc0 (which
> produces mess when I press my remote).
>
> Thanks.
>
After 1h of work, I have produced what I need. This bashscript reads lirc0
and produces the binary stream I need for further work. This converts IR
frames into 0/1 frames.
It's probably not portable, and would probably NOT work for other people
as is; but it works 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
}
--
>o_/ DEMAINE Benoît-Pierre (aka DoubleHP) http://benoit.demaine.info/
If computing were an exact science, IT engineers would'nt have work \_o<
"So all that's left, Is the proof that love's not only blind but deaf."
(FAKE TALES OF SAN FRANCISCO, Arctic Monkeys)
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot