chain of commands to connect to port and execute script does not work in mpremote

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
generator87
Posts: 2
Joined: Sat Dec 04, 2021 12:51 am

chain of commands to connect to port and execute script does not work in mpremote

Post by generator87 » Sat Dec 04, 2021 12:59 am

Trying to run this chain and getting nothing in reply:
mpremote connect COM2 exec "import os; os.listdir()"
but when I add mount to this after changing setup chain then it works: mpremote connect COM2 mount . exec "import os; os.listdir()"
also tried to first run this: mpremote connect COM2
and received:
Connected to MicroPython at COM2
Use Ctrl-] to exit this shell

next I ran the second half : import os; os.listdir()
and got expected responce:
['abc', 'def']

so it seems like combining connection to a COM port with executing a script not on mounted location but on a real device (Nucleo board STM32WB55) does not work for some scripts.
Tried the following and it worked: mpremote connect COM2 exec "import machine; machine.reset()"

generator87
Posts: 2
Joined: Sat Dec 04, 2021 12:51 am

Re: chain of commands to connect to port and execute script does not work in mpremote

Post by generator87 » Sun Dec 05, 2021 12:11 am

Solution is found. It is addition of print

mpremote connect COM2 exec "import os; print(os.listdir())"

Post Reply