This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS570LS0332: Using CR with Printf()

Part Number: TMS570LS0332

Tool/software: Code Composer Studio

Hi,

My customer is using CCS9.3 on Windows. The device is Hercules TMS570.
He wants to put some logs on CCS console and uses printf() in his code.
He found using \r(CR) at the end of line works exactly same as \n(CR+LF).
Is there any way to use CR with printf()?

Thanks and regards,
Koichiro Tashiro

  • For clarity, I need to define these two terms.

    • LF - the control character for line feed, decimal value of 10, escape sequence \n
    • CR - the control character for carriage return, decimal value of 13, escape sequence \r

    Generally speaking, a text file on a Unix or Unix-like system ends a line with LF.  A text file on a Windows systems ends a line with the sequence CR LF.

    I think text files created by the printf family of functions in the RTS for the TI ARM compiler follow the Unix convention, and not the Windows convention.  Later today, I'll run a test to be certain.

    Thanks and regards,

    -George

  • George Mock said:
    I think text files created by the printf family of functions in the RTS for the TI ARM compiler follow the Unix convention

    That's wrong.  I wrote a program that writes a text file, and executed on an ARM system, all under control of CCS hosted on Windows.  The resulting text file has CR LF line endings.

    As for what happens on when CCS is hosted on Linux, I need to test to be sure.  And I don't have a Linux system available to me right now.

    Thanks and regards,

    -George

  • Hi George,

    Do you mean it is not possible to use CR only in CCS on Windows?

    Thanks and regards,
    Koichiro Tashiro

  • You can write the character \r out into a text file.  That causes a character with the decimal value 13 to appear at that point in the stream of characters.  How that gets interpreted depends on the software used to display the text file.

    As an example, consider this code ...

        for (i = 1; i <=5; i++)
            fprintf(fptr, "line %d\r", i);

    Note the use of \r instead of \n.  I ran this on an ARM system under control of CCS, which is installed on a Windows system.  Here is how Notepad displays these lines.

    Here is how gvim (a Windows variant of the Unix editor vi) displays the same lines.

    Here is how the Windows command type displays the same lines.

    Thanks and regards,

    -George