Detect if REPL is connected



  • How do you detect if there is a console connection present?
    Use case is I don't want my device to go into deepsleep if I'm working on it.



  • I am using a W01 module connected via P0, P1 (the standard Rx/Tx lines of the serial REPL) to a FT232R serial-USB-interface. The FT232R is powered from USB.
    By defining P0 (i.e. Rx) as input with pull down activated, it is possible to dectect if REPL (i.e. the USB) is connected (P0=1=yes)
    It may be interesting to note that UART operation is not affected by having Rx(P0) declared as digital input simultaneously.

    By this method, the module detects a serial console during boot and continues in REPL mode. If there is no active serial connection detected, it autostarts its application.

    I am not sure if this works with a Wipy since the serial-USB interface may be powered from the Wipy, possibly making the status of Rx independent of the USB cable connection.



  • I had a similiar situation where I wish to disable WDT when using console.
    I put a jumper cable in between ground and a pin. The check for it on bootup and then if pulled to ground will not start the WDT.



  • @tobz If you have the chance to connect one of the modem control signals like RTS to a GPIO port, then you can use that one.



  • I have found myself stuck a few times with ESP8266 as well as ESP32 with exactly the same issue!

    The Pyboard has a useful USB_VCP.isconnected method which does exactly the function you are after. However, I am not sure if ESP32 offers that function. Perhaps a Pycom github enhancement request?

    As an interim measure I now put in a 30 second delay on a hard reset ( using machine.RESET_CAUSE) allowing me time to interrupt the script.
    Not very elegant, but it works.


Log in to reply
 

Pycom on Twitter