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
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
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
picox-1.1.4.tar.gz
(10.4 kB
view details)
Built Distribution
picox-1.1.4-py3-none-any.whl
(10.0 kB
view details)
File details
Details for the file picox-1.1.4.tar.gz
.
File metadata
- Download URL: picox-1.1.4.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 092cf0113a5811c39c39a9da1e1d114a278789071a4d55c64ce940158a148e60 |
|
MD5 | 51549e037d5ffcf7233db8cf3ad6a5be |
|
BLAKE2b-256 | 3c96634d93127212b58441c2fee67784096b6155a0e8e34c06859070be957a87 |
File details
Details for the file picox-1.1.4-py3-none-any.whl
.
File metadata
- Download URL: picox-1.1.4-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8b7e30ec95375e2804757672e778f9608de0eaa7dc1467d1826b14fa164b2bf |
|
MD5 | 2e18e33cae287a59465a0f6613f02d1f |
|
BLAKE2b-256 | 7f1fc2cdb61f56b5c0e146b1d9d96803f7e7d02d88cd0b2564a745feecb9b080 |