Page 1 of 1

Possibility of dumping all contents ESP32's Queue or Ring Buffer

Posted: Fri Nov 11, 2022 8:24 pm
by kh13824
Hello, for context I am trying to using either a queue or ring buffer to store 24 arrays of image data which has been flattened to a size of 100. I would like to use the FIFO structure to push new images and pop old images but I would like to know if it is possible to grab all contents from either queue or ring buffer whenever a new image is pushed and popped(kind of like a "snapshot") of the 24 arrays and be able to read this data?

Re: Possibility of dumping all contents ESP32's Queue or Ring Buffer

Posted: Sun Nov 13, 2022 11:53 pm
by ljden-
Queues and ring buffers do no allow for traversal by nature of being strictly FIFO. I'm not sure if you can make a deep copy of a queue/buffer. If you can then that's your answer.
If you are not particularly constrained by time, I would suggest you pop each element off, make a copy and the push them back on until you reach back to the first element.
Pseudocode along the lines of:

Code: Select all

first = peak queue()
do {
  elem = pop queue()
  copy elem
  push queue (elem)
} while( peek queue() != first);