First steps for an interactive micropython ... IPython

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.
torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: First steps for an interactive micropython ... IPython

Post by torwag » Sun May 24, 2015 6:31 pm

Hi,

sorry didn't saw the replies for some strange reasons. I will try to pack all together and publish it asap.
I did not come much further. If I could only have the time to do things I like rather then doing things which have a deadline ;)

It was pretty easy to create the micropyhon unix kernel wrapper. I almost plain copied it from the example.
It all comes down to handle pexpect correctly.

http://pexpect.readthedocs.org/en/latest/

I will get all in shape and reward myself this evening to play again with it, as soon as I finished that deadline thing... ;)
All the best

v923z
Posts: 168
Joined: Mon Dec 28, 2015 6:19 pm

Re: First steps for an interactive micropython ... IPython

Post by v923z » Wed Dec 28, 2016 11:42 pm

I know that this is a rather old thread, and I would be happy to open a new one, if desired. I only wanted to keep this in context.

I also wanted to have some sort of interactive development environment for the board, and ended up defining a new cell-level magic for ipython. I outlined the details here https://github.com/v923z/micropython/bl ... bone.ipynb.

The notebook is interactive in the sense that one can capture data from the board, and one can also execute large chunks of code in a single step. Syntax highlighting and traceback colouring is automatic, since the code is in python anyway. (The traceback and the body of the cell, where the new magic is applied are not coloured properly in the notebook rendered on github, though. I haven't the foggiest idea, why that is so.) Code completion is also implemented for two modules, ustruct, and ujson, and extension is obvious for the rest. And this is where I would like to pose my question and also ask for comments.

1. First, do you think that this is a reliable/viable way of dealing with the problem, or are there other alternatives. I have read this thread, but I think the suggestions are not entirely satisfactory.

2. Second, if so, is there an obvious way of extracting the function signatures and doc strings from the micropython modules? For ustruct and ujson, I simply copied the content of ustruct.rst and ujson.rst, but I am not sure that this is how it should be done.

If there is interest, I would be happy to undertake maintenance of this project and define the "empty" modules necessary for the code inspection to work.

Again, I would really appreciate any comments and insights.

Thanks,
Zoltán

openfablab
Posts: 3
Joined: Thu Nov 10, 2016 6:04 pm

Re: First steps for an interactive micropython ... IPython

Post by openfablab » Thu Dec 07, 2017 5:26 pm

[quote=v923z post_id=16743 time=1482968556 user_id=1137]
I also wanted to have some sort of interactive development environment for the board, and ended up defining a new cell-level magic for ipython. I outlined the details here [url]https://github.com/v923z/micropython/bl ... bone.ipynb[/url].
[/quote]

Hello, Zoltán!

I just have tried your code, it works OK :) .

Greatly thank you, this is definitely right approach! Interaction between Jupyter at PC and MicroPython at board is more useful for many cases than simple uPy kernels. This is exactly thing I dreamed of, but I had not enough python skill to implement it.

It make easy to solve very important teacher tasks purely in Python:

* Building interactive running graphs of physical measurements - and affecting them through notebook widgets.
* Getting robot sensor data from board, processing them on desktop with Tensorflow or doing other neuro/image/other hard computations, sending commands back to motors.
* Millions of other ideas...

It is enough for basic work. I want to use it in my scientific online course.
And it is definitely worse of maintenance and development.

Also I have some ideas about its development (very raw yet):

* Going from uPy cells to uPy lines and codeblocks. May be, colored in background accordingly to ID of each connected pyboard.
* Some class of "superglobal" variables shared between Python and uPython. Just for eauty - to get rid of printing & parsing when we want to share data. This variables can be syncronized unidirectionally when control switches from pyboard to PC and vice versa.
* Variable monitor (probably JS based) - to see real-time graphs of PC and pyboard variables ( I wrote some simple working prototype with threading ang HTML Canvas)

Post Reply