OVMS3-idf/docs/_static/diagrams/ring-buffer/ring_buffer_read_ret_byte_buf.diag
Darian Leung 4bfa30967f freeRTOS/Re-factor ring buffers
This fixes multiple bugs with ring buffers and re-factors the code. The public
API has not changed, however the underlying implementation have various private
functions have been changed. The following behavioral changes have been made

-   Size of ring buffers for No-Split/Allow-Split buffers will not be rounded
    up to the nearest 32-bit aligned size. This was done to simplify the
    implementation

-   Item size for No-Split/Allow-Split buffers will also be rounded up to the
    nearest 32-bit aligned size.

The following bugs have been fixed

-   In copyItemToRingbufAllowSplit(), when copying an item where the aligned
    size is smaller than the remaining length, the function does not consider
    the case where the true size of the item is less than 4 bytes.

-   The copy functions will automatically wrap around the write pointers when
    the remaining length of the buffer is not large enough to fit a header, but
    does not consider if wrapping around will cause an overlap with the read
    pointer. This will make a full buffer be mistaken for an empty buffer

closes #1711
-   xRingbufferSend() can get stuck in a infinite loop when the size of the
    free memory is larger than the needed_size, but too small to fit in the ring
    buffer due to alignment and extra overhead of wrapping around.

closes #1846
-   Fixed documentation with ring buffer queue set API

-   Adding and removing from queue set does not consider the case where the
    read/write semaphores actually hold a value.

The following functions have been deprecated
    - xRingbufferIsNextItemWrapped() due to lack of thread safety
    - xRingbufferAddToQueueSetWrite() and xRingbufferRemoveFromQueueSetWrite()
    as adding the queue sets only work under receive operations.

The following functions have been added
    - xRingbufferReceiveSplit() and xRingbufferReceiveSplitFromISR() as a thread
    safe way to receive from allow-split buffers
    - vRingbufferGetInfo()

Documentation for ring buffers has also been added.
2018-05-21 01:04:58 +00:00

30 lines
702 B
Plaintext

#Diagram demonstrating reading and returning an item in a byte buffer
#Buffer of 128 bytes, with 68 bytes occupied but wrapped. All data is read
packetdiag ring_buffer_read_ret_byte_buf {
node_width = 6
node_height = 24
default_fontsize = 12
colwidth = 128
#Initial
0-29: 30 [color = lightyellow];
30-89: 60 Free
90-127: 38 [color = lightyellow];
#Read all continuous data
128-157: 30 [color = lightyellow];
158-217: 60 Free
218-255: 38 [color = pink];
#Return data
256-285: 30 [color = lightyellow];
286-383: 98 Free
#Read remaining data
384-413: 30 [color = pink];
414-511: 98 Free
#Return data
512-639: 128 Free
}