WebREPL not working with main.py-started app (fixed)
WebREPL not working with main.py-started app (fixed)
Hi!
I used WebREPL to interactively play around with my board without any issues. I start WebREPL within boot.py.
After starting another program (after WebREPL in boot.py) however, WebREPL does not properly work any more. When trying to log in, I'm queried for the password, and after that, I don't get any response any more (not even a newline after entering the password).
The other program I launch apparently continues execution without issues. It basically consists of a main loop in the form of " while True: measure something; send to server; delay 60s".
My guess is that the incoming WebREPL connection preempts (?) this main loop, and the connection is handled up to the point that the initial welcome message and the password prompt is sent to the client. Further IO on the WebREPL connection however is not handled as the main loop is not preempted any more. Does this make sense?
How can this be avoided? That is, how can I execute some sort of main loop while remaining responsive to WebREPL? Is there some function I could call within the main loop that triggers the handling of pending connections?
Thanks in advance!
Thanks,
yolk
I used WebREPL to interactively play around with my board without any issues. I start WebREPL within boot.py.
After starting another program (after WebREPL in boot.py) however, WebREPL does not properly work any more. When trying to log in, I'm queried for the password, and after that, I don't get any response any more (not even a newline after entering the password).
The other program I launch apparently continues execution without issues. It basically consists of a main loop in the form of " while True: measure something; send to server; delay 60s".
My guess is that the incoming WebREPL connection preempts (?) this main loop, and the connection is handled up to the point that the initial welcome message and the password prompt is sent to the client. Further IO on the WebREPL connection however is not handled as the main loop is not preempted any more. Does this make sense?
How can this be avoided? That is, how can I execute some sort of main loop while remaining responsive to WebREPL? Is there some function I could call within the main loop that triggers the handling of pending connections?
Thanks in advance!
Thanks,
yolk
Re: WebREPL not working with main loop
No, WebREPL just doesn't work how you apparently think it does. ESP8266 is not a gigahertz/gigabyte machine where each opens a new independent session, like telnet/SSH connection to Unix boxes does. ESP8266 is very resource-constrained device, and there's only one session running. You can access that session either via UART or WebREPL. That's it. So, when you connect via WebREPL, you get to your running application. If it doesn't accept any input and doesn't produce any output, it appears to be "hung" for you. Ctrl+C it to get back to the Python interactive prompt if that's what you want.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: WebREPL not working with main loop
Hi!
Thanks for the quick reply!
[quote="pfalcon"]No, WebREPL just doesn't work how you apparently think it does. ESP8266 is not a gigahertz/gigabyte machine where each opens a new independent session, like telnet/SSH connection to Unix boxes does. ESP8266 is very resource-constrained device, and there's only [i]one session[/i] running. You can access that session either via UART or WebREPL. That's it. So, when you connect via WebREPL, you get to your running application. [/quote]
Yes, that's roughly what I assumed.
[quote="pfalcon"] If it doesn't accept any input and doesn't produce any output, it appears to be "hung" for you. Ctrl+C it to get back to the Python interactive prompt if that's what you want.[/quote]
Ctrl+C doesn't have any effect, the application continues executing. Also, I don't get the debug output of the running application.
Thanks,
yolk
Thanks for the quick reply!
[quote="pfalcon"]No, WebREPL just doesn't work how you apparently think it does. ESP8266 is not a gigahertz/gigabyte machine where each opens a new independent session, like telnet/SSH connection to Unix boxes does. ESP8266 is very resource-constrained device, and there's only [i]one session[/i] running. You can access that session either via UART or WebREPL. That's it. So, when you connect via WebREPL, you get to your running application. [/quote]
Yes, that's roughly what I assumed.
[quote="pfalcon"] If it doesn't accept any input and doesn't produce any output, it appears to be "hung" for you. Ctrl+C it to get back to the Python interactive prompt if that's what you want.[/quote]
Ctrl+C doesn't have any effect, the application continues executing. Also, I don't get the debug output of the running application.
Thanks,
yolk
Re: WebREPL not working with main loop
A can't reproduce this with a minimal test script. So, feel free to prepare a minimal code snippet to reproduce the issue, and submit a ticket on github with the exact steps to reproduce and related information (see viewtopic.php?f=16&t=1689 for more info).yolk wrote: Ctrl+C doesn't have any effect, the application continues executing. Also, I don't get the debug output of the running application.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: WebREPL not working with main loop
Hi!
I just flashed a freshly compiled version (26b7d8a7b) onto my board (NodeMCU V3, the cheap one from China).
My boot.py is
and testapp.py is
Apart from setting up the network connection and uploading the scripts above, the board is in vanilla state. As I previously described, WebREPL prompts for the password and then does not show any reaction.
Can someone reproduce this?
Thanks in advance!
Thanks,
yolk
I just flashed a freshly compiled version (26b7d8a7b) onto my board (NodeMCU V3, the cheap one from China).
My boot.py is
Code: Select all
# This file is executed on every boot (including wake-boot from deepsleep)
import webrepl
webrepl.start()
import testapp
testapp.loop()
Code: Select all
import utime as time
def loop():
while True:
print(".")
time.sleep(10)
Can someone reproduce this?
Thanks in advance!
Thanks,
yolk
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: WebREPL not working with main loop
@yolk I can reproduce this. I must admit it isn't obvious to me why this main.py fails to let me log in:
The following, of course, works. main.py
Followed by (at webrepl prompt)
It would seem that the firmware needs to get to the Python prompt before webrepl can accept a login and provide a REPL.
Code: Select all
import webrepl
import time
webrepl.start()
time.sleep(20) # Allow time for me to log in
import testapp
testapp.loop()
Code: Select all
import webrepl
webrepl.start()
Code: Select all
import testapp
testapp.loop()
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: WebREPL not working with main loop
Thanks, with the details above, I was able to reproduce it. I'm looking into it.yolk wrote:Can someone reproduce this?
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: WebREPL not working with main loop
This was fixed in master.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Re: WebREPL not working with main loop
Hi!
Maybe that's a good time to emphasize that I'm really excited about the MicroPython project and the immediate help you and others provide!
Thanks,
yolk
Works like a charm. Thanks!pfalcon wrote:This was fixed in master.
Maybe that's a good time to emphasize that I'm really excited about the MicroPython project and the immediate help you and others provide!
Thanks,
yolk