<?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>Assertion Fail Using ble_nus_client_send with UART in NRF Connect SDK 1.8.0</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86948/assertion-fail-using-ble_nus_client_send-with-uart-in-nrf-connect-sdk-1-8-0</link><description>Hello, 
 I am getting the error: ASSERTION FAIL @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/conn.c:1152 E: r0/a1: 0x00000004 r1/a2: 0x00000480 r2/a3: 0x200060d0 
 
 I&amp;#39;m using the Fanstel BLG840X which integrates an nrf52840 and nrf9160. I am using NRF</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 May 2022 09:31:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86948/assertion-fail-using-ble_nus_client_send-with-uart-in-nrf-connect-sdk-1-8-0" /><item><title>RE: Assertion Fail Using ble_nus_client_send with UART in NRF Connect SDK 1.8.0</title><link>https://devzone.nordicsemi.com/thread/366875?ContentTypeID=1</link><pubDate>Mon, 09 May 2022 09:31:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea04413d-1def-4000-bae4-0f183232e948</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Great. if you want can verify the answer or I can close the case.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Kazi Afroza Sultana&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion Fail Using ble_nus_client_send with UART in NRF Connect SDK 1.8.0</title><link>https://devzone.nordicsemi.com/thread/366789?ContentTypeID=1</link><pubDate>Fri, 06 May 2022 21:34:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd893db0-7c93-4d65-a4dc-47751817a173</guid><dc:creator>jake11212</dc:creator><description>&lt;p&gt;This was it, working with the line in conn.c back in, thanks so much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion Fail Using ble_nus_client_send with UART in NRF Connect SDK 1.8.0</title><link>https://devzone.nordicsemi.com/thread/365541?ContentTypeID=1</link><pubDate>Fri, 29 Apr 2022 09:09:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e358cfab-ed35-4af3-9adc-787070fe5bb3</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;PDU stands for protocol data unit, commonly known as packets. Looks like you can&amp;#39;t call&amp;nbsp;bt_nus_client_send() from the UART ISR. Instead, just put the UART data in a FIFO, e.g. with&amp;nbsp;&lt;span&gt;k_fifo_put(), and have a separate&amp;nbsp;thread that sends the data. E.g. as done in &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v1.9.1/samples/bluetooth/peripheral_uart/src/main.c"&gt;peripheral_uart sample&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion Fail Using ble_nus_client_send with UART in NRF Connect SDK 1.8.0</title><link>https://devzone.nordicsemi.com/thread/364317?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 17:22:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6524724a-b3a0-41ef-8c85-f24924c3ce4b</guid><dc:creator>jake11212</dc:creator><description>[quote userid="108933" url="~/f/nordic-q-a/86948/assertion-fail-using-ble_nus_client_send-with-uart-in-nrf-connect-sdk-1-8-0/364224#364224"]Are you sending the data from the UART Interrupt Handler[/quote]
&lt;p&gt;Are you referring to data sent over UART or data send with the Nordic UART Service (for BLE)?&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am just calling both directly, could that be an issue?&amp;nbsp; So you&amp;#39;re recommending I generate an interrupt then use that interrupt handler to send the data?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also my code for sending over UART is:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int uart_send(struct uart_data_t *uart_data)
{
    int status = uart_tx(device_uart, uart_data-&amp;gt;data, uart_data-&amp;gt;length, SYS_FOREVER_MS);

    if (status != 0)
    {
        printk(&amp;quot;uart_tx ( error: %d )\n&amp;quot;, status);

        // Add to tx queue to try and process / send later ...
        k_fifo_put(&amp;amp;fifo_uart_tx_data, uart_data);
    }

    return status;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also for more context on the error I&amp;#39;ve started debugging with Ozone, this is the full error state that I&amp;#39;m still working through:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/ble_5F00_error_5F00_hardfault.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The line throwing the error was in: ..\ncs\v1.8.0\zephyr\subsys\bluetooth\host\conn.c line 1152 which is:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;__ASSERT_NO_MSG(!k_is_in_isr());&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;It has the associated comment:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;/*&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* PDU must not be allocated from ISR as we block with &amp;#39;K_FOREVER&amp;#39;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* during the allocation&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I wasn&amp;#39;t sure what this meant, could you elaborate on what might be causing this error to throw.&amp;nbsp; ISR is the interrupt service routine but I&amp;#39;m not sure what PDR is or why my code might have caused this assert.&amp;nbsp; For testing purposes I commented out the line and the send worked properly but I want to solve the issue causing the error.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion Fail Using ble_nus_client_send with UART in NRF Connect SDK 1.8.0</title><link>https://devzone.nordicsemi.com/thread/364224?ContentTypeID=1</link><pubDate>Thu, 21 Apr 2022 12:39:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:124fe9dc-2dbb-4bda-bb15-bf6203e5a6bd</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Are you sending the data from the UART Interrupt Handler &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/subsys/bluetooth/host/conn.c#L1152"&gt;sdk-zephyr/conn.c at v2.7.0-ncs1 · nrfconnect/sdk-zephyr · GitHub&lt;/a&gt;? You can use a work thread or similar to send the data instead of calling it directly from the uart_handler.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kazi Afroza Sultana&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Assertion Fail Using ble_nus_client_send with UART in NRF Connect SDK 1.8.0</title><link>https://devzone.nordicsemi.com/thread/363561?ContentTypeID=1</link><pubDate>Tue, 19 Apr 2022 12:03:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:649ebf33-678d-42da-87b3-c955c768625b</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Your case arrived in Easter vacation so a bit late reply. I have started looking at your case and will get back to you later.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Kazi Afroza Sultana&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>