Skip to main content

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

Project description

encukou-ampy

This is an experimental fork of adafruit-ampy that tries to fix an issue on Windows 10.

ampy

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

Ampy 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 ampy 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.

Note that ampy by design is meant to be simple and does not support advanced interaction like a shell or terminal to send input to a board. Check out other MicroPython tools like rshell or mpfshell for more advanced interaction with boards.

Installation

You can use ampy 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 encukou-ampy

On Windows, do:

pip install encukou-ampy

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

sudo pip3 install encukou-ampy

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

pip install encukou-ampy

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

ampy --help

You should see usage information displayed like below:

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

  ampy - Adafruit MicroPython Tool

  Ampy is a tool to control MicroPython boards over a serial connection.
  Using ampy 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

Ampy 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:

ampy --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 ampy with --help to see more information:

ampy --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):

ampy --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
ampy ls

Or on Windows (untested) try the SET command:

set AMPY_PORT=COM4
ampy 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 ampy, copy them into a file named .ampy:

# Example .ampy 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 .ampy 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

encukou-ampy-1.0.7.1.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

encukou_ampy-1.0.7.1-py2.py3-none-any.whl (16.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file encukou-ampy-1.0.7.1.tar.gz.

File metadata

  • Download URL: encukou-ampy-1.0.7.1.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for encukou-ampy-1.0.7.1.tar.gz
Algorithm Hash digest
SHA256 307d3319c5e5da2cec73ce80847808ecad9108827a77be2ed1fa4bec2a09b805
MD5 6665e5bb74ec4ec45257a2bddf764e31
BLAKE2b-256 0e73725e3b766c5dd11d5f558b00f9766f851dd8778b94675016a7b10ef22a6e

See more details on using hashes here.

File details

Details for the file encukou_ampy-1.0.7.1-py2.py3-none-any.whl.

File metadata

  • Download URL: encukou_ampy-1.0.7.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for encukou_ampy-1.0.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9686e05a07e27112ce3b4def8f7333067c73d656e3eca61c17948b913cd6b0f6
MD5 5b7be0b8e041106bc33753be65e6dd79
BLAKE2b-256 cc84938d2832d179b6b1e163774f9e787b2ca754798c438e0fdab8c90862e649

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