概要
picoでmicropythonやってみた。
ampyやってみた。
環境
windows10
インストール
>pip install adafruit-ampy
Collecting adafruit-ampy
Downloading adafruit_ampy-1.1.0-py2.py3-none-any.whl.metadata (5.2 kB)
Requirement already satisfied: click in c:\users\ohisa\radioconda\lib\site-packages (from adafruit-ampy) (8.1.8)
Requirement already satisfied: pyserial in c:\users\ohisa\radioconda\lib\site-packages (from adafruit-ampy) (3.5)
Collecting python-dotenv (from adafruit-ampy)
Downloading python_dotenv-1.2.2-py3-none-any.whl.metadata (27 kB)
Requirement already satisfied: colorama in c:\users\ohisa\radioconda\lib\site-packages (from click->adafruit-ampy) (0.4.6)
Downloading adafruit_ampy-1.1.0-py2.py3-none-any.whl (16 kB)
Downloading python_dotenv-1.2.2-py3-none-any.whl (22 kB)
Installing collected packages: python-dotenv, adafruit-ampy
Successfully installed adafruit-ampy-1.1.0 python-dotenv-1.2.2
>ampy --help
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. Can optionally
specify with AMPY_PORT environment variable. [required]
-b, --baud BAUD Baud rate for the serial connection (default 115200).
Can optionally specify with AMPY_BAUD environment
variable.
-d, --delay DELAY Delay in seconds before entering RAW MODE (default 0).
Can optionally specify with AMPY_DELAY environment
variable.
--version Show the version and exit.
--help Show this message and exit.
Commands:
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.
コマンド説明
| コマンド | 操作内容 | osとの対応 |
|---|---|---|
| ls | ファイル一覧の表示 | os.listdir() |
| カレントディレクトリの取得 | os.getcwd() | |
| ディレクトリの移動 | os.chdir('/dir_name') | |
| mkdir | ディレクトリの作成 | os.mkdir('new_dir') |
| rm | ファイルの削除 | os.remove('file.txt') |
| rmdir | ディレクトリの削除 | os.rmdir('dir') |
| ファイル名の変更 | os.rename('old.txt', 'new.txt') | |
| get | ファイル転送(ダウン) | |
| put | ファイル転送(アップ) | |
| run | プログラム実行 | |
| reset | リセット |
実行結果
>ampy -p COM3 put apico1.py
>ampy -p COM3 ls
/apico1.py
>type apico1.py
led = machine.Pin(25, machine.Pin.OUT)
led.toggle()
>ampy -p COM3 run apico1.py
>ampy -p COM3 run apico1.py
以上。