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).
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
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).