mpremote & pyboard.py: some questions

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
jahr
Posts: 11
Joined: Fri Apr 02, 2021 1:20 pm

mpremote & pyboard.py: some questions

Post by jahr » Fri Jan 07, 2022 12:51 pm

Hello,

First I would like to write few words why am I asking. Some (short) time ago I spoted Jupyter Notebook and I've found it quite usefull ;) I tried to find a way to use it with micropython. I've found two or three kernels, but either they didn't work at all or they were so clumsy that I decided not to use them. Then I found that VS Code has its own notebook API and decided to write an extension for micropython notebook. And I want to do it in the easiest way possible - execute cells using mpremote. Recently I found that it would be not so easy but it's another story.

I've found that when using mpremote's exec, eval and run comamnds, then on each call of mpremote the device is soft reset. It means that if I call e.g.

Code: Select all

mpremote exec "aaa=42" exec "print(aaa)"
it returns 42 as expected. But dividing it to two calls

Code: Select all

mpremote exec "aaa=42"
mpremote exec "print(aaa)"
returns

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'aaa' isn't defined
So my first question is:

1. Is this behavior intended?

and if it is, the second question is

2. Makes it sense (or wouldn't it harm) to add an argument (e.g. --no-soft-reset as the 1st argument) to the mpremote command to give the user a chance to change that behavior? BTW repl command does'n soft reset the device so two consequent repl calls share variables.

Then I played with the pyboard.py tool (which already has the --no-soft-reset argument ;)) and I've found that version of the pyboard.py installed by pip is 1.1.4 (which BTW has no such argument). So the final question is

3. Is keeping of that old version of pyboard.py intended? Wouldn't it be better to have there an actual version?

Thank you

Post Reply