🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Running code with ampy or rshell or REPL?

    Micropython
    4
    6
    11.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dclaar
      last edited by

      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:

      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')
      
      1 Reply Last reply Reply Quote 0
      • D
        dclaar
        last edited by

        Oh, I can:

        import apps.purple_air as pa
        pa.main()
        
        1 Reply Last reply Reply Quote 0
        • ajb2k3A
          ajb2k3
          last edited by

          Vcode does have a series console that you can use to run REPL through.

          UIFlow, so easy an adult can learn it!
          If I don't know it, be patient!
          I've ether not learned it or am too drunk to remember it!
          Author of the WIP UIFlow Handbook!
          M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

          J 1 Reply Last reply Reply Quote 0
          • lukasmaximusL
            lukasmaximus
            last edited by

            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

            D 1 Reply Last reply Reply Quote 1
            • D
              dclaar @lukasmaximus
              last edited by

              @lukasmaximus I read that Mu requires 1.5.0, and I also read that it isn't out yet for the M5StickC.
              @ajb2k3 I sure haven't been able to find it!

              1 Reply Last reply Reply Quote 0
              • J
                jhfoo @ajb2k3
                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.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post