From 865f415d30a4f41e2ef58134da3a97ed6920926c Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Wed, 15 Jan 2025 22:46:13 +0800 Subject: [PATCH] Fix Print::printf implementation --- cores/nRF5/Print.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cores/nRF5/Print.cpp b/cores/nRF5/Print.cpp index 2cce751..f8a3863 100644 --- a/cores/nRF5/Print.cpp +++ b/cores/nRF5/Print.cpp @@ -22,9 +22,15 @@ #include #include #include "Arduino.h" +#include "libc/printf/printf.h" #include "Print.h" +extern "C" void streamOutput(char c, void* arg) +{ + (static_cast(arg))->write(c); +} + // Public Methods ////////////////////////////////////////////////////////////// /* default implementation: may be overridden */ @@ -191,7 +197,7 @@ int Print::printf(const char* format, ...) { va_list va; va_start(va, format); - int ret = vprintf(format, va); + int ret = vfctprintf(&streamOutput, this, format, va); va_end(va); return ret; }