Add ::peek for compatibility with trunk Arduino.

git-svn-id: https://arducopter.googlecode.com/svn/trunk@943 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
DrZiplok@gmail.com 2010-11-27 01:49:10 +00:00
parent 73eab31d0c
commit 0fd1228e27
2 changed files with 14 additions and 0 deletions

View File

@ -209,6 +209,19 @@ FastSerial::read(void)
return(c);
}
int
FastSerial::peek(void)
{
// if the head and tail are equal, the buffer is empty
if (!_open || (_rxBuffer->head == _rxBuffer->tail))
return(-1);
// pull character from tail
return(_rxBuffer->bytes[_rxBuffer->tail]);
}
void
FastSerial::flush(void)
{

View File

@ -100,6 +100,7 @@ public:
virtual void end(void);
virtual int available(void);
virtual int read(void);
virtual int peek(void);
virtual void flush(void);
virtual void write(uint8_t c);
using BetterStream::write;