Page 2 of 5

Re: main.py does not appear to working after boot

Posted: Fri Jul 12, 2019 2:03 pm
by Frida
Roberthh wrote:
Fri Jul 12, 2019 12:31 pm
It may depend from the terminal emulator. Picocom switches by default the modem control lined in a way that is seen by the esressif kind if bott loader enabling as reset. You can disable that with calling options
I use GtkTerm to communicate with.
The same is true when I supply the circuits from a USB power supply as well.

Re: main.py does not appear to working after boot

Posted: Sat Jul 13, 2019 7:49 pm
by smith.randallscott
I moved everything from main.py to boot.py and it seems to be working after a reboot now; however now I don't seem to be able to connect to the ESP32 with rshell. I suspect its because of the never ending while loop (in boot.py). Can anyone confirm this?

Re: main.py does not appear to working after boot

Posted: Sat Jul 13, 2019 7:56 pm
by Roberthh
REPL starts after both boot.py and main.py have finished. An endless loop in boot.py or main.py prevents REPL.

Re: main.py does not appear to working after boot

Posted: Sun Jul 14, 2019 1:15 pm
by smith.randallscott
So in the case where I want to continuously monitor something, in this case a temperature; how do I accomplish that? Do I call a function from main that initiates an never ending loop? Do I use the scheduler module instead? What would be the best practice?

Also based on my experience, in this specific instance, it did not seem like any of the code in main was being executed, I am basing this on the steps I took putting all of the code into boot.py. Before I got all of the code into boot.py (I was moving it a few pieces at a time); after each power cycle, I would enter the REPL and run dir(), and it was only returning the items in boot.py. Thanks, for all your input.

Re: main.py does not appear to working after boot

Posted: Sun Jul 14, 2019 1:29 pm
by Roberthh
The way the firmware is coded (main.c, function mp_task()) , first boot.py is called, and then main.py, if the mode is PYEXEC_MODE_FRIENDLY_REPL. The behavior you have seen does not meet that coding, unless boot.py does not finish or the device is set to raw mode (Ctrl.A).
You may start code from main.py, but that would also not get you a REPL prompt, as long as it is running. You can start a thread in main.py with you program, which will run in parallel to the REPL. But if the device is planned to run unattended, this is seems not to be needed.

Re: main.py does not appear to working after boot

Posted: Sun Jul 14, 2019 1:46 pm
by smith.randallscott
I only need the repl during testing and troubleshooting. It will run unattended

Re: main.py does not appear to working after boot

Posted: Sun Jul 14, 2019 5:42 pm
by smith.randallscott
Moving items between boot.py and main.py leads me to conclude that main.py is not being executed. How can I look under the hood and figure this out? How do I check PYEXEC_MODE_FRIENDLY_REPL mode? How do I determine if raw mode (Ctrl.A) is set? should I try to call main.py explicitly?

Re: main.py does not appear to working after boot

Posted: Sun Jul 14, 2019 6:59 pm
by Roberthh
If xou see the normal REPL prompt >>> then the device is in the friendly mode.

Re: main.py does not appear to working after boot

Posted: Sun Jul 14, 2019 7:18 pm
by smith.randallscott
I do see the normal >>>. Is there any other reason main.py wouldn't be called? So far I have set a variable at the last line of boot.py and I see this variable when I run dir() from the REPL, I also set a variable on the first line of main.py and I do not see this when I run dir()

Re: main.py does not appear to working after boot

Posted: Sun Jul 14, 2019 7:57 pm
by Roberthh
- How did you create and modify main.py on the device?
- DO you use rhsell as terminal for REPL ro a different program like picocom or putty?