Skip to content

Conversation

@jaguilar
Copy link
Contributor

It's useful to have a vprintf version of
the uart_debug functions. This will be used
in a later change to assist with logging
messages originating in BTStack.

Also, there was a bug where the error from
writing to the UART was not captured. This
fixes that bug and logs the error on
the next attempt to use the port.

We also increase the buffer size because when
doing higher volume logging the 256 bytes alloted
before were sometimes not enough.

It's useful to have a vprintf version of
the uart_debug functions. This will be used
in a later change to assist with logging
messages originating in BTStack.

Also, there was a bug where the error from
writing to the UART was not captured. This
fixes that bug and logs the error on
the next attempt to use the port.

We also increase the buffer size because when
doing higher volume logging the 256 bytes alloted
before were sometimes not enough.
@coveralls
Copy link

Coverage Status

coverage: 59.78%. remained the same
when pulling 1064875 on jaguilar:uart-debug
into cff1933 on pybricks:master.

@jaguilar jaguilar marked this pull request as ready for review October 30, 2025 03:22
@laurensvalk laurensvalk merged commit 17495a7 into pybricks:master Nov 3, 2025
17 checks passed
@laurensvalk
Copy link
Member

Merged, thanks!

Tested that debug print is still working on Prime Hub.

diff --git a/lib/pbio/platform/prime_hub/pbdrvconfig.h b/lib/pbio/platform/prime_hub/pbdrvconfig.h
index 66b3816b2..43b5883a1 100644
--- a/lib/pbio/platform/prime_hub/pbdrvconfig.h
+++ b/lib/pbio/platform/prime_hub/pbdrvconfig.h
@@ -109,7 +109,7 @@
 #define PBDRV_CONFIG_SOUND_STM32_HAL_DAC            (1)
 
 #define PBDRV_CONFIG_UART                           (1)
-#define PBDRV_CONFIG_UART_DEBUG_FIRST_PORT          (0)
+#define PBDRV_CONFIG_UART_DEBUG_FIRST_PORT          (1)
 #define PBDRV_CONFIG_UART_STM32F4_LL_IRQ            (1)
 #define PBDRV_CONFIG_UART_STM32F4_LL_IRQ_NUM_UART   (6)
 
diff --git a/lib/pbio/sys/hmi_pup.c b/lib/pbio/sys/hmi_pup.c
index 047a97891..4b9a224c2 100644
--- a/lib/pbio/sys/hmi_pup.c
+++ b/lib/pbio/sys/hmi_pup.c
@@ -28,7 +28,7 @@
 
 #include "hmi.h"
 
-#define DEBUG 0
+#define DEBUG 1
 
 #if DEBUG
 #include <pbdrv/../../drv/uart/uart_debug_first_port.h>

void pbdrv_uart_debug_printf(const char *format, ...) {

void pbdrv_uart_debug_vprintf(const char *format, va_list args) {
char buf[BUF_SIZE];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is making the stack quite huge now. We should probably use a separate size for this buffer and the ring buffer.

@jaguilar
Copy link
Contributor Author

jaguilar commented Nov 3, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants