Skip to content

Commit 60c8206

Browse files
mathieucarbouSuGliderpre-commit-ci-lite[bot]
authored
feat(logging): Arduino log redirection (#11159)
* feat(logging): Arduino log redirection * fix(uart): log will only use ets_printf() for uart and cdc * feat(uart_cdc): when CDC is logging, UART is silent * feat(uart_cdc): when CDC is logging, UART is silent * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: Sugar Glider <[email protected]> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 3fcc316 commit 60c8206

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

cores/esp32/HWCDC.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ void HWCDC::setDebugOutput(bool en) {
603603
} else {
604604
ets_install_putc2(NULL);
605605
}
606+
ets_install_putc1(NULL); // closes UART log output
606607
}
607608

608609
#if ARDUINO_USB_MODE && ARDUINO_USB_CDC_ON_BOOT // Hardware JTAG CDC selected

cores/esp32/USBCDC.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ void USBCDC::setDebugOutput(bool en) {
455455
} else {
456456
ets_install_putc2(NULL);
457457
}
458+
ets_install_putc1(NULL); // closes UART log output
458459
}
459460

460461
USBCDC::operator bool() const {

cores/esp32/esp32-hal-uart.c

+1-9
Original file line numberDiff line numberDiff line change
@@ -1186,24 +1186,16 @@ int log_printfv(const char *format, va_list arg) {
11861186
return 0;
11871187
}
11881188
}
1189-
/*
1189+
/*
11901190
// This causes dead locks with logging in specific cases and also with C++ constructors that may send logs
11911191
#if !CONFIG_DISABLE_HAL_LOCKS
11921192
if(s_uart_debug_nr != -1 && _uart_bus_array[s_uart_debug_nr].lock){
11931193
xSemaphoreTake(_uart_bus_array[s_uart_debug_nr].lock, portMAX_DELAY);
11941194
}
11951195
#endif
11961196
*/
1197-
#if (ARDUINO_USB_CDC_ON_BOOT == 1 && ARDUINO_USB_MODE == 0) || CONFIG_IDF_TARGET_ESP32C3 \
1198-
|| ((CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32P4) && ARDUINO_USB_CDC_ON_BOOT == 1)
11991197
vsnprintf(temp, len + 1, format, arg);
12001198
ets_printf("%s", temp);
1201-
#else
1202-
int wlen = vsnprintf(temp, len + 1, format, arg);
1203-
for (int i = 0; i < wlen; i++) {
1204-
ets_write_char_uart(temp[i]);
1205-
}
1206-
#endif
12071199
/*
12081200
// This causes dead locks with logging and also with constructors that may send logs
12091201
#if !CONFIG_DISABLE_HAL_LOCKS

0 commit comments

Comments
 (0)