Hi - sorry I'm a bit late to reply here. You really did have a good look in to it!
The output buffer is relatively small, yes - but it won't cause a crash or any kind of problem if that is overflowed - the function will just take a longer time to execute as it will wait for the buffer to become non-full.
For example:
Serial1.print("Hello"); // returns immediately
Serial1.print("Really long string .... ..."/* and so on */); // returns as soon as string length-128 characters have been transmitted (as then the rest is in the buffer)
Do you have up to date firmware? Does pressing Ctrl-C break out of it?
Please could you try and post up a really simple bit of code that crashes the Pico? Something I could just stick in the RHS of the IDE and try myself?
The only thing that immediately sticks out with what you're doing is:
var strRepresentation = JSON.stringify(obj);
Serial1.print(strRepresentation + '\u0004');
Adding a character on to the end of strRepresentation will cause a new variable to be created. If strRepresentation really is big then it could use up all your memory (but it still shouldn't crash - it should warn you of low memory).
To get around it you'd be better off doing 2 prints:
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.
Hi - sorry I'm a bit late to reply here. You really did have a good look in to it!
The output buffer is relatively small, yes - but it won't cause a crash or any kind of problem if that is overflowed - the function will just take a longer time to execute as it will wait for the buffer to become non-full.
For example:
Do you have up to date firmware? Does pressing Ctrl-C break out of it?
Please could you try and post up a really simple bit of code that crashes the Pico? Something I could just stick in the RHS of the IDE and try myself?
The only thing that immediately sticks out with what you're doing is:
Adding a character on to the end of strRepresentation will cause a new variable to be created. If strRepresentation really is big then it could use up all your memory (but it still shouldn't crash - it should warn you of low memory).
To get around it you'd be better off doing 2 prints: