Forum Discussion

HLana's avatar
HLana
Icon for New Contributor rankNew Contributor
7 years ago

printf in Nios to stdout (altera_avalon_uart) sends "\ n" (LF) without translating to CR LF

Hello

our system is a Nios (with uCOS) in a CycloneV using an altera_avalon_uart as stdout. In other embedded systems the "\n" in a printf is often replaced with CR+LF. In some systems it is possible to select the behavior by activating O_TEXT or O_BINARY with fcntl(). A printf​ in the Nios never translates \n to CR+LF. It sends only LF. Is there a setting to change this behavior? fcntl() does not work for me. O_TEXT is unknown in fcntl.h.

Thanks

Hendrik

1 Reply

  • JOHI's avatar
    JOHI
    Icon for Contributor rankContributor

    Hello Hendrik,

    Since nios is open source, you can dive into the system code during debugging and follow the source.

    There you will see all opportunities.

    From what I remember, it was not possible to change the behaviour as requiested, but i am not 100% sure, it has been some time since i did this;

    However, you can write a wrapper around printf (with the same name) and change the behaviour as specified or write your own printf function.

    What you can also do is change one of the helper functions

    see alt_printf.c for more details.

    A few lines of code might get you the desired result.

    Best Regards,

    Johi.