But when I tried MicroPython's mpremote tool, I almost decided it was going to be my go-to tool.
![Very Happy :D](./images/smilies/icon_e_biggrin.gif)
I usually use it in conjunction with VScode. Its code highlighting, auto-completion, and auto-indentation are very useful. It is also easy to open other plugins at the same time. The important thing is that VScode is also a multi-platform IDE.
Maybe some minimalists, I think the mpremote tool will also be suitable, just use the system's terminal with any text editor, if you are a terminal command line veteran, you only need a terminal to do everything.
Docs : https://docs.micropython.org/en/latest/ ... emote.html
Github : https://github.com/micropython/micropyt ... s/mpremote
pypi : https://pypi.org/project/mpremote/
----------
Most of the use cases are pretty clear in the documentation, but I'm not a command line veteran, so I'll put some use cases I figured out here, maybe it will help some newbies like me.
cp
This is probably the most common command besides repl, used to copy files from local to device, or from device to local. Probably because I am not yet familiar with the terminal command syntax, at first I could not fully grasp the usage of the cp command from the several use cases in the documentation.
First create a clean temporary folder and write a main.py into it.
Code: Select all
print ("start")
for i in range(2):
print(i)
print ("end")
Code: Select all
mpremote connect COM1 cp main.py :
mpremote connect COM1 cp ./main.py :
mpremote connect COM1 cp ./main.py :main.py
mpremote connect COM1 cp main.py :main.py
After the ":" symbol, if you enter a filename, the file will be renamed to this filename when copied to the device.
Copy file from device to local :
Code: Select all
mpremote connect COM1 cp :main.py .
mpremote connect COM1 cp :main.py ./
mpremote connect COM1 cp :main.py ./main.py
mpremote connect COM1 cp :main.py main.py
Just use the "." or "./" achieve the same function. But if you want to rename the file, it must be "./", or not used at all.
The above is the operation performed in the relative path, that is, in the path where the current terminal is located.
Copying files in absolute paths is a little more complicated.
On Windows, use the absolute path to the file to copy from local to device:
Code: Select all
mpremote connect COM1 cp D:\temp\main.py :main.py
Code: Select all
mpremote connect COM1 cp :main.py D:\temp\main.py
Using mpremote 0.3.0 that has been released in pypi, you will get a similar error when you do the following on Windows PowerShell:
Code: Select all
PS D:\temp> mpremote connect COM1 cp D:\temp\main.py :
cp D:\temp\main.py :D:\temp\main.py
PS D:\temp> mpremote connect COM1 ls
ls :
66 D: emp\main.py
139 boot.py
PS D:\temp> mpremote connect COM1 cat D: emp\main.py
cat :D:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OSError: [Errno 2] ENOENT
In case you get the same error, follow the steps below to remove the incorrect file.
Code: Select all
PS D:\temp> mpremote connect COM1 cat D:\temp\main.py
cat :D:\temp\main.py
print ("start")
for i in range(2):
print(i)
print ("end")
PS D:\temp> mpremote connect COM1 rm D:\temp\main.py
rm :D:\temp\main.py
PS D:\temp> mpremote connect COM1 ls
ls :
139 boot.py
Code: Select all
PS D:\temp> mpremote connect COM1 cp :main.py D:\temp\
cp :main.py D:\temp\
Traceback (most recent call last):
File "C:\Users\Wind\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Wind\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Wind\AppData\Local\Programs\Python\Python310\Scripts\mpremote.exe\__main__.py", line 7, in <module>
File "C:\Users\Wind\AppData\Local\Programs\Python\Python310\lib\site-packages\mpremote\main.py", line 569, in main
do_filesystem(pyb, args)
File "C:\Users\Wind\AppData\Local\Programs\Python\Python310\lib\site-packages\mpremote\main.py", line 334, in do_filesystem
pyboard.filesystem_command(pyb, args, progress_callback=show_progress_bar)
File "C:\Users\Wind\AppData\Local\Programs\Python\Python310\lib\site-packages\mpremote\pyboard.py", line 594, in filesystem_command
op(src, dest2, progress_callback=progress_callback)
File "C:\Users\Wind\AppData\Local\Programs\Python\Python310\lib\site-packages\mpremote\pyboard.py", line 499, in fs_get
with open(dest, "wb") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\temp\\'
Code: Select all
mpremote connect /dev/ttyACM0 cp ~/temp/main.py :
mpremote connect /dev/ttyACM0 cp /home/wind/temp/main.py :
mpremote connect /dev/ttyACM0 cp :main.py ~/temp/
mpremote connect /dev/ttyACM0 cp :main.py /home/wind/temp/