• If you use console.log in a program but disconnect the program execution is blocked when the console buffer is full.

    For example:

    // Console.log blocks LED On/Off flashing when
    // disconnected
    
    var l=0;
    myinterval=setInterval(function () {
       digitalWrite(LED1,l=!l);
    }, 1000);
    
    var i=0;
    setInterval(function(){
      console.log(i);
      i++;
    },200);
    
    // load program
    // LED is pulsing On an dOff
    // Console is displaying the count in i
    // Disconnect the WebIde
    // The LED action stops
    // Reconnect the WebIde
    // Buffered count is displayed
    // LED resumes action
    

    and the output:

              |_| http://espruino.com
     1v95 Copyright 2017 G.Williams
    >
    =undefined
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    Disconnected   ( the LED stops until reconnected)
    >
    12
    13
    14
    15
    16
    

    If you are using console.log to show the connection status etc. of a WiFi connection, disconnecting the WebIde will block the server.

    Not complaining about this, just posting to let others know about this gotcha.

  • Wow, I'm amazed you only just hit this :) It's been in troubleshooting for a while (http://www.espruino.com/Troubleshooting) but might be a bit hard to find.

    It's because Espruino doesn't want to lose data when it's connected to USB, and it has no way of knowing if data is not being accepted because the computer on the end is busy, or because no application is running on it

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

console.log blocks action when disconnected from WebIDE (or a terminal program)

Posted by Avatar for ClearMemory041063 @ClearMemory041063

Actions