<?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>Terminal dropping messages</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/111890/terminal-dropping-messages</link><description>Good afternoon, 
 I am trying to send some analog data from a function generator to my nRF7002 DK and visualize the output in Putty. I use printk to print the values and I see that I have a lot of messages being dropped (I constantly get --- 17 messages</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Jun 2024 08:18:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/111890/terminal-dropping-messages" /><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/488046?ContentTypeID=1</link><pubDate>Mon, 10 Jun 2024 08:18:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1efdcb4-d1a2-4ed3-ac3f-d247b847a75e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You are printing in an interrupt handler, which will block the system (logger) from running.&lt;/p&gt;
&lt;p&gt;Try printing your saadc buffer from main context instead by setting a flag or similar in saadc_evet_handler() function.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also; remember that your UART is running at 115k2 baud, which isn&amp;#39;t that fast. Printing 8k buffers will take some time, and you risk underrun due to the serial interface being too slow compared to your saadc sampling.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/487920?ContentTypeID=1</link><pubDate>Fri, 07 Jun 2024 12:50:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2be68f05-0d8a-4ed6-ba20-389c0f706be7</guid><dc:creator>Raluca</dc:creator><description>&lt;p&gt;Of course, here is the function where I am printing:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void saadc_event_handler(nrfx_saadc_evt_t const * p_event)
{
    nrfx_err_t err;
    switch (p_event-&amp;gt;type)
    {
        case NRFX_SAADC_EVT_READY:
        
           /* STEP 6.1 - Buffer is ready, timer (and sampling) can be started. */
            nrfx_timer_enable(&amp;amp;timer_instance);

            break;                        
            
        case NRFX_SAADC_EVT_BUF_REQ:
        
            /* STEP 6.2 - Set up the next available buffer. Alternate between buffer 0 and 1 */
            err = nrfx_saadc_buffer_set(saadc_sample_buffer[(saadc_current_buffer++)%2], SAADC_BUFFER_SIZE);
            if (err != NRFX_SUCCESS) 
            {
            LOG_ERR(&amp;quot;nrfx_saadc_buffer_set error: %08x&amp;quot;, err);
            return;
            }

            break;

        case NRFX_SAADC_EVT_DONE:

            /* STEP 6.3 - Buffer has been filled. Do something with the data and proceed */

            int16_t current_value; 
            for(int i=0; i &amp;lt; p_event-&amp;gt;data.done.size; i++){
                current_value = ((int16_t *)(p_event-&amp;gt;data.done.p_buffer))[i];

                printk(&amp;quot;%d, &amp;quot;, current_value);

            }

            break;

        default:
            LOG_INF(&amp;quot;Unhandled SAADC evt %d&amp;quot;, p_event-&amp;gt;type);
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and I`ll also attach my project, in case it is helpful for you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/current_5F00_code.zip"&gt;devzone.nordicsemi.com/.../current_5F00_code.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This version does not contain any of the k_sleep that I was mentioning, becasue they did not help anyway.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thank you so much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/487836?ContentTypeID=1</link><pubDate>Fri, 07 Jun 2024 07:19:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:86d1303f-b6db-403e-af2f-054f5bfa7b97</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Can you share your sample code? Or atleast from which function(s) you are printing from? It sounds like you are in interrupt priority and printing.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/487768?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2024 14:07:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84a7aa80-56dc-4f15-82af-534882eaeb14</guid><dc:creator>Raluca</dc:creator><description>&lt;p&gt;My SAADC buffer is 8000. I tried 50 us, 50ms&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/487755?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2024 13:47:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ea6ff41-c398-41ba-8095-cb1e502cde05</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote userid="131531" url="~/f/nordic-q-a/111890/terminal-dropping-messages/487753"]I tried adding a K_SLEEP in the for loop and outside,[/quote]
&lt;p&gt;How large is the array that you&amp;#39;re printing? and what was the k_sleep that you tried? k_msleep(1) should be sufficient per half-word.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;H&amp;aring;kon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/487753?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2024 13:42:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1323d9b0-2b22-42c6-b059-40da6c901239</guid><dc:creator>Raluca</dc:creator><description>&lt;p&gt;Hey!&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int16_t current_value; &lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for(int i=0; i &amp;lt; p_event-&amp;gt;data.done.size; i++){&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; current_value = ((int16_t *)(p_event-&amp;gt;data.done.p_buffer))[i];&lt;/strong&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; printk(&amp;quot;%d, &amp;quot;, current_value);&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I am using this function to print my values. I tried adding a K_SLEEP in the for loop and outside, but I still get only 10% of my values. Which is the best way to print big arrays?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Thank you!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Kind regards,&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Raluca&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/487720?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2024 12:23:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:715d0814-df83-46f2-9358-c07cdbb3cd2d</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;That means that you&amp;#39;re blocking the logger thread from running somewhere in your application.&lt;/p&gt;
&lt;p&gt;Increasing the logger size then will not do much, as there&amp;#39;s a function effectively blocking the rest of your application from running.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try yielding/sleeping, and avoid tight while(1) / for(;;) loops without sleep calls.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/487713?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2024 12:05:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffd67992-0e13-4c24-a688-4f0db84e707a</guid><dc:creator>Raluca</dc:creator><description>&lt;p&gt;Thank you so much for replying!&lt;/p&gt;
&lt;p&gt;I tried changing with that buffer size for testing the SAADC for just calculating the internal voltage and I still got&amp;nbsp;--- 7744 messages dropped ---&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Terminal dropping messages</title><link>https://devzone.nordicsemi.com/thread/487710?ContentTypeID=1</link><pubDate>Thu, 06 Jun 2024 12:00:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d9b347a-d1db-4449-8752-a7abe577683d</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In your prj.conf, you can increase the log buffer size via this configuration:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_LOG_BUFFER_SIZE=8192&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>