New line + Carriage return on RTT-Terminal of VS Code

Hello
I have a custom board with the nRF52840, using nRF Connect + VS-Code.

By some reason, the '\n' on printk() does not make also a carriage return, thus making an indenting on the VS-Code integrated RTT-Terminal View.

On external Segger-RTT-Viewer it works fine.

Where can I find the setting that "new line" should also make a "carriage return" on the integrated RTT / printk?

On other projects it works fine, therefore it should be a setting or CONFIG_x, I guess...

Many thanks in advance!

Best Regards

Gerardo

  • Hi,

    I know that for historical reasons, the use of "\n" and "\r\n" has ended up varying between different platforms and applications, so I'm not sure if this should be considered a bug.

    Still, I've asked the extension team whether there is anything we can do to change this - it would be nice to have consistency. However, I'm not sure if this is up to the extension, or VS Code itself.

    Meanwhile, try using "\r\n" in your print statements to enforce a carriage return.

    Best regards,

    Raoul

  • Hi Raoul
    Many thanks!
    But for some reason, on a sample project it works correctly out-of-the-box, without additional "\r".

    So I guess that I messed up a setting somewhere in the IDE for this workspace/project or in a CONFIG_xx - Flag (my project with the custom board is initally based on the Bluetooth LBS sample).

    Question is what / where...

    Best Regards
    Gerardo

  • Okay, that's interesting! Especially if you think it could be caused by some Kconfig option ("CONFIG_xx"). Would you mind sharing your code, or a part of it  that still exhibits this behavior?

    And would you mind telling me which sample works "correctly" for you? I'll try running both your code and the sample to see what's causing this exactly.

    Best regards,
    Raoul

  • Hi Raoul

    I think I found it...!

    Changing log mode from minimal to deferred did the magic!


    => Change to CONFIG_LOG_MODE_DEFERRED=y instead of CONFIG_LOG_MODE_MINIMAL=y did the formatting of the "\n" in the VS-Code RTT window properly...

    But why the LOG _MODE impacts the non-log printk-usage, I don't know... As from the description in Kconfig.mode, the LOG is built on-top of the printk, not integrated into printk...

    If you find out why, please let me know...! I'm very curious about it, after all the time spent with this issue...

    Best Regards

    Gerardo

  • Gerardo, thanks for the update! I'm glad you have a solution for now.

    I would like to pass this on to the NCS team, but currently I'm not able to reproduce this, since it seems that CONFIG_LOG_MODE_MINIMAL is incompatible with CONFIG_LOG_BACKEND_RTT. So I'm surprised you were able to get that initial configuration (with the bug) at all.

    Would you mind sharing a minimal working example with us? Something that exhibits that bug. If that's too much, perhaps share your prj.conf if you can.

    Best regards,

    Raoul

Related