Skip to content

Immediately pause pulse_in after initialization #47

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

Merged
merged 1 commit into from
Aug 25, 2020

Conversation

michaellass
Copy link

Right now, pulse_in is active until the first reading and only paused after that. Let's immediately pause it to free up the CPU.

This problem was reported by @lane-maxwell at adafruit/Adafruit_Blinka#210 (comment).

This is only mildly tested right now, so please do not merge immediately.

Right now, pulse_in is active until the first reading and only paused
after that. Let's immediately pause it to free up the CPU.
@lane-maxwell
Copy link

Impressive turnaround, thank you.

@michaellass
Copy link
Author

@lane-maxwell Could you confirm that this fixes the problem for you?

@kattni
Copy link

kattni commented Aug 17, 2020

@michaellass @lane-maxwell Please feel free to tag me directly once you've gotten this tested, and I'll request a review from our review group.

@baddonkey
Copy link

@lane-maxwell Could you confirm that this fixes the problem for you?

Had pretty much the same problem with 100% CPU of libgpiod_pulsein on Raspberry Pi 3. Patching my local environment with this commit fixed it.

@lane-maxwell
Copy link

I can also confirm, this resolved the issue for me. Thank you

git clone git@github.com:michaellass/Adafruit_CircuitPython_DHT.git
cd Adafruit_CircuitPython_DHT/
git checkout -b start_paused
git branch --set-upstream-to=origin/start_paused start_paused
git pull
pip3 install .

@michaellass
Copy link
Author

I also had this in use now for a while, so @kattni, I think this is ready for review from your side.

Copy link

@kattni kattni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@kattni kattni merged commit 91f6e8c into adafruit:master Aug 25, 2020
@hkeown
Copy link

hkeown commented Aug 26, 2020

Been experiencing erratic hanging of RPi-4 Buster (RPi) since migrating to Circuit Python.

Executed: pip3 install --upgrade --force-reinstall adafruit-blinka.

RPi still hangs/crashes.

Using PTTY via ethernet (ping to router to see when link goes down) and serial port for extra debugging (running HTOP).

When executing my_py script, RPi will either:

  1. Hang and Ethernet connection is dropped, HTOP on the serial port is still running.
  1. Hang, kill Ethernet and hang the serial port/HTOP - RPi requires a power cycle.

See below a screen shot of HTOP:
Annotation 2020-08-26 123912

Observation: After a power-up, the py script is stuck in a long wait process, and recovers. But subsequent execution of the script waits for a shorter time period, and continues, no problem.

Pls advise any other information that I can provide from my side to assist resolving this issue.

@michaellass
Copy link
Author

@hkeown Do you use this DHT library or some other part of Blinka that uses pulseio? To update this library, you would need to run
pip3 install --upgrade --force-reinstall adafruit-circuitpython-dht

However, this change has just been merged and the change is not included yet in the version you get via pip. You can however edit /usr/local/lib/python3.7/dist-packages/adafruit_dht.py (I guess that is the location) manually as shown here: https://github.com/adafruit/Adafruit_CircuitPython_DHT/pull/47/files#diff-3cb2b6ae0f442877839768eb1ea0386d

That all said, I find it very surprising that this library has any influence on the functionality of ethernet or serial connections.

adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Sep 1, 2020
Updating https://github.com/adafruit/Adafruit_CircuitPython_DHT to 3.5.1 from 3.5.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_DHT#48 from adafruit/lint
  > Merge pull request adafruit/Adafruit_CircuitPython_DHT#47 from michaellass/start_paused

Updating https://github.com/adafruit/Adafruit_CircuitPython_DPS310 to 1.2.0 from 1.1.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_DPS310#9 from caternuson/iss8

Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 3.5.0 from 3.4.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#105 from makermelissa/master
  > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#104 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_IS31FL3731 to 2.6.5 from 2.6.4:
  > Merge pull request adafruit/Adafruit_CircuitPython_IS31FL3731#31 from esmil/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Seesaw to 1.6.3 from 1.6.2:
  > Merge pull request adafruit/Adafruit_CircuitPython_seesaw#52 from jepler/remove-bad-whitespace-directive

Updating https://github.com/adafruit/Adafruit_CircuitPython_AdafruitIO to 4.1.0 from 4.0.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_AdafruitIO#44 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_MatrixPortal to 1.3.0 from 1.1.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_MatrixPortal#13 from makermelissa/master
  > Merge pull request adafruit/Adafruit_CircuitPython_MatrixPortal#12 from makermelissa/master

Updating https://github.com/adafruit/Adafruit_CircuitPython_Motor to 3.2.2 from 3.2.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_Motor#48 from kattni/update-example

Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 1.6.0 from 1.5.0:
  > Merge pull request adafruit/Adafruit_CircuitPython_Requests#30 from tannewt/add_tests
@darton
Copy link

darton commented Sep 9, 2020

The problem with 100% usage of libgpiod_pulsein CPU on Raspberry Pi with DHT22 still exists.

However, sometimes you have to wait several hours for it to appear and permanently prevent reading data from the DHT22 sensor.

After today's update to the version below, the script runs 8 hours without any problems.

Raspbian GNU/Linux 10 (buster)
Raspberry Pi 3 Model B Plus Rev 1.3
Python 3.7.3
Adafruit-Blinka-5.3.4
Adafruit-PlatformDetect-2.16
Adafruit-PureIO-1.1.5 RPi.GPIO-0.7.0
adafruit-circuitpython-dht-3.5.1
pyftdi-0.51.2 pyserial-3.4 pyusb-1.0.2
rpi-ws281x-4.2.4 sysv-ipc-1.0.1

@darton
Copy link

darton commented Sep 10, 2020

But after 8 hours, the problem came back.

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

Successfully merging this pull request may close these issues.

6 participants