Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Redirecting printf

Posted by Paul Coleman on May 11, 2012
Is there an easy way to redirect printf? I'm using the Atmel AVR32 port and it would be nice if I could redirect printf to one of three USARTS, so maybe fprintf with something like...
fprintf(USART_1, "text");
fprintf(USART_2, "text");
fprintf(USART_3, "text");
would be good. However, I'm not sure what I need to modify to accomplish this. Has anybody achieved something similar?

Thanks, Paul.

RE: Redirecting printf

Posted by Richard on May 11, 2012
Normally you can implement the low level byte in and byte out functions any way you like, so send them to any device you like. How this is done is dependent on your compiler, or, more specifically, the libraries provided with your compiler. Most embedded environments are set up to make it easy to do, and I think the Atmel provided example applications actually are already configured to send printf() output to a UART.

I think you can also implement the low level functions in the low overhead io file being discussed in your other thread this morning.


RE: Redirecting printf

Posted by Paul Coleman on May 11, 2012
Thanks for the info. After my previous thread I then thought that I could achieve what I wanted by redirecting printf().

I was hoping that fprintf() called down to the _write() function contained in the portable section of FreeRTOS but this doesn't seem to be the case. This would have been easy as the first parameter to _write() is the file descriptor which I could have checked and then diverted the output accordingly. So, if _write() is not called by fprintf() what does it get called by?

Thanks, Paul.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner