Uploading code without restarting the board



  • 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?



  • 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.



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



  • @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.



  • @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-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))```




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



  • @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.


Log in to reply
 

Pycom on Twitter