<?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>ESB receive the data sent by itself</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/100601/esb-receive-the-data-sent-by-itself</link><description>Hi all, 
 Question preconditions: 
 nRF52832, SDK 17.1.0, use FreeRTOS. 
 1 PTX and 2 PRX, PTX send heart beat to every PRX to receive the data from PRX. 
 Two PRX enable different pipe by nrf_esb_enable_pipes(bit_n). 
 . 
 Question. 
 I use the ESB to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Aug 2023 01:19:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/100601/esb-receive-the-data-sent-by-itself" /><item><title>RE: ESB receive the data sent by itself</title><link>https://devzone.nordicsemi.com/thread/440600?ContentTypeID=1</link><pubDate>Thu, 10 Aug 2023 01:19:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32867d6a-d0d2-4fe9-909d-3c6a9e43c7f4</guid><dc:creator>Lurn_Z</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for your reply, but now this problem is solved,&amp;nbsp;I&amp;nbsp;changed the buffer_t struct to use a uint8_t array for data rather than a pointer in IRQ callback, and do a memcpy to copy the data into this array before push it to the queue.&lt;/p&gt;
&lt;p&gt;The problem is that I&amp;#39;m not pushing the actual data into the queue, just pushing the pointers to the data. Then later on the original buffers where the data was stored might be overwritten as upload or receive something else, and then the data pointed to by the item in the queue will be different.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Lurn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ESB receive the data sent by itself</title><link>https://devzone.nordicsemi.com/thread/440473?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 11:13:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d460966-5402-491e-9b76-0c897dcdf320</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Lurn_Z"]&lt;p&gt;&lt;span&gt;&amp;nbsp;I get this problem again. And this problem will only appear when it is transmitted in two -way.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you give me some suggestions?&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Not sure if you have made any progress on this. But, since it seems very application-specific, I think I would need an stripped down example of this, that reproducers the issue on 2-DK&amp;#39;s to investigate this further.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ESB receive the data sent by itself</title><link>https://devzone.nordicsemi.com/thread/433361?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2023 06:29:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10076672-7bab-42f1-a13d-f1a348b83ea3</guid><dc:creator>Lurn_Z</dc:creator><description>&lt;p&gt;Hi Sigurd,&lt;/p&gt;
&lt;p&gt;Are you still following this issue?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;I get this problem again. And this problem will only appear when it is transmitted in two -way.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Can you give me some suggestions?&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;Lurn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ESB receive the data sent by itself</title><link>https://devzone.nordicsemi.com/thread/430598?ContentTypeID=1</link><pubDate>Tue, 13 Jun 2023 03:31:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d82c901-6b0d-42dc-a1c5-1161d90a0741</guid><dc:creator>Lurn_Z</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I modify the UART IRQ handler to&amp;nbsp;distinguish different packets and put them in different queues. Now this problem doesn&amp;#39;t occur again(I just tested it a few times,but it used to happen every time), but I still don&amp;#39;t know why.&lt;/p&gt;
&lt;p&gt;At first, I will put all packets to a same queue then in UART_main to distinguish it and use switch...case... to put it in different queues, now&amp;nbsp;I&amp;#39;m just moving the process forward.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ESB receive the data sent by itself</title><link>https://devzone.nordicsemi.com/thread/430102?ContentTypeID=1</link><pubDate>Fri, 09 Jun 2023 05:50:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3273ca01-9ae2-4666-9a0a-fef1e42896ed</guid><dc:creator>Lurn_Z</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I found that this happens only when I go to the UART queue to fetch data. Because I set a queue and push some data in a new thread, it works fine. In this case the UART in PTX side will not send data.&lt;/p&gt;
&lt;p&gt;But when I use the device to sent data to PTX via UART and pop the data from UART queue.Then send it through ESB. the &lt;span&gt;problem arises.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Is something wrong with UART?&lt;/p&gt;
&lt;p&gt;here is code about uart&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void uart_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
{
    nrf_libuarte_async_t *p_libuarte = (nrf_libuarte_async_t *)context;
    ret_code_t ret;

    switch (p_evt-&amp;gt;type)
    {
        case NRF_LIBUARTE_ASYNC_EVT_ERROR:
            PRINTF(&amp;quot;NRF_LIBUARTE_ASYNC_EVT_ERROR = %d.&amp;quot;, p_evt-&amp;gt;data.errorsrc);
            break;
        case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
            buffer_t buf = {
                .p_data = p_evt-&amp;gt;data.rxtx.p_data,
                .length = p_evt-&amp;gt;data.rxtx.length,
            };
            ret = nrf_queue_push(&amp;amp;m_buf_queue, &amp;amp;buf);
            APP_ERROR_CHECK(ret);
            nrf_libuarte_async_rx_free(p_libuarte, p_evt-&amp;gt;data.rxtx.p_data, p_evt-&amp;gt;data.rxtx.length);
            break;
        case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
            break;
        default:
            PRINTF(&amp;quot;Unexpected LibUarte Event = %d.&amp;quot;, p_evt-&amp;gt;type);
            break;
    }
}


static int uart_cmd_set(uint8_t * data, uint8_t len)
{
    uint8_t ret;
    BaseType_t xReturn = pdTRUE;
    buffer_t buf = {
        .p_data = data,
        .length = len,
    };
    switch(data[2])
    {
        case REAL_TIME_SHARE:
            ret = nrf_queue_push(&amp;amp;real_time_queue, &amp;amp;buf);
            break;
        default:
            break;
    }
    return ret;
}

void uart_main(void)
{
    uint8_t err_code;
    while (!nrf_queue_is_empty(&amp;amp;m_buf_queue))
    {
        err_code = nrf_queue_pop(&amp;amp;m_buf_queue, &amp;amp;buf);
        APP_ERROR_CHECK(err_code);
        uart_cmd_set(data_array, index);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is also an esb_share() in the previous reply, the esb_share will be call in another thread to send data.&lt;/p&gt;
&lt;p&gt;Note: I use libuarte to transfer data.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Lurn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ESB receive the data sent by itself</title><link>https://devzone.nordicsemi.com/thread/429964?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 11:19:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20d0e50b-27e0-49f5-a8f6-df3489c36b0a</guid><dc:creator>Lurn_Z</dc:creator><description>&lt;p&gt;Hi Sigurd,&lt;/p&gt;
&lt;p&gt;The complete process I made is like this.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1686303659951v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;When the PTX send data from UART to PRX, at the same time the PRX will send data to PTX(with ACK payload), Under normal circumstances the PRX side will receive data from PTX,&amp;nbsp;but I found that this is not the case here. The PRX side has received the data&amp;nbsp;it sent itself, and the PTX side has received the data too.&lt;/p&gt;
&lt;p&gt;like this&amp;nbsp; TX send A to RX, at same time RX send B to TX&lt;/p&gt;
&lt;p&gt;The PRX should only receive data A but it also receive data B via ESB. The TX side also received the data A.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1686223486174v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Lurn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ESB receive the data sent by itself</title><link>https://devzone.nordicsemi.com/thread/429958?ContentTypeID=1</link><pubDate>Thu, 08 Jun 2023 11:11:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c0cd494-efb9-4ff8-97ee-ab28ccd34c4d</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]But when I send the data from UART to two PRX, the PRX side will not receive the correct data(from PTX) but will receive the data sent by itself.[/quote]
&lt;p&gt;I&amp;#39;m not sure If I understand this correctly. Could you explain a bit more what is meant by&amp;nbsp;&amp;quot;&lt;span&gt;receive the data sent by itself&amp;quot; ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>