MaJerle / lwrb

Lightweight generic ring buffer manager library

Home Page:https://majerle.eu/projects/lwrb-lightweight-ring-buff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RX Buffer clear after reading

machfax opened this issue · comments

Thanks for the great example, I'm using it on the Nucleo-G474RE at the moment.
When I use the function ringbuff_read it works until the RX buffer is full (512Bytes). What am I doing wrong? With a terminal tool I send a string to the STM32, the STM32 sends it back. As soon as 512Bytes are in the Buffer, it doesn't works anymore. The data in the buffer should be marked as free after reading but something is not working on my code:

void UARTRxComplete(void)
{
uint8_t addr;
uint16_t len;
rxThisPos=UART_DMA_WRITE_PTR; //get current write pointer
len=(rxThisPos-rxLastPos+UART_RX_RINGBUFF_SZ)%UART_RX_RINGBUFF_SZ; //calculate how far the DMA write pointer has moved
if(len<=UART_RX_MAX_MESSAGE_LEN) { //check message size
ringbuff_advance(&rxRing,len); //move the ring buffer write pointer
rxLastPos=rxThisPos;

//test: send the received data out -> its working until 512bytes, then the RX buffer is full
ringbuff_read(&rxRing,processBuf,len); //read out the data to an array for processing
UARTAddToTxBuff(processBuf, len);

}
else {
while(1); //implement message to large exception
}
}

Finally issue not relevant to ringbuff but hardware architecture instead.