WebREPL tutorial

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
User avatar
mathieu
Posts: 40
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: 1706
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: 8
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: 1706
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: 817
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

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: 817
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

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: 1706
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: 817
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

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.

Post Reply