Just a longshot...You ARE trying to determine how many bytes are in the buffer, yes? Not the SIZE of the buffer?I didn't follow all of your code, but the Flash function looks okay...If you're getting two flashes, I'd guess that there two bytes in the buffer at the time you reach the call of Flash.It might be worth doing a little debug version that tests Flash in more isolated circumstances.I note you are doing a third Serial.read after the Flash call, when you don't know that there are more than two bytes TO read. (You don't actually test whether there's ONE to read, but Flash seems to say that there is.You might want to use the fact that Serial.read returns -1 if there is no data TO read at the time Serial.read is called.
Maybe you need a delay after the first serial.available? It could be that the buffer isn't completely filled when you get to the next serial.available.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16