Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timed Out Error with PulseIn on Raspberry pi #259

Closed
hyansuper opened this issue Mar 3, 2020 · 15 comments
Closed

Timed Out Error with PulseIn on Raspberry pi #259

hyansuper opened this issue Mar 3, 2020 · 15 comments

Comments

@hyansuper
Copy link

This happens on my Raspberrypi zero(Buster) and Raspberrypi 3(stretch):

Python 3.7.3 (default, Dec 20 2019, 18:57:59)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board, pulseio
>>> p = pulseio.PulseIn(board.D14)
/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/libgpiod_pulsein: error while loading shared libraries: libgpiod.so.2: cannot open shared object file: No such file or directory
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py", line 64, in __init__
    message = self._wait_receive_msg()
  File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py", line 80, in _wait_receive_msg
    raise RuntimeError("Timed out waiting for PulseIn message")
RuntimeError: Timed out waiting for PulseIn message

I first notice this error when I was using ultrasonic sensor, see adafruit/Adafruit_CircuitPython_HCSR04#16

@yeyeto2788
Copy link
Contributor

yeyeto2788 commented Mar 3, 2020

@hyansuper did you try with other pin? I just noticed this on your error log libgpiod_pulsein: error while loading shared libraries: libgpiod.so.2: cannot open shared object file: No such file or directory

If I'm not wrong that pin is assigned to TXD0 as I could see in https://pinout.xyz/pinout/pin8_gpio14, do you have the UART enable?

@hyansuper
Copy link
Author

I don't have UART enabled. I also tried many other pins, same error. Do I have to manually install libgpiod? I tried to install libgpiod with this script but failed. below is the log running the script

Installing build requirements - this may take a few minutes!

