Ignore any '\r' characters received from Serial Monitor

This allows the Serial Monitor to send NL or CR/NL at end of each line.  A newline ('\n') must be at the end to terminate reading from the Serial Monitor, but any preceeding carriage returns are stripped out.
This commit is contained in:
Gregg 2021-01-23 20:55:06 -06:00
parent d68c34c53f
commit 9f7d288d18
1 changed files with 5 additions and 4 deletions

View File

@ -55,10 +55,11 @@ char *Utils::readSerial(char *c, int max){
return(c); // return updated string return(c); // return updated string
} }
if(buf!='\r'){ // save any character except carriage return
c[i]=buf; // store new character c[i]=buf; // store new character
if(i<max) // do not store more than max characters (excluding string terminator) if(i<max) // do not store more than max characters (excluding string terminator)
i++; i++;
}
} // while(1) } // while(1)