Don't crash on early debug print

This commit is contained in:
Scott Shawcroft 2022-03-08 17:55:21 -08:00
parent 96f5eec2ee
commit 91468ed36b
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA

View File

@ -73,6 +73,11 @@ const mp_print_t debug_uart_print = {NULL, debug_uart_print_strn};
int debug_uart_printf(const char *fmt, ...) {
#if defined(CIRCUITPY_DEBUG_UART_TX)
// Skip prints that occur before debug serial is started. It's better than
// crashing.
if (common_hal_busio_uart_deinited(&debug_uart)) {
return 0;
}
va_list ap;
va_start(ap, fmt);
int ret = mp_vprintf(&debug_uart_print, fmt, ap);