BetaRavener / uPyLoader

File transfer and communication tool for MicroPython boards
MIT License
355 stars 76 forks source link

wifi connection not possible running asyncio script #46

Closed balku closed 6 years ago

balku commented 6 years ago

HI, I'm able to connect to webrepl running on ESP8266 (nodemcu-board) if connection is done via USB while my script using asyncio by loop.run_forever(). But, if I want to do the same using wifi, I get in 90% of my attemts an error message in the upper left corner of uPyLoader. Every task of my script does await asyncio.sleep(0). Can I do something in my script to give webrepl a chance to interact with uPyLoader? Many thanks balku

BetaRavener commented 6 years ago

You're stating that you can connect to WebREPL if you're using USB. That doesn't make much sense. WebREPL is only for WiFi connection. So if you are using COM port (Windows) or devtty (Linux), you're not using WebREPL.

I don't know how much help I can offer. I never tried async on MicroPython. You can try using the official WebREPL client. If that works for you without an issue, there's probably something in the communication that uPyLoader is not expecting.

balku commented 6 years ago

Found a solution by import webrepl into my script and do a webrepl.start() after wifi connection is established. Now, all works fine. Both webrepl client (not using https) and uPyLoader. Many thanks for your help. balku

BetaRavener commented 6 years ago

Great to hear that. Did you use daily build or something other than stable MicroPython binary release? I have found this issue, which mentions that for everything else than stable release, WebREPL is turned off by default.

This is possibly reason why you have to start WebREPL yourself. In such case I would recommend placing those 2 commands (import and start) at the end of boot script (boot.py), if you didn't do that already :). I will try to mention this issue in readme so other users won't get stuck.

balku commented 6 years ago

I use micropython 1.9.3 stable release. Webrepl was not activated by default. I enabled it and provided a password. Without doing this, no connection is possible anyway. Despite the activation in boot.py, I need to import and start it inside of my script. Only with this it works fine.