How to use serial to communicate with a host win32 program

Robin2's serial input basics tutorial may be of interest. It shows how to read incoming serial data into a separate buffer for that purpose. The separate buffer can be made any size (within limits of memory). The bytes are read into the separate buffer as they come in and they are not stored in the hardware serial receive buffer (which is 64 bytes by default).

From the tutorial:

const byte numChars = 32;
char receivedChars[numChars];   // an array to store the received data

You can set the size of the receive buffer (receivedChars) to the size that you need. Be aware that the data is read into a string (null terminated character array) so there needs to be room in the buffer for the terminating null ('\0'). So to receive 128 bytes you need a 129 byte buffer.

1 Like