mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-26 18:48:30 -04:00
AP_HAL_AVR: implementation for each BetterStream vprintf
* had to rename the utility vprintf function calls to print_vprintf to make the naming work.
This commit is contained in:
parent
7681fef988
commit
1ed6a49a7a
@ -1,7 +1,7 @@
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "vprintf.h"
|
||||
#include "print_vprintf.h"
|
||||
|
||||
#include <AP_HAL.h>
|
||||
#include "Console.h"
|
||||
@ -63,20 +63,29 @@ void AVRConsoleDriver::println_P(const prog_char_t *s) {
|
||||
println();
|
||||
}
|
||||
|
||||
|
||||
void AVRConsoleDriver::printf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vprintf((AP_HAL::Print*)this, 0, fmt, ap);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void AVRConsoleDriver::_printf_P(const prog_char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vprintf((AP_HAL::Print*)this, 1, fmt, ap);
|
||||
vprintf_P(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void AVRConsoleDriver::vprintf(const char *fmt, va_list ap){
|
||||
print_vprintf((AP_HAL::Print*)this, 0, fmt, ap);
|
||||
}
|
||||
|
||||
void AVRConsoleDriver::vprintf_P(const prog_char *fmt, va_list ap){
|
||||
print_vprintf((AP_HAL::Print*)this, 1, fmt, ap);
|
||||
}
|
||||
|
||||
// Stream method implementations /////////////////////////////////////////
|
||||
int16_t AVRConsoleDriver::available(void) {
|
||||
if (_user_backend) {
|
||||
|
@ -24,6 +24,9 @@ public:
|
||||
void _printf_P(const prog_char *s, ...)
|
||||
__attribute__ ((format(__printf__, 2, 3)));
|
||||
|
||||
void vprintf(const char *s, va_list ap);
|
||||
void vprintf_P(const prog_char *s, va_list ap);
|
||||
|
||||
/* Implementations of Stream virtual methods */
|
||||
int16_t available();
|
||||
int16_t txspace();
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <AP_HAL.h>
|
||||
#include <AP_Math.h>
|
||||
|
||||
#include "vprintf.h"
|
||||
#include "print_vprintf.h"
|
||||
#include "UARTDriver.h"
|
||||
using namespace AP_HAL_AVR;
|
||||
|
||||
@ -271,14 +271,23 @@ void AVRUARTDriver::println_P(const prog_char_t *s) {
|
||||
void AVRUARTDriver::printf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vprintf((AP_HAL::Print*)this, 0, fmt, ap);
|
||||
vprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void AVRUARTDriver::vprintf(const char *fmt, va_list ap) {
|
||||
print_vprintf((AP_HAL::Print*)this, 0, fmt, ap);
|
||||
}
|
||||
|
||||
void AVRUARTDriver::_printf_P(const prog_char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vprintf((AP_HAL::Print*)this, 1, fmt, ap);
|
||||
vprintf_P(fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void AVRUARTDriver::vprintf_P(const prog_char *fmt, va_list ap) {
|
||||
print_vprintf((AP_HAL::Print*)this, 1, fmt, ap);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -47,6 +47,9 @@ public:
|
||||
void _printf_P(const prog_char *s, ...)
|
||||
__attribute__ ((format(__printf__, 2, 3)));
|
||||
|
||||
void vprintf(const char *s, va_list ap);
|
||||
void vprintf_P(const prog_char *s, va_list ap);
|
||||
|
||||
/* Implementations of Stream virtual methods */
|
||||
int16_t available();
|
||||
int16_t txspace();
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
#include "Util.h"
|
||||
#include "utility/vprintf.h"
|
||||
#include "print_vprintf.h"
|
||||
using namespace AP_HAL_AVR;
|
||||
|
||||
/* Helper class implements AP_HAL::Print so we can use utility/vprintf */
|
||||
@ -43,7 +43,7 @@ int AVRUtil::snprintf_P(char* str, size_t size, const prog_char_t *format, ...)
|
||||
int AVRUtil::vsnprintf(char* str, size_t size, const char *format, va_list ap)
|
||||
{
|
||||
BufferPrinter buf(str, size);
|
||||
vprintf(&buf, 0, format, ap);
|
||||
print_vprintf(&buf, 0, format, ap);
|
||||
return (int) buf._offs;
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ int AVRUtil::vsnprintf_P(char* str, size_t size, const prog_char_t *format,
|
||||
va_list ap)
|
||||
{
|
||||
BufferPrinter buf(str, size);
|
||||
vprintf(&buf, 1,(const char*) format, ap);
|
||||
print_vprintf(&buf, 1,(const char*) format, ap);
|
||||
return (int) buf._offs;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ extern "C" {
|
||||
#include "xtoa_fast.h"
|
||||
}
|
||||
|
||||
#include "vprintf.h"
|
||||
#include "print_vprintf.h"
|
||||
|
||||
// workaround for GCC bug c++/34734
|
||||
#undef PROGMEM
|
||||
|
Loading…
Reference in New Issue
Block a user