<?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>Zephyr ASYNC Uart and Data Processing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104822/zephyr-async-uart-and-data-processing</link><description>Hi, 
 Context: 
 I am looking at feeding the ASYNC UART data into a ring buffer. Then, processing that ring buffer at regular intervals. I&amp;#39;m concerned that the ASYNC UART callback function could get triggered while the ring buffer is being processed.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 19 Oct 2023 10:49:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104822/zephyr-async-uart-and-data-processing" /><item><title>RE: Zephyr ASYNC Uart and Data Processing</title><link>https://devzone.nordicsemi.com/thread/451252?ContentTypeID=1</link><pubDate>Thu, 19 Oct 2023 10:49:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1b304fc3-02e1-4eb7-b070-378fbc7ff1d4</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Chad&lt;/p&gt;
&lt;p&gt;One of the reasons for using a ring buffer is to allow it to be filled and emptied concurrently. The critical point is to ensure that there is enough free space in the buffer at all time to handle the maximum amount of data that you might have to process in a single UART callback (set by the UART RX buffer size).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t respond to buffer requests then RX will eventually get disabled, and no more data will be received, but this will limit the data transfer speed, and lead to data loss if you don&amp;#39;t use hardware flow control.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Some time back I made my own UART async wrapper in an attempt to provide a simple interface to the application, while at the same time allowing for high throughput and minimal memory consumption.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I decided to use memslabs for the RX buffers rather than ringbuffers, because the&amp;nbsp;ringbuffers have some limitations in the way the UART RX buffers are allocated and freed that made them less optimal.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The library is available &lt;a href="https://github.com/too1/ncs-uart-handler"&gt;here&lt;/a&gt; if you want to have a look at it. It if is sufficient for your application it might save you some time not having to make your own &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f609.svg" title="Wink"&gt;&amp;#x1f609;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;As you can see from the &lt;a href="https://github.com/too1/ncs-uart-handler/blob/master/samples/simple/src/main.c"&gt;simple sample&lt;/a&gt; you can initialize and use it with very little application code needed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>