[SOLVED] Bug report: Printf AND RTT prototype

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Bug report: Printf AND RTT prototype

    Printf over RTT has an improperly declared prototype and/or the function name is incorrect and/or comment is incorrect. This is with Release 4.10a Build 201810203.37618 Windows x64

    SEGGER_RTT.h has the following prototype:

    Source Code: SEGGER_RTT.h

    1. /*********************************************************************
    2. *
    3. * RTT printf functions (require SEGGER_RTT_printf.c)
    4. *
    5. **********************************************************************
    6. */
    7. int SEGGER_RTT_printf(unsigned BufferIndex, const char * sFormat, ...);

    I looked and there is no SEGGER_RTT_printf.c

    However, there is a SEGGER_RTT_SES.c and it has a printf() that looks about right.

    Source Code: SEGGER_RTT_SES.c

    1. int printf(const char *fmt,...) {
    2. char buffer[128];
    3. va_list args;
    4. va_start (args, fmt);
    5. int n = vsnprintf(buffer, sizeof(buffer), fmt, args);
    6. SEGGER_RTT_Write(0, buffer, n);
    7. va_end(args);
    8. return n;
    9. }

    I tested this printf, without a prototype, and it works just fine.
  • Hello,

    Thank you for your inquiry.
    The comment is correct. You can find the SEGGER_RTT_printf.c in the latest version either in your J-Link install folder under Samples\RTT
    or on the RTT website: segger.com/products/debug-prob…about-real-time-transfer/

    The SEGGER_RTT_SES.c should not be used here. That file defines the printf handling in case of RTT is used.

    Best regards,

    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Sorry but I'm confused.

    When I used printf() in SEGGER_RTT_SES.c, I saw output in the Debug Terminal pane of Embedded Studio.

    It looks like SEGGER_RTT_printf.c in the Samples\RTT does the same thing.

    When should I use which one?
    What is wrong with using printf() in SEGGER_RTT_SES.c?

    Thanks.
  • Hello,

    Thank you for the update.
    This thread will be closed now.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.