RMT: RX input and xRingBufferAddToQueueSetWrite ...
Posted: Sun Jan 22, 2017 5:29 am
This is a subtle one ... I'm studying the RMT RX input functions. I see that we can ask the RMT driver to create a ring buffer and get the handle to that ring buffer using "rmt_get_ringbuf_handler". Here comes the first part of the puzzle:
What is the "origin" on the ring buffer functions? They appear to be supplied as part of the FreeRTOS package but I haven't found any reference to their existence outside of ESP-IDF.... were they created by Espressif as FreeRTOS extensions?
Once we have a handle to the ring buffer, we might then want to be informed when new items are added to it. We can do this by calling xRingbufferReceive which polls/blocks on one ring buffer. However, if we have many sources of input (eg. multiple ring buffers or queues) then we might want to use a FreeRTOS Queue Set so that we can block on one or more potential sources becoming ready. The Ring Buffer functions seem to have a solution for this. There is a function called "xRingbufferAddToQueueSetWrite" that will add a ring buffer into a queue set. Awesome ... I can now block on the queue set and learn when the ring buffer becomes written to ...
But ... and here is the major question ...
What if I have TWO or more ring buffers? I can add each of them to the Queue Set and then block on that ... I am presuming I will be woken up when ANY of the ring buffers are written to ... however ... and here's the rub ... the "xQueueSelectFromSet" returns the handle of the object that is ready for reading ... and I am led to believe that for ring buffers, this will be an internal semaphore buried deep in the internals of the Ring Buffer. What that means to me in practical terms is that if I have two ring buffers, add both of them to a queue set and then block waiting for either ring buffer to have an item written into it, when one of them does I'll be woken up ... but form the information available to me, I won't know WHICH of the ring buffers caused me to wake.
What is the "origin" on the ring buffer functions? They appear to be supplied as part of the FreeRTOS package but I haven't found any reference to their existence outside of ESP-IDF.... were they created by Espressif as FreeRTOS extensions?
Once we have a handle to the ring buffer, we might then want to be informed when new items are added to it. We can do this by calling xRingbufferReceive which polls/blocks on one ring buffer. However, if we have many sources of input (eg. multiple ring buffers or queues) then we might want to use a FreeRTOS Queue Set so that we can block on one or more potential sources becoming ready. The Ring Buffer functions seem to have a solution for this. There is a function called "xRingbufferAddToQueueSetWrite" that will add a ring buffer into a queue set. Awesome ... I can now block on the queue set and learn when the ring buffer becomes written to ...
But ... and here is the major question ...
What if I have TWO or more ring buffers? I can add each of them to the Queue Set and then block on that ... I am presuming I will be woken up when ANY of the ring buffers are written to ... however ... and here's the rub ... the "xQueueSelectFromSet" returns the handle of the object that is ready for reading ... and I am led to believe that for ring buffers, this will be an internal semaphore buried deep in the internals of the Ring Buffer. What that means to me in practical terms is that if I have two ring buffers, add both of them to a queue set and then block waiting for either ring buffer to have an item written into it, when one of them does I'll be woken up ... but form the information available to me, I won't know WHICH of the ring buffers caused me to wake.