WebREPL tutorial

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
User avatar
mathieu
Posts: 88
Joined: Fri Nov 10, 2017 9:57 pm

WebREPL tutorial

Post by mathieu » Sat Oct 19, 2019 3:35 pm

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.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: WebREPL tutorial

Post by Roberthh » 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.

cgglzpy
Posts: 47
Joined: Thu Jul 18, 2019 4:20 pm

Re: WebREPL tutorial

Post by cgglzpy » Sun Oct 20, 2019 5:59 pm

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 :? .

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: WebREPL tutorial

Post by Roberthh » Sun Oct 20, 2019 8:24 pm

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.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: WebREPL tutorial

Post by jimmo » Mon Oct 21, 2019 1:06 am

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.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: WebREPL tutorial

Post by jimmo » Mon Oct 21, 2019 5:07 am

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.

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: WebREPL tutorial

Post by Roberthh » Mon Oct 21, 2019 6:35 am

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.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: WebREPL tutorial

Post by jimmo » Mon Oct 21, 2019 10:20 am

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.

agners
Posts: 6
Joined: Thu Jul 25, 2019 9:48 pm

Re: WebREPL tutorial

Post by agners » Sun Mar 08, 2020 11:20 pm

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).

taco-tuesday
Posts: 2
Joined: Tue Mar 23, 2021 5:41 pm

Re: WebREPL tutorial

Post by taco-tuesday » Mon Jun 21, 2021 12:12 am

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.

Post Reply