From b2d69e6a8cc13fa2c330d8d8652b9e35d861665a Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 19 Dec 2012 14:02:08 -0800 Subject: [PATCH] AP_HAL_Empty: betterstreams get vprintfs --- libraries/AP_HAL_Empty/Console.cpp | 20 ++++++++++++++------ libraries/AP_HAL_Empty/Console.h | 2 ++ libraries/AP_HAL_Empty/UARTDriver.cpp | 2 ++ libraries/AP_HAL_Empty/UARTDriver.h | 3 +++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/libraries/AP_HAL_Empty/Console.cpp b/libraries/AP_HAL_Empty/Console.cpp index e26a5fe6d7..4c10515c32 100644 --- a/libraries/AP_HAL_Empty/Console.cpp +++ b/libraries/AP_HAL_Empty/Console.cpp @@ -32,20 +32,28 @@ void EmptyConsoleDriver::println_P(const prog_char_t *pstr) { _d->println_P(pstr); } -void EmptyConsoleDriver::printf(const char *pstr, ...) { +void EmptyConsoleDriver::printf(const char *fmt, ...) { va_list ap; - va_start(ap, pstr); - _d->printf(pstr, ap); + va_start(ap, fmt); + vprintf(fmt, ap); va_end(ap); } -void EmptyConsoleDriver::_printf_P(const prog_char *pstr, ...) { +void EmptyConsoleDriver::_printf_P(const prog_char *fmt, ...) { va_list ap; - va_start(ap, pstr); - _d->printf_P(pstr, ap); + va_start(ap,fmt); + vprintf_P(fmt, ap); va_end(ap); } +void EmptyConsoleDriver::vprintf(const char *fmt, va_list ap) { + _d->vprintf(fmt, ap); +} + +void EmptyConsoleDriver::vprintf_P(const prog_char *fmt, va_list ap) { + _d->vprintf_P(fmt, ap); +} + int16_t EmptyConsoleDriver::available() { return _d->available(); } diff --git a/libraries/AP_HAL_Empty/Console.h b/libraries/AP_HAL_Empty/Console.h index 8fca7c4877..eb467f4418 100644 --- a/libraries/AP_HAL_Empty/Console.h +++ b/libraries/AP_HAL_Empty/Console.h @@ -17,6 +17,8 @@ public: void println_P(const prog_char_t *pstr); void printf(const char *pstr, ...); void _printf_P(const prog_char *pstr, ...); + void vprintf(const char *pstr, va_list ap); + void vprintf_P(const prog_char *pstr, va_list ap); int16_t available(); int16_t txspace(); diff --git a/libraries/AP_HAL_Empty/UARTDriver.cpp b/libraries/AP_HAL_Empty/UARTDriver.cpp index 3fbd103cb7..cba12cb24a 100644 --- a/libraries/AP_HAL_Empty/UARTDriver.cpp +++ b/libraries/AP_HAL_Empty/UARTDriver.cpp @@ -18,6 +18,8 @@ void EmptyUARTDriver::print_P(const prog_char_t *pstr) {} void EmptyUARTDriver::println_P(const prog_char_t *pstr) {} void EmptyUARTDriver::printf(const char *pstr, ...) {} void EmptyUARTDriver::_printf_P(const prog_char *pstr, ...) {} +void EmptyUARTDriver::vprintf(const char *pstr, va_list ap) {} +void EmptyUARTDriver::vprintf_P(const prog_char *pstr, va_list ap) {} /* Empty implementations of Stream virtual methods */ int16_t EmptyUARTDriver::available() { return 0; } diff --git a/libraries/AP_HAL_Empty/UARTDriver.h b/libraries/AP_HAL_Empty/UARTDriver.h index 47dec53bf6..abd67f257a 100644 --- a/libraries/AP_HAL_Empty/UARTDriver.h +++ b/libraries/AP_HAL_Empty/UARTDriver.h @@ -22,6 +22,9 @@ public: void printf(const char *pstr, ...); void _printf_P(const prog_char *pstr, ...); + void vprintf(const char* fmt, va_list ap); + void vprintf_P(const prog_char* fmt, va_list ap); + /* Empty implementations of Stream virtual methods */ int16_t available(); int16_t txspace();