<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Issue with CR when using CLI and RTT logger</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64629/issue-with-cr-when-using-cli-and-rtt-logger</link><description>Hi 
 
 I have a project that uses several protocols, including UART and USB CLI 
 As such, I had to move the nRF logger to work on RTT, so that everything could work properly 
 My issue is that if I get the RTT logger working, my CLI printing break (they</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 11 Aug 2020 09:00:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64629/issue-with-cr-when-using-cli-and-rtt-logger" /><item><title>RE: Issue with CR when using CLI and RTT logger</title><link>https://devzone.nordicsemi.com/thread/263970?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 09:00:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6621ad69-7963-479d-ac94-6eaa38a8f3b3</guid><dc:creator>Aviv Okon</dc:creator><description>&lt;p&gt;I couldn&amp;#39;t figure how to change nrf_fprintf_fmt, so I decided to change buffer_add instead as it was simpler&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve attached the code changes I made, and it seems that it works with NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED set to 1 for both CLI and RTT logs&lt;/p&gt;
&lt;p&gt;so I believe this is the simplest solution to this situation, though let me know if you have a better one&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static char prev_char = &amp;#39;\0&amp;#39;;

static void buffer_add(nrf_fprintf_ctx_t * const p_ctx, char c)
{
#if NRF_MODULE_ENABLED(NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF)
    if (c == &amp;#39;\n&amp;#39;
		&amp;amp;&amp;amp; prev_char != &amp;#39;\r&amp;#39;)
    {
        buffer_add(p_ctx, &amp;#39;\r&amp;#39;);
    }

	prev_char = c;
#endif
    p_ctx-&amp;gt;p_io_buffer[p_ctx-&amp;gt;io_buffer_cnt++] = c;

    if (p_ctx-&amp;gt;io_buffer_cnt &amp;gt;= p_ctx-&amp;gt;io_buffer_size)
    {
        nrf_fprintf_buffer_flush(p_ctx);
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with CR when using CLI and RTT logger</title><link>https://devzone.nordicsemi.com/thread/263866?ContentTypeID=1</link><pubDate>Mon, 10 Aug 2020 14:08:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3398768-7393-4bbc-916c-5ee4f1a49af2</guid><dc:creator>Aviv Okon</dc:creator><description>&lt;p&gt;Thanks for confirming this&lt;/p&gt;
&lt;p&gt;I was somewhat afraid of having to modify something in the SDK, due to the nature of my project and how it is managed&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll relay this, and see if the issue is considered severe enough to go through the process of changing the implementation in the SDK&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll report back if I find any issues with this&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thanks again&lt;/p&gt;
&lt;p&gt;Aviv&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue with CR when using CLI and RTT logger</title><link>https://devzone.nordicsemi.com/thread/263828?ContentTypeID=1</link><pubDate>Mon, 10 Aug 2020 12:46:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc954259-0a16-4171-b7be-c3e083d9da2a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Aviv,&lt;/p&gt;
&lt;p&gt;I have reported this to the SDK developers.&lt;/p&gt;
&lt;p&gt;The natural place to fix this would be in &amp;lt;SDK&amp;gt;\external\fprintf\nrf_fprintf_format.c. You could check if an \r has proceeded the \n, and only add it if it has not. As you can see it is not just a matter of changing&amp;nbsp;buffer_add() though, as that function works on single characters. You either have to rewrite a bit more or consider a hack where you use a static variable to hold the previous character or similar.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>