diff --git a/libraries/FastSerial/FastSerial.cpp b/libraries/FastSerial/FastSerial.cpp index 96c613d41c..99553a877b 100644 --- a/libraries/FastSerial/FastSerial.cpp +++ b/libraries/FastSerial/FastSerial.cpp @@ -150,7 +150,7 @@ void FastSerial::end() } -uint8_t +int FastSerial::available(void) { return((RX_BUFFER_SIZE + _rxBuffer.head - _rxBuffer.tail) % RX_BUFFER_SIZE); diff --git a/libraries/FastSerial/FastSerial.h b/libraries/FastSerial/FastSerial.h index 6188986b1f..9849e4a655 100644 --- a/libraries/FastSerial/FastSerial.h +++ b/libraries/FastSerial/FastSerial.h @@ -45,11 +45,14 @@ #define FastSerial_h // disable the stock Arduino serial driver +#ifdef HardwareSerial_h +# error Must include FastSerial.h before the Arduino serial driver is defined. +#endif #define HardwareSerial_h #include #include -#include +#include #include // @@ -82,7 +85,7 @@ extern class FastSerial Serial2; extern class FastSerial Serial3; -class FastSerial : public Print { +class FastSerial : public Stream { public: FastSerial(const uint8_t portNumber, volatile uint8_t *ubrrh, @@ -97,12 +100,12 @@ public: // Serial API void begin(long baud); void end(void); - uint8_t available(void); + int available(void); int read(void); void flush(void); void write(uint8_t c); void write(const uint8_t *buffer, int count); - using Print::write; + using Stream::write; // stdio extensions int printf(const char *fmt, ...); diff --git a/libraries/FastSerial/examples/FastSerial/FastSerial.pde b/libraries/FastSerial/examples/FastSerial/FastSerial.pde index 2923645ebb..4cda83940b 100644 --- a/libraries/FastSerial/examples/FastSerial/FastSerial.pde +++ b/libraries/FastSerial/examples/FastSerial/FastSerial.pde @@ -18,7 +18,7 @@ // Create a FastSerial driver that looks just like the stock Arduino // driver. // -FastSerial Serial; +FastSerialPort0(Serial); // // To create a driver for a different serial port, on a board that