AWOL:
In your original code, if there is no data in the receive buffer, Serial.available returns zero.
Zero, as I pointed out, is less than five, so you go ahead and read the five bytes of data that aren't in the buffer.
I get that if Serial.available is 0 when no data is present. Which means that the While statment and all below it would not even run cause the If statement would be false for no data.
So, the following is what I had interpeted the while statement was doing.
If serial data available (true or greater than 0), and while (serial.available) is less than 5 (true), keep receiving and putting in data into arrray via the for loop. When Serial data is 5, the while statement is finished and we reached end of packet. The If statement has to be true before it will even bother executing the while statement right? I guess I am over anaylizing it. Seems While x < y do something in the while loop when x = y, the while loop terminates.
Sorry, just want to be sure I fully understand this and why it works as you have shown.
I would still like to know why the working result returns three lines of data when I only expected 1 and shown in three posts up.
Shawn