I'm using the native port as emulated serial port (USB-CDC) with "SerialUSB" to write/read data from Serial Monitor. When I send a first message this code works well, but, when I send some others messages, the recived data are lost as if the buffer does not supply a message.
Here is my simple code:
void setup()
{
SerialUSB.begin(115200);
while (!SerialUSB) ;
}
void loop()
{
String aux = " ";
SerialUSB.flush();
while( SerialUSB.available() > 0 )
{
char c = SerialUSB.read();
aux += c;
}
if(aux != " ")
SerialUSB.println(aux);
}