erg
Posts: 19
Joined: Thu Oct 25, 2018 5:41 pm

Can't connect to pigpio at localhost(8888) "[solved]"

Tue Aug 13, 2019 8:57 pm

Hi,

not sure if this is the right place on the forum as it's python3 related.

Running 64 bit Gentoo on Rpi 3B+

managed to get pigpiod started with version 70 but:

Code: Select all

python
Python 3.6.9 (default, Aug  6 2019, 18:42:28)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pigpio
>>> pi = pigpio.pi()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8888)

Do you have permission to access the pigpio daemon?
Perhaps it was started with sudo pigpiod -nlocalhost
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Changing default port in /etc/conf.d/pigpio to 8889 doesn't seem to make a difference:

Code: Select all

python
Python 3.6.9 (default, Aug  6 2019, 18:42:28)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pigpio
>>> pi = pigpio.pi('soft', 8889)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at soft(8889)

Did you start the pigpio daemon? E.g. sudo pigpiod

Did you specify the correct Pi host/port in the environment
variables PIGPIO_ADDR/PIGPIO_PORT?
E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888

Did you specify the correct Pi host/port in the
pigpio.pi() function? E.g. pigpio.pi('soft', 8888)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
any ideas?
Last edited by erg on Tue Jan 21, 2020 6:40 pm, edited 1 time in total.

User avatar
joan
Posts: 14885
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Can't connect to pigpio at localhost(8888)

Tue Aug 13, 2019 9:12 pm

It might be worth getting the latest commit from github (a sort of V70+). That had an update for a 64-bit issue.

Possibly simplest just to overwrite your copy of pigpio.c with https://github.com/joan2937/pigpio/blob/master/pigpio.c

erg
Posts: 19
Joined: Thu Oct 25, 2018 5:41 pm

Re: Can't connect to pigpio at localhost(8888)

Tue Aug 13, 2019 9:52 pm

I have:

Code: Select all

eix pigpio
[I] dev-libs/pigpio
     Available versions:  ~*67 (~*)68 (~*)70 {python PYTHON_TARGETS="python2_7 python3_5 python3_6 python3_7"}
     Installed versions:  70(12:10:24 13/08/19)(python PYTHON_TARGETS="python2_7 python3_6 -python3_5 -python3_7")
     Homepage:            http://abyz.me.uk/rpi/pigpio/index.html
     Description:         A library for the Raspberry which allows control of the GPIOs
and:

Code: Select all

 cat /etc/portage/package.accept_keywords/pigpio 
>=dev-libs/pigpio-70 **
shouldn't that do?

I'll make a backup and try replacing it then.
Cheers

erg
Posts: 19
Joined: Thu Oct 25, 2018 5:41 pm

Re: Can't connect to pigpio at localhost(8888)

Tue Aug 13, 2019 10:38 pm

Well,

Code: Select all

find / -name pigpio.c
returns nothing,

Code: Select all

find / -name pigpio*
/usr/lib64/python2.7/site-packages/pigpio.py
/usr/lib64/python2.7/site-packages/pigpio.pyc
/usr/lib64/python2.7/site-packages/pigpio-1.44-py2.7.egg-info
/usr/lib64/python2.7/site-packages/pigpio.pyo
/usr/lib64/python3.6/site-packages/pigpio-1.44-py3.6.egg-info
/usr/lib64/python3.6/site-packages/pigpio.py
/usr/lib64/python3.6/site-packages/__pycache__/pigpio.cpython-36.pyc
/usr/lib64/python3.6/site-packages/__pycache__/pigpio.cpython-36.opt-1.pyc
/usr/lib64/python3.6/site-packages/__pycache__/pigpio.cpython-36.opt-2.pyc
/usr/portage/dev-libs/pigpio
/usr/portage/dev-libs/pigpio/pigpio-70.ebuild
/usr/portage/dev-libs/pigpio/pigpio-67.ebuild
/usr/portage/dev-libs/pigpio/files/pigpio-70-makefile.patch
/usr/portage/dev-libs/pigpio/files/pigpiod.confd
/usr/portage/dev-libs/pigpio/files/pigpiod.systemd
/usr/portage/dev-libs/pigpio/files/pigpio-67-makefile.patch
/usr/portage/dev-libs/pigpio/files/pigpiod.initd
/usr/portage/dev-libs/pigpio/pigpio-68.ebuild
/usr/portage/metadata/md5-cache/dev-libs/pigpio-70
/usr/portage/metadata/md5-cache/dev-libs/pigpio-68
/usr/portage/metadata/md5-cache/dev-libs/pigpio-67
/usr/portage/distfiles/pigpio-70.tar.gz
/usr/portage/distfiles/pigpio-68.tar.gz
/usr/bin/pigpiod
/usr/include/pigpio.h
/usr/include/pigpiod_if2.h
/usr/include/pigpiod_if.h
/usr/share/doc/pigpio-70
/usr/share/man/man3/pigpiod_if2.3.bz2
/usr/share/man/man3/pigpiod_if.3.bz2
/usr/share/man/man3/pigpio.3.bz2
/usr/share/man/man1/pigpiod.1.bz2
/lib/systemd/system/pigpiod.service
/var/tmp/portage/dev-libs/pigpio-68
/var/db/pkg/dev-libs/pigpio-70
/var/db/pkg/dev-libs/pigpio-70/pigpio-70.ebuild
/etc/runlevels/default/pigpiod
/etc/init.d/pigpiod
/etc/portage/package.keywords/pigpio
/etc/portage/package.use/pigpio
/etc/portage/patches/dev-libs/pigpio
/etc/portage/patches/dev-libs/pigpio/pigpio.c.patch.zip
/etc/portage/package.accept_keywords/pigpio
/etc/conf.d/pigpiod
/home/pi/pigpio.c.patch.zip

