Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Uploading code without restarting the board

    Scheduled Pinned Locked Moved LoPy
    lopyftpvscode
    9 Posts 3 Posters 1.1k Views 3 Watching
    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.
    • O Offline
      oved.yavine
      last edited by

      Is there a way to update code on the board without restarting it?
      the VS code plugin is uploading the files and resetting it.
      This is a frustrating process to test code.
      I know I can run 1 file, but i have several code files and not only 1
      I wish I could just copy files to the board and test without it getting restarted

      I also tried to upload changes via FTP, but the latest code copied is not updated (cached files?)

      any solution?

      robert-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @oved.yavine
        last edited by robert-hh

        @oved-yavine You have to remove the names of the to-be-tested module from the list of symbols. The following short function may do so:

        def reload(mod):
            import sys
            mod_name = mod.__name__
            del sys.modules[mod_name]
            return __import__(mod_name)
        

        If the module you are testing is called mymodule.py, and you had it imported with import mymodule, then calling
        reload(mymodule) will re-import it and start it again. I have that function included in my main.py, so I can call it from REPL when needed.

        O 2 Replies Last reply Reply Quote 0
        • O Offline
          oved.yavine @robert-hh
          last edited by

          @robert-hh so what you are suggesting is to upload via FTP and call the reload function?

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @oved.yavine
            last edited by

            @oved-yavine Yes.

            O 1 Reply Last reply Reply Quote 0
            • O Offline
              oved.yavine @robert-hh
              last edited by

              @robert-hh I was partially able to accomplish what you explained

              it seems like that if i am testing module A, but calling a function on Module B that loads Module A your method to relaod module A is not working
              I tried reloading module A and B, but with no luck

              After struggling i found that I need to reload all tested modules in the hierarchy starting from the bottom
              in my case reloading module A and then reloading module B

              I enhanced your reload function to be:

              def reload(mods):
                  import sys
                  for mod in mods:
                      mod_name = mod.__name__
                      del sys.modules[mod_name]
                      print (__import__(mod_name))```
              1 Reply Last reply Reply Quote 1
              • O Offline
                oved.yavine @robert-hh
                last edited by

                @robert-hh I am still having issues with testing my modules without "upload all" files and restart my board. my code changes are not reflected even when I execute reload as mentioned.

                I cannot figure out how to do this.

                making a code change, upload all and test again is a painful process..

                Any help would be appreciated

                robert-hhR 1 Reply Last reply Reply Quote 0
                • robert-hhR Offline
                  robert-hh @oved.yavine
                  last edited by

                  @oved-yavine I would not consider re-boot as a painful process. It's just pushing Ctrl-D. If uploading is what hurts, you could also keep all files on the device and edit them in-place, for instance with the use of Filezilla. Once you see the files of your device in the device pane of Filezilla, you can edit them there with your favorite editor. Filezilla will take care of downloading and uploading the file. That#s what I do.

                  O 1 Reply Last reply Reply Quote 0
                  • O Offline
                    oved.yavine @robert-hh
                    last edited by oved.yavine

                    @robert-hh thanks for the reply .. i resolved my issue ... your help is really appreciated

                    1 Reply Last reply Reply Quote 0
                    • R Offline
                      Ralph
                      last edited by

                      Hi guys, I didn't read everything below in detail, but I just wanted to add that the Pymakr package for Atom has an option for not rebooting after upload :) No need to switch to FTP if the reboot part is the issue.

                      Actually, VSCode is supposed to have the same option, but when testing it just now it shows a bug (it doesn't show any output in the terminal after upload). I'm going to fix that now and add it in the next release. After that, you can add "reboot_after_upload" key to the global or project config file ("reboot_after_upload": false) and it will not reboot the board after uploading or downloading.

                      1 Reply Last reply Reply Quote 0

                      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                      With your input, this post could be even better 💗

                      Register Login
                      • 1 / 1
                      • First post
                        Last post

                      Pycom on Twitter

                      Pycom