Tools for working with a Rasbperry Pi Pico running MicroPython
Project description
picox
picox is a tool that facilitates the interaction with Raspberry Pi Pico running MicroPython boards through the terminal or within a Python script. This uses the USB serial port for communication.
Windows, Linux and macOS are supported.
Features
- Detect a connected Raspberry Pi Pico device running MicroPython
- REPL session
- File operations: Upload, download, execute, and list files on Pi Pico
- Stop current execution on device
Known issues
- REPL can timeout on long operations such as sleep. Its in the nature of how it scans for the end
- Line endings of files coming out can get a little strange. watch out if there are som extra spaces etc. Best bet is to ensure you always work in the same line endings
- File operations do not include folder operations yet
- Most commands will halt what is running on the pico. Such as a detect will stop execution in order to get a good communication test. For a more manual detection, you can use
picox attach <device>to try and stream stdout from the pico
Installation
Install via pip:
pip install picox
CLI Usage
Detecting Pi Pico:
# get first found device
picox detect
# get a list of all connected pico devices
pico detect --all
# Output: COM7 or /dev/ttyUSB0
REPL session on Pi Pico
picox repl /dev/ttyUSB0
View console output from already running pico
picox attach /dev/ttyUSB0
Soft reboot pico
picox reboot /dev/ttyUSB0
Listing files on Pi Pico:
picox ls /dev/ttyUSB0
# exmaple output:
# demo.py
# home.py
Uploading a file:
picox upload /dev/ttyUSB0 local.py remote.py --overwrite
# --overrite to force update the file on the Pi Pico
Downloading a file:
picox download /dev/ttyUSB0 remote.py local.py
Executing a file on Pi Pico:
picox exec /dev/ttyUSB0 remote.py
Stopping any ongoing operation on Pi Pico:
picox stop /dev/ttyUSB0
Python Script Usage
You can also use picox within your Python scripts as follows:
from picox import Pico
from picox.detect import get_first_pico_serial
# Init device
serial_device = get_first_pico_serial()
pico = Pico(serial_device)
# File listing
for file in pico.get_file_list():
print(file)
# Download
with open("./local/demo.py", "w") as download_file:
pico.download_file("remote_demo.py", download_file)
# Upload
with open("./local/demo.py", "rb") as upload_file:
pico.upload_file(upload_file, "remote_demo.py", overwrite=True)
# Execute
pico.execute_file("remote_demo.py")
# Halt execution on device
pico.stop_exec()
# Soft reboot device
pico.send_soft_reboot()
Local development
- Create virtual env
python -m venv _env
- Activate env
# Win
_env/Scripts/activate.ps1
# nix
source _env/bin/activate
- Install requirements
pip install -r requirement.txt
- Install module editable
pip install -e .
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file picox-1.4.0.tar.gz.
File metadata
- Download URL: picox-1.4.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
042bf76a947733f2529861504d6d46ca017622e561e3f5021b8dd5ea36b34c0d
|
|
| MD5 |
ec6cafbbff8a50a94f8e6326d4c56eb8
|
|
| BLAKE2b-256 |
01c385deba213e8705638d737f4758da5ba9e4935b84a8a8be82fbcac2fb3a2b
|
File details
Details for the file picox-1.4.0-py3-none-any.whl.
File metadata
- Download URL: picox-1.4.0-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d31560e32bdc986a27a593df0118cc05bbe036756c178bfe838140fc325787f
|
|
| MD5 |
efac6694fb04d9a29e160276bf4e23bf
|
|
| BLAKE2b-256 |
dc7656cde1d83aa9695fd511d397051accc3de0730de6568907fec1db76f30a1
|