[SOLVED] Feature Request RTT: SEGGER_RTT_TerminalOutBuffer()

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

  • [SOLVED] Feature Request RTT: SEGGER_RTT_TerminalOutBuffer()

    Hi!

    The current RTT APIs provide a SEGGER_RTT_TerminalOut() function. That function requires a null-terminated string.

    The current debug logging APIs have a function of the following form:
    size_t write(const char * buffer, size_t size);

    Would it be possible to add a SEGGER_RTT_TerminalOutBuffer() function?

    Here's a draft diff based on RTT version 6.60d:\
    github.com/henrygab/Adafruit_n…2d7c0b79b9773b165f8f8ea01

    In combination with the implementation of SEGGER_RTT_Peek() (requested earlier), these two functions would simplify drop-in replacement use of RTT.

    Thank you for considering this simple proposal.

    Henry

    [edit: for avoidance of doubt, the changes in both those diffs is given to the public domain]
  • I am responding due to a month passing, hoping this can be forwarded to the dev team for consideration.

    Why is this important?
    I want to enable (in a 3rd party arduino board support package), compile-time switching of debug output to use RTT.
    Unfortunately, although I could code the solution, the maintainers are very uncomfortable with adding to or changing any RTT implementation files.

    There are two functions that are necessary to allow a seamless integration, and these functions would also seem to be basic capabilities for enabling RTT to be used as other common C++ objects.

    1. The ability to Peek() at the next byte coming in over RTT is needed to emulate many stream-like classes. That request has already been forwarded for consideration (thank you!).

    2. The ability to print, to a specified terminal, a buffer having a fixed length (not null-terminated). This is important for performance(*) and ease of integration.

    Accordingly, please do consider this simple request, as it will simplify using RTT as drop-in replacement for well-defined C++ objects such as Streams, and be the basis for enabling the use of multiple terminal IDs.


    Thank you in advance for any consideration you can offer this.



    (*) Why is this so hard?

    The current terminal ID is declared as a static variable, and thus the variable is visible only in the compilation unit (SEGGER_RTT.c). The variable thus cannot be accessed outside of SEGGER_RTT.c. And, without knowing the current terminal ID, no external helper function can be written to temporarily switch away from that current ID, send the buffer, and then switch back to the prior terminal ID.

    Of course, there is an option to have a function with a fixed-size stack buffer, and send the buffer in chunks that are manually null-terminated. Even ignoring the memory copy overhead, each chunk would take locks, and be sandwiched between terminal change output bytes, and it becomes possible to have output that is only partially output, breaking the model provided by some RTT modes. It's also wasteful and relatively slow.
  • Hi Henry,
    Thank you for your inquiry.

    both proposals were passed to the responsible developers.

    Stay up-to-date regarding J-Link:
    segger.com/notification/subscribe.php?prodid=7,94

    We will consider this thread as closed.

    Best regards,
    Fabian
    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.