Serial command handler Improvements Help.

sterretje:
Robin's code does not contain the first line in the below

  if (Serial.available() > 0) {

while (Serial.available() > 0 && newData == false) { // <<== NEW - get all bytes from buffer




Maybe you did not show us your latest code but I based my conclusion on


void showNewData() {
 if (newData == true) {
   if (Commands[6] == 87) {
     //Serial.print("This just in ... ");
     //Serial.println(receivedChars);
     parseData();
     showParsedData();
     newData = false;
   }
 }
}



As commands[6] is set by the parser, it's highly unlikely that *if (Commands[6] == 87)* will evaluate to true before the parser is called.

And looking a bit more at your code, don't use delay to simulate in doOtherStuff(). At 115200 baud you have roughly 10 characters per millisecond. 20ms delay is basically 200 characters lost. The software buffer used by HardWare Serial is only 64 bytes; once that's full, other data is lost.

Your other long duration process needs to be chopped into smaller chunks.

how bout we get on the same page real quick and you go read this which IS ROBINS POST... http://forum.arduino.cc/index.php?topic=288234.msg2075585#msg2075585 cuz it kinda just feels a bit like your here to argue, instead of help ... i was using the example code purely as it is presented in order to evaluate its effectiveness.... IN A TUTORIAL POST BY ROBIN TO SHOW NON BLOCKING SERIAL CODE....

when i posted the code the second time i was showing what i had changed it to which makes it worse. I am not here to get help with the non blocking code. I would like to know how to modify that library to include one more value instead of just a single command and a single value. The more we talk about the sample code that i posted just to show what i had tried outside of that the more off topic we become and the more i fear for the fate of the human race as reading becomes only for leisure....

Your other long duration process needs to be chopped into smaller chunks.

that is another awesome reason why i was looking at the library that i took time out of my day to post both the header file and cpp file is because there are routines in my code that cannot be chopped into smaller blocks or made any faster than they are therefore the library manages the serial better with longer execution times. functions that take between 1 and 5 seconds to execute and that is without dead time...