You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PulseIn seems to be holding back data until displaced by further data, resulting in unpredictable behaviour #10586
print("code.py")
importboard,timeimportpulseio,adafruit_irremote# Maxlen is set high to mitigate a separate hard fault issue encountered, Adafruit_CircuitPython_IRRemote issue #76pulsein=pulseio.PulseIn(board.D4, maxlen=600, idle_state=True)
decoder=adafruit_irremote.NonblockingGenericDecode(pulsein)
defmain():
whileTrue:
formessageindecoder.read():
ifisinstance(message, adafruit_irremote.IRMessage):
code=message.codeprint("Decoded:", code)
elifisinstance(message, adafruit_irremote.NECRepeatIRMessage):
print("NEC repeat!")
elifisinstance(message, adafruit_irremote.UnparseableIRMessage):
print("Failed to decode", message.reason)
print("pulsein rem: ", len(pulsein))
if__name__=="__main__":
main()
Behavior
Following issues are while using the adafruit_irremote library but I believe it's caused by pulseio based on report here I believe is happening because of pulseio
Issue 1: Last NEC repeat code is "held back" until next button press and displaces that button press (the next button press after the late repeat will be correct)
Issue 2: Pressing a button multiple times without repeat seems to cause a duplicate to be inserted. For example if you press 5 5 8 8 9 9 on the remote with then CircuitPython outputs 5 5 5 8 8 9
Description
Here's why I think it's to do with pulseio:
len(pulsein) is 0 after each NEC repeat, including the last one.
It seems like a subsequent PR [to the irremote lib] means _unparsed_pulses to be fully cleared out each time so there won't be any unparsed pulses there
There is clearly some form of extra data/state being held until more pulses arrive but the above 2 showing as empty makes me believe it must be coming from a user inaccessible part of PulseIo
Additional information
I used a logic analyzer to verify the pulses being sent to the board match what's being pressed on the remote
Willing to do more testing but not sure what else would test PulseIn in the same way. Maybe a really slow UART stream?
Activity
mikeysklar commentedon Nov 9, 2026
I could not reproduce this on a Metro RP2040 with 11.0.0-alpha.2.
D5 sent NEC frames and repeat codes over a jumper to PulseIn on D6, and I read PulseIn 150 ms after each burst.
No pulse was held back and no frame was duplicated.
The RP2 PulseIn code has not changed since this was reported, so the problem may be in the irremote decoder rather than PulseIn.
Each burst after the first starts with 65535, which is the idle time before the first edge, and the decoder has to handle that.
@SuperThunder could you print the raw pulses from PulseIn when it happens, so we can see whether the data is already there?