<?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>SD16 nRF52840 - Queue library</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79579/sd16-nrf52840---queue-library</link><description>Hi everyone, 
 I am experimenting with the queue library 
 
 After pushing some data by calling nrf_queue_push how do I print the data stored in the buffer?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Nov 2021 19:10:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79579/sd16-nrf52840---queue-library" /><item><title>RE: SD16 nRF52840 - Queue library</title><link>https://devzone.nordicsemi.com/thread/340421?ContentTypeID=1</link><pubDate>Tue, 23 Nov 2021 19:10:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02b3df2d-a536-4b7c-99c7-4e6257fad090</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Hi Tesc, I have got my answers through other tickets. You can close this one, thanks for your assistance!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD16 nRF52840 - Queue library</title><link>https://devzone.nordicsemi.com/thread/340403?ContentTypeID=1</link><pubDate>Tue, 23 Nov 2021 15:50:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:489f1ad4-82f6-46d7-9761-5fbe1a1ada44</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am very sorry for the delays. I see you have gotten some answers in the threads &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/81742/sdk17---queue-module---pushing-elements-to-the-queue"&gt;SDK17 - Queue module - pushing elements to the queue&lt;/a&gt; and &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/81746/sdk-17---nrf52840---nrf_queue_write-asserts-when-buffer-size-queue-size"&gt;SDK 17 - NRF52840 - nrf_queue_write() asserts when buffer size &amp;gt; queue size&lt;/a&gt;, is there anything remaining that you need answers to?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD16 nRF52840 - Queue library</title><link>https://devzone.nordicsemi.com/thread/339032?ContentTypeID=1</link><pubDate>Mon, 15 Nov 2021 13:30:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:600731c5-b6d3-4176-a394-bf2a93e71b51</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Thank you for your assistance. I used the second approach to buffer data, but I have some questions regarding the functionality.&lt;br /&gt;My function so far:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define QUEUE_BUFFER_INTERVAL APP_TIMER_TICKS(1000) // timer for queuing data
#define QUEUE_SIZE 20                           

NRF_QUEUE_DEF(int16_t, m_sensor_data_queue, QUEUE_SIZE, NRF_QUEUE_MODE_OVERFLOW); // define a queue instance
APP_TIMER_DEF(queue_buffer_timer_id);

int16_t data_in[] = {1024, 3000, -10000, -18000, -10000, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 15000};
int16_t data_out[20];
uint8_t data_in_size = sizeof(data_in) / sizeof(data_in[0]);

