Hello Kyle,
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
:
#include "mbed.h"
...
FileHandle *mbed::mbed_override_console(int)
{
static BufferedSerial custom_target_console(D0, D1);
return &custom_target_console;
}
...
int main()
{
...
}
NOTE: The mbed_override_console
is declared in the mbed-os/platform/mbed_retarget.h
file.
Best regards, Zoltan