Page 1 of 1

software rest from python code vs CRTL-D

Posted: Sun Jan 23, 2022 1:26 am
by OutoftheBOTS_
so when I press CRTL-D in repl it software resets then runs boot.py then main.py but nicely maintains USB and network connections.

When I run machine.soft_reset() in my python code it resets then runs boot.py but doesn't run main.py. It also nicely maintains USB and network connections

boot.py has network connection and starts webrepl then main.py just has print("Shane makes his mark")

Here's my repl output on CTRL-D

Code: Select all

MPY: soft reboot
trying to connect to WiFi
('192.168.0.146', '255.255.255.0', '192.168.0.1', '192.168.0.1')
WebREPL daemon started on ws://192.168.0.146:8266
Started webrepl in normal mode
Shane makes his mark
MicroPython v1.17 on 2021-09-02; ESP32 module with ESP32
Type "help()" for more information.
This is my output from machine.soft_reset()

Code: Select all

MPY: soft reboot
trying to connect to WiFi
('192.168.0.146', '255.255.255.0', '192.168.0.1', '192.168.0.1')
WebREPL daemon started on ws://192.168.0.146:8266
Started webrepl in normal mode

Re: software rest from python code vs CRTL-D

Posted: Sun Jan 23, 2022 1:33 am
by OutoftheBOTS_
OK a little more info here. It seems that if the machine.soft_reset is executed from main.py then when it resets it runs main.py but if it is executed from another script then it doesn't run main.py

Re: software rest from python code vs CRTL-D

Posted: Sun Jan 23, 2022 7:54 pm
by marcidy
this explanation may help:

viewtopic.php?f=18&t=10201&p=56672&hili ... set#p56672

Basically if you run anything that will call soft_reset, it should be from main.py. boot.py should be for initialization only.

Re: software rest from python code vs CRTL-D

Posted: Sun Jan 23, 2022 8:52 pm
by OutoftheBOTS_
I wasn't calling machine.soft_reset() from boot.py but rather calling it from another script called line.py but the easy work around that I found was that main.py would just have the line from line import * then when line.py executed machine.soft_reset() it reset and run both boot.py and main.py

basically I wanted to be able to update line.py on my computer and send it to the board via webrepl then when line.py detected the boot button pressed it would call machine.soft_reset then rerun the new updated line.py

It would be nice if I could just hit CRTL-C then CRTL-D in the webrepl and it would reboot but at the moment I can't get webrepl to work it can only upload or download files but not use repl