Under-reported no. of bytes in circular buffer
Posted: Thu Feb 22, 2024 9:01 pm
Hi Guys.
I presently have six active hardware UARTS on an STM32F407 micro.
Each UART is served by an Rx-Int, each calling a separate dedicated interrupt service macro for each port, and the data is captured to separate circular buffers for each UART.
In the main thread, it was my intention to branch if any particular circular buffer contained more than zero bytes, then simply wait a period of time for possibly remaining data to arrive, then extract the data from the circular buffer for processing. However, regardless of data in the buffers, the main flow would never branch in response to data.
So I added a simple debug test to the end of the main program loop (shown) and ran a few tests. Basically, a 3s delay applied to each main loop permits me to right-click (send) a sequence of 20 chars via PuTTY terminal (20 chars per click x 1/2/3/4/5/6/7 during the interval for each successive test), and the pictorials reveal the number of bytes under-reported by the circular buffer in each case.
Please don't be confused by the printed strings - limited/maxed to 64 bytes, including the nul of-course (with the circular buffer set at 128 bytes). Each successive test increases the number of bytes in the circular buffer by +20 in each case.
Many thanks,
Brendan
I presently have six active hardware UARTS on an STM32F407 micro.
Each UART is served by an Rx-Int, each calling a separate dedicated interrupt service macro for each port, and the data is captured to separate circular buffers for each UART.
In the main thread, it was my intention to branch if any particular circular buffer contained more than zero bytes, then simply wait a period of time for possibly remaining data to arrive, then extract the data from the circular buffer for processing. However, regardless of data in the buffers, the main flow would never branch in response to data.
So I added a simple debug test to the end of the main program loop (shown) and ran a few tests. Basically, a 3s delay applied to each main loop permits me to right-click (send) a sequence of 20 chars via PuTTY terminal (20 chars per click x 1/2/3/4/5/6/7 during the interval for each successive test), and the pictorials reveal the number of bytes under-reported by the circular buffer in each case.
Please don't be confused by the printed strings - limited/maxed to 64 bytes, including the nul of-course (with the circular buffer set at 128 bytes). Each successive test increases the number of bytes in the circular buffer by +20 in each case.
Many thanks,
Brendan