mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-08 04:02:27 +00:00
fix(esp_ringbuf): Fixed no-split ringbuf issue where acquire pointer wraps around
This commit fixes an issue with no-split ring buffers where in the the buffer did not receive items correctly if the acquire pointer wraps around before items are sent to it.
This commit is contained in:
@@ -386,7 +386,7 @@ static void prvSendItemDoneNoSplit(Ringbuffer_t *pxRingbuffer, uint8_t* pucItem)
|
||||
*/
|
||||
pxCurHeader = (ItemHeader_t *)pxRingbuffer->pucWrite;
|
||||
//Skip over Items that have already been written or are dummy items
|
||||
while (((pxCurHeader->uxItemFlags & rbITEM_WRITTEN_FLAG) || (pxCurHeader->uxItemFlags & rbITEM_DUMMY_DATA_FLAG)) && pxRingbuffer->pucWrite != pxRingbuffer->pucAcquire) {
|
||||
while (((pxCurHeader->uxItemFlags & rbITEM_WRITTEN_FLAG) || (pxCurHeader->uxItemFlags & rbITEM_DUMMY_DATA_FLAG))) {
|
||||
if (pxCurHeader->uxItemFlags & rbITEM_DUMMY_DATA_FLAG) {
|
||||
pxCurHeader->uxItemFlags |= rbITEM_WRITTEN_FLAG; //Mark as freed (not strictly necessary but adds redundancy)
|
||||
pxRingbuffer->pucWrite = pxRingbuffer->pucHead; //Wrap around due to dummy data
|
||||
@@ -401,6 +401,12 @@ static void prvSendItemDoneNoSplit(Ringbuffer_t *pxRingbuffer, uint8_t* pucItem)
|
||||
if ((pxRingbuffer->pucTail - pxRingbuffer->pucWrite) < rbHEADER_SIZE) {
|
||||
pxRingbuffer->pucWrite = pxRingbuffer->pucHead;
|
||||
}
|
||||
|
||||
// If the write pointer has caught up to the acquire pointer, we can break out of the loop
|
||||
if (pxRingbuffer->pucWrite == pxRingbuffer->pucAcquire) {
|
||||
break;
|
||||
}
|
||||
|
||||
pxCurHeader = (ItemHeader_t *)pxRingbuffer->pucWrite; //Update header to point to item
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user