ok first you know the size of the array 512bytes
so
even if you forget the size, the library is smart enough to tell you what the size you wrote, not the raw space
ex, if you wrote 256 bytes instead of 512, it will tell you 256.
Here we go:
to get the length of the buffer in queue, do this:
Code:
uint16_t length = myBuffer.length_front();
then you create a buffer for yourself
Now to get the data out AND dequeue at same time, just:
Code:
myBuffer.pop_front(mySDBuf,length);
IF you prefer to access the data directly without dequeueing, you may also do so:
Code:
myBuffer.peek_front()[i] ; // where I is the indice of the array you want to read
example:
Code:
for ( uint16_t i = 0; i < myBuffer.length_front(); i++ ) {
Serial.print(myBuffer.peek_front()[i]);
Serial.print(" "); // a space between bytes
}
Serial.println();
that will read the whole buffer but not dequeue
to finally dequeue it you can do:
by the way, the array system your using requires a buffered input
you need to feed the SD's buffer and length to it:
Code:
myBuffer.write(SDPacketBuffer,length);
You cant feed it single bytes. If you choose the ring buffer, you can, but doesnt make sense to run 8 ring buffers when your data is already there to be dumped immediately in a array in less that 5uS time
you can also do:
Code:
myBuffer.push_front(SDPacketBuffer,length);
myBuffer.push_back(SDPacketBuffer,length);
you can queue and dequeue from either back or front of the queue, but never do single bytes, yes, a queue will be created, but not with all your entries in it, the array system needs an entire buffer to write to it