How to stop program running on board



  • Hi,
    I'm sure there's a simple answer to this that I've missed, but what's the best way to interrupt a program on a pycom board, to allow REPL access using pymakr?

    Up until now I've been resetting the board, then quickly (within a second) clicking run then stop in pymakr - this usually worked. Now I've placed a 'try:' around my code though, with 'except: machine.reset()' and my old method doesn't seem to work anymore. I've got a suspicion I should have included something to allow keyboard interrupts?



  • @robert-hh @crumble
    Thanks - problem solved.



  • @alg there will be many ways. You can exit your main loop under certain conditions.

    • You can use a free input pin to detect a certain state on which you break the loop
    • If your *Py acts as a server, you can stop when you receive a special message
    • At boot you detect if you are in your development WiFi and stop at the end of your loop.

    If you cannot set a pin for safeboot, you can use FTP to overwrite main.py and reboot the



  • @alg You can always perform as safeboot, which does nto execute boot.y and main.py on startup and brings you back into the REPL prompt. For doing that, you have to connect P12 (also called G20) to 3.3V and push reset. See also https://docs.pycom.io/chapter/toolsandfeatures/bootmodes.html. The documentation there is wrong, telling that previous versions of the firmware are executed. That is not the case and was only valid for the WiPy 1 device. But the boot script skipping part is right.


Log in to reply
 

Pycom on Twitter