Skip to main content

obmpy (OpenBlock MicroPython tool) is a command line tool to interact with a CircuitPython or MicroPython board over a serial connection.

Project description

obmpy

This tool is modified from ampy, which fixes the bug that the serial port can not time out, and supports calling with python -m

MicroPython Tool (obmpy) - Utility to interact with a CircuitPython or MicroPython board over a serial connection.

Obmpy is meant to be a simple command line tool to manipulate files and run code on a CircuitPython or

MicroPython board over its serial connection.

With obmpy you can send files from your computer to the

board's file system, download files from a board to your computer, and even send a Python script

to a board to be executed.

Installation

You can use obmpy with either Python 2.7.x or 3.x and can install it easily from

Python's package index. On MacOS or Linux, in a terminal run the following command (assuming

Python 3):

pip3 install --user openblock-obmpy

On Windows, do:

pip install openblock-obmpy

Note on some Linux and Mac OSX systems you might need to run as root with sudo:

sudo pip3 install openblock-obmpy

If you don't have Python 3 then try using Python 2 with:

pip install openblock-obmpy

Once installed verify you can run the obmpy program and get help output:

obmpy --help

You should see usage information displayed like below:

Usage: obmpy [OPTIONS] COMMAND [ARGS]...



  obmpy - Adafruit MicroPython Tool



  Obmpy is a tool to control MicroPython boards over a serial connection.

  Using obmpy you can manipulate files on the board's internal filesystem and

  even run scripts.



Options:

  -p, --port PORT  Name of serial port for connected board.  [required]

  -b, --baud BAUD  Baud rate for the serial connection. (default 115200)

  -d, --delay DELAY Delay in seconds before entering RAW MODE (default 0)

  --help           Show this message and exit.



Commands:

  get  Retrieve a file from the board.

  ls   List contents of a directory on the board.

  put  Put a file on the board.

  rm   Remove a file from the board.

  run  Run a script and print its output.

If you'd like to install from the Github source then use the standard Python

setup.py install (or develop mode):

python3 setup.py install

Note to run the unit tests on Python 2 you must install the mock library:

pip install mock

Usage

Obmpy is made to talk to a CircuitPython MicroPython board over its serial connection. You will

need your board connected and any drivers to access it serial port installed.

Then for example to list the files on the board run a command like:

obmpy --port /dev/tty.SLAB_USBtoUART ls

You should see a list of files on the board's root directory printed to the

terminal. Note that you'll need to change the port parameter to the name or path

to the serial port that the MicroPython board is connected to.

Other commands are available, run obmpy with --help to see more information:

obmpy --help

Each subcommand has its own help, for example to see help for the ls command run (note you

unfortunately must have a board connected and serial port specified):

obmpy --port /dev/tty.SLAB_USBtoUART ls --help

Configuration

For convenience you can set an AMPY_PORT environment variable which will be used

if the port parameter is not specified. For example on Linux or OSX:

export AMPY_PORT=/dev/tty.SLAB_USBtoUART

obmpy ls

Or on Windows (untested) try the SET command:

set AMPY_PORT=COM4

obmpy ls

Similarly, you can set AMPY_BAUD and AMPY_DELAY to control your baud rate and

the delay before entering RAW MODE.

To set these variables automatically each time you run obmpy, copy them into a

file named .obmpy:

# Example .obmpy file

# Please fill in your own port, baud rate, and delay

AMPY_PORT=/dev/cu.wchusbserial1410

AMPY_BAUD=115200

# Fix for macOS users' "Could not enter raw repl"; try 2.0 and lower from there:

AMPY_DELAY=0.5

You can put the .obmpy file in your working directory, one of its parents, or in

your home directory.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openblock-obmpy-1.1.3.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

openblock_obmpy-1.1.3-py2.py3-none-any.whl (17.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file openblock-obmpy-1.1.3.tar.gz.

File metadata

  • Download URL: openblock-obmpy-1.1.3.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.4

File hashes

Hashes for openblock-obmpy-1.1.3.tar.gz
Algorithm Hash digest
SHA256 13120a560bf9e1fee7154295e1d8bc6ed58aca3000a9cf6a0ef85a7464a4d022
MD5 d097a967f8b5eaabefbd8ca5d6c8ee9b
BLAKE2b-256 d5a64ce3d47947e8c43c8c7ed0db2cf64fe43646310272cbacfbed0be6feeeb3

See more details on using hashes here.

File details

Details for the file openblock_obmpy-1.1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for openblock_obmpy-1.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0acc804176506f7d053aa0def424b77a1eef354d05eee0becbb086b6caa8339d
MD5 0ded19eab8768ac5ba0b3adc6951207d
BLAKE2b-256 a1944f201c9947ca8f6fdcdf67b221b83924e0356eb3a0d2c0a652cc33ebbf70

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page