Hit:1 http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian buster InRelease
Hit:2 http://mirrors.tuna.tsinghua.edu.cn/raspberrypi buster InRelease
Reading package lists... Done
N: Ignoring file 'raspi.list.b' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
Reading package lists... Done
Building dependency tree
Reading state information... Done
autoconf is already the newest version (2.69-11).
autoconf-archive is already the newest version (20180313-1).
automake is already the newest version (1:1.16.1-4).
build-essential is already the newest version (12.6).
git is already the newest version (1:2.20.1-2+deb10u1).
libtool is already the newest version (2.4.6-9).
pkg-config is already the newest version (0.29-6).
python3 is already the newest version (3.7.3-1).
python3-dev is already the newest version (3.7.3-1).
python3-setuptools is already the newest version (40.8.0-1).
swig3.0 is already the newest version (3.0.12-2).
wget is already the newest version (1.20.1-1.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
N: Ignoring file 'raspi.list.b' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
Reading package lists... Done
Building dependency tree
Reading state information... Done
raspberrypi-kernel-headers is already the newest version (1.20200212-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
N: Ignoring file 'raspi.list.b' in directory '/etc/apt/sources.list.d/' as it has an invalid filename extension
Cloning libgpiod repository to /tmp/libgpiod.kLk2

Cloning into '.'...
remote: Enumerating objects: 1130, done.
remote: Counting objects: 100% (1130/1130), done.
remote: Compressing objects: 100% (1040/1040), done.
remote: Total 5081 (delta 735), reused 114 (delta 87)
Receiving objects: 100% (5081/5081), 850.97 KiB | 4.00 KiB/s, done.
Resolving deltas: 100% (3459/3459), done.
Building libgpiod

autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force -I m4
aclocal: warning: couldn't open directory 'm4': No such file or directory
autoreconf: configure.ac: tracing
autoreconf: configure.ac: creating directory autostuff
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, 'autostuff'.
libtoolize: copying file 'autostuff/ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:61: installing 'autostuff/ar-lib'
configure.ac:61: installing 'autostuff/compile'
configure.ac:64: installing 'autostuff/config.guess'
configure.ac:64: installing 'autostuff/config.sub'
configure.ac:42: installing 'autostuff/install-sh'
configure.ac:42: installing 'autostuff/missing'
bindings/cxx/Makefile.am: installing 'autostuff/depcomp'
autoreconf: Leaving directory `.'
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking build system type... armv6l-unknown-linux-gnueabihf
checking host system type... armv6l-unknown-linux-gnueabihf
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert armv6l-unknown-linux-gnueabihf file names to armv6l-unknown-linux-gnueabihf format... func_convert_file_noop
checking how to convert armv6l-unknown-linux-gnueabihf file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... yes
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for ANSI C header files... (cached) yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for ioctl... yes
checking for asprintf... yes
checking for scandir... yes
checking for alphasort... yes
checking for ppoll... yes
checking for realpath... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking dirent.h usability... yes
checking dirent.h presence... yes
checking for dirent.h... yes
checking sys/poll.h usability... yes
checking sys/poll.h presence... yes
checking for sys/poll.h... yes
checking sys/sysmacros.h usability... yes
checking sys/sysmacros.h presence... yes
checking for sys/sysmacros.h... yes
checking linux/gpio.h usability... yes
checking linux/gpio.h presence... yes
checking for linux/gpio.h... yes
checking linux/version.h usability... yes
checking linux/version.h presence... yes
checking for linux/version.h... yes
configure: error: "libgpiod needs linux headers version >= v5.5.0"
cp: cannot stat 'bindings/python/.libs/gpiod.so': No such file or directory
cp: cannot stat 'bindings/python/.libs/gpiod.la': No such file or directory
cp: cannot stat 'bindings/python/.libs/gpiod.a': No such file or directory

@makermelissa
Copy link
Contributor

Hi, have you been able to solve this? If not please try running sudo apt install libgpiod2.

@makermelissa makermelissa changed the title RuntimeError with PulseIn on Raspberry pi Timed Out Error with PulseIn on Raspberry pi May 4, 2020
@hyansuper
Copy link
Author

Solved after I run sudo apt install libgpiod2
Thank you!

@edcon0
Copy link

edcon0 commented Aug 22, 2020

sudo apt install libgpiod2

Solved, Thank you!!!

@Firesphere
Copy link

If you are encountering this problem on an older version of Raspberry Pi OS, download libgpiod2 from the Debian website, the one for Buster, and install that one. LibGPIOD2 is not available on versions before buster, so you'll have to do it the hacky way

@CesMak
Copy link

CesMak commented Mar 12, 2022

I encounter this problem only if I run my python program from a systemd service. Any ideas why?

@Firesphere
Copy link

The systemd service runs as possibly the wrong user, who does not have the libraries required installed. What's your systemd service look like?

@CesMak
Copy link

CesMak commented Mar 13, 2022

[Unit]
Description=dht logging service
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python3 /home/pi/dht_logger.py
Environment=PYTHONUNBUFFERED=1

[Install]
WantedBy=default.target

@Firesphere
Copy link

Try adding User={User that works when running the command manually] to the Service part

@CesMak
Copy link

CesMak commented Mar 13, 2022

Wow thanks for that fast answer it works! Perfect.
Do you know if I also need my service file here:
sudo cp /etc/systemd/system/dht_logger.service /lib/systemd/system/dht_logger.service
I read some hints on that but I am not sure for what that would be required?

@Firesphere
Copy link

No, you should not need to do that, if you have enabled the timer (If you use a timer) or the service, via systemctl enable servicename, a symlink to the required location (in your case it's added to default.target), which is enough.

@tschetschpi2
Copy link

I was running into this too as root. The comment about systemd service file needing a username added made me try it as a non-root user and it works now. Thank you!

@RandomTypek
Copy link

Any idea how to fix this on arch? Running arch linux arm on my rpi, installing libgpiod doesn't work and libgpiod2 doesn't exist. I even tried converting the libgpiod2 deb package with debtap, didn't work either

@makermelissa
Copy link
Contributor

Any idea how to fix this on arch? Running arch linux arm on my rpi, installing libgpiod doesn't work and libgpiod2 doesn't exist. I even tried converting the libgpiod2 deb package with debtap, didn't work either

You could try compiling from source: https://github.com/adafruit/libgpiod_pulsein

If you need libgpiod, that can also be compiled from source. See https://learn.adafruit.com/adding-a-single-board-computer-to-blinka/software-setup#installing-libgpiod-from-source-3058818.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants