Quantcast

Lirc git master (0.10.0) on Raspberry PI

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Lirc git master (0.10.0) on Raspberry PI

Saskia van Emst
Today I installed Lirc from git master on my Raspberry PI 3. This caused some headaches.
As far as getting Lirc to work, sending IR commands works, I managed circumvent some issues. However they are just workarounds since I have no clue how to properly fix it.
Maybe someone else does, or if it is not a bug/problem, can tell me what I should have done instead :)

My system is a Raspberry PI 3 running Raspbian jessie with all updates installed:
--pi@raspberrypi:/usr/local/bin $ lsb_release -a
--No LSB modules are available.
--Distributor ID: Raspbian
--Description:    Raspbian GNU/Linux 8.0 (jessie)
--Release:        8.0
--Codename:       jessie

--pi@raspberrypi:/usr/local/bin $ uname -a
--Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux

So I was following: http://www.lirc.org/html/install.html
First I installed the mandatory dependencies, and pyyaml.
(Also at some point installed some USB libs / header files to get configure to tell me I would get USB support.)
Then I cloned the git repo, git clone  https://git.code.sf.net/p/lirc/git lirc-git

After running ./autogen.sh and ./configure (with --prefix=/usr because I read this somewhere and I never know which prefix I need/want on different systems T_T),
then I ran make and ran into the following errors:

--In file included from config_file.c:41:0:
--../include/media/lirc.h:14:25: fatal error: lirc/config.h: No such file or directory
--#include <lirc/config.h>
--                         ^
--compilation terminated.

This I changed in "include/media/lirc.h" to: #include <config.h>
There is no lirc directory and only one config.h file I could find.
Next retry:

--default.c:37:24: fatal error: media/lirc.h: No such file or directory
-- #include "media/lirc.h"
--                        ^

Checking where this was mentioned:

--pi@raspberrypi:~/lirc-git $ grep -R '"media/lirc.h' .
--grep: warning: ./test/lirc: recursive directory loop
--Binary file ./.git/objects/pack/pack-7f5b1466b3dee227a3de2f5b5d745dfdbd5fa38b.pack matches
--./plugins/default.c:#include "media/lirc.h"    <------------------------------- Changed
--grep: ./tools/lirc-setup/config.py: No such file or directory
--./tools/irpipe.cpp:#include "media/lirc.h"    <------------------------------- Changed
--grep: warning: ./lib/lirc: recursive directory loop

Changed to: #include "include/media/lirc.h"

Then on the next try I got syntax errors on python stuff like "async def" methods.
After some Googling I found that this was supported on Python >= 3.5. Didn't really check further if there is something in testing/unstable (I am very new to the PI/Raspbian),
but python 3 in Raspbian respository which I had installed is version 3.4.

So I followed "http://bohdan-danishevsky.blogspot.nl/2017/01/building-python-360-on-raspberry-pi-3.html" to install Python 3.6 from source (First purged 3.4).
Note: do not use the configure option for optimizations which it will mention. This will take forever on the pi (at least hours which is when I aborted it).
Note2: read comments on tech blogs (someone mentioned the "issue" in the note above already).

Afterwards I also installed pyyaml, I think with just "sudo pip3.6 install pyyaml".

On the next try, I got some error which I do not get at all tbh.
All I found is that it might have to do something with libraries for different python versions being used or something like that. Part of the make output:

--/bin/bash ./libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.  -I/usr/local/include/python3.6m   -I/home/pi/lirc-git/lib   -g -O2  -MT python-pkg/lirc/python_pkg_lib__client_la-_client.lo -MD -MP -MF python-pkg/lirc/.deps/python_pkg_lib__client_la-_client.Tpo  -c -o python-pkg/lirc/python_pkg_lib__client_la-_client.lo `test -f 'python-pkg/lirc/_client.c' || echo './'`python-pkg/lirc/_client.c
--libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I/usr/local/include/python3.6m -I/home/pi/lirc-git/lib -g -O2 -MT python-pkg/lirc/python_pkg_lib__client_la-_client.lo -MD -MP -MF python-pkg/lirc/.deps/python_pkg_lib__client_la-_client.Tpo -c python-pkg/lirc/_client.c   -fPIC -DPIC -o python-pkg/lirc/.libs/python_pkg_lib__client_la-_client.o
--mv -f python-pkg/lirc/.deps/python_pkg_lib__client_la-_client.Tpo python-pkg/lirc/.deps/python_pkg_lib__client_la-_client.Plo
--/bin/bash ./libtool  --tag=CC   --mode=link gcc  -g -O2  -module -avoid-version -export-symbols-regex client -L/usr/local/lib -lpython3.6m   -o python-pkg/lib/_client.la -rpath /usr/lib/python3.6/site-packages/lirc python-pkg/lirc/python_pkg_lib__client_la-_client.lo  lib/liblirc_client.la -ldl  -ludev
--libtool: link: /usr/bin/nm -B  python-pkg/lirc/.libs/python_pkg_lib__client_la-_client.o   | sed -n -e 's/^.*[   ]\([ABCDGIRSTW][ABCDGIRSTW]*\)[         ][      ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | sed '/ __gnu_lto/d' | /bin/sed 's/.* //' | sort |  uniq > python-pkg/lib/.libs/_client.exp
--libtool: link: /bin/grep -E -e "client" "python-pkg/lib/.libs/_client.exp" > "python-pkg/lib/.libs/_client.expT"
--libtool: link: mv -f "python-pkg/lib/.libs/_client.expT" "python-pkg/lib/.libs/_client.exp"
--libtool: link: echo "{ global:" > python-pkg/lib/.libs/_client.ver
--libtool: link:  cat python-pkg/lib/.libs/_client.exp | sed -e "s/\(.*\)/\1;/" >> python-pkg/lib/.libs/_client.ver
--libtool: link:  echo "local: *; };" >> python-pkg/lib/.libs/_client.ver
--libtool: link:  gcc -shared  -fPIC -DPIC  python-pkg/lirc/.libs/python_pkg_lib__client_la-_client.o   -Wl,-rpath -Wl,/home/pi/lirc-git/lib/.libs -L/usr/local/lib -lpython3.6m lib/.libs/liblirc_client.so -ldl -ludev  -O2   -Wl,-soname -Wl,_client.so -Wl,-version-script  -Wl,python-pkg/lib/.libs/_client.ver -o python-pkg/lib/.libs/_client.so
--libtool: link: ( cd "python-pkg/lib/.libs" && rm -f "_client.la" && ln -s "../_client.la" "_client.la" )
--echo "# Rename to devinput.lircd.dist if not using devinput driver" > devinput.lircd.conf
--echo "# Re-generate for current kernel using lirc-make-devinput" >> devinput.lircd.conf
--echo '#' >> devinput.lircd.conf
--./tools/lirc-make-devinput  >> devinput.lircd.conf
--cp ./VERSION /home/pi/lirc-git/python-pkg
--test . == . || \
--    cp ./lirc.pc .
--cd /home/pi/lirc-git/python-pkg; CFLAGS=-I/home/pi/lirc-git/lib \
--    LDFLAGS=-L/home/pi/lirc-git/lib/.libs python3 setup.py -q sdist
--Fatal Python error: PyThreadState_Get: no current thread
--
--/bin/bash: line 1:  3637 Aborted                 CFLAGS=-I/home/pi/lirc-git/lib LDFLAGS=-L/home/pi/lirc-git/lib/.libs python3 setup.py -q sdist

This error I could replicate by trying to manually install the python-pkg package:

--pi@raspberrypi:~/lirc-git/python-pkg $ sudo pip3.6 install .
--Processing /home/pi/lirc-git/python-pkg
--    Complete output from command python setup.py egg_info:
--    Fatal Python error: PyThreadState_Get: no current thread
--
--
--    ----------------------------------------
--Command "python setup.py egg_info" failed with error code -6 in /tmp/pip-7fr71hae-build/

Aparently, this error was caused by "import lirc.config". (This I found by adding some prints around it)
Manually set version in python-pkg/setup.py (commented out original try except part importing lirc.config):

#try:
#    import lirc.config
#    VERSION = lirc.config.VERSION.replace('-devel','')
#except ImportError:
#    VERSION='0.0.0'

VERSION='0.10.0'

Now I could actually build and install lirc. (make && sudo make install)
Then I couldn't find tools like irsend, so I installed those:

--cd tools
--sudo make install

Now I seem to have a (at least partially) working lirc:

--pi@raspberrypi:~ $ /usr/sbin/lircd --version
--lircd 0.10.0-devel

After some more looking around I saw Systemd unit files which I installed:

--cd systemd
--sudo make install

After that I did some configuration for my Irdroid (I wanted a cheap, ready-made USB IR Transceiver since I'm horrible with hardware/soldering)
and changed the output and pidfile location because I got some errors probably because of my prefix or w/e:

------------------------------------------------------------------------------
pi@raspberrypi:~/lirc-git/systemd $ cat /usr/etc/lirc/lirc_options.conf
[lines omitted]
driver          = irtoy
device          = /dev/ttyACM0
output          = /usr/var/run/lirc/lircd
pidfile         = /usr/var/run/lirc/lircd.pid
[lines omitted]
------------------------------------------------------------------------------

And setting up a remote (I used a remote for ARRIS 2952, used by KPN (interactieve tv) in NL) found on: https://gist.github.com/proycon/d8f730bb47ff6d7eaa12

Then I started the service:
--service lircd start

This actually ran properly (after fixing the config file location I think, when it did not find the config file it gave a segfault o.O).
Then I had to sort out some stuff with the paths of the tools like irsend. I had leftover files from different lirc versions which had to be cleaned up.

But then finally testing commands like:
--irsend SEND_ONCE KPN GUIDE
--irsend SEND_ONCE KPN POWER
Etc they worked :)

So now I can finally control my KPN settopbox, which has no other options for control at all (no CEC, network ... )

