This really will be the last thing I post on this topic. You have (more than once) posted code that contains:
while(Serial.available())
{
delay();
[glow]if(Serial.available() > 0)[/glow]
{
// Read the serial data
}
}
The question that I have asked more than once, and that you have not answered, is what is the purpose of the highlighted statement?
If there is no serial data, the body of the while loop, where the delay statement and if statement are will not be executed.
If there is serial data, the delay statement will be executed. While the delay is going on, the amount of serial data waiting to be read may increase. But, there is no possible way for the amount of serial data waiting to be read to decrease.
So, after the delay is done, why is there a need to test whether there is serial data available to be read?
Your belief that the delay is used to decrease the amount of data in the buffer is something you have created in your mind and only stated by you.
I have never, ever said that the delay could in any way reduce the amount of data available. Quite to the contrary, I have repeatedly said that the amount of data can only increase during the (completely unnecessary) delay.