8000 pulseio.PulseOut's send function hanging project · Issue #6735 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
pulseio.PulseOut's send function hanging project #6735
Closed
@Sakuyal

Description

@Sakuyal

CircuitPython version

Adafruit CircuitPython 7.3.2 on 2022-07-20; Adafruit Circuit Playground Bluefruit with nRF52840

Code/REPL

# NOTE: This is modified from the adafruit-irremote example irremote_transmit.py. Removed the use of the irremote library to make the issue clearer.
import pulseio
import pwmio
import board
import digitalio
import array

# Create a button object to trigger IR transmit
button = digitalio.DigitalInOut(board.D4)
button.direction = digitalio.Direction.INPUT
button.pull = digitalio.Pull.DOWN

# Create a 'pwmio' output, to send infrared signals on the IR transmitter @ 38KHz
pwm = pwmio.PWMOut(board.D9, frequency=38000, duty_cycle=2**15)
pulseout = pulseio.PulseOut(pwm)

data = array.array('H', (9500, 4500, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 550, 550, 1700, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 0))


while True:
    if button.value:
        print("IR signal sent!")
        pulseout.send(data)
        print("Done sending!")

Behavior

When the button is pressed, IR signal sent! is printed to serial.
Done sending! never prints to serial. The program does not loop. It hangs at the send function.
Soft-resetting (e.g. saving the code.py file to the Circuit Playground) does not restart the program or remove the hung state.
The only way to get out of the hung state is to hard reset (reset button or power cycle).

Description

Encountered this while trying to transmit an IR signal along with other functions in the same script. I found that once it reaches the IR transmission the code does not execute further. Troubleshooting within the adafruit-irremote library file allowed me to isolate the line on which this is occurring and simplify the recreation of the bug to the small bit of code above.

It is a huge hinderance as it means any Circuit Playground transmitting an IR signal can do nothing else, including remove itself from that transmission state. The larger issue must be within pulseio itself but I wasn't able to poke my head in the codebase easily to see (nor do I think my coding is up to the repo's standards), so assistance in resolving this issue would be appreciated.

Thanks all!

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0