<?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>Clear Uarte Rx Buffer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85201/clear-uarte-rx-buffer</link><description>Hi, I am using libuartes to comunicate with gps and I get the Rx buffer like a problem already asked in this thread when I send a text &amp;quot;abc&amp;quot; 
 the first 3 times : everything is fine (9 bytes) on the 4th time : my application call 2 NRF_LIBUARTE_ASYNC_EVT_RX_DATA</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 02 Mar 2022 13:15:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85201/clear-uarte-rx-buffer" /><item><title>RE: Clear Uarte Rx Buffer</title><link>https://devzone.nordicsemi.com/thread/355829?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2022 13:15:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b6116d2-8f46-4d5e-80e9-7b25cc372058</guid><dc:creator>Pham Tam</dc:creator><description>&lt;p&gt;Thank Jorgen, I got it !!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clear Uarte Rx Buffer</title><link>https://devzone.nordicsemi.com/thread/355826?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2022 13:10:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3fa77f3-9fc8-4026-b671-1e9269e72c34</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="pham_tam"]In step 4 the 2nd buffer will be used ?[/quote]
&lt;p&gt;In step 4, both 1st and 2nd buffer will be used. 1st buffer will hold the&amp;nbsp;first received byte, while the two next bytes that did not fit in the rest of the 1st buffer will be stored in 2nd buffer.&lt;/p&gt;
[quote user="pham_tam"]And when the 3th buffer full, the 1st buffer will be reused because it&amp;#39;s freed in step 1, 2, 3&amp;nbsp; ?[/quote]
&lt;p&gt;Yes, as long as&amp;nbsp;&lt;strong&gt;&lt;em&gt;all&lt;/em&gt; &lt;/strong&gt;the bytes in first buffer is freed, the buffer will be reused when the 3rd buffer have been filled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clear Uarte Rx Buffer</title><link>https://devzone.nordicsemi.com/thread/355679?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2022 02:27:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6346cbcb-4cfe-4911-952b-c432f70e14a3</guid><dc:creator>Pham Tam</dc:creator><description>[quote userid="14926" url="~/f/nordic-q-a/85201/clear-uarte-rx-buffer/355262#355262"]At this point, the buffer can be freed and reused by the library at a later point. As you can understand, it is not possible to start the reception at the start of the buffer with the current architecture.[/quote]
&lt;p&gt;According what I understand, there are 3 10byte buffer.&lt;br /&gt;NRF_LIBUARTE_ASYNC_DEFINE(libuarte1, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 10, 3);&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/2210.png" /&gt;&lt;br /&gt;In step 4 the 2nd buffer will be used ?&lt;br /&gt;And when the 3th buffer full, the 1st buffer will be reused because it&amp;#39;s freed in step 1, 2, 3&amp;nbsp; ?&lt;br /&gt;Thank Jorgen&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Clear Uarte Rx Buffer</title><link>https://devzone.nordicsemi.com/thread/355262?ContentTypeID=1</link><pubDate>Mon, 28 Feb 2022 12:05:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:af400590-9b7b-4d1b-a7fd-c3102ccbe4e5</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Like I &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/84124/nrf_libuarte_async_rx_free-not-working-tx-buffer-overflow/350036#350036"&gt;already told you before&lt;/a&gt;, this is not how libUARTE works. The library will not stop the transfer on a timeout, it will only report the number of received bytes to the application. The buffer is still in use by the UART peripheral, waiting for more data to fill the requested number of bytes in the buffer. When the full buffer size is received, the library will immediately switch to the next buffer to avoid losing data. At this point, the buffer can be freed and reused by the library at a later point. As you can understand, it is not possible to start the reception at the start of the buffer with the current architecture.&lt;/p&gt;
&lt;p&gt;Instead of using the events as the indicator that a transfer is completed, you should use some string termination character (\0, \r, \n, etc) or the string length if that is fixed/known.&lt;/p&gt;
&lt;p&gt;If you require the transfer to start at the beginning of the buffer on each receive operation, you can use the UART driver directly. Note that this does not support any timeouts, so you need to handle that yourself. You may also risk losing data when using this approach, as you need to stop the reception before being able to set a new buffer. I would much rather recommend using libUARTE with the above described suggestions.&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>