Page 1 of 1

ESP8266: instead of main.py start from REPL an script

Posted: Sat Jun 29, 2019 11:32 am
by BigMan
Hi,

I do a lot of try-and-error coding. Means I write a main.py and flash it on the ESP8266 with ampy. The issue is: after rebooting the ESP8266, the main.py may be started but I cannot see any error messages while main.py is executed.
It would be much better, if I access with picocom the REPL first and start from there the main.py.

My first attempt was to rename the main.py, so it doesn't get started automatically. Then I logged into the REPL with picocom, loaded os and tried os.system("main_new_name.py") ... well but os.system isn't available in µPython.

Anyhow: what is the correct approach to test µPyhton-Skripts on the ESP8266, in a way I can see in a terminal all the errors?

In advance: thanks for all your support

(Note: already searched the forum for similar issues, e.g. with the term "execute scripts" but found nothing appropriate)

Re: ESP8266: instead of main.py start from REPL an script

Posted: Sat Jun 29, 2019 11:47 am
by jimmo
Hi,

If you put your code in foo.py, then on the repl run "import foo", you should get what you want.

Also you can use Ctrl-D to soft-reset.

Re: ESP8266: instead of main.py start from REPL an script

Posted: Sat Jun 29, 2019 11:49 am
by Kip
I recently got the ESP8266 and had a play around. I made a "note to self" of my workflow. Check it out: https://github.com/KipCrossing/ESP2866-MicroPython

I put my code in a different file just in case my main.py file got corrupted. It seems difficult to remove corrupted files.




Re: ESP8266: instead of main.py start from REPL an script

Posted: Sat Jun 29, 2019 12:53 pm
by Christian Walther
BigMan wrote:
Sat Jun 29, 2019 11:32 am
the main.py may be started but I cannot see any error messages while main.py is executed.
There must be something wrong here. You should see error messages or anything else printed to stdout on the serial output while main.py is running.

Re: ESP8266: instead of main.py start from REPL an script

Posted: Sat Jun 29, 2019 2:24 pm
by BigMan
Christian Walther wrote:
Sat Jun 29, 2019 12:53 pm
BigMan wrote:
Sat Jun 29, 2019 11:32 am
the main.py may be started but I cannot see any error messages while main.py is executed.
There must be something wrong here. You should see error messages or anything else printed to stdout on the serial output while main.py is running.
main.py will be executed automatically when the ESP8266 is powered on. Many messages will be generated long before I am able to login with picocom.

Re: ESP8266: instead of main.py start from REPL an script

Posted: Sat Jun 29, 2019 2:24 pm
by BigMan
jimmo wrote:
Sat Jun 29, 2019 11:47 am
Hi,

If you put your code in foo.py, then on the repl run "import foo", you should get what you want.

Also you can use Ctrl-D to soft-reset.
import foo.py <- that the solution and works! Thanks!!!