Custom printf handler for CW MCU 10.2/Kinetis

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Custom printf handler for CW MCU 10.2/Kinetis

996 次查看
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 

标签 (1)
0 项奖励
回复
1 回复

699 次查看
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