What is the appropriate way to remap printf to a custom serial port in Mbed 6? When moving from a FRDM k64f board to a custom board, I removed the USB port and would like to know the “correct” way to redirect printf to a different UART.
I have tried to rename the change the STDIO_UART_TX , STDIO_UART_RX, and STDIO_UART macros to the different pins, but that doesn’t seem to have had an effect.
I don’t know whether this is the “correct” way to do it but you can try the mbed_override_console hook:
/** Applications may implement this to change stdin, stdout, stderr.
*
* This hook gives the application a chance to specify a custom FileHandle
* for the console.
...
*/
FileHandle *mbed_override_console(int fd);
For example, to remap printf to an USART port available on pins D0, D1: