mpfshell: remote shell for esp8266
mpfshell: remote shell for esp8266, support for Python 2+3
The tool should now support Python 2 and 3.
Regards,
Stefan
Regards,
Stefan
mpfshell basic Windows support
Since there seams to be some demand , I added basic Windows support to the shell. Basic means, that in general it works (serial, websocket, telnet), but some keys (e.g. tab) don't work as they are known to work under Linux. Also note, that I only tested on Windows 10 with Python 3.5 (and PySerial 3.1). To connect via serial line on Windows, e.g. to COM4:
Websocket connection etc. is the same as for Linux. More details here: https://github.com/wendlers/mpfshell
Regards,
Stefan
Code: Select all
open COM4
Regards,
Stefan
Re: mpfshell now supports connections via websockets
Hi Stefan,wendlers wrote:Hi,
I finished basic support for connecting with the "shell" to the ESP8266 via websockets (WebREPL needs to be active). Thus, all the shell operations (like put, get, full REPL, ...) are usable via a WiFi connection.
What are your thoughts on this usecase: I am looking for a "glue" between SaltStack "remote execution/orchestration/config management" and the ESP8266. I have played around with the three tools I found (rshell, mpfshell and ampy).
Since Salt itself is Python 2.7 I like to keep it with that.
And as ampy also seems to be a "wrapper" around pyboard.py, but less feature-rich,
I am now looking deeper into mpfshell.
This is all purely hobbyist stuff, btw.
Salt has this nice feature called "proxy minions" which means one can "talk" to devices without Salt's agent software installed, by using SSH or a REST interface or whatever the device-to-be-controlled offers. The ESP8266 offers micropython (which I was a backer of).
https://groups.google.com/forum/#!topic ... UCFRcbTexg is where I got the missing hints, and
now have a basic "proxy minion" in place already. But need to find a way to execute code on the ESP8266.
Here is what I can do with ampy:
Code: Select all
In [1]: import ampy.files as files
In [2]: import ampy.pyboard as pyboard
In [3]: pyb = pyboard.Pyboard('/dev/ttyUSB0')
In [4]: pyb.enter_raw_repl()
In [5]: pyb.exec_("import machine\n\nprint(machine.freq())")
Out[5]: '80000000\r\n'
Code: Select all
In [1]: import mp.mpfshell
In [2]: from mp.mpfshell import MpFileShell
In [3]: mpfs = MpFileShell()
In [4]: mpfs.do_open('ser:/dev/ttyUSB0')
Connected to esp8266
In [5]: mpfs.do_exec("import machine\n\nprint(machine.freq())")
80000000
You describe as one feature mpfshell to be scriptable. As my usecase is slightly different, importing mpfshell as kind of a library, I wanted to mention it here -- it never hurts to toss out ideas.
Re: mpfshell now supports connections via websockets
Hi,
The reason why I would not use the "do_xyz" from "mpfshell" is, that all the commands here are wrapping the "mpfexp" commands in a way so they are suitable to be used within a command shell, and they include stuff you would not need when using as an API (e.g. command completion on TAB).
And for the "scriptable" thing of mpfshell: this "only" allows you to write a script which uses mpfshell commands. Which I thin is not what you are intending (since you are using it as a library).
Regards,
Stefan
The underlying code to mpfshell is intended to be used as a library, so what you are doing perfectly fits into the idea of mpfshell. However, I would recommend to not use "mp.mpfshell" but the library class which is "mp.mpfexp" (the MicroPython File Explorer). Then you would have the file transfer functions at hand, and also everything that is provided by "pyboard.py" (since MpFileExplorer is derived from PyBoard). The benefit still is, that you could use serial connection or websocket connection. Your code above would then look something like this:cpr wrote:wendlers wrote:Hi,
And here the equivalent with mpfshell:I definitely want to avoid writing files and uploading them. I want to run a few commands from the micropython libraries https://docs.micropython.org/en/latest/ ... index.html and update config files.Code: Select all
In [1]: import mp.mpfshell In [2]: from mp.mpfshell import MpFileShell In [3]: mpfs = MpFileShell() In [4]: mpfs.do_open('ser:/dev/ttyUSB0') Connected to esp8266 In [5]: mpfs.do_exec("import machine\n\nprint(machine.freq())") 80000000
You describe as one feature mpfshell to be scriptable. As my usecase is slightly different, importing mpfshell as kind of a library, I wanted to mention it here -- it never hurts to toss out ideas.
Code: Select all
import mp.mpfexp
exp = mp.mpfexp.MpFileExplorer('ser:/dev/ttyUSB0')
ret = exp.exec_('import machine\nprint(machine.freq())')
print(ret)
And for the "scriptable" thing of mpfshell: this "only" allows you to write a script which uses mpfshell commands. Which I thin is not what you are intending (since you are using it as a library).
Regards,
Stefan
Re: mpfshell: remote shell for esp8266
Thank you for the quick reply, very encouraging and motivating!!
Re: mpfshell: remote shell for esp8266
Thank you very much for mpfshell, i use it often, also because it is one of the things that besides Linux actually also works on Android (in Termux), (Webrepl doesn't work in mobile Firefox nor Chrome).
I am looking into more integrated environment to show to my kids how to use th esp8266, and while for me it is simple to run mpfshell back and forth, i was thinking of customizing it a bit, to allow simplified upload/execute. Perhaps the library like nature of mpfshell could help here:
I am looking more at serial connection, is it possible to use file upload and at the same time as having the repl cli opened? Or would i have to script it up to do something like "connect to ttyusb; upload file; start repl; exec_ import file, and finally keep repl open for further debugging"?
Thank you
Petr
I am looking into more integrated environment to show to my kids how to use th esp8266, and while for me it is simple to run mpfshell back and forth, i was thinking of customizing it a bit, to allow simplified upload/execute. Perhaps the library like nature of mpfshell could help here:
I am looking more at serial connection, is it possible to use file upload and at the same time as having the repl cli opened? Or would i have to script it up to do something like "connect to ttyusb; upload file; start repl; exec_ import file, and finally keep repl open for further debugging"?
Thank you
Petr
Re: mpfshell: remote shell for esp8266
I think there is a version of the Mu editor that works with the ESP8266 -- that seems like a nice thing to show to kids.vanous wrote:Thank you very much for mpfshell, i use it often, also because it is one of the things that besides Linux actually also works on Android (in Termux), (Webrepl doesn't work in mobile Firefox nor Chrome).
I am looking into more integrated environment to show to my kids how to use th esp8266, and while for me it is simple to run mpfshell back and forth, i was thinking of customizing it a bit, to allow simplified upload/execute. Perhaps the library like nature of mpfshell could help here:
I am looking more at serial connection, is it possible to use file upload and at the same time as having the repl cli opened? Or would i have to script it up to do something like "connect to ttyusb; upload file; start repl; exec_ import file, and finally keep repl open for further debugging"?
Thank you
Petr
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: mpfshell: remote shell for esp8266
There is, but it's not without issues viewtopic.php?f=15&t=2182. Unless these fixes have percolated upstream by now.deshipu wrote:I think there is a version of the Mu editor that works with the ESP8266 -- that seems like a nice thing to show to kids.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: mpfshell: remote shell for esp8266
Thank you, mu in indeed interesting. the toggle behavior is quite annoying though as there is no visual cue about tab state. So i added toggle to repeat itself (in logic.py):
When i used the same for fs (toggle_fs) while repl is active, the connection to usb fails, probably due to some funny timing with repl release. python's time.sleep probably blocks the main thread and doesn't seem to help here, but I can live with that, anyways this is for my children only, just in case they play with the esp.
Btw. one more dependency worth mentioning in readme is python3-pyqt5.qsci.
Also, python3-pyflakes and python3-pycodestyle might be in peoples' repos and better to be installed via their packaging manager then pip, just my 5c and depends on opinion. But this is more for this [1] thread...
[1] viewtopic.php?f=15&t=2182
Code: Select all
def toggle_repl(self):
if self.fs is not None:
self.remove_fs()
self.toggle_repl()
...
Btw. one more dependency worth mentioning in readme is python3-pyqt5.qsci.
Also, python3-pyflakes and python3-pycodestyle might be in peoples' repos and better to be installed via their packaging manager then pip, just my 5c and depends on opinion. But this is more for this [1] thread...
[1] viewtopic.php?f=15&t=2182
Re: mpfshell: remote shell for esp8266
So here I am 2 years after this thread was started and I am so keen on finding out whether the mpfshell in its current development level can be imported and send remote commands to let's say a raspberry pi?
I'm an advance pi user but a baby esp8266 which I only learnt about some 4 months ago.
I'm an advance pi user but a baby esp8266 which I only learnt about some 4 months ago.