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

kh13824
Posts: 10
Joined: Tue Oct 18, 2022 6:01 pm

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

Postby kh13824 » Fri Nov 11, 2022 8:24 pm

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?

ljden-
Posts: 1
Joined: Wed Oct 19, 2022 11:44 pm

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

Postby ljden- » Sun Nov 13, 2022 11:53 pm

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);

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 116 guests