This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SDK17 - Queue module - pushing elements to the queue

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 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.

nrf_queue_in is used to push a portion of elements, defining the buffer and its elements number to push

nrf_queue_write is the same as nrf_queue_in? I do not see any difference rather that it supports debugging capabilities

When I use either nrf_queue_in or nrf_queue_write the elements get pushed to the end of the queue?

Do I miss something else? To push an array of elements into the queue is more convenient to use function 2 or 3 right?

Parents
  • Hi,

    To my understanding nrf_queue_push is used to push a single 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.

    Yes, that is correct.

    nrf_queue_write is the same as nrf_queue_in? I do not see any difference rather that it supports debugging capabilities

    When I use either nrf_queue_in or nrf_queue_write the elements get pushed to the end of the queue?

    There is a small but important difference. With 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 NRF_ERROR_NO_MEM is returned. If you use 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.

    Do I miss something else? To push an array of elements into the queue is more convenient to use function 2 or 3 right?

    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.

Reply Children
No Data
Related