Page 1 of 1

WebREPL tutorial

Posted: Sat Oct 19, 2019 3:35 pm
by mathieu
Dear all,

Sorry if this is a stupid/lazy question, but I wasn't able to figure it out myself: is it possible to edit or upload code wirelessly on a pyboard-D, using webREPL or some other method? If so, is there a tutorial somewhere?

Thanks in advance.

Re: WebREPL tutorial

Posted: Sun Oct 20, 2019 6:41 am
by Roberthh
webrepl does not work on the PYBD. The _webrepl module is missing, and also when including it, I get an error:

Code: Select all

Traceback (most recent call last):
  File "webrepl.py", line 47, in accept_conn
AttributeError: 'module' object has no attribute 'dupterm_notify'
So there is more to do. I use my ftp server for copying file by ftp locally. https://github.com/robert-hh/FTP-Server ... 2-and-PYBD
File uftpd.py, which runs in background. There are other variants, like ftp.py, which runs in foreground. The server uses the same event noticing mechanism as webrepl, so it cannot coexist with webrepl. ftp.py can. One task on my list is to rewrite it using uasyncio.

Re: WebREPL tutorial

Posted: Sun Oct 20, 2019 5:59 pm
by cgglzpy
Roberthh wrote:
Sun Oct 20, 2019 6:41 am
webrepl does not work on the PYBD. The _webrepl module is missing, and also when including it, I get an error:

Code: Select all

Traceback (most recent call last):
  File "webrepl.py", line 47, in accept_conn
AttributeError: 'module' object has no attribute 'dupterm_notify'
So there is more to do. I use my ftp server for copying file by ftp locally. https://github.com/robert-hh/FTP-Server ... 2-and-PYBD
File uftpd.py, which runs in background. There are other variants, like ftp.py, which runs in foreground. The server uses the same event noticing mechanism as webrepl, so it cannot coexist with webrepl. ftp.py can. One task on my list is to rewrite it using uasyncio.
Hi, Roberthh
Are you sure WebREPL does not work on the PYBD? In this thread viewtopic.php?f=20&t=6438 jimmo says otherwise, but that was a couple months ago, so maybe the WebREPL support has been dropped recently. I would like to check that but I don't have a PYBD yet :? .

Re: WebREPL tutorial

Posted: Sun Oct 20, 2019 8:24 pm
by Roberthh
I'm not sure.
I build the firmware myself. If I do that, neither webrepl.py is present. I can copy webrepl.py from the ESP8266 port to the device, and the I get the error above. dupterm_notify() is a method of the uos module for ESP32 and ESP8266, and in the STM32 package it does not exist. It may be that a different webrepl.py i needed, but that is not in the repository.

Re: WebREPL tutorial

Posted: Mon Oct 21, 2019 1:06 am
by jimmo
I think back in that thread I was using the firmware images that were on the downloads page before PYBD was integrated into master. I guess Damien must have been manually including webrepl.py into the builds. It definitely worked at the time. I don't know why the dupterm_notify wasn't a problem then though -- it's kind of annoying that this is a esp32/esp8266-port specific feature, I just ran into it with the BLE REPL too.

Anyway, now that we have manifests, there's a better path forward for how to make the STM32 builds include webrepl, so I will send a PR this morning to fix this and get webrepl properly supported in the PYBD builds.

Re: WebREPL tutorial

Posted: Mon Oct 21, 2019 5:07 am
by jimmo
The answer was that the pre-merging-to-master PYBD firmware available at the time had a version of webrepl.py with the dupterm_notify line commented out.

Anyway https://github.com/micropython/micropython/pull/5235 should sort this out. I've tested it with sending/receiving files.

Re: WebREPL tutorial

Posted: Mon Oct 21, 2019 6:35 am
by Roberthh
With that change to webrepl it works indeed. I do not know whether is is needed to create a new place for webrepl. It may be better now that it is shared by three ports. But instead of extmod it could also be another existing directory like drivers, which already hold python modules.

Re: WebREPL tutorial

Posted: Mon Oct 21, 2019 10:20 am
by jimmo
Yeah...conceptually I think it makes sense to live alongside modwebrepl.c as they only make sense together, but it does feel weird to put python code in extmod. Perhaps the answer is that webrepl doesn't live in extmod? There's a category of things that aren't drivers or tools... a kind of micropython standard library that isn't micropython-lib. I don't have strong feelings...will see what Damien thinks.

Re: WebREPL tutorial

Posted: Sun Mar 08, 2020 11:20 pm
by agners
At least with MicroPython 1.12 on PYBD (Pyboard D-series) seems to work when installing
https://github.com/micropython/micropyt ... od/webrepl

and setup using the usual "import webrepl_setup". However, when there is a main.py running, I get a password prompt but I do not get any output after login. When there is no main.py, I can login, start script, but I cannot abort execution (Ctrl+C).

Re: WebREPL tutorial

Posted: Mon Jun 21, 2021 12:12 am
by taco-tuesday
I came here seeking answers to my webrepl issue on my esp32. In my case, I was using a chrome extension that forced a https connection at all times. As you know, the Micropython Webrepl can not work on an https connection, only http. In my case I just switched over to firefox and the problem went away.

Bottom line, when troubleshooting webrepl issues make sure your browser will accept http connections.