diff --git a/libraries/AP_HAL/UARTDriver.h b/libraries/AP_HAL/UARTDriver.h index 9176ef8e32..7eca440269 100644 --- a/libraries/AP_HAL/UARTDriver.h +++ b/libraries/AP_HAL/UARTDriver.h @@ -60,10 +60,10 @@ public: void println_P(const prog_char_t *pstr) {} void printf(const char *pstr, ...) {} void _printf_P(const prog_char *pstr, ...) {} - int txspace() { return 1; } /* Empty implementations of Stream virtual methods */ int available() { return 0; } + int txspace() { return 1; } int read() { return -1; } int peek() { return -1; } diff --git a/libraries/AP_HAL/utility/BetterStream.h b/libraries/AP_HAL/utility/BetterStream.h index d7160b0c75..bc26fabc3d 100644 --- a/libraries/AP_HAL/utility/BetterStream.h +++ b/libraries/AP_HAL/utility/BetterStream.h @@ -32,9 +32,6 @@ class AP_HAL::BetterStream : public AP_HAL::Stream { public: BetterStream(void) {} - // Stream extensions - virtual int txspace(void) = 0; - virtual void print_P(const prog_char_t *) = 0; virtual void println_P(const prog_char_t *) = 0; virtual void printf(const char *, ...) diff --git a/libraries/AP_HAL/utility/Stream.h b/libraries/AP_HAL/utility/Stream.h index 6cb6aba57e..b278c5492b 100644 --- a/libraries/AP_HAL/utility/Stream.h +++ b/libraries/AP_HAL/utility/Stream.h @@ -11,10 +11,15 @@ class AP_HAL::Stream : public AP_HAL::Print { public: virtual int available() = 0; + /* NB txspace was traditionally a member of BetterStream in the + * FastSerial library. As far as concerns go, it belongs with available() */ + virtual int txspace() = 0; + /* return value for read() and peek() : * -1 if nothing available, uint8_t value otherwise. */ virtual int read() = 0; virtual int peek() = 0; + }; #endif // __AP_HAL_UTILITY_STREAM_H__ diff --git a/libraries/AP_HAL_AVR/UARTDriver.h b/libraries/AP_HAL_AVR/UARTDriver.h index 1e1d82b416..67c4c3af0b 100644 --- a/libraries/AP_HAL_AVR/UARTDriver.h +++ b/libraries/AP_HAL_AVR/UARTDriver.h @@ -40,7 +40,6 @@ public: } /* Implementations of BetterStream virtual methods */ - int txspace(); void print_P(const prog_char_t *s); void println_P(const prog_char_t *s); void printf(const char *s, ...) @@ -50,6 +49,7 @@ public: /* Implementations of Stream virtual methods */ int available(); + int txspace(); int read(); int peek();