kunsa / ardupilot-mega

Automatically exported from code.google.com/p/ardupilot-mega
0 stars 0 forks source link

Think there is a small bug in FastSerial #818

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Know that a ring buffer witn N byte arrays can store at most N-1 bytes 
(unless some kind of full-or-empty flag is added)
2. Look at FastSerial::txspace(void) : return ((_txBuffer->mask+1) - 
((_txBuffer->head - _txBuffer->tail) & _txBuffer->mask));
3. Realize this may return N = _txBuffer->mask+1 if the buffer is empty. This 
is one too many.

What is the expected output? What do you see instead?
No effects observed but the last byte in a chunk of data might occasinally get 
lost.

What version of the product are you using? On what operating system?
ArduPilot 2.68

Original issue reported on code.google.com by Soren.Kuula@gmail.com on 5 Dec 2012 at 10:03

GoogleCodeExporter commented 8 years ago
Did mean "with an array length on N bytes" in 1).

Original comment by Soren.Kuula@gmail.com on 5 Dec 2012 at 10:05