Replies: 2 comments 4 replies
-
We have two REPL modes in MicroPython: 1) REPL, and 2) raw REPL. The second mode is for program to program script transfer and execution, like ampy and your program with MicroPython firmware. Have you tried mpremote mount . You can run your scripts without making copies on your board. Good for development and testing. But it is up to you, there is a useful learning process to be gained here. To make your program work properly, you need to handle different REPL modes, especially the raw REPL. |
Beta Was this translation helpful? Give feedback.
-
Perhaps I can show you a simple example. $ cd ~/micropython/scripts/tests/tool_test
$ ls
ESP8266 pow.py
$ mpremote a0 mount .
Local directory . is mounted at /remote
Connected to MicroPython at /dev/ttyACM0
Use Ctrl-] or Ctrl-x to exit this shell
>
MicroPython v1.25.0-preview.442.g3805e65ed.dirty on 2025-04-05; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>> import os
>>> os.listdir()
['pow.py', 'ESP8266']
>>> with open('ESP8266/pow.mpy', 'rb') as f:
... w = f.read(10)
... print(w)
...
b'M\x06\x00\x1f\t\x00\x0cpow'
>>> import pow
2.828427
>>> with open('test.txt', 'w') as f:
... f.write('Hello World!')
...
12
>>> Ctrl-x
$ cat test.txt
Hello World! What you want to do already exists. But as I said, if you have the time and the will, please continue. Or maybe you have some other features you want to implement. We learn by doing! $ mpremote --help
mpremote -- MicroPython remote control
See https://docs.micropython.org/en/latest/reference/mpremote.html
List of commands:
connect connect to given device
disconnect disconnect current device
edit edit files on the device
eval evaluate and print the string
exec execute the string
fs execute filesystem commands on the device
help print help and exit
mip install packages from micropython-lib or third-party sources
mount mount local directory on device
repl connect to given device
resume resume a previous mpremote session (will not auto soft-reset)
rtc get (default) or set the device RTC
run run the given local script
sleep sleep before executing next command
soft-reset perform a soft-reset of the device
umount unmount the local directory
version print version and exit
List of shortcuts:
--help
--version
a0 connect to serial port "/dev/ttyACM0"
a1 connect to serial port "/dev/ttyACM1"
a2 connect to serial port "/dev/ttyACM2"
a3 connect to serial port "/dev/ttyACM3"
bootloader make the device enter its bootloader
c0 connect to serial port "COM0"
c1 connect to serial port "COM1"
c2 connect to serial port "COM2"
c3 connect to serial port "COM3"
cat
cp
devs list available serial ports
df
ls
mkdir
reset hard reset the device
rm
rmdir
sha256sum
touch
u0 connect to serial port "/dev/ttyUSB0"
u1 connect to serial port "/dev/ttyUSB1"
u2 connect to serial port "/dev/ttyUSB2"
u3 connect to serial port "/dev/ttyUSB3" |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is anyone familiar with the repl virtual terminal? I'm writing a program that accesses the repl via uart just like putty but allows me to upload and download files like ampy. Why? Because ampy SUCKS and you have to close putty to upload a program. It was going really well until I got to Control+E Paste mode. The commands start behaving completely different. I dont understand how putty knows what mode its in, it doesn't send any commands to tell it that its in a different mode but backspace doesn't send ^[K to erase to end of line.
Also the bug part, even in putty, you are allowed to backspace over the === which causes an error. Invalid syntax I think. This is not allowed in normal mode with >>>
Beta Was this translation helpful? Give feedback.
All reactions