<?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>UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64836/uarte-communication-using-config_uart_interrupt_driven-dropping-data-after-8-bytes</link><description>I&amp;#39;ve configured UART2 on the nRF9160 to connect to a nRF52840. The nRF52840 generates a payload and sends it over to the nRF91. The payload size during testing was 65 bytes. The problem with all of this? Using the CONFIG_UART_INTERRUPT_DRIVEN code, the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Aug 2020 02:26:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64836/uarte-communication-using-config_uart_interrupt_driven-dropping-data-after-8-bytes" /><item><title>RE: UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/thread/266603?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 02:26:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f698bd10-b895-40e1-8b3a-4e082eacf940</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;The only solution that I&amp;#39;ve found for this is a as follows:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;1. &amp;nbsp;Use the ASYNC API as I was before (&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/8e4ccb303bf9b7eb42d76e1acdd9550c489a396e/samples/bluetooth/peripheral_uart/src/main.c#L80"&gt;Github Link&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;2. On the other device, pad any remaining bytes with 0&amp;#39;s so they always align with the size of the RX buffer on the nRF9160&amp;nbsp;&lt;/p&gt;
&lt;p&gt;3. When trying to figure out message boundaries, the first byte indicates how many data bytes are in a stream. So technically the following byte after the last in the &amp;quot;frame&amp;quot; would be the size. I now disregard any size of 0.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a little clunky but it works for now.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Edit:&lt;/p&gt;
&lt;p&gt;Also another hint from Eli H. that if you&amp;#39;re logging within the interrupt context you will, for sure, drop data if&amp;nbsp;&lt;span&gt;CONFIG_LOG_MODE_IMMEDIATE is set to &amp;#39;y&amp;#39;. Either turn of immediate logging or remove logging from the ISR and you should be good to go!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/thread/266594?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 21:57:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8612ded-542b-4c33-a84e-517cdf9bbd30</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hey Jonathan,&lt;/p&gt;
&lt;p&gt;I was able to try your suggestion here. Here&amp;#39;s my&amp;nbsp;code looks like:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint8_t buf[256];

static void uart_cb(struct device *dev)
{

  uart_irq_update(dev);

  /* Read as much data as possible */
  if (uart_irq_rx_ready(dev))
  {
    /* Read operation and get bytes read*/
    int len = uart_fifo_read(dev, buf, 256);

    LOG_INF(&amp;quot;%d bytes&amp;quot;, len);
  }

  if (uart_irq_tx_ready(dev))
  {
    /* Release last buf */

    /* Get next */
  }
}

int comms_init(comms_evt_callback_t cb)
{
  if (cb == NULL)
  {
    return -EINVAL;
  }

  /* Copy pointer to callback */
  callback = cb;

  /* Get the UART device */
  uart = device_get_binding(DT_LABEL(DT_NODELABEL(uart2)));
  if (!uart)
  {
    return -ENXIO;
  }

  /* Enable ISR */
  uart_irq_callback_set(uart, uart_cb);

  /* Enable RX events */
  uart_irq_rx_enable(uart);

  /* Enable the thread */
  k_sem_give(&amp;amp;comms_init_ok);

  return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s extremely similar compared to the example you sent. Unfortunately it&amp;#39;s still receiving only single bytes. Here&amp;#39;s the debug printout showing I only got 12 bytes out of the 30+ bytes sent on the other end.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;1 bytes
1 bytes
1 bytes
1 bytes
1 bytes
1 bytes
1 bytes
1 bytes
1 bytes
1 bytes
1 bytes
1 bytes&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/thread/266561?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 15:01:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dee25b1c-6c9c-4785-a57e-9fc3b8557e15</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Thanks Jonathan!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will try exactly that and let you know.&amp;nbsp;I think the biggest difference in mine was that I was trying to read byte by byte. I found that code elsewhere in NCS. Must have been for a different purpose!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/thread/266532?ContentTypeID=1</link><pubDate>Wed, 26 Aug 2020 13:59:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4e717e2-7ce7-4cf6-a5fd-6a931f523d95</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi, I might have misunderstood you original problem.&lt;/p&gt;
&lt;p&gt;I see that you are using a uart_cb function not implemented as a nrf9160 example yet so I would recommend to look&amp;nbsp;at &lt;a href="https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/uart/src/main.c"&gt;this example&lt;/a&gt;.&lt;br /&gt;Could you se if the same behavior persists&amp;nbsp;using the example implementation?&lt;br /&gt;I have not tested to see if there is a 8 byte internal buffer or tested to se if it&amp;nbsp;the buffer is configurable at this moment. &lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/thread/266301?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 15:27:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15cc48f0-7439-4d42-a80b-11e67c6d818a</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hey Jonathan,&lt;/p&gt;
&lt;p&gt;Thanks for the tip. I&amp;#39;m not sure how it relates though.&lt;/p&gt;
&lt;p&gt;This seems to be an issue related to the UART implementation unless Im missing something huge here. If I simply print&amp;nbsp;out the bytes from the ISR, it prints the first 8 and then stops. Seems like there&amp;#39;s an internal 8 byte buffer. Anything after that 8 bytes gets dropped as far as I can tell.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/thread/266282?ContentTypeID=1</link><pubDate>Tue, 25 Aug 2020 14:28:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d4aa82c-bb4f-47df-b2da-89366e0a2f49</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Hi Jared,&lt;br /&gt;&lt;br /&gt;Check out Ring buffers,&amp;nbsp;&lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/other/ring_buffers.html#implementation"&gt;https://docs.zephyrproject.org/latest/reference/kernel/other/ring_buffers.html#implementation&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/thread/266069?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 20:49:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2581555a-677a-4843-a052-d935ae6c2d47</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;While this is good for many cases, it doesn&amp;#39;t quite work for my use case. I&amp;#39;d like to read byte by byte as I have variable payloads. Any thoughts here would be great!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UARTE communication using CONFIG_UART_INTERRUPT_DRIVEN dropping data after 8 bytes</title><link>https://devzone.nordicsemi.com/thread/264686?ContentTypeID=1</link><pubDate>Sat, 15 Aug 2020 02:07:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:048f353a-b9ea-4091-ae6f-3223aabd2afa</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Appears to be fixed with ASYNC. I used the code in the &lt;strong&gt;peripheral_uart&lt;/strong&gt;&amp;nbsp;example. &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/8e4ccb303bf9b7eb42d76e1acdd9550c489a396e/samples/bluetooth/peripheral_uart/src/main.c#L80"&gt;Github Link&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using flow control so here&amp;#39;s my final&amp;nbsp;&lt;strong&gt;prj.conf&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_UART_LINE_CTRL=y
CONFIG_NRFX_UARTE2=y
CONFIG_SERIAL=y&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>