if (serial.available()==0)...

I’ve put some stuff in the serial buffer. I have no way of knowing how much of what’s in the buffer is what I want to read now, so I’m reading through it a byte at a time. I do know I won’t want to read more than 5 bytes.

(By the way, I DO seem to be getting bytes from the buffer, not 16 bit chunks, which I wondered if I’d get, give that the docs say that read CAN return integers. And I’m reading into an integer.)

//Prepare…
boDone=false;

//First attempt to read and use a byte from buffer…
if (serial.available()==0)
{boDone=true;}
else
{iTmp=serial.read;
<do things with it, some of which can lead to
setting boDone true.>;};

//Second attempt…
if ((serial.available()==0)||(boDone==true))
{boDone=true;}
else
{iTmp=serial.read
<do things with it, some of which can lead to
setting boDone true.>;};

… and then there are 3rd, 4th and 5th attempts, just like the second.

For some reason, my program is saying there isn’t anything in the buffer when I’m pretty sure there is.

I don’t think anything new is being written to the buffer.

I’m not using interupts or anything “clever”.

If I put a delay(80) in front of each if ((serial.available()==0), it SOMETIMES helps, I think.

Any ideas???

It’s late, I have a fever. The above typed by hand, the Arduino (s/w 010, by the way) is on another machine. You don’t need to tell me about capital letter, semicolon, etc errors… I hope!

Thanks, Tom

Re-wrote the program, to avoid serial.available.

Late in the course of that (too late to go back and re-try the serial.avaialble alternative), found a flaw in logic of code using the data.

Bottom line: serial.available may be working just fine.

Whew!