char inputBuffer[91]; // Handles up to 90 bytes in a c-style string, with a null character termination.
void setup()
{
Serial.begin(115200); // initialization
inputBuffer[0] = '\0'; //Initialize string to emtpy.
Serial.println("Begin:");
}
void loop() {
if (Serial.available()>0)
{
char input = Serial.read();
static int s_lens_len; =// strnlen(inputBuffer,static 91);variables default to 0
inputBuffer[s_len++]if (input != input;
'\n' && input != inputBuffer[s_len]'\r') ={
'\0'; // Make string null-terminated again
inputBuffer[s_len++] = input;
if (input ==} '\n')else {
// Have received a LF or CR character
// Flush the receive buffer from linefeed, etc
while(Serial.available()) {
Serial.read();
}
// INSERT YOUR CODE HERE TO PROCESS THE RECEIVED DATA //
// YOU COULD COPY TO A NEW VARIABLE WITH strncpy() OR //
// SET A FLAG TO SAY TO START SOME OTHER TASK //
Serial.print("RECEIVED MSG: ");
inputBuffer[0]Serial.println(inputBuffer);
memset(inputBuffer, 0, sizeof(inputBuffer));
s_len = '\0';0; // Reset input buffer here if you
// have already copied the data.
// If you don't reset here, then
// you can't start receiving more
// serial port data. This is your
// 'software' serial buffer, contrast
// with the hardware serial buffer.
}
}
}