<?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>data length to push &amp;amp; pop on queue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/119010/data-length-to-push-pop-on-queue</link><description>nRF5_SDK_17.1.0 
 PCA10059 
 According to the source code: 
 
 The data length is fixed,it will still copy element-size bytes to buffer even if no so much data. 
 For communication packet, the length is not fixed,maybe different type with different length</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 17 Feb 2025 14:43:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/119010/data-length-to-push-pop-on-queue" /><item><title>RE: data length to push &amp; pop on queue</title><link>https://devzone.nordicsemi.com/thread/523319?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2025 14:43:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:463b84be-8a9f-4252-917b-deeef71e20e9</guid><dc:creator>OldXiao</dc:creator><description>&lt;p&gt;Get it.&lt;/p&gt;
&lt;p&gt;It is the most free way to operate queue with one byte element size except the efficiency is a little low.&lt;/p&gt;
&lt;p&gt;It is acceptable to fix the byte count written into queue if the difference between element size and actual data size is not so big.&lt;/p&gt;
&lt;p&gt;In my case,I have to assume the difference is big in most case.&lt;/p&gt;
&lt;p&gt;So I just add functions to nrf_queue.c to support my requirement.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: data length to push &amp; pop on queue</title><link>https://devzone.nordicsemi.com/thread/523277?ContentTypeID=1</link><pubDate>Mon, 17 Feb 2025 13:22:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32da6a08-c894-4b31-abd7-db61bc09bfbf</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can push N elements to a queue through use of &lt;a href="https://docs.nordicsemi.com/bundle/sdk_nrf5_v17.1.0/page/group_nrf_queue.html#gae790c55761bf7cc1a7875c21cf235501"&gt;nrf_queue_write()&lt;/a&gt;. For instance, if the element size is one byte, then to write N bytes to the queue you can pass N as the element_count argument to nrf_queue_write().&lt;/p&gt;
&lt;p&gt;Similarly, to read N bytes, you can use &lt;a href="https://docs.nordicsemi.com/bundle/sdk_nrf5_v17.1.0/page/group_nrf_queue.html#gab663896f58e0214a5f5f3681eed575b4"&gt;nrf_queue_read()&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Basically, with those APIs as building blocks, you could build something more advanced on top, if you need more control of what is put into the queue. Or, you could use those APIs directly.&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>