Running code with ampy or rshell or REPL?
I'm trying to streamline the debug cycle. Since vscode doesn't have a serial console (does it?) I run my code from there, it fails, then I have to stop that, go to putty, see what the error was, quit putty, reconnect vscode...
I tried a couple of suggestions I found here: ampy & rshell, but couldn't get them to work.
I have a file /flash/apps/purple_air.py. I can't seem to run it. If I start rshell, there's no run command. If I try using the shell command:
cd /flash/apps shell purple_air.py
It opens the file in vscode. But since vscode isn't connected to the com port, the run icon doesn't work.
From ampy, the run command can't seem to find imports, but when I run from vscode or via the apps interface on the m5stickC, it works just fine. My imports:
from m5stack import * from m5ui import * from uiflow import * import imu import wifiCfg
ampy -pcom4 run purple_air.py Traceback (most recent call last): File "c:\python36\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Python36\Scripts\ampy.exe\__main__.py", line 7, in <module> File "c:\python36\lib\site-packages\click\core.py", line 764, in __call__ return self.main(*args, **kwargs) File "c:\python36\lib\site-packages\click\core.py", line 717, in main rv = self.invoke(ctx) File "c:\python36\lib\site-packages\click\core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "c:\python36\lib\site-packages\click\core.py", line 956, in invoke return ctx.invoke(self.callback, **ctx.params) File "c:\python36\lib\site-packages\click\core.py", line 555, in invoke return callback(*args, **kwargs) File "c:\python36\lib\site-packages\ampy\cli.py", line 337, in run output = board_files.run(local_file, not no_output) File "c:\python36\lib\site-packages\ampy\files.py", line 303, in run out = self._pyboard.execfile(filename) File "c:\python36\lib\site-packages\ampy\pyboard.py", line 273, in execfile return self.exec_(pyfile) File "c:\python36\lib\site-packages\ampy\pyboard.py", line 267, in exec_ raise PyboardError('exception', ret, ret_err) ampy.pyboard.PyboardError: ('exception', b'', b'Traceback (most recent call last):\r\n File "<stdin>", line 6, in <module>\r\n File "flowlib/lib/wifiCfg.py", line 3, in <module>\r\nImportError: cannot import name cfgRead\r\n')
Oh, I can:
import apps.purple_air as pa pa.main()
ajb2k3 last edited by
Vcode does have a series console that you can use to run REPL through.
You could also try Mu. It may not have all the features that vscode has but it has a nice clean interface and works for transferring files between computer and m5stack, REPL, and has autocomplete for micropython base modules, i made a video on it a couple of weeks ago https://www.youtube.com/watch?v=GPRNUCBTVy4&t=6s
jhfoo last edited by
@ajb2k3 Adding to this: I'm using the pymakr extension to VS Code. It handles selective code upload (only changed ones).
Note that pymakr does not handle binary file transfer eg. jpg.