Print Statement without REPL

  • Setup:

    • Wipy 3.0 on breadboard powered via 5V DC
    • External ADC interfaced via I2C
    • REPL access via uart0 and a uart/rs232 converter cable to PC

    Basic Tasks:

    • turn LED on with various color scheme as visual debug
    • read ADC
    • print ADC result statement
    • I2C.deinit()
    • machine.deepsleep(10000) # deepsleep 10sec.

    The code reads the ADC fine , goes to deepsleep fine. I add a bunch of debug print statements along the way and I can see them roll out on the REPL. All ok.
    Then I disconnect the uart cable (while running the code) since there won't be any cables during deployment. After a few iterations the code stalls, back into a state with a heartbeat going on the LED.

    If I remove all the print statements from the code, it runs fine even after I remove the uart cable... It ran 12 hrs no problem.

    If I use a wifi+telnet access to the REPL : same thing: as long as the telnet gives me access to the REPL, the program runs fine, when telnet is disconnected, after a few iterations, the code fails similarly as above. (uart was disconnected from the onset)

    Is it a problem to have Print statements in the code when no actual REPL connection is made via either usb, uart, telnet ???

  • Interesting, I'll have to attempt to reproduce this internally. It should be fine to use print statements at any point in time.

  • @timh , Thx for the suggestion, I am going to try that.

  • @ldbm

    I ran into this once too.
    It started occurring fwhen I was trying to use AWS MQTT in a thread in conjunction with pybytes.
    (pybytes is no use to me as we use LTE-CAT M1 and Pybytes doesn't yet support OTA over LTE).

    At the time to work around I ended up creating a Fake Terminal device

    class FakeTerm():
        def read(self):
        def write(self,value):
    term = os.dupterm(FakeTerm())

Log in to reply

Pycom on Twitter