-
Notifications
You must be signed in to change notification settings - Fork 33
read_pulses() still blocks #32
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
Comments
I now have an ItsyBitsy M4, and I'm seeing the same thing as I saw above on my rPi. It still blocks while a button is pressed down. |
Same problem, sadly this lib is unusable in the current state. |
I can reproduce this. A continuous stream of pulses (caused by holding down a button the remote) causes the $ diff examples/irremote_simpletest.py /media/dallan/CIRCUITPY/code.py
8a9
> import time
15c16,22
< pulses = decoder.read_pulses(pulsein)
---
> t0 = time.monotonic()
> pulses = decoder.read_pulses(pulsein, blocking=False)
> t1 = time.monotonic()
> if t1 - t0 > 0.02: # 20 ms
> print(f"Blocked for {t1 - t0:.2} seconds")
> if pulses is None:
> continue The output from a short button press looks OK:
but the output from holding down the button reproduces the issue described above.
I have an idea of how to fix this. PR forthcoming... |
My fix works well. See #42. |
I think it safe to close this now that #42 is in. |
Thanks @danielballan! |
I've read through #18 after having trouble reading repeat commands from my IR remote. Here's some code to illustrate what I'm seeing, which is that while the remote is "clicked" on anything, the loop gets stuck:
(this is a light change from the bundled example file in this repo)
If you run this, you'll see a flood of "." filling the console, as expected, but as soon as you put some activity on the pin, the flood will pause. This will pause indefinitely... I held down for 10+ seconds, and it blocked. When I let go, only one event was returned.
I tried to reason through
_read_pulses_non_blocking()
in adafruit_irremote.py but I'm having trouble, since I don't really know what it's trying to do, so I can't spot the bug in the logic there.I've also seen Kevin's work here that includes a timeout feature that seems to taking a stab at the same thing. It works, and even supports the repeat exception that in the example code.
The text was updated successfully, but these errors were encountered: