# Redirecting printf

**URL:** <https://forums.freertos.org/t/redirecting-printf/5259>\
**Category:** Kernel\
**Created:** [May 11, 2012, 11:09am UTC](https://forums.freertos.org/t/redirecting-printf/5259 "2012-05-11T11:09:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 11, 2012, 11:09am UTC](https://forums.freertos.org/t/redirecting-printf/5259/1 "2012-05-11T11:09:12Z")

</div>

**[paulgcoleman](https://sourceforge.net/u/paulgcoleman/)** wrote on [Friday, May 11, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/e946d8dd/#7745):

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.

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [May 11, 2012, 11:31am UTC](https://forums.freertos.org/t/redirecting-printf/5259/2 "2012-05-11T11:31:09Z")

</div>

**[rtel](https://sourceforge.net/u/rtel/)** wrote on [Friday, May 11, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/e946d8dd/#5acb):

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.&nbsp; How this is done is dependent on your compiler, or, more specifically, the libraries provided with your compiler.&nbsp; 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.

Regards.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 11, 2012, 11:47am UTC](https://forums.freertos.org/t/redirecting-printf/5259/3 "2012-05-11T11:47:28Z")

</div>

**[paulgcoleman](https://sourceforge.net/u/paulgcoleman/)** wrote on [Friday, May 11, 2012](https://sourceforge.net/p/freertos/discussion/382005/thread/e946d8dd/#abad):

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.
