<?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>SDK17 - Queue module - pushing elements to the queue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81742/sdk17---queue-module---pushing-elements-to-the-queue</link><description>Hi everyone, 
 I want to integrate the Queue module into my firmware. I found three functions for writting elements in the queue 
 1. nrf_queue_push 
 2. nrf_queue_in 
 3. nrf_queue_write 
 To my understanding nrf_queue_push is used to push a single element</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Nov 2021 06:30:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81742/sdk17---queue-module---pushing-elements-to-the-queue" /><item><title>RE: SDK17 - Queue module - pushing elements to the queue</title><link>https://devzone.nordicsemi.com/thread/339333?ContentTypeID=1</link><pubDate>Wed, 17 Nov 2021 06:30:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c62d90cb-b8fa-4b59-a872-444b2e31a29d</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;That&amp;#39;s clear!! Thank you Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SDK17 - Queue module - pushing elements to the queue</title><link>https://devzone.nordicsemi.com/thread/339185?ContentTypeID=1</link><pubDate>Tue, 16 Nov 2021 10:12:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d36c76e3-c0c4-4589-83b9-2d8132cd06db</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]To my understanding&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__queue.html?cp=8_5_0_6_10_38_21#ga4b5f2bd85034cf76aaf2267ce4a27378"&gt;nrf_queue_push&lt;/a&gt;&amp;nbsp;is used to push a &lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;single&lt;/strong&gt; &lt;/span&gt;element to the end of the queue. If you want to push more than one elements you have to use pointers and call the function through a loop.[/quote]
&lt;p&gt;Yes, that is correct.&lt;/p&gt;
[quote user=""]&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__queue.html?cp=8_5_0_6_10_38_25#gae790c55761bf7cc1a7875c21cf235501"&gt;nrf_queue_write&lt;/a&gt;&amp;nbsp;is the same as&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__queue.html?cp=8_5_0_6_10_38_15#ga121f997fb27625dfe621b4fae4ff6154"&gt;nrf_queue_in&lt;/a&gt;? I do not see any difference rather that it supports debugging capabilities&lt;/p&gt;
&lt;p&gt;When I use either&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__queue.html?cp=8_5_0_6_10_38_15#ga121f997fb27625dfe621b4fae4ff6154"&gt;nrf_queue_in&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__queue.html?cp=8_5_0_6_10_38_25#gae790c55761bf7cc1a7875c21cf235501"&gt;nrf_queue_write&lt;/a&gt;&amp;nbsp;the elements get pushed to the end of the queue?&lt;/p&gt;[/quote]
&lt;p&gt;There is a small but important difference. With&amp;nbsp;nrf_queue_write() you write all elements, or none. Say you want to write 3 elements, but there are only room for 2. In that case, no elements are written and&amp;nbsp;NRF_ERROR_NO_MEM is returned. If you use&amp;nbsp;nrf_queue_in() in this case, 2 elements are written (but not all 3), and it returns 2 to let you know this. You can see this described in the API documentation in nrf_queue.h.&lt;/p&gt;
[quote user=""]Do I miss something else? To push an array of elements into the queue is more convenient to use function 2 or 3 right?[/quote]
&lt;p&gt;Yes, that is the case. Which of these to use depends on what behavior you want if there is room for some elements, but not all.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>