diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index 04205f498..0205aa66d 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -1,4 +1,5 @@ #include "RedirectablePrint.h" +#include "configuration.h" #include /** @@ -10,4 +11,14 @@ void RedirectablePrint::setDestination(Print *_dest) { assert(_dest); dest = _dest; +} + +size_t RedirectablePrint::write(uint8_t c) +{ +#ifdef SEGGER_STDOUT_CH + SEGGER_RTT_PutCharSkip(SEGGER_STDOUT_CH, c); +#endif + + dest->write(c); + return 1; // We always claim one was written, rather than trusting what the serial port said (which could be zero) } \ No newline at end of file diff --git a/src/RedirectablePrint.h b/src/RedirectablePrint.h index f75aea010..2d525118d 100644 --- a/src/RedirectablePrint.h +++ b/src/RedirectablePrint.h @@ -19,7 +19,7 @@ class RedirectablePrint : public Print */ void setDestination(Print *dest); - virtual size_t write(uint8_t c) { return dest->write(c); } + virtual size_t write(uint8_t c); }; class NoopPrint : public Print diff --git a/src/configuration.h b/src/configuration.h index 5e8964d22..ed851ed8f 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -404,8 +404,11 @@ along with this program. If not, see . // Always include the SEGGER code on NRF52 - because useful for debugging #include "SEGGER_RTT.h" +// The channel we send stdout data to +#define SEGGER_STDOUT_CH 0 + // Debug printing to segger console -#define SEGGER_MSG(...) SEGGER_RTT_printf(0, __VA_ARGS__) +#define SEGGER_MSG(...) SEGGER_RTT_printf(SEGGER_STDOUT_CH, __VA_ARGS__) // If we are not on a NRF52840 (which has built in USB-ACM serial support) and we don't have serial pins hooked up, then we MUST // use SEGGER for debug output diff --git a/src/main.cpp b/src/main.cpp index 0f24e1bc4..b61ef9e18 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -233,8 +233,8 @@ RadioInterface *rIf = NULL; void setup() { -#ifdef USE_SEGGER - SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_TRIM); +#ifdef SEGGER_STDOUT_CH + SEGGER_RTT_ConfigUpBuffer(SEGGER_STDOUT_CH, NULL, NULL, 1024, SEGGER_RTT_MODE_NO_BLOCK_TRIM); #endif // Debug diff --git a/variants/eink/variant.h b/variants/eink/variant.h index 5ce975fb5..6e3fedd67 100644 --- a/variants/eink/variant.h +++ b/variants/eink/variant.h @@ -243,7 +243,7 @@ External serial flash WP25R1635FZUIL0 #define PIN_SPI_SCK (0 + 19) // To debug via the segger JLINK console rather than the CDC-ACM serial device -#define USE_SEGGER +// #define USE_SEGGER #ifdef __cplusplus } diff --git a/variants/pca10056-rc-clock/variant.h b/variants/pca10056-rc-clock/variant.h index 48dc72df2..9d35325c8 100644 --- a/variants/pca10056-rc-clock/variant.h +++ b/variants/pca10056-rc-clock/variant.h @@ -147,7 +147,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #define SX1262_ANT_SW (32 + 10) // P1.10 // To debug via the segger JLINK console rather than the CDC-ACM serial device -#define USE_SEGGER +// #define USE_SEGGER #ifdef __cplusplus } diff --git a/variants/ppr1/variant.h b/variants/ppr1/variant.h index cfefa091b..e6bfd8a03 100644 --- a/variants/ppr1/variant.h +++ b/variants/ppr1/variant.h @@ -168,7 +168,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #define LORA_DISABLE_SENDING // Define this to disable transmission for testing (power testing etc...) // To debug via the segger JLINK console rather than the CDC-ACM serial device -#define USE_SEGGER +// #define USE_SEGGER #ifdef __cplusplus }