Page 1 of 1

[SOLVED] script that behave differently when launched from main.py than from rrepl.

Posted: Thu Dec 15, 2016 4:16 pm
by pidou46
I have a script that behave differently when launched from main.py than from rrepl.

I run the dailybuild firmware "mp-esp8266-firmware-latest.bin" downloaded on 14/12/16 on a "nodemcu V3"

I have a script based on example_sub_led.py from umqtt library:
https://github.com/micropython/micropyt ... sub_led.py

I can run it from webrepl:
import example_sub_led.py
example_sub_led.main()

Note: main() doesn't start automaticaly when importing the module, is this normal ?

But, if I call it from the main.py, it doesn't work, it doesn't respond to publication to the topic, and of course I can't see what happen because the infinite loop eat 100% of the cpu so I can't log with webrep in the same time.

I have attached the sources files to help investigate if some can help?

Thanks Pidou46

Re: script that behave differently when launched from main.py than from rrepl.

Posted: Thu Dec 15, 2016 6:49 pm
by pidou46
I have some new informations to give. When I'm connecting back with repl through serial line, I get some error message: [Errno 103] ECONNABORTED

Code: Select all

dhcp client start...
ip:192.168.1.213,mask:255.255.255.0,gw:192.168.1.254
Traceback (most recent call last):
  File "main.py", line 3, in <module>
  File "example_sub_servo.py", line 34, in main
  File "umqtt/simple.py", line 56, in connect
OSError: [Errno 103] ECONNABORTED

MicroPython v1.8.4-65-g67d52d8 on 2016-09-24; ESP module with ESP8266
Type "help()" for more information.
>>> 
Can I do something to workaround this issue ?

Thanks

Re: script that behave differently when launched from main.py than from rrepl.

Posted: Thu Dec 15, 2016 7:28 pm
by pidou46
Solved

I have just added:

Code: Select all

import time
time.sleep(5)
at the beginning of my script to give it some time to connect to network.

Thanks