-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jupyter style interface for the code instead of just the terminal mode #32
Comments
Possibly an even quicker way to get here is to build a new Jupyter kernel that works like a gateway and sends and receives the cell contents from the Jupyter front end and relays it to the Micropython microcontroller (if it's connected) through the USB or over the wifi. It should be able to interpret those special % commands to handle the connections, as well as especially if some of the cells could represent code to be saved into a py or mpy module. This would mean your whole app could be developed speedily and interactively. By using the standard IPython notebook system we've got a way to publish it on github to see the workings of a micropython session in a nice format, as we do for so many other python systems already. |
Great ideas! Consider putting them into reality and maintaining this solution for the community! |
I'll do what I can, but I'm not very good at this sort of thing. I'm starting this by forking a small bash_kernel implementation which I have been hacking extensively in order to find out how it works. (print statements don't work, you've got to keep a copy of stderr in a variable and write to that). The second step is to steal some functions from the webrepl_cli code to implement jupyter's do_execute() function and get a barely functional implementation in order to see how much I like it. (I'll report progress here, if I make any. I'm still kind of hoping that I'm not the first person to think of this obvious idea, and someone's already got the solution stashed away somewhere I haven't found it yet.) |
I have found this idea has been successfully implemented here (subject to a small number of issues) I have been using for a few hours, and it is a most satisfactory way to hack code interactively. If developed further, I can imagine this becoming a really popular alternative to webrepl. |
Glad that you found what you looked for. As a hint, you may find that http://forum.micropython.org/ is a better place to search/post about anything but the bugreports (the purpose of this tracker). Please don't forget to close this ticket if it's "done". |
I think I've nailed it here: https://github.com/goatchurchprime/jupyter_micropython_kernel It primarily got inspired by the script https://github.com/micropython/micropython/blob/master/tools/pyboard.py on which https://github.com/adafruit/jupyter_micropython_kernel is based, and makes use of the ctrl-A no-echo paste "raw-repl" mode, of which there is not much documentation, and may be subject to change: One obscurity with it is when you do ctrl-D it writes "OK" then does the output, then "\x04" then writes any errors (if there are any), then does "\x04>". When you have dependent projects outside the main project, and the main project changes an obscure mode (like raw-repl) and breaks it, or requires new features so that the dependent project works better, it is not obvious whether it would be welcome to post tickets about what could be improved. Anyhow, "Comment and close" |
@goatchurchprime It would be nice to have a docker image that builts the whole thing for jupyter lab... |
The Jupyter interface is really good because it's gives a really productive interface that's half-way between using the python immediate command line and writing and rerunning scripts.
Webrepl links to a 6000 line terminal emulator library term.js -- which is a lot of trouble to make the browser look and feel like an old fashioned unfriendly terminal.
But instead of this we could have a very similar interface to the jupyter system with a series of boxes where the code is uploaded when you press "run" by bracketing it with Control-E and Control-D, as I've done in this experiment below. (I've had to put in a delay between each line because otherwise it chokes).
To make this efficient, does anyone know what are the limitations of this mysterious Control-E / Control-D type of block? Is it saving it all in the RAM before processing it (otherwise how could Control-C work to end processing), or does it stream it to a temporary file and then import it?
The text was updated successfully, but these errors were encountered: