I'm working on a low level USB Host library on a Pico/W, so I can't log to the USB device. I've hooked up a Pico Debug probe, so I can see output on the UART.
There's a bit of printf() logging that I'm doing, which is probably not a great idea, but it is also very helpful and useful.
I'd like to intercept calls to printf() and have them get sent to a ring_buffer (or a string buffer). Then, when there's not much going on, I'd like to be able to output the contents of the buffer to the actual UART, so I can see what's going on.
Here's what I've done or tried to do:
1) Instead of stdio_init_all(), I'm just using stdout_uart_init()
2) I have a buffer ready to use
3) I can't seem to intercept/override the stdio_uart.out_chars callback, I have no handle to it
What I'd like to do:
1) Redirect the stdio_uart.out_chars callback to use my function and not the default one
2) When my function gets called, it just printf's to my buffer
3) When the performance sensitive code is complete, I'd like to queue a task to write the data to the UART
This seems like a task that is relatively common, but I can't find any good example of it.
Is there anything in pico-sdk that lets me do this?
Thanks,
Steve
There's a bit of printf() logging that I'm doing, which is probably not a great idea, but it is also very helpful and useful.
I'd like to intercept calls to printf() and have them get sent to a ring_buffer (or a string buffer). Then, when there's not much going on, I'd like to be able to output the contents of the buffer to the actual UART, so I can see what's going on.
Here's what I've done or tried to do:
1) Instead of stdio_init_all(), I'm just using stdout_uart_init()
2) I have a buffer ready to use
3) I can't seem to intercept/override the stdio_uart.out_chars callback, I have no handle to it
What I'd like to do:
1) Redirect the stdio_uart.out_chars callback to use my function and not the default one
2) When my function gets called, it just printf's to my buffer
3) When the performance sensitive code is complete, I'd like to queue a task to write the data to the UART
This seems like a task that is relatively common, but I can't find any good example of it.
Is there anything in pico-sdk that lets me do this?
Thanks,
Steve
Statistics: Posted by shreeve — Tue Mar 05, 2024 12:18 am — Replies 0 — Views 5