Tools: ampy reloaded
-
ampy is a great console script implemented in Python to conntect to the M5/Micropython Devices via serial terminal
NOTE: so this will not work if another tool (like putty) already using the serial port!
The following command (in windows style) would print the content of the file boot.py from the system on the command line
ampy -p COM1 get /flash/boot.py
Use the following to write a new file
ampy -p COM1 get /flash/boot.py boot.py
that is
ampy -p {{port}} get {{remote_file_path}} {{local_file_path}}
To put a file on the device you have to write
ampy -p COM1 put boot.py /flash/boot.py
that is
ampy -p {{port}} put {{local_file_path}} {{remote_file_path}}
There are some ideas for improvement of the process of ampy:
- the serial port would better be read from a configuration file, hence it often the same entry
you may use the environment variable AMPY_PORT, AMPY_BAUD... but this is a little bit too static
you can find my test code on the forked repository https://github.com/ahaeberle/ampy- add default path for local files and write them without giving the name on a second parameter
from the system on the command line to write a new file.
remember to put the an ampy.json in the folder or use a
--json {{filename}}
ampy -p COM1 get /flash/boot.py
Use the following to write a new file
ampy get /flash/boot.py # with implicit filename
- add default path for remote files to put them with a simpler command
new command to get a file with an ampy.json in the calling directory
ampy get /flash/boot.py
that is
ampy get {{remote_file_path}} # implicit name and path with json
and the JSON-File
{ "AMPY_PORT": "COM1", "AMPY_DELAY": 0.0, "AMPY_BAUD": 115200, "REMOTE_PATH": "/flash/", "LOCAL_PATH": "./" }
-
there is a small mistake in the last commands:
ampy put boot.py
that is
ampy put {{local_file_path}} # implicit remote path and name with json
and the JSON-File