Console output messed up using Pymkr plugin "Run"



  • Hi all, I'm using a few threads in my script but I have a problem with the console. The first thread that I start is used to manage the WiFi connection as described in the tutorials like this:
    [REMOVED AS OF EDIT2]

    The problem is that at first boot (at power up) I only get this thread's output. Any other "print" gets lost.
    The only way to be able to see the output is to stop and restart the script (i'm using Atom plugin) so the WiFi stays connected an the output is brief.

    How can I solve this? I'm facing serious problems developing

    EDIT:
    Thanks to @Innocenzo I can say for sure that the issue is with the Pymkr plugin for Atom. If I use "execfile('main.py')" all the output is printed (even inside the Atom console); this means that there's a bug in the "Run" command

    EDIT 2:
    Use this code to reproduce the problem (change wifi credential to a valid one). Using the "Run" command the output stops after successfully connecting to the WiFi network.
    If you use "execfile()" the output keeps being printed

    import _thread
    import time
    import machine
    from network import WLAN
    
    
    def th_wifi_mng(delay):
        try:
            wlan = WLAN()
            found = 0
            while True:
                if not wlan.isconnected():
                    nets = wlan.scan()
                    for net in nets:
                        if net.ssid == "yourSSID":
                            wlan.connect(net.ssid, auth=(net.sec,"yourPsw"), timeout=5000)
                            found = 1
                    if found == 1:
                        while not wlan.isconnected():
                            machine.idle() # save power while waiting
                wifi_connected = wlan.isconnected()
                time.sleep(delay)
        except Exception as e:
            print('th_wifi_mng', e)
    
    
    # WiFi initialization
    wlan = WLAN()
    if(wlan.mode() != WLAN.STA):
        wlan = WLAN(mode=WLAN.STA)
    
    # spawn threads
    _thread.start_new_thread(th_wifi_mng, (2,))
    
    while True:
        print("main loop")
        time.sleep(.1)
    


  • @Ralph It seems there's a new bug. (almost) Every time I click the "Sync" button all the files get uploaded. Also I notice something that looks like a piece of checksum being printed like this:

    >>> Syncing project (main folder)...
    
    >>>
    >>> [1/12] Writing file communication.py
    c8474829a403c5fefb5e339b"]]
    [2/12] Writing file config.py
    [3/12] Writing file globals.py
       [...etc...]
    [12/12] Writing file utils.py
    Synchronizing done, resetting board...
    

    EDIT:
    Also, "Run" command on a file doesn't update the file on the flash, resulting in a strange behaviour if the current file is also present in the flash.
    Editing the script and running it seems to use the classes from the file on the flash memory, and the "top level" instructions from the editor file :/

    EDIT2:
    Now the "Sync" end with an error. I rebooted the board, the PC and updated the firmware....

    >>> Syncing project (main folder)...
     
    >>>
    >>> [1/13] Writing file communication.py
    [2/13] Writing file config.py
    Synchronizing failed: Write failed. Please reboot your device manually.   
    

    EDIT3:
    Fixed with the new release



  • @Ralph Thank you! I confirm the bug is fixed



  • @Andrea-Filippini Thanks for posting your code. Using it I got the same issue and found the bug that was causing it. It's been solved in the latest commit on the develop branch on github. It'll be included in the next release. Until then, feel free to manually install the plugin from the develop branch



  • @Ralph See edit 2



  • hi @Andrea-Filippini can you post your code, or a simplified version of it, so I can try to replicate the problem? The quick usage example from the docs seems to be working for me.



  • @Andrea-Filippini Use Filezilla or ampy to put your script on board. After, from REPL, use

    execfile("myscript.py")
    


  • @Innocenzo I can connect to the REPL console via USB cable, but I don't exactly know how to run a python script from there :/



  • @Andrea-Filippini Try to execute your code on Terminal like Tera Term or Termite. Sometimes the Atom plugins does not print me everything.


Log in to reply
 

Pycom on Twitter