<?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>How to clear UARTE buffer?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97280/how-to-clear-uarte-buffer</link><description>Hi everyone, 
 I use the UARTE to receive data, and I want to clear rx buffer every time, because If not when the buffer will be full , the next data I received will be split into two parts, 
 for example, the buffer is 32bytes, for now i received 30bytes</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 03 Mar 2023 08:24:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97280/how-to-clear-uarte-buffer" /><item><title>RE: How to clear UARTE buffer?</title><link>https://devzone.nordicsemi.com/thread/413165?ContentTypeID=1</link><pubDate>Fri, 03 Mar 2023 08:24:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77f151b3-ba31-4dcf-b0a1-ebd9782c8526</guid><dc:creator>Lurn_Z</dc:creator><description>&lt;p&gt;Ok,&lt;span class="HwtZe" lang="en"&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;I used the method of judging the data header&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="ZSCsVd"&gt;&lt;/span&gt; to solve the data split, and test OK.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;{
        if (!nrf_queue_is_empty(&amp;amp;m_buf_queue))
        {
            buffer_t buf;
            err_code = nrf_queue_pop(&amp;amp;m_buf_queue, &amp;amp;buf);
            APP_ERROR_CHECK(err_code);
            err_code = nrf_libuarte_async_tx(&amp;amp;libuarte, buf.p_data, buf.length);
            APP_ERROR_CHECK(err_code);
            if(buf.p_data[0] == 0x5A &amp;amp;&amp;amp; (buf.p_data[1] == 0xC4 || buf.p_data[1] == 0xC5))
            {
                memset(data_array, 0, sizeof(data_array));
                index = 0;
                memcpy(&amp;amp;data_array[index], buf.p_data, buf.length);
                index = buf.length;
            }
            else
            {
                memcpy(&amp;amp;data_array[index], buf.p_data, buf.length);
                index += buf.length;
            }
        }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to clear UARTE buffer?</title><link>https://devzone.nordicsemi.com/thread/413144?ContentTypeID=1</link><pubDate>Fri, 03 Mar 2023 05:56:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cd1dbd6-90e6-4e4b-b9da-de0beb951767</guid><dc:creator>Lurn_Z</dc:creator><description>&lt;p&gt;Here&amp;#39;s what&amp;#39;s happening:&lt;/p&gt;
&lt;p&gt;I initialised 3 buffers, each of 32 bytes wide.&lt;/p&gt;
&lt;p&gt;I use another system sends a 30 bytes data.&lt;/p&gt;
&lt;p&gt;Everything works as expected. I get an event after 30 bytes.&lt;/p&gt;
&lt;p&gt;After that, I again get an event from the other system, as expected, because one buffer is filled. And then the buffer fills from start.&lt;/p&gt;
&lt;p&gt;What I want is this:&lt;/p&gt;
&lt;p&gt;After I process a response from the other device, I want to reset the write location of Rx buffer so that it starts from beginning.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>