User avatar
sakaki
Posts: 543
Joined: Sun Jul 16, 2017 1:11 pm

Re: Can't connect to pigpio at localhost(8888)

Tue Aug 13, 2019 11:12 pm

Hi erg,

just a random thought, but have you checked the daemon isn't launching on ::1 (IPv6) rather than 127.0.0.1 (IPv4)? There was a client/server mismatch reported a while back concerning this (here). You can check where it is listening, by starting pigpiod and then running "netstat -vatn" in a terminal.

You can force pigpiod to bind to IPv4 localhost by adding "-n 127.0.0.1" when you start it.

Best, sakaki

erg
Posts: 19
Joined: Thu Oct 25, 2018 5:41 pm

Re: Can't connect to pigpio at localhost(8888)

Tue Aug 13, 2019 11:37 pm

hi sakaki,

Code: Select all

netstat -tulpn
tcp        0      0 127.0.0.1:8889          0.0.0.0:*               LISTEN      30107/pigpiod
Does that seem sane? Local address seems fine to me, I've set it in /etc/conf.d/pigpiod to:

Code: Select all

PIGPIOD_OPTS="-l -n 127.0.0.1 -p 8889"

Code: Select all

 pi = pigpio.pi('localhost', 8889)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Can't connect to pigpio at localhost(8889)

Do you have permission to access the pigpio daemon?
Perhaps it was started with sudo pigpiod -nlocalhost
Could it be permissions issue?

User avatar
sakaki
Posts: 543
Joined: Sun Jul 16, 2017 1:11 pm

Re: Can't connect to pigpio at localhost(8888)

Wed Aug 14, 2019 1:35 am

Just tried this on an RPi3B+ running 64-bit Gentoo. It works fine (IPv4 or iPv6) if you patch the file joan mentioned above.

Best, sakaki

erg
Posts: 19
Joined: Thu Oct 25, 2018 5:41 pm

Re: Can't connect to pigpio at localhost(8888)

Wed Aug 14, 2019 12:38 pm

sakaki,

The thing is:

I haven't had a pigpio.c file on my system at all.

I did copy/paste it into /usr/lib64/python3.6/site-packages/pigpio.c
Is that the correct place for it?

Didn't make no difference though, I'm still getting the same error while running pigpio in python interpreter.

Why that file isn't there in the first place though?

Thanks,

User avatar
sakaki
Posts: 543
Joined: Sun Jul 16, 2017 1:11 pm

Re: Can't connect to pigpio at localhost(8888)

Wed Aug 14, 2019 1:21 pm

erg,

you need to modify the file as part of the emerge (build) process. It is just a source file - only the resulting binaries (plus python bits) get installed on your system, which is why you can't find it there.

The file needs changing simply because this is a bug that has been addressed upstream after the versioned ebuild you are using (version 70 in this case) was released. One option would just be to wait for version 71 or whatever.

But, if you want to do something now, you have to modify it. Probably the easiest way is to make use of Portage's nice user patching facilities.

To do so, as root, make an appropriate patch directory, and enter it:

Code: Select all

# mkdir -pv /etc/portage/patches/dev-libs/pigpio-70
# cd /etc/portage/patches/dev-libs/pigpio-70
You can see the changes to the pigpio.c file if you look here.

From that, you can work out the relevant commits, then pull them down as patches into the dir just created:

Code: Select all

# wget https://github.com/joan2937/pigpio/commit/55d8b880fca26ccf4b897bca1fe66796b9972345.patch -O 02-fix-net-comms-on-arm64.patch
# wget https://github.com/joan2937/pigpio/commit/5847d5c0991ba3d8b00fe11125aca5f74f72bc9d.patch -O 01-add-rpi4-arm64-support.patch
With that done, exit the patch dir, and try rebuilding (re-emerging) it:

Code: Select all

# cd
# emerge -v pigpio
Hopefully should then work! The way this is set up, these patches will only get applied to v70.

hth,

Sakaki

erg
Posts: 19
Joined: Thu Oct 25, 2018 5:41 pm

Re: Can't connect to pigpio at localhost(8888)

Wed Aug 14, 2019 2:23 pm

Thanks for detailed explanation. I've learned something about portage and wget today. I had a patch in that folder in a zip file...

Looks like that sorted it out. Daemon starts, python module loads, so far things seem to work!:

Code: Select all

import pigpio
>>> pi = pigpio.pi('pi', 8889)
>>> 
Thanks a ton to all,

so happy I can keep hacking at it.

For a moment there I thought perhaps it was not the smartest idea to drop raspbian for gentoo on that one,

glad I was proved wrong :-)

User avatar
sakaki
Posts: 543
Joined: Sun Jul 16, 2017 1:11 pm

Re: Can't connect to pigpio at localhost(8888)

Wed Aug 14, 2019 9:28 pm

Good to hear it's working for you now!

Best, sakaki

PS: if you get a chance, it might be an idea to mark the thread title "[solved]" to help others searching for a resolution for this issue. Thanks! S.

Return to “Gentoo”