• Stars
    star
    395
  • Rank 108,694 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple shell based file explorer for ESP8266 Micropython based devices β›Ί

mpfshell

PyPI version

2016-06-21, [email protected]

A simple shell based file explorer for ESP8266 and WiPy Micropython based devices.

The shell is a helper for up/downloading files to the ESP8266 (over serial line and Websockets) and WiPy (serial line and telnet). It basically offers commands to list and upload/download files on the flash FS of the device.

mpfshell

Main features:

  • Support for serial connections (ESP8266 and WiPy)
  • Support for websockets (via WebREPL) connections (ESP8266 only)
  • Support for telnet connections (WiPy only)
  • Full directory handling (enter, create, remove)
  • Transfer (upload/download) of multiple files matching a reg.-exp.
  • All files are transferred in binary mode, and thus it should be possible to also upload pre-compiled code (.mpy) too.
  • You can compile and upload files with one command.
  • Integrated REPL (supporting a workflow like: upload changed files, enter REPL, test, exit REPL, upload ...)
  • Fully scriptable
  • Tab-completion
  • Command history
  • Best of all: it comes with color

Note: The software is mainly tested on Ubuntu 16.04 LTS. However, there is basic Windows support (tested with Python 3.5 and PySerial 3.1), but some of the keys (e.g. Tab) are note working as expected yet.

Requirements

General:

  • ESP8266 or WiPy board running latest Micropython
  • For the ESP8266 firmware build from the repository, please note, that WebREPL is not started by default. For more information see the quickstart.
  • For the WiPy, please note, that you need to enable REPL on UART if you intend to connect via serial line to the WiPy (see here)

For the shell:

  • Python >= 2.7 or Python >= 3.4
  • The PySerial, colorama, and websocket-client packages (pip install -r requirements.txt)

IMPORTANT: It is highly recommended to use PySerial version 3.x on Python 2 and 3.

Note: The tools only work if the REPL is accessible on the device!

Installing

From PyPi

To install the latest release from PyPi:

sudo pip install mpfshell

From Source

Clone this repository:

git clone https://github.com/wendlers/mpfshell

To install for Python 2, execute the following:

sudo pip install -r requirements.txt
sudo python setup.py install

To install for Python 3, execute the following:

sudo pip3 install -r requirements.txt
sudo python3 setup.py install

Known Issues

  • For PySerial 2.6 the REPL is deactivated since Miniterm (which comes with 2.6) seems broken.

General

TAB Completion

The shell supports TAB completion for commands and file names. So it's totally worth pressing TAB-TAB every now and then :-)

File/Directory Names

File names including whitespaces are supported, but such names need to be enclosed in quotes. E.g. accessing a file named "with white space.txt" needs to quoted:

get "with white space.txt"
put "with white space.txt" without-white-space.txt
put without-white-space.txt "with white space.txt"

The following characters are accepted for file and directory names:

A-Za-z0-9 _%#~@/\$!\*\.\+\-

Shell Usage

Note: Since version 0.7.1, the shell offers caching for file and directory names. It is now enabled by default. To disable caching, add the --nocache flag on the command line.

Start the shell with:

mpfshell

At the shell prompt, first connect to the device. E.g. to connect via serial line:

mpfs> open ttyUSB0

Or connect via websocket (ESP8266 only) with the password "python":

mpfs> open ws:192.168.1.1,python

Or connect vial telnet (WiPy only) with username "micro" and password "python":

mpfs> open tn:192.168.1.1,micro,python

Note: Login and password are optional. If left out, they will be asked for.

Now you can list the files on the device with:

mpfs> ls

To upload e.g. the local file "boot.py" to the device use:

mpfs> put boot.py

If you like to use a different filename on the device, you could use this:

mpfs> put boot.py main.py

To compile before uploading and upload the compiled file (you need mpy-cross in your path):

mpfs > putc boot.py

Or to upload all files that match a regular expression from the current local directory to the current remote directory:

mpfs> mput .*\.py

And to download e.g. the file "boot.py" from the device use:

mpfs> get boot.py

Using a different local file name:

mpfs> get boot.py my_boot.py

Or to download all files that match a regular expression from the current remote directory to the current local directory:

mpfs> mget .*\.py

To remove a file (or directory) on the device use:

mpfs> rm boot.py

Or remove all remote files that match a regular expression:

mpfs> mrm test.*\.py

To create a new remote directory:

mpfs> md test

To navigate remote directories:

mpfs> cd test
mpfs> cd ..
mpfs> cd /some/full/path

See which is the current remote directory:

mpfs> pwd

Remove a remote directory:

mpfs> rm test

Note: The directory to delete needs to be empty!

To navigate on the local filesystem, use:

lls, lcd lpwd

Enter REPL:

repl

To exit REPL and return to the file shell use Ctrl+]

For a full list of commands use:

mpfs> help
mpfs> help <command>

The shell is also scriptable.

E.g. to execute a command, and then enter the shell:

mpfshell -c "open ttyUSB0"

Or to copy the file "boot.py" to the device, and don't enter the shell at all:

mpfshell -n -c "open ttyUSB0; put boot.py"

It is also possible to put a bunch of shell commands in a file, and then execute them from that file.

E.g. creating a file called "myscript.mpf":

open ttyUSB0
put boot.py
put main.py
ls

And execute it with:

mpfshell -s myscript.mpf

Running the Shell in a Virtual Environment

Somtimes the easiest way to satisfy the requirements is to setup a virtual environment. E.g. on Debian Jessie (which still has PySerial 2.6), this could be done like so (assuming you are within the mpfshell base directory):

Install support for virtual environments:

sudo apt-get install python3-venv

Create a new virtual environment:

pyvenv venv

Or you could use python3 -m virtualenv venv instead of pyvenv.

Activate it (so every following pip install goes to the new virtual environment):

source venv/bin/activate

Now install the dependencies to the virtual environment:

pip install -r requirements.txt
python setup.py install

Now run the shell with the following command:

python -m mp.mpfshell

Note: The environment always has to be activated with the above command before using it.

More Repositories

1

micropython-mfrc522

(Micro)Python class to access the MFRC522 RFID reader
Python
162
star
2

libemb

"libemb" is a collection of libraries which try to make things needed in many STM32 (ARM-Cortex-M3) or MSP430 (MSP430G2553) based projects more convenient. It includes an API for the Nordic nRF24l01+ modules.
C
56
star
3

rpi-kmod-samples

Set of example kernel-modules for the Raspberry Pi (includes basic module sample as well as samples for GPIOs, GPIO-interrupts)
C
50
star
4

ediplug-py

Simple Python class to access a "EDIMAX Smart Plug Switch SP-1101W"
Python
32
star
5

msp430-harduart

Hardware UART example for MSP430G2553 on TI Launchpad using mps430-gcc on Linux
C
31
star
6

stm32-pwm-servo-sample

Sample showing the usage of timers for PWM generation on the STM32 with libopencm3
C
29
star
7

pyscmpd

Python based sound-cloud music server talking MPD protocol.
Python
18
star
8

msp430-softuart

Software UART example for MSP430 using mps430-gcc on Linux
C
16
star
9

msp430-spi-nrfreg

Example on how to read registers of the Nordic nRF24l01+ radio through SPI on USCI_B of MSP430G2553
C
14
star
10

msp430-i2cslave

MSP430 I2C slave example (for MSP430G2553 on Launchpad) including master example (e.g. for TP-Link MR3020)
C
12
star
11

stm32-rob01

Firmware for STM32 based autonomous robot β€œrob01β€³
C
7
star
12

lattice-logic-sniffer

Simple 8 port logic sniffer written in Verilog for the Lattice MachXO2 Breakout Board.
Verilog
7
star
13

atom-microbit-micropython

Microbit Micropython support package for Atom editor
JavaScript
7
star
14

ywasp

YWasp is a firmware for STM32 ARM-Cortex-M3 microcontrollers for "arifaying" a serial line over an Nordic nRF24l01+ module.
C
6
star
15

msp430-pwm-servo-sample

This example shows how to use TIMER_A0+A1 PWM with a MSP430G2xx3 MCU. It controls two servos on P1.6
C
6
star
16

rcswitch-kmod

Linux Kernel Module to control 434Mhz based RC switches through sysfs.
Python
6
star
17

install-propeller-toolchain

Simple shell script to install Parallax-Propeller toolchain, including the BST tools and the Propeller GCC.
Shell
4
star
18

pyesp8266

Python API to the ESP8266 WiFo to serial module.
Python
3
star
19

msp430-standalone-sample

Running MSP430G2xxx stand alone (without Lauchpad), use Launchpad for in circuit programming
C
3
star
20

usherpa-firmware

uSherpa is a micro-controller firmware (currently for the MSP430G2553) which helps in quickly adding a micro-controller to a more powerful embedded system (e.g. the MIPS based Carambola or the ARM based beaglebone).
C
3
star
21

scratch-pynetsense

Python library provides a simple to use client implementation for implementing scratch networking sensors.
Python
2
star
22

atom-stlink

Flash your STM32 / stlink V2 device from Atom with stlink
JavaScript
2
star
23

nano-pixel-client-electron

An electron applicatoin to access a 8x8 neopixel matrix via BLE as exposed by nano-pixel-firmware
JavaScript
2
star
24

carambot

Simple Python script for Carambola SoC to drive a 4-wheel robot remotely
Python
1
star
25

rcswitch-fpga

RC Switch Send - Verilog Module to Operate 434MHz RC Switches
Verilog
1
star
26

tinr2d2

Simple tin can based, R2D2 like robot with 3D printed parts, using a Parallax Propeller
Propeller Spin
1
star
27

usherpa-pysherpa

This library provides a Python binding to a microcontroller (e.g. the MSP430G2553) running the uSherpa firmware.
Python
1
star
28

srf05modweb

This project provides a kernel module and a web service to access the SRF05 ultra sonic range finder from a Linux based device (e.g. TP-Link MR3020).
C
1
star
29

msp430-ebunny

This is just a quick little Easter hack. This firmware for the MSP430G2231 makes two glass Easter bunnies glow through a PWM.
C
1
star
30

xzrem

Example of How to Control Digital Outputs of Remote XBee using Java and XBee API
Java
1
star