<?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>get data from uart receive buffer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/21776/get-data-from-uart-receive-buffer</link><description>hello, there my application is like that... 
 (1) calculate size of receive buffer. than read that size of data.
again new data comes, then again calculate that size of receive buffer and read that size of data. for that i have to clear buffer after</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 04 May 2017 12:08:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/21776/get-data-from-uart-receive-buffer" /><item><title>RE: get data from uart receive buffer</title><link>https://devzone.nordicsemi.com/thread/85505?ContentTypeID=1</link><pubDate>Thu, 04 May 2017 12:08:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59cf46f5-9af1-4709-b2c1-653662dc34de</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Hey nordicbeginner,&lt;br /&gt;
I&amp;#39;ve made some modification to your event handler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    void uart_error_handle(app_uart_evt_t * p_event)
    {
        static uint8_t data_array[CHOOSE_YOUR_SIZE];
        static uint8_t index = 0;
        uint32_t       err_code;
        
        if (p_event-&amp;gt;evt_type == APP_UART_COMMUNICATION_ERROR)
        {
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_communication);
        }
        else if (p_event-&amp;gt;evt_type == APP_UART_FIFO_ERROR)
        {
            APP_ERROR_HANDLER(p_event-&amp;gt;data.error_code);
        }
        if (p_event-&amp;gt;evt_type == APP_UART_DATA_READY)
        {  
           err_code = app_uart_get(&amp;amp;data_array[index]);
           index++;
           /* TODO: Substitute &amp;#39;\n&amp;#39; in the statement below with the Modbus escape character, if 
               applicable */
           if ((data_array[index - 1] == &amp;#39;\n&amp;#39;) || (index &amp;gt;= (CHOOSE_YOUR_SIZE)))
           {
                uart_callback(&amp;amp;data_array[0], index);

                if (err_code != NRF_ERROR_INVALID_STATE)
                {
                    APP_ERROR_CHECK(err_code);
                }

                index = 0;
            }

       }
    }

    void uart_callback(uint8_t * p_data, uint8_t length)
    {
        // TODO: Process &amp;#39;data_array&amp;#39; of size &amp;#39;length&amp;#39;.
    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cheers,&lt;br /&gt;
Håkon H&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>