PS. In some git commit I found a mention of an "irdroid" driver for Lirc. In current master this does not seem to exist.
Were changes made to the irtoy driver to make it work with more hardware / fw versions or something? Or was I just lucky :)    
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lirc git master (0.10.0) on Raspberry PI

Alec Leamas
Hi!

Thanks for important feedback!

On 04/03/17 14:59, Saskia van Emst wrote:

> After running ./autogen.sh and ./configure (with --prefix=/usr because I read this somewhere and I never know which prefix I need/want on different systems T_T),
> then I ran make and ran into the following errors:

Hm... you did have the kernel headers package installed, right? If so,
this might be a bug caused by upstream not checking builds against older
kernels.  What is your kernel version?

> Checking where this was mentioned:

> --./tools/irpipe.cpp:#include "media/lirc.h"    <------------------------------- Changed


This file is not part of the core build, so no fix is required.

> Then on the next try I got syntax errors on python stuff like "async def" methods.
> After some Googling I found that this was supported on Python >= 3.5. Didn't really check further if there is something in testing/unstable (I am very new to the PI/Raspbian),
> but python 3 in Raspbian respository which I had installed is version 3.4.


So, we need to add tests in configure to disable python stuff if python
is < 3.5 - lirc should build also on python 3.4. Added this as a note on
#267

> This error I could replicate by trying to manually install the python-pkg package:
>
> --pi@raspberrypi:~/lirc-git/python-pkg $ sudo pip3.6 install .
> --Processing /home/pi/lirc-git/python-pkg
> --    Complete output from command python setup.py egg_info:
> --    Fatal Python error: PyThreadState_Get: no current thread
> --
> --
> --    ----------------------------------------
> --Command "python setup.py egg_info" failed with error code -6 in /tmp/pip-7fr71hae-build/
>
> Aparently, this error was caused by "import lirc.config". (This I found by adding some prints around it)
> Manually set version in python-pkg/setup.py (commented out original try except part importing lirc.config):

Hm... this is, as they say, odd. Can you reproduce it using:

   $ cd python-pkg;
   $ python3 -c "import lirc.config; print(lirc.config.VERSION)"


> PS. In some git commit I found a mention of an "irdroid" driver for Lirc. In current master this does not seem to exist.
> Were changes made to the irtoy driver to make it work with more hardware / fw versions or something? Or was I just lucky :)

Indeed, in master irdroid is supported  by the irtoy driver. See #269

Cheers!

--alec

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lirc git master (0.10.0) on Raspberry PI

Saskia van Emst
In reply to this post by Saskia van Emst
> Hm... you did have the kernel headers package installed, right? If so, 
> this might be a bug caused by upstream not checking builds against older 
> kernels.  What is your kernel version?

While I was sure I had, apparently I did not install kernel headers on this system, my apologies, that was the problem :) I guess I installed it on my VM but not on the pi.
It is a recent install and up to date kernel: Linux raspberrypi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux.

> This file is not part of the core build, so no fix is required.

Indeed it seems I did not have to change that file. Only changing:
./plugins/default.c:#include "media/lirc.h" -> Changed to: '#include "include/media/lirc.h"' works.

> Hm... this is, as they say, odd. Can you reproduce it using:

>   $ cd python-pkg;
>   $ python3 -c "import lirc.config; print(lirc.config.VERSION)"

Yes that causes the same problem in 'import lirc.config':

--pi@raspberrypi:~/lirc-git/python-pkg $ python3 -c "import lirc.config; print(lirc.config.VERSION)"
--Fatal Python error: PyThreadState_Get: no current thread
--
--Aborted
--pi@raspberrypi:~/lirc-git/python-pkg $ python3 -c "import lirc.config;"
--Fatal Python error: PyThreadState_Get: no current thread
--
--Aborted

It might be something weird on my system because there have been different python3 versions installed? I don't know. Unfortunately I don't know how to actually fix this and searching didn't bring me closer to the answer.

Thank you for the reply and updating the tickets where necessary (now I found the tickets section too :)).  
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Lirc git master (0.10.0) on Raspberry PI

Alec Leamas


On 05/03/17 17:04, Saskia van Emst wrote:

>
>> Hm... this is, as they say, odd. Can you reproduce it using:
>
>>    $ cd python-pkg;
>>    $ python3 -c "import lirc.config; print(lirc.config.VERSION)"
>
> Yes that causes the same problem in 'import lirc.config':
>
> --pi@raspberrypi:~/lirc-git/python-pkg $ python3 -c "import lirc.config; print(lirc.config.VERSION)"

Well, unless your system is really screwed up the config.py file which
only holds some constants shouldn't cause this.

However, importing config.py also implicitly imports __init__.py, and it
does some more things which might be the root of the trouble. Since the
reproducer is simple, you could perhaps hack this to verify the part, if
any, which is the culprit?

To be honest, I havn't thought hard enough on the cross-compile
scenario. This is not the first but of this kind.


Cheers!

--alec


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Loading...