## obmpy
[![Publish PyPI Package](https://github.com/openblockcc/obmpy/actions/workflows/publish.yml/badge.svg)](https://github.com/openblockcc/obmpy/actions/workflows/publish.yml)
This tool is modified from [ampy](https://github.com/scientifichackers/ampy), which fixes the bug that the serial port can not time out, and supports calling with python -m. At the same time, it also supports setting rts/dtr to support K210 MaixDock and other devices that need to set the rts and dtr level to high to run.
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 - OpenBlock 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. Can
optionally specify with OBMPY_PORT environment
variable. [required]
-b, --baud BAUD Baud rate for the serial connection (default
115200). Can optionally specify with OBMPY_BAUD
environment variable.
-d, --delay DELAY Delay in seconds before entering RAW MODE
(default 0). Can optionally specify with
OBMPY_DELAY environment variable.
-R, --rts RTS Set RTS flow control (default True). Can
optionally specify with OBMPY_RTS environment
variable.
-D, --dtr DTR Set DTR flow control (default True). Can
optionally specify with OBMPY_DTR environment
variable.
-a, --abort-time ABORTTIME The number of times an abort command was sent
after entering repl mode (default 2). Can
optionally specify with ABORT_TIME environment
variable.
-s, --state STATE Set raw repl state (default N). If it is the
default value, the raw REPL will be opened and
exited on each command. This can be set to
N|S|C|E
--version Show the version and exit.
--help Show this message and exit.
Commands:
fsi Get the file system information.
get Retrieve a file from the board.
ls List contents of a directory on the board.
mkdir Create a directory on the board.
put Put a file or folder and its contents on the board.
reset Perform soft reset/reboot of the board.
rm Remove a file from the board.
rmdir Forcefully remove a folder and all its children 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 `OBMPY_PORT` environment variable which will be used
if the port parameter is not specified. For example on Linux or OSX:
export OBMPY_PORT=/dev/tty.SLAB_USBtoUART
obmpy ls
Or on Windows (untested) try the SET command:
set OBMPY_PORT=COM4
obmpy ls
Similarly, you can set `OBMPY_BAUD` and `OBMPY_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`:
```sh
# Example .obmpy file
# Please fill in your own port, baud rate, and delay
OBMPY_PORT=/dev/cu.wchusbserial1410
OBMPY_BAUD=115200
# Fix for macOS users' "Could not enter raw repl"; try 2.0 and lower from there:
OBMPY_DELAY=0.5
# To set rts and dtr level
OBMPY_RTS=False
OBMPY_DTR=False
# Fix for k210 'could not enter raw repl', Just send one 0x03 when try to bort task.
OBMPY_ABORTTIME=1
```
You can put the `.obmpy` file in your working directory, one of its parents, or in
your home directory.
Raw data
{
"_id": null,
"home_page": "https://github.com/openblock/obmpy",
"name": "openblock-obmpy",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "openblock obmpy hardware micropython circuitpython",
"author": "OpenBlock Team",
"author_email": "arthurzheng@openblock.cc",
"download_url": "https://files.pythonhosted.org/packages/42/05/2403b9976346e02f097ea03f9a7ee24ca77b15777463065f69276e469d64/openblock-obmpy-1.3.4.tar.gz",
"platform": null,
"description": "## obmpy\n\n[![Publish PyPI Package](https://github.com/openblockcc/obmpy/actions/workflows/publish.yml/badge.svg)](https://github.com/openblockcc/obmpy/actions/workflows/publish.yml)\n\nThis tool is modified from [ampy](https://github.com/scientifichackers/ampy), which fixes the bug that the serial port can not time out, and supports calling with python -m. At the same time, it also supports setting rts/dtr to support K210 MaixDock and other devices that need to set the rts and dtr level to high to run.\n\nMicroPython Tool (obmpy) - Utility to interact with a CircuitPython or MicroPython board over a serial connection.\n\nObmpy is meant to be a simple command line tool to manipulate files and run code on a CircuitPython or\nMicroPython board over its serial connection.\nWith obmpy you can send files from your computer to the\nboard's file system, download files from a board to your computer, and even send a Python script\nto a board to be executed.\n\n## Installation\n\nYou can use obmpy with either Python 2.7.x or 3.x and can install it easily from\nPython's package index. On MacOS or Linux, in a terminal run the following command (assuming\nPython 3):\n\n pip3 install --user openblock-obmpy\n\nOn Windows, do:\n\n pip install openblock-obmpy\n\nNote on some Linux and Mac OSX systems you might need to run as root with sudo:\n\n sudo pip3 install openblock-obmpy\n\nIf you don't have Python 3 then try using Python 2 with:\n\n pip install openblock-obmpy\n\nOnce installed verify you can run the obmpy program and get help output:\n\n obmpy --help\n\nYou should see usage information displayed like below:\n\n Usage: obmpy [OPTIONS] COMMAND [ARGS]...\n\n obmpy - OpenBlock MicroPython Tool\n\n Obmpy is a tool to control MicroPython boards over a serial connection.\n Using obmpy you can manipulate files on the board's internal filesystem and\n even run scripts.\n\n Options:\n -p, --port PORT Name of serial port for connected board. Can\n optionally specify with OBMPY_PORT environment\n variable. [required]\n -b, --baud BAUD Baud rate for the serial connection (default\n 115200). Can optionally specify with OBMPY_BAUD\n environment variable.\n -d, --delay DELAY Delay in seconds before entering RAW MODE\n (default 0). Can optionally specify with\n OBMPY_DELAY environment variable.\n -R, --rts RTS Set RTS flow control (default True). Can\n optionally specify with OBMPY_RTS environment\n variable.\n -D, --dtr DTR Set DTR flow control (default True). Can\n optionally specify with OBMPY_DTR environment\n variable.\n -a, --abort-time ABORTTIME The number of times an abort command was sent\n after entering repl mode (default 2). Can\n optionally specify with ABORT_TIME environment\n variable.\n -s, --state STATE Set raw repl state (default N). If it is the\n default value, the raw REPL will be opened and\n exited on each command. This can be set to\n N|S|C|E\n --version Show the version and exit.\n --help Show this message and exit.\n\n Commands:\n fsi Get the file system information.\n get Retrieve a file from the board.\n ls List contents of a directory on the board.\n mkdir Create a directory on the board.\n put Put a file or folder and its contents on the board.\n reset Perform soft reset/reboot of the board.\n rm Remove a file from the board.\n rmdir Forcefully remove a folder and all its children from the board.\n run Run a script and print its output.\n\nIf you'd like to install from the Github source then use the standard Python\nsetup.py install (or develop mode):\n\n python3 setup.py install\n\nNote to run the unit tests on Python 2 you must install the mock library:\n\n pip install mock\n\n## Usage\n\nObmpy is made to talk to a CircuitPython MicroPython board over its serial connection. You will\nneed your board connected and any drivers to access it serial port installed.\nThen for example to list the files on the board run a command like:\n\n obmpy --port /dev/tty.SLAB_USBtoUART ls\n\nYou should see a list of files on the board's root directory printed to the\nterminal. Note that you'll need to change the port parameter to the name or path\nto the serial port that the MicroPython board is connected to.\n\nOther commands are available, run obmpy with --help to see more information:\n\n obmpy --help\n\nEach subcommand has its own help, for example to see help for the ls command run (note you\nunfortunately must have a board connected and serial port specified):\n\n obmpy --port /dev/tty.SLAB_USBtoUART ls --help\n\n## Configuration\n\nFor convenience you can set an `OBMPY_PORT` environment variable which will be used\nif the port parameter is not specified. For example on Linux or OSX:\n\n export OBMPY_PORT=/dev/tty.SLAB_USBtoUART\n obmpy ls\n\nOr on Windows (untested) try the SET command:\n\n set OBMPY_PORT=COM4\n obmpy ls\n\nSimilarly, you can set `OBMPY_BAUD` and `OBMPY_DELAY` to control your baud rate and\nthe delay before entering RAW MODE.\n\nTo set these variables automatically each time you run `obmpy`, copy them into a\nfile named `.obmpy`:\n\n```sh\n# Example .obmpy file\n# Please fill in your own port, baud rate, and delay\nOBMPY_PORT=/dev/cu.wchusbserial1410\nOBMPY_BAUD=115200\n# Fix for macOS users' \"Could not enter raw repl\"; try 2.0 and lower from there:\nOBMPY_DELAY=0.5\n# To set rts and dtr level\nOBMPY_RTS=False\nOBMPY_DTR=False\n# Fix for k210 'could not enter raw repl', Just send one 0x03 when try to bort task.\nOBMPY_ABORTTIME=1\n```\n\nYou can put the `.obmpy` file in your working directory, one of its parents, or in\nyour home directory.\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "obmpy (OpenBlock MicroPython tool) is a command line tool to interact with a CircuitPython or MicroPython board over a serial connection.",
"version": "1.3.4",
"project_urls": {
"Homepage": "https://github.com/openblock/obmpy"
},
"split_keywords": [
"openblock",
"obmpy",
"hardware",
"micropython",
"circuitpython"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "79ca8fa38e7a43aa6497e70a7ab8915226c06ca6cc5fe10f561cad1deaec29d9",
"md5": "fa7aabce9ad7a316346b2e62ce255453",
"sha256": "065a6bf78f0690a1771d5d690a9699ddf8f27607f92403fbbca6f0618e23af95"
},
"downloads": -1,
"filename": "openblock_obmpy-1.3.4-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "fa7aabce9ad7a316346b2e62ce255453",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 18776,
"upload_time": "2024-07-08T11:49:50",
"upload_time_iso_8601": "2024-07-08T11:49:50.521022Z",
"url": "https://files.pythonhosted.org/packages/79/ca/8fa38e7a43aa6497e70a7ab8915226c06ca6cc5fe10f561cad1deaec29d9/openblock_obmpy-1.3.4-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "42052403b9976346e02f097ea03f9a7ee24ca77b15777463065f69276e469d64",
"md5": "16844c50cdf00558ff9f8b92f76dabb7",
"sha256": "22f26393f866f3906e23599eb84d6b1b38b6b06fc768867b68d5549fd48edb00"
},
"downloads": -1,
"filename": "openblock-obmpy-1.3.4.tar.gz",
"has_sig": false,
"md5_digest": "16844c50cdf00558ff9f8b92f76dabb7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 18716,
"upload_time": "2024-07-08T11:49:51",
"upload_time_iso_8601": "2024-07-08T11:49:51.758675Z",
"url": "https://files.pythonhosted.org/packages/42/05/2403b9976346e02f097ea03f9a7ee24ca77b15777463065f69276e469d64/openblock-obmpy-1.3.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-08 11:49:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "openblock",
"github_project": "obmpy",
"github_not_found": true,
"lcname": "openblock-obmpy"
}