Skip to content

implement -panic=reset #2742

@stevegt

Description

@stevegt

I'm suggesting this as a lighter-weight change versus #2331 and #2162. While #2331 looks like it will take a while to resolve and merge due to code growth concerns, #2162 looks like it may not be merged at all due to API issues.

As @ysoldak mentions in #2162, panics happen. In the project I'm working on at the moment, if tinygo hits a runtime error (e.g. slice out of bounds), this can mean pumps left running, valves left open, and chemicals and water all over the floor in the middle of the night when nobody is around.

For any reasonable control system, having some way to implement a fail-safe mode is pretty important. In circuitpython, I can use try/finally to make sure all of those relays are powered off. But this can't be done in tinygo wIth no recover() and with no reset on abort.

If tinygo had a -panic=reset build option (mentioned as a side note in #2331), then I could deal with this by sending the i2c commands to power everything off at the top of main().

Platform: Adafruit qtpy (Cortex M0) --> sparkfun DEV-17047 i2c GPIO expander --> multiple relay coils.

Possible workaround (and a good idea anyway): Add a second qtpy as a watchdog timer. Use it to switch off the power bus for all relay coils on loss of heartbeat from the first qtpy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions