What happens if sketch tries to write to serial when no port is available?

Hi all,

For testing purposes i write data to the serial port. But what happens if the serial port is not connected and the sketch still tries to write to serial port?

and another question:

In my sketch i append data to a string which i write to an SD card. It seems that when the string becomes too large (8000 characters orso) there is just garbage in the file. Can't post it here cos the charater coding is not accepted...

This happens faster (i.e. the strings size is smaller (at 4000 characters)) when the baudrate is higher. I assume hereby that when you write a lot to the serial port, it eats more memory thus leaving less room for the datastring to become large.

is this true?

But what happens if the serial port is not connected and the sketch still tries to write to serial port?

Nothing happens. Unless the other end should write something back or some kind of handshake protocol is involved, your sketch can't tell if the port is connected or not.

For testing purposes i write data to the serial port. But what happens if the serial port is not connected and the sketch still tries to write to serial port?

The data spills out of the port and runs all over the carpet. Data stains are a pain to get out.

In my sketch i append data to a string which i write to an SD card. It seems that when the string becomes too large (8000 characters orso) there is just garbage in the file. Can't post it here cos the charater coding is not accepted...

This happens faster (i.e. the strings size is smaller (at 4000 characters)) when the baudrate is higher. I assume hereby that when you write a lot to the serial port, it eats more memory thus leaving less room for the datastring to become large.

is this true?

The faster you write to the serial port the more chance you have of overflowing the serial buffer. As this is a cyclic buffer you will start losing characters. It won't corrupt other memory, nor consume more space.

It is more likely that you are using the String class and you are fragmenting your memory and it's all getting in a mess.

Data stains are a pain to get out.

Only the 1s. The 0s are easy to clean up.