Disable console on UART with printf

Showing results for 
Search instead for 
Did you mean: 

Disable console on UART with printf

Contributor IV


I'm not sure the title is very correct. 

I use latest CW 10.4 and MQX 4.0 with a K60F120M bsp configuration.  I use the console printf for debug and redirected it to an UART (UART2 -> ttyc)  and it works fine.

So I use printf in my code to help debug and develop.  => OK

Now I reach the final steps, this UART should be used for something else so I want to completely disable the console output.

What should I do?

And what should I do with all the places I use printf now? 

Thanks and best regards


0 Kudos
3 Replies

Contributor IV

I have always incorporated a simple Ethernet or telnet interface into my applications (of course I realize this doesn't help if you are not incorporating the Ethernet port).  Telnet is still available as a command line interface in most operating systems... including Windows (although they are making it more and more difficult to locate).

0 Kudos

Contributor III

Hi -stéphan-,

In file \mqx\source\bsp\<BOARD_NAME>\<BOARD_NAME>.h is defined BSP_DEFAULT_IO_CHANNEL. You can change it here,probably set to NULL.(also you can set this macros in user_config.h).

If you want change only app you can use function _io_set_handle() and change IO_STDOUT and IO_STDIN to NULL or other io driver. ! !

_io_set_handle(IO_STDOUT, NULL);

I hope this answer will help.



0 Kudos

NXP Employee
NXP Employee

Hi Stephan,

Martin has best solution to disable the default io capability.

Another method would be to make modifications to the user_config.h (this is the highest level header file in the RTOS that can over ride default RTOS settings).

Simply setting all the selected BSPCFG_ENABLE(I)TTYx #defines to 0 will disable the RTOS from using a physical UART.

That doesn't resolve the printf's matter you have in your code base.

For that you can modify the PSP fio.h header and add a #define to the user_config.h to switch on and off the printf capability:

fio.h modifications:

ScreenHunter_32 Oct. 22 13.06.gif

user_config.h modification:

ScreenHunter_33 Oct. 22 13.06.gif

As always, please re-compile the RTOS when making modifications to user_config.h.



0 Kudos