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

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
pidou46
Posts: 13
Joined: Sat May 28, 2016 7:01 pm

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

Postby pidou46 » Thu Dec 15, 2016 4:16 pm

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
Attachments
script.zip
(1.43 KiB) Downloaded 2 times
Last edited by pidou46 on Thu Dec 15, 2016 7:28 pm, edited 1 time in total.
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

pidou46
Posts: 13
Joined: Sat May 28, 2016 7:01 pm

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

Postby pidou46 » Thu Dec 15, 2016 6:49 pm

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
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016

pidou46
Posts: 13
Joined: Sat May 28, 2016 7:01 pm

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

Postby pidou46 » Thu Dec 15, 2016 7:28 pm

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
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016


Return to “Programs, Libraries and Tools”

Who is online

Users browsing this forum: No registered users and 1 guest