diff --git a/api/Stream.cpp b/api/Stream.cpp index f6f9bda6..577c5845 100644 --- a/api/Stream.cpp +++ b/api/Stream.cpp @@ -86,6 +86,11 @@ int Stream::peekNextDigit(LookaheadMode lookahead, bool detectDecimal) // Public Methods ////////////////////////////////////////////////////////////// +void Stream::clear() { + while (available()) + read(); +} + void Stream::setTimeout(unsigned long timeout) // sets the maximum number of milliseconds to wait { _timeout = timeout; diff --git a/api/Stream.h b/api/Stream.h index e81c71ba..fb28ea95 100644 --- a/api/Stream.h +++ b/api/Stream.h @@ -61,6 +61,8 @@ class Stream : public Print virtual int read() = 0; virtual int peek() = 0; + virtual void clear(); // clears the receive buffer + Stream() {_timeout=1000;} // parsing methods @@ -130,4 +132,4 @@ class Stream : public Print } -using arduino::Stream; \ No newline at end of file +using arduino::Stream;