<?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>Serial library event handler example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26550/serial-library-event-handler-example</link><description>Hi, 
 Does anyone have a complete example of using an event handler to read UART data set up with the serial library? This post is the only incomplete example I can find. The example program sets _ev_handler to NULL in the setup NRF_SERIAL_CONFIG_DEF</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 03 Sep 2018 15:22:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26550/serial-library-event-handler-example" /><item><title>RE: Serial library event handler example</title><link>https://devzone.nordicsemi.com/thread/147031?ContentTypeID=1</link><pubDate>Mon, 03 Sep 2018 15:22:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7180a5f1-43b4-4be8-80a6-f535d1c28877</guid><dc:creator>Igor</dc:creator><description>&lt;p&gt;This works in SDK 15:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void serial_rx_cb(struct nrf_serial_s const *p_serial, nrf_serial_event_t event) {
    if (event == NRF_SERIAL_EVENT_RX_DATA) {
        char c;
        APP_ERROR_CHECK(nrf_serial_read(&amp;amp;serial_uart, &amp;amp;c, sizeof(c), NULL, 500));
        APP_ERROR_CHECK(nrf_serial_write(&amp;amp;serial_uart, &amp;amp;c, sizeof(c), NULL, 500));
        //__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;%c\n&amp;quot;, c);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But it is still char by char. I don&amp;#39;t know how to use it properly with a bigger&amp;nbsp;SERIAL_BUFF_RX_SIZE?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial library event handler example</title><link>https://devzone.nordicsemi.com/thread/133588?ContentTypeID=1</link><pubDate>Mon, 28 May 2018 08:10:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acd083c1-604e-4da9-a67e-b08d0fb2be27</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You are correct, how often the event handler is called depends on the size of the buffers set using&amp;nbsp;&lt;a title="Creates an instance of serial port buffers." href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrf__serial.html#ga0195d5e9660413084d03965fd387df07"&gt;NRF_SERIAL_BUFFERS_DEF&lt;/a&gt;. These buffers are used for transfers, and the size will determine the smallest slices of data that can be transfered in a single&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.0.0/group__nrf__drv__uart.html"&gt;UART driver - legacy layer&lt;/a&gt;&amp;nbsp;driver request. Increasing the buffer size should give you fever calls of the handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial library event handler example</title><link>https://devzone.nordicsemi.com/thread/133530?ContentTypeID=1</link><pubDate>Sat, 26 May 2018 14:37:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d9f9c67-50d0-4d81-ab17-452e3411754f</guid><dc:creator>aaronxu</dc:creator><description>&lt;p&gt;I am afraid that the&amp;nbsp;&amp;nbsp;&lt;span&gt;event handler will be called on every single byte&amp;nbsp;received by the UART. No matter the &amp;quot;nrf_serial_read&amp;quot; parameters.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Could you kindly share with us an example use&amp;nbsp;event handler for receive more than one byte?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial library event handler example</title><link>https://devzone.nordicsemi.com/thread/104465?ContentTypeID=1</link><pubDate>Mon, 13 Nov 2017 14:09:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4162010f-57db-4ba9-bf8a-6ca986b71ceb</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The event handler will be called on every &lt;code&gt;NRF_DRV_UART_EVT_RX_DONE&lt;/code&gt; event from the UART driver. This will either happen when the number of bytes passed to the size parameter of &lt;code&gt;nrf_serial_read()&lt;/code&gt; have been received, or when the timeout have been reached.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial library event handler example</title><link>https://devzone.nordicsemi.com/thread/104464?ContentTypeID=1</link><pubDate>Mon, 06 Nov 2017 16:24:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d363173-297f-41f5-ae8b-804439d10797</guid><dc:creator>SRose</dc:creator><description>&lt;p&gt;Jørgen,  Does the event handler set in &lt;code&gt;NRF_SERIAL_CONFIG_DEF&lt;/code&gt; get called for EACH byte received by the UART, or does it get called once after &lt;code&gt;__?__&lt;/code&gt;  From the previous post,  should I read the entire queue until empty?  or just one byte off the queue like the example?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial library event handler example</title><link>https://devzone.nordicsemi.com/thread/104463?ContentTypeID=1</link><pubDate>Fri, 03 Nov 2017 15:12:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8712badc-4699-4e64-9513-ace926ba5824</guid><dc:creator>SRose</dc:creator><description>&lt;p&gt;The byte data coming in is a proprietary protocol. I need to store the data in a big buffer and search for the start / end bytes for each message and then parse the message.  I do have a timing requirement.  Once I receive the end byte for a given message, the program needs to respond by sending a msg on the serial within 300us - 6.0ms.   It seems to me using the event handler is better for this than always querying the serial queue with a timer?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Serial library event handler example</title><link>https://devzone.nordicsemi.com/thread/104462?ContentTypeID=1</link><pubDate>Fri, 03 Nov 2017 14:33:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:860fbb8d-2b9e-4d4c-acbb-0a22cb069dc5</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You should only have to define the event handler and pass this to &lt;code&gt;NRF_SERIAL_CONFIG_DEF&lt;/code&gt;. What exactly do you want the handler to do?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>