Custom printf handler for CW MCU 10.2/Kinetis

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom printf handler for CW MCU 10.2/Kinetis

708 Views
konrada
Contributor IV

Hello everyone,

 

our C++ project targets CW10.2 on Kinetis and uses EWL. We've written our own custom logger. Now, a third-party library thinks it may just call printf() to output error messages. Currently, the EWL printf writes these messages to the debugger via some kind of Cortex debug magic.

 

Instead, I'd like to redirect the output to our logger. I've tried defining my own __ConsoleWrite function in my application, but that changed nothing; the printf call still went to the debugger. What else can I try? I'd like to keep the other C standard library functions, so I'd like to continue including EWL.

 

Greetings

KA 

Labels (1)
0 Kudos
Reply
1 Reply

411 Views
PetrC
Contributor II

Hi

Not sure about the C++ project, but in C project I use to define functions with the following prototypes to redirect printf:

int __read_console(__file_handle handle, unsigned char* buffer, size_t * count);
int __write_console(__file_handle handle, unsigned char* buffer, size_t* count);
int __close_console(__file_handle handle);

 

Regards

PetrC