<?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>nRFSDK v17 libuarte cli example and logging float numbers</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/68445/nrfsdk-v17-libuarte-cli-example-and-logging-float-numbers</link><description>Dear all, 
 The forum is full of questions around printing floating point numbers, however, I have a rather strange issue where maybe someone can help. 
 I have a project based on the libuarte cli example (set up in VisualGDB using v17 of the SDK). cli</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Nov 2020 11:28:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/68445/nrfsdk-v17-libuarte-cli-example-and-logging-float-numbers" /><item><title>RE: nRFSDK v17 libuarte cli example and logging float numbers</title><link>https://devzone.nordicsemi.com/thread/281519?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2020 11:28:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:335011ab-bbbc-4d9c-865c-80b4d8f17a79</guid><dc:creator>Krzysztof Chruscinski</dc:creator><description>&lt;p&gt;Hi Franz,&lt;/p&gt;
&lt;p&gt;you can delay NRF_LOG_PROCESS() by adding a delay or sleep to while loop. When NRF_LOG_PROCESS() is called it takes one message from the queue and passes it to all active backends. CLI is one of the active backends. CLI takes this message and queues. When cli_process() is called it handles cli pending actions, it will find pending log message and will process it.&lt;/p&gt;
&lt;p&gt;Logger passes whole message to the cli, cli is the one who formats the string and sends it to transport layer (uart, rtt).&lt;/p&gt;
&lt;p&gt;Regarding 3.1 one call to LOG_PROCESS() and one to nrf_cli_process() will process (print) one log message.&lt;/p&gt;
&lt;p&gt;3.2 Logger passes the message to all backends. It is up to the backend to react. Simple backend like uart may print immediately but more complex may require more operations. CLI is that example, logger only enqueues the message so cli process must be explicitly called by the user.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFSDK v17 libuarte cli example and logging float numbers</title><link>https://devzone.nordicsemi.com/thread/281137?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2020 14:19:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef772954-4a81-49c1-b9c7-48b4a7fa5b5f</guid><dc:creator>Franz</dc:creator><description>&lt;p&gt;Hi Krzysztof,&lt;/p&gt;
&lt;p&gt;Thanks for the reply. So that I understand better:&lt;/p&gt;
&lt;p&gt;1.) NRF_LOG_PUSH pushes the string into a ringbuffer and what I see is that the loop is pushing strings to the buffer faster than the strings are taken from the ringbuffer (by the uart backend), right? That means the NRF_LOG_PROCESS() and nrf_cli_process() commands are non-blocking and just pass the message to the backend?&lt;/p&gt;
&lt;p&gt;2.) If so, is there a way to make NRF_LOG_PROCESS and cli_process blocking so that I can trade off the blocking behaviour against a small buffer size?&lt;/p&gt;
&lt;p&gt;3.) Can you shortly explain how NRF_LOG_PROCESS() and nrf_cli_process() work together?&lt;/p&gt;
&lt;p&gt;3.1) For one string pushed to the ringbuffer, Is ONE call of NRF_LOG_PROCESS() and ONE call to nrf_cli() sufficient? Or does that depend on the length of the string? (does the logger backend somehow cut the string into a fixed chunk size during processing)&lt;/p&gt;
&lt;p&gt;3.2) As far as I understand the libuart_cli example, the cli module is used as a backend for the logger, so I am not sure why I have to call both processing functions. Should&amp;acute;nt the logger itself trigger the processing of all the enabled backends?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFSDK v17 libuarte cli example and logging float numbers</title><link>https://devzone.nordicsemi.com/thread/281113?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2020 13:20:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31fb071d-ea4a-4bf0-9200-8d067e458a5b</guid><dc:creator>Krzysztof Chruscinski</dc:creator><description>&lt;p&gt;Unfortunately, what you see is the limitation of string pushing. They are copied into ring buffer and when next allocation lands at the end of the buffer string is trimmed. See comment in nrf_log_push() (in nrf_log_frontend.c).&lt;/p&gt;
&lt;p&gt;What i could recommend is to not use pushing but statically allocated array on your side and logging strings directly from that array. You can tune array size so logs are processed faster than strings update. I know it is not perfect but should work better.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFSDK v17 libuarte cli example and logging float numbers</title><link>https://devzone.nordicsemi.com/thread/280639?ContentTypeID=1</link><pubDate>Wed, 18 Nov 2020 14:08:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f10bd620-39c9-4961-8b0c-de34374da313</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Regarding&amp;nbsp;NRF_LOG_PROCESS() that only processes one entry at a time. And so it also makes sense to call&amp;nbsp;cli_process() for every call, like you do now. I do not have full overview of the CLI module though, but I have asked one of the authors to look at it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFSDK v17 libuarte cli example and logging float numbers</title><link>https://devzone.nordicsemi.com/thread/280384?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 13:48:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ad8b47b-8d96-4889-bf1c-b74f2ea818c4</guid><dc:creator>Franz</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_LOG_ALLOW_OVERFLOW is already at 0&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I look at the requested data directly in putty (i.e. in the terminal&amp;quot;, i do not get any &amp;quot;logs dropped&amp;quot; messages.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Since I write the data from the uC to the PC in the loop as shown above, the uC should never run into a buffer overflow because in each iteration it has time to process the logs, right?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also, since in the example I have shown above, the second value is already corrupted and the firmware has nothing else to do, this also does not seem like a buffer overflow. What else could I check?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;//EDIT: Is it possible, that the cli module somehow &amp;quot;overwrites&amp;quot; data before inserting the &amp;quot;terminal style escape sequences&amp;quot;?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;A snapshot of the raw string received on the PC side is e.g.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt; 0.025194759,cli:~$\x1b[6D\x1b[J   0.025259649,cli:~$\x1b[6D\x1b[J   0.025324948,cli:~$\x1b[6D\x1b[J   0.02,cli:~$\x1b[6D\x1b[J   0.025456227,cli:~$\x1b[6D\x1b[J&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;//EDIT 2:&lt;br /&gt;It seems like the issues can be &amp;quot;solved&amp;quot; with a&amp;nbsp;ridiculously big buffer for&amp;nbsp;NRF_LOG_STR_PUSH_BUFFER_SIZE of 2048 and slight modification of the code to every time call log and cli process, i.e.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;		NRF_LOG_RAW_INFO(&amp;quot;%s,&amp;quot;, NRF_LOG_PUSH(floatchar));
		while (NRF_LOG_PROCESS())
		{
			cli_process();
		}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you maybe tell me how (i.e. how often) I have to cavv NRF_LOG_PROCESS() and or cli_process per loop iteration? In my code portion I posted initially, It seems that the string cannot be processed by a single call to NRF_LOG_PROCESS() and that NRF_LOG_PROCESS does &amp;quot;more work&amp;quot; than a single call of cli_process can handle. Still, I would not suspect that I have to increase&amp;nbsp;NRF_LOG_STR_PUSH_BUFFER_SIZE&amp;nbsp;, because the doc says that&amp;nbsp;NRF_LOG_PUSH just overwrites the existing string in the buffer, so I should get garbage values but the buffer should not increase. Instead It looks like something is filling up anf then starts overwriting data in the buffer.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Maybe you can give me some more insights on how to fix that problem. I suspect I have to add some kind of delay in the loop since cli somhow makes use of APP_TIMER for log processing?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRFSDK v17 libuarte cli example and logging float numbers</title><link>https://devzone.nordicsemi.com/thread/280356?ContentTypeID=1</link><pubDate>Tue, 17 Nov 2020 12:48:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57fb1c8a-c967-41e3-9af5-d68871bd0aa8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You convert the floating point to string yourself, so that should not be related. Also, you write that all the strings passed to NRF_LOG_RAW is correct. If that is the case, then the issue could be related to buffer overflows so that strings are cropped, either on the nRF side or the receiving end.&lt;/p&gt;
&lt;p&gt;Do you see the same behavior of you logg less or with a lower frequency? What happens if you set NRF_LOG_ALLOW_OVERFLOW to 0 in sdk_config.h (assuming it is not already)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>