void my_sensors_buffer() {
  ret_code_t err_code;

  NRF_LOG_INFO(&amp;quot;Queue some data&amp;quot;);
  NRF_LOG_INFO(&amp;quot;Byte size of array: %d&amp;quot;, sizeof(data_in));
  NRF_LOG_INFO(&amp;quot;Index size of array: %d&amp;quot;, data_in_size);

  if (sizeof(data_in) &amp;gt; QUEUE_SIZE) {
    NRF_LOG_INFO(&amp;quot;Warning: data input &amp;gt; queue size&amp;quot;)
  }

  uint16_t queue_available_space = nrf_queue_available_get(&amp;amp;m_sensor_data_queue);
  NRF_LOG_INFO(&amp;quot;Available queue space: %d&amp;quot;, queue_available_space);

  for (uint16_t i = 0; i &amp;lt; data_in_size; i++) {
    err_code = nrf_queue_push(&amp;amp;m_sensor_data_queue, data_in + i); // queue the buffer
    APP_ERROR_CHECK(err_code);
    uint16_t queue_available_space = nrf_queue_available_get(&amp;amp;m_sensor_data_queue);
    NRF_LOG_INFO(&amp;quot;Push[%d] - Available queue space: %d&amp;quot;, i, queue_available_space);
  }

  for (uint16_t i = 0; i &amp;lt; data_in_size; i++) {
    err_code = nrf_queue_pop(&amp;amp;m_sensor_data_queue, data_out + i); // get data from the buffer
    APP_ERROR_CHECK(err_code);
  }

  for (uint16_t i = 0; i &amp;lt; data_in_size; i++) {
    NRF_LOG_INFO(&amp;quot;Pop[%d] %d&amp;quot;, i, *(data_out + i));
  }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1. What is the 3rd parameter in&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span&gt;NRF_QUEUE_DEF()&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;&amp;nbsp;function (QUEUE_SIZE in my case)? Is this the number of queue entries? For example, in my case, the size of the queue is 20 x 2bytes = 40bytes?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. The&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span&gt;nrf_queue_available_get&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;() returns the available (unqueued) entries of the buffer right? When I run the code, the&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span&gt;nrf_queue_available_get()&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;&amp;nbsp;returns a value reduced by one after each&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span&gt;push&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;call:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;info&amp;gt; app: Queue some data
&amp;lt;info&amp;gt; app: Byte size of array: 40
&amp;lt;info&amp;gt; app: Index size of array: 20
&amp;lt;info&amp;gt; app: Warning: data input &amp;gt; queue size
&amp;lt;info&amp;gt; app: Available queue space: 20
&amp;lt;info&amp;gt; app: Push[0] - Available queue space: 19
&amp;lt;info&amp;gt; app: Push[1] - Available queue space: 18
&amp;lt;info&amp;gt; app: Push[2] - Available queue space: 17
&amp;lt;info&amp;gt; app: Push[3] - Available queue space: 16
&amp;lt;info&amp;gt; app: Push[4] - Available queue space: 15
&amp;lt;info&amp;gt; app: Push[5] - Available queue space: 14
&amp;lt;info&amp;gt; app: Push[6] - Available queue space: 13
&amp;lt;info&amp;gt; app: Push[7] - Available queue space: 12
&amp;lt;info&amp;gt; app: Push[8] - Available queue space: 11
&amp;lt;info&amp;gt; app: Push[9] - Available queue space: 10
&amp;lt;info&amp;gt; app: Push[10] - Available queue space: 9
&amp;lt;info&amp;gt; app: Push[11] - Available queue space: 8
&amp;lt;info&amp;gt; app: Push[12] - Available queue space: 7
&amp;lt;info&amp;gt; app: Push[13] - Available queue space: 6
&amp;lt;info&amp;gt; app: Push[14] - Available queue space: 5
&amp;lt;info&amp;gt; app: Push[15] - Available queue space: 4
&amp;lt;info&amp;gt; app: Push[16] - Available queue space: 3
&amp;lt;info&amp;gt; app: Push[17] - Available queue space: 2
&amp;lt;info&amp;gt; app: Push[18] - Available queue space: 1
&amp;lt;info&amp;gt; app: Push[19] - Available queue space: 0
&amp;lt;info&amp;gt; app: Pop[0] 1024
&amp;lt;info&amp;gt; app: Pop[1] 3000
&amp;lt;info&amp;gt; app: Pop[2] -10000
&amp;lt;info&amp;gt; app: Pop[3] -18000
&amp;lt;info&amp;gt; app: Pop[4] -10000
&amp;lt;info&amp;gt; app: Pop[5] 5
&amp;lt;info&amp;gt; app: Pop[6] 6
&amp;lt;info&amp;gt; app: Pop[7] 7
&amp;lt;info&amp;gt; app: Pop[8] 8
&amp;lt;info&amp;gt; app: Pop[9] 9
&amp;lt;info&amp;gt; app: Pop[10] 10
&amp;lt;info&amp;gt; app: Pop[11] 11
&amp;lt;info&amp;gt; app: Pop[12] 12
&amp;lt;info&amp;gt; app: Pop[13] 13
&amp;lt;info&amp;gt; app: Pop[14] 14
&amp;lt;info&amp;gt; app: Pop[15] 15
&amp;lt;info&amp;gt; app: Pop[16] 16
&amp;lt;info&amp;gt; app: Pop[17] 17
&amp;lt;info&amp;gt; app: Pop[18] 18
&amp;lt;info&amp;gt; app: Pop[19] 19
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3. I use the&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span&gt;NRF_QUEUE_MODE_OVERFLOW&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;&amp;nbsp;mode. When the buffer is getting full, I expect to start overwriting starting from the 1st element of the queue. However, this does not happen. If I reduce the QUEUE_SIZE to 19 (instead of 20), maintaining the same payload, I got the error&amp;nbsp;&lt;/span&gt;&lt;strong&gt;&lt;span&gt;NRF_ERROR_NOT_FOUND&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1636982704627v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD16 nRF52840 - Queue library</title><link>https://devzone.nordicsemi.com/thread/329832?ContentTypeID=1</link><pubDate>Thu, 16 Sep 2021 12:19:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f711e45-e28b-4924-a158-76b24465200d</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What you actually push and pop is one element; the first value in the arrays, which has the value 0.&lt;/p&gt;
&lt;p&gt;You can use two approaches:&lt;/p&gt;
&lt;p&gt;Either use your old approach with the my_sensor_data_t, have a queue with elements of that type, and use pointers to that type for pushing and popping to/from the queue...&lt;/p&gt;
&lt;p&gt;...or use your new approach with single elements in the queue, but then you have to manually loop through the records_push and records_pop arrays, and push/pop each element.&lt;/p&gt;
&lt;p&gt;The confusion is probably coming from the queue handling API using pointers, combined with the fact that c arrays are stored as pointers as well. This means a funciton taking a pointer as argument can also take an array as argument, but that is only because an array in essence is a pointer to its first element. The result of passing an array to such a function is that the function operates on the first element of the array only, and it only works because the full array and the first element both have the same address and are of compatible types.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD16 nRF52840 - Queue library</title><link>https://devzone.nordicsemi.com/thread/329269?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 14:25:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b73d26c6-e4be-4420-ad47-4550d1196a8a</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;I tried to push and pop some data but it didn&amp;#39;t work. When I pop data and read the buffer I read just zeros..&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int16_t records_push[16];
int16_t records_pop[16];
int16_t received_data[16];

NRF_QUEUE_DEF(int16_t, m_sensor_data_queue, 200, NRF_QUEUE_MODE_OVERFLOW); // define a queue instance

uint8_t records_size = sizeof(records_push) / sizeof(records_push[0]);

void my_sensors_buffer() {

//Populate the buffer
  ret_code_t err_code;
  for (uint8_t i = 0; i &amp;lt; records_size; i++) {
    records_push[i] = i;
  }

  err_code = nrf_queue_push(&amp;amp;m_sensor_data_queue, records_push); // queue the buffer
  APP_ERROR_CHECK(err_code);

  err_code = nrf_queue_pop(&amp;amp;m_sensor_data_queue, records_pop);
  APP_ERROR_CHECK(err_code);

  //memcpy(received_data, records_pop, records_size);

  for (uint8_t i = 0; i &amp;lt; records_size; i++) {
    NRF_LOG_INFO(&amp;quot;Data_pop %d = %d&amp;quot;,i, records_pop[i]);
  }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1631543095566v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD16 nRF52840 - Queue library</title><link>https://devzone.nordicsemi.com/thread/329253?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 13:29:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61360d4e-2009-45cc-bf47-20291e31f15d</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Thank you for your prompt responce &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I am a bit confused.&amp;nbsp;When I call&amp;nbsp;nrf_queue_pop(), how do I define the lenght of data to pop from the queue?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD16 nRF52840 - Queue library</title><link>https://devzone.nordicsemi.com/thread/329191?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 10:53:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb866e39-963e-44f2-a8ed-e887041a47d0</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;To get values out of the queue, you can use &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrf__queue.html&amp;amp;anchor=ga1276ca06f2b8456a21bd3e4b9b0362e5"&gt;nrf_queue_pop()&lt;/a&gt;, which will remove the item from the queue and copy the contents to the location pointed to by _p_element. See &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Flib_queue.html&amp;amp;anchor=mailbox_usage"&gt;Using the queue&lt;/a&gt; from the Queue library documentation for more information and examples how to use it and other API functions for interacting with the queue.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>