From 908de78fe941c3a36b7f3ae5b39e1e30cb16ba97 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Fri, 24 Oct 2014 15:26:38 +0200 Subject: [PATCH] Move the flush method from Stream to Print This method originally flushed pending input bytes, which makes sense in Stream. At some point it was changed to flush output bytes instead, but it was never moved to Print to reflect this. Since Stream inherits from Print, this should not really affect any users of the Stream or Print classes. However to prevent problems with existing implementations of the Print class that do not provide a flush() implementation, a default implementation is provided. We should probably remove this at some point in the future, though. --- hardware/arduino/avr/cores/arduino/Print.h | 2 ++ hardware/arduino/avr/cores/arduino/Stream.h | 1 - hardware/arduino/sam/cores/arduino/Print.h | 2 ++ hardware/arduino/sam/cores/arduino/Stream.h | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hardware/arduino/avr/cores/arduino/Print.h b/hardware/arduino/avr/cores/arduino/Print.h index 7b53aa4d17e..a2a56de62c6 100644 --- a/hardware/arduino/avr/cores/arduino/Print.h +++ b/hardware/arduino/avr/cores/arduino/Print.h @@ -79,6 +79,8 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); + + virtual void flush() { /* Empty implementation for backward compatibility */ } }; #endif diff --git a/hardware/arduino/avr/cores/arduino/Stream.h b/hardware/arduino/avr/cores/arduino/Stream.h index 15f6761f001..c30d16463e2 100644 --- a/hardware/arduino/avr/cores/arduino/Stream.h +++ b/hardware/arduino/avr/cores/arduino/Stream.h @@ -48,7 +48,6 @@ class Stream : public Print virtual int available() = 0; virtual int read() = 0; virtual int peek() = 0; - virtual void flush() = 0; Stream() {_timeout=1000;} diff --git a/hardware/arduino/sam/cores/arduino/Print.h b/hardware/arduino/sam/cores/arduino/Print.h index 7b53aa4d17e..a2a56de62c6 100644 --- a/hardware/arduino/sam/cores/arduino/Print.h +++ b/hardware/arduino/sam/cores/arduino/Print.h @@ -79,6 +79,8 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); + + virtual void flush() { /* Empty implementation for backward compatibility */ } }; #endif diff --git a/hardware/arduino/sam/cores/arduino/Stream.h b/hardware/arduino/sam/cores/arduino/Stream.h index 0d9a49aca3a..b677dd18d52 100644 --- a/hardware/arduino/sam/cores/arduino/Stream.h +++ b/hardware/arduino/sam/cores/arduino/Stream.h @@ -48,7 +48,6 @@ class Stream : public Print virtual int available() = 0; virtual int read() = 0; virtual int peek() = 0; - virtual void flush() = 0; Stream() {_timeout=1000;}