You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • but the computer isn't "connected" to the serial port

    This is the problem, and has been since the first Espruino. There's no way to tell, so you'd just have to have some kind of timeout.

    The obvious one is throwing away the Espruino logo on startup, but let's assume nobody cares about that :)

    So let's take a simple example - someone writes some script on the connected computer that does:

    while (true) {
      while (!data_has_newline) data += get_serial_char;
      http_post(data);
      data = "";
    }
    

    I guess a sensible delay for throwing away data might be 1 second? But an HTTP post could easily block for that time sometimes, and now your reliable USB connection is actually throwing away data :(

    Even if you don't care about that, your Espruino randomly halting for 1 second every so often would probably be really annoying, and difficult to track down (since it'd work when you plugged it in).

About

Avatar for Gordon @Gordon started