<?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>NRF_LOG_PUSH seems to be outputting invalid data intermittently</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61899/nrf_log_push-seems-to-be-outputting-invalid-data-intermittently</link><description>Hi! 
 I&amp;#39;m using the nRF52840 DK with SDK 15.2 and on Windows 10. I have been testing USB communication and while I was testing input and output data, some of the data I was outputting in the RTT viewer with NRF_LOG_INFO() was invalid. What I mean by that</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 22 Jul 2020 15:30:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61899/nrf_log_push-seems-to-be-outputting-invalid-data-intermittently" /><item><title>RE: NRF_LOG_PUSH seems to be outputting invalid data intermittently</title><link>https://devzone.nordicsemi.com/thread/261242?ContentTypeID=1</link><pubDate>Wed, 22 Jul 2020 15:30:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:004876e3-b503-41d3-94dc-5824ecb672fd</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Quite, you have to add the code for &lt;em&gt;log_is_busy&lt;/em&gt; yourself in 15.3 onwards, as i wrote it based on info from this post I quoted for a sample code to add.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/39188/nrf_log_frontend_dequeue-must-be-atomically-protected-against-re-entry-from-interrupt-context"&gt;dequeue-must-be-atomically-protected-against-re-entry-from-interrupt-context&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_LOG_PUSH seems to be outputting invalid data intermittently</title><link>https://devzone.nordicsemi.com/thread/261238?ContentTypeID=1</link><pubDate>Wed, 22 Jul 2020 15:09:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9027b4eb-616a-44b6-bc1f-8a28e841033f</guid><dc:creator>g_frenette</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;Thanks for your input and sorry for the late response. The issue you referred to uses SDK 15.2. However, my issue is with SDK 15.3 and m_log_data has no member log_is_busy in my SDK version unless I&amp;#39;m mistaken.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_LOG_PUSH seems to be outputting invalid data intermittently</title><link>https://devzone.nordicsemi.com/thread/257209?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 21:08:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b461f90-8554-42fd-b8f6-b0d2729f6b40</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Maybe check this out, if not done already:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;bool nrf_log_frontend_dequeue(void)
{
    if (buffer_is_empty())
    {
        return false;
    }
    // Note also add atomic flag set before this __DSB() and after this function exits
    // See https://devzone.nordicsemi.com/f/nordic-q-a/39188/nrf_log_frontend_dequeue-must-be-atomically-protected-against-re-entry-from-interrupt-context
    if (nrf_atomic_flag_set_fetch(&amp;amp;m_log_data.log_is_busy))
    {
        return false;
    }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;See&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/39188/nrf_log_frontend_dequeue-must-be-atomically-protected-against-re-entry-from-interrupt-context"&gt;frontend dequeue interrupt context&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_LOG_PUSH seems to be outputting invalid data intermittently</title><link>https://devzone.nordicsemi.com/thread/257205?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 18:31:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae9eaed8-71a7-4701-a50a-31e201b9fd10</guid><dc:creator>g_frenette</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/6330.main.c"&gt;devzone.nordicsemi.com/.../6330.main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0385.sdk_5F00_config.h"&gt;devzone.nordicsemi.com/.../0385.sdk_5F00_config.h&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;No problem regarding the delay!&lt;/p&gt;
&lt;p&gt;Using SDK 15.2, example USBD_CDC_ACM found in examples/peripheral/usbd_cdc_acm. You can swap de skd_config file by the one attache. Same for main.c. Pressing button 1 on nRF52840-DK will print in the logger and then you will be able to see the behavior reproduced (the end of the string printed in the logger/viewer will regularly be missing). If that&amp;#39;s not enough, please notify me, I can send you some more files but I believe you&amp;#39;ll have everything you need with these two files.&lt;/p&gt;
&lt;p&gt;Thank you for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_LOG_PUSH seems to be outputting invalid data intermittently</title><link>https://devzone.nordicsemi.com/thread/257166?ContentTypeID=1</link><pubDate>Fri, 26 Jun 2020 13:44:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e004b036-2ee4-4d31-88e9-a237c351a7bb</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Sorry for the slow response. I forgot to include&amp;nbsp;&lt;span&gt;NRF_LOG_STR_PUSH_BUFFER_SIZE&amp;nbsp;in my list.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you provide a minimal example that we can use to reproduce this behavior?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_LOG_PUSH seems to be outputting invalid data intermittently</title><link>https://devzone.nordicsemi.com/thread/252482?ContentTypeID=1</link><pubDate>Fri, 29 May 2020 18:00:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:443097d2-0b84-4f64-9168-56d7c30e0779</guid><dc:creator>g_frenette</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I tested the output from the logger modifying each config you sent and none of them did anything to the output. However, that got me thinking and I went back on this &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.sdk5.v15.3.0%2Flib_nrf_log.html"&gt;page&lt;/a&gt;&amp;nbsp;and read that&amp;nbsp;&lt;a class="el" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__log__config.html#gaf7bd2dcbd3b311b17ea0e8258ca634cd"&gt;NRF_LOG_STR_PUSH_BUFFER_SIZE&lt;/a&gt;&amp;nbsp;is closely linked to the usage of NRF_LOG_PUSH(). I also tried&amp;nbsp;NRF_LOG_HEXDUMP_INFO and&amp;nbsp; NRF_LOG_RAW_HEXDUMP_INFO. These last two do print properly. However, they print a lot of extra data which makes it not ideal. So I tested extensively with NRF_LOG_STR_PUSH_BUFFER_SIZE and found the following results when outputting incrementing data (the numbers mentioned are those where there is an error printing, so incrementing values not size values):&lt;/p&gt;
&lt;table width="560"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width="217"&gt;NRF_LOG_STR_PUSH_BUFFER SIZE&lt;/td&gt;
&lt;td width="67"&gt;First error&lt;/td&gt;
&lt;td width="151"&gt;Interval between errors&lt;/td&gt;
&lt;td width="125"&gt;Last error recorded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;512&lt;/td&gt;
&lt;td&gt;235&lt;/td&gt;
&lt;td&gt;74&lt;/td&gt;
&lt;td&gt;975&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1024&lt;/td&gt;
&lt;td&gt;309&lt;/td&gt;
&lt;td&gt;147&lt;/td&gt;
&lt;td&gt;1038&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2048&lt;/td&gt;
&lt;td&gt;309&lt;/td&gt;
&lt;td&gt;293&lt;/td&gt;
&lt;td&gt;895&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4096&lt;/td&gt;
&lt;td&gt;601&lt;/td&gt;
&lt;td&gt;562&lt;/td&gt;
&lt;td&gt;1163&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8192&lt;/td&gt;
&lt;td&gt;1163&lt;/td&gt;
&lt;td&gt;9174&lt;/td&gt;
&lt;td&gt;10337&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;After the last error recorded, the buffer seems to have stabilized and doesn&amp;#39;t output any more errors, but I might not be printing enough data. For these tests, the string printed is the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_LOG_RAW_INFO(&amp;quot;\t\t%s\n&amp;quot;, NRF_LOG_PUSH(value));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also, I tested using a different string for an NRF_LOG_STR_PUSH_BUFFER_SIZE of 512:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_LOG_RAW_INFO(&amp;quot;\t%s\n&amp;quot;, NRF_LOG_PUSH(value));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And the first error is at 104; with an interval of 86 and the last error at 1043.&lt;/p&gt;
&lt;p&gt;Hopefully, that would tell you a bit more. I can always rely on&amp;nbsp;&lt;span&gt;NRF_LOG_RAW_HEXDUMP_INFO but this wouldn&amp;#39;t be ideal.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you so much for your help&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF_LOG_PUSH seems to be outputting invalid data intermittently</title><link>https://devzone.nordicsemi.com/thread/252452?ContentTypeID=1</link><pubDate>Fri, 29 May 2020 14:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ced8739-4242-48c4-b942-4104c3c24697</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is a lot of configs that you can play around with in your sdk_config.h file to help solve this issue. I&amp;#39;m not sure exactly which one is causing this in your application:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// &amp;lt;o&amp;gt; NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE - Size of buffer for partially processed strings. 
// &amp;lt;i&amp;gt; Size of the buffer is a trade-off between RAM usage and processing.
// &amp;lt;i&amp;gt; if buffer is smaller then strings will often be fragmented.
// &amp;lt;i&amp;gt; It is recommended to use size which will fit typical log and only the
// &amp;lt;i&amp;gt; longer one will be fragmented.

#ifndef NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE
#define NRF_LOG_BACKEND_RTT_TEMP_BUFFER_SIZE 64
#endif

// &amp;lt;h&amp;gt; Log message pool - Configuration of log message pool

//==========================================================
// &amp;lt;o&amp;gt; NRF_LOG_MSGPOOL_ELEMENT_SIZE - Size of a single element in the pool of memory objects. 
// &amp;lt;i&amp;gt; If a small value is set, then performance of logs processing
// &amp;lt;i&amp;gt; is degraded because data is fragmented. Bigger value impacts
// &amp;lt;i&amp;gt; RAM memory utilization. The size is set to fit a message with
// &amp;lt;i&amp;gt; a timestamp and up to 2 arguments in a single memory object.

#ifndef NRF_LOG_MSGPOOL_ELEMENT_SIZE
#define NRF_LOG_MSGPOOL_ELEMENT_SIZE 20
#endif

// &amp;lt;o&amp;gt; NRF_LOG_MSGPOOL_ELEMENT_COUNT - Number of elements in the pool of memory objects 
// &amp;lt;i&amp;gt; If a small value is set, then it may lead to a deadlock
// &amp;lt;i&amp;gt; in certain cases if backend has high latency and holds
// &amp;lt;i&amp;gt; multiple messages for long time. Bigger value impacts
// &amp;lt;i&amp;gt; RAM memory usage.

#ifndef NRF_LOG_MSGPOOL_ELEMENT_COUNT
#define NRF_LOG_MSGPOOL_ELEMENT_COUNT 8
#endif

// &amp;lt;/h&amp;gt; 
//==========================================================

// &amp;lt;q&amp;gt; NRF_LOG_ALLOW_OVERFLOW  - Configures behavior when circular buffer is full.
 

// &amp;lt;i&amp;gt; If set then oldest logs are overwritten. Otherwise a 
// &amp;lt;i&amp;gt; marker is injected informing about overflow.

#ifndef NRF_LOG_ALLOW_OVERFLOW
#define NRF_LOG_ALLOW_OVERFLOW 1
#endif

// &amp;lt;o&amp;gt; NRF_LOG_BUFSIZE  - Size of the buffer for storing logs (in bytes).
 

// &amp;lt;i&amp;gt; Must be power of 2 and multiple of 4.
// &amp;lt;i&amp;gt; If NRF_LOG_DEFERRED = 0 then buffer size can be reduced to minimum.
// &amp;lt;128=&amp;gt; 128 
// &amp;lt;256=&amp;gt; 256 
// &amp;lt;512=&amp;gt; 512 
// &amp;lt;1024=&amp;gt; 1024 
// &amp;lt;2048=&amp;gt; 2048 
// &amp;lt;4096=&amp;gt; 4096 
// &amp;lt;8192=&amp;gt; 8192 
// &amp;lt;16384=&amp;gt; 16384 

#ifndef NRF_LOG_BUFSIZE
#define NRF_LOG_BUFSIZE 1024
#endif

// &amp;lt;o&amp;gt; SEGGER_RTT_CONFIG_BUFFER_SIZE_UP - Size of upstream buffer. 
// &amp;lt;i&amp;gt; Note that either @ref NRF_LOG_BACKEND_RTT_OUTPUT_BUFFER_SIZE
// &amp;lt;i&amp;gt; or this value is actually used. It depends on which one is bigger.

#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_UP
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_UP 512
#endif

// &amp;lt;o&amp;gt; SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS - Size of upstream buffer. 
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS
#define SEGGER_RTT_CONFIG_MAX_NUM_UP_BUFFERS 2
#endif

// &amp;lt;o&amp;gt; SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN - Size of upstream buffer. 
#ifndef SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN
#define SEGGER_RTT_CONFIG_BUFFER_SIZE_DOWN 16
#endif

// &amp;lt;o&amp;gt; SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS - Size of upstream buffer. 
#ifndef SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS
#define SEGGER_RTT_CONFIG_MAX_NUM_DOWN_BUFFERS 2
#endif

// &amp;lt;o&amp;gt; SEGGER_RTT_CONFIG_DEFAULT_MODE  - RTT behavior if the buffer is full.
 

// &amp;lt;i&amp;gt; The following modes are supported:
// &amp;lt;i&amp;gt; - SKIP  - Do not block, output nothing.
// &amp;lt;i&amp;gt; - TRIM  - Do not block, output as much as fits.
// &amp;lt;i&amp;gt; - BLOCK - Wait until there is space in the buffer.
// &amp;lt;0=&amp;gt; SKIP 
// &amp;lt;1=&amp;gt; TRIM 
// &amp;lt;2=&amp;gt; BLOCK_IF_FIFO_FULL 

#ifndef SEGGER_RTT_CONFIG_DEFAULT_MODE
#define SEGGER_RTT_CONFIG_DEFAULT_MODE 0
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>