From efe04751ff3cd065e7246306a2e38a4354ef14c8 Mon Sep 17 00:00:00 2001 From: tyeth Date: Tue, 17 Dec 2024 18:09:20 +0000 Subject: [PATCH] Flush after debug prints, except SAMD (flush routine too big for SAMD21) --- src/Wippersnapper.cpp | 2 ++ src/Wippersnapper.h | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Wippersnapper.cpp b/src/Wippersnapper.cpp index a4c190825..9e749848b 100644 --- a/src/Wippersnapper.cpp +++ b/src/Wippersnapper.cpp @@ -2711,8 +2711,10 @@ void print_reset_reason(int reason) { */ /**************************************************************************/ void printDeviceInfo() { + WS_PRINTER.flush(); WS_DEBUG_PRINTLN("-------Device Information-------"); WS_DEBUG_PRINT("Firmware Version: "); + WS_PRINTER.flush(); WS_DEBUG_PRINTLN(WS_VERSION); WS_DEBUG_PRINT("Board ID: "); WS_DEBUG_PRINTLN(BOARD_ID); diff --git a/src/Wippersnapper.h b/src/Wippersnapper.h index ede523228..5c3292bdc 100644 --- a/src/Wippersnapper.h +++ b/src/Wippersnapper.h @@ -46,17 +46,49 @@ // Define actual debug output functions when necessary. #ifdef WS_DEBUG +#if defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRWIFI1010) #define WS_DEBUG_PRINT(...) \ - { WS_PRINTER.print(__VA_ARGS__); } ///< Prints debug output. + { \ + WS_PRINTER.print(__VA_ARGS__); \ + yield(); \ + } ///< Prints line from debug output. +#define WS_DEBUG_PRINTLN(...) \ + { \ + WS_PRINTER.println(__VA_ARGS__); \ + yield(); \ + } ///< Prints line from debug output. +#define WS_DEBUG_PRINTHEX(...) \ + { \ + WS_PRINTER.print(__VA_ARGS__, HEX); \ + yield(); \ + } ///< Prints debug output. +#else +#define WS_DEBUG_PRINT(...) \ + { \ + WS_PRINTER.print(__VA_ARGS__); \ + WS_PRINTER.flush(); \ + yield(); \ + } ///< Prints line from debug output. #define WS_DEBUG_PRINTLN(...) \ - { WS_PRINTER.println(__VA_ARGS__); } ///< Prints line from debug output. + { \ + WS_PRINTER.println(__VA_ARGS__); \ + WS_PRINTER.flush(); \ + yield(); \ + } ///< Prints line from debug output. #define WS_DEBUG_PRINTHEX(...) \ - { WS_PRINTER.print(__VA_ARGS__, HEX); } ///< Prints debug output. + { \ + WS_PRINTER.print(__VA_ARGS__, HEX); \ + WS_PRINTER.flush(); \ + yield(); \ + } ///< Prints debug output. +#endif #else #define WS_DEBUG_PRINT(...) \ {} ///< Prints debug output #define WS_DEBUG_PRINTLN(...) \ {} ///< Prints line from debug output. +#define WS_DEBUG_PRINTHEX(...) \ + {} ///< Prints debug output. #endif #define WS_DELAY_WITH_WDT(timeout) \