I have a project built with freertos integrated on the MIMXRT1015 platform. I'm using LPUART3 to read serial messages that are of unpredictable length (SLIP format, so there are END characters to define messages).
The only Read function in the RTOS LPUART driver is LPUART_RTOS_Receive(). Because I do not know my message length in advance, I can't call it for more than one byte at a time. I have a thread set up to do nothing but call this function and put anything it gets into a buffer so that I can scan that buffer for messages.
Calling function:
size_t tempReadCount = 0;
std::uint8_t tempByte = 0;
if (raw_rx_count < MAX_BUFFER_SIZE)
{
int readStatus = LPUART_RTOS_Receive(&LPUART3_rtos_handle, &tempByte, 1 , &tempReadCount);
if ((readStatus == kStatus_Success) && (tempReadCount == 1))
{
raw_rx_buffer[raw_rx_count++] = tempByte;
}
}
Unfortunately, it does not work correctly. If I call LPUART_RTOS_Receive() and request 50 bytes, then send in enough messages to fill that request I get all of the messages returned correctly as soon as all 50 bytes are read. If I call it and request 1 byte repeatedly, quite a few bytes are skipped, apparently always in the same pattern.
It looks like the unblocking read used at lower level in the driver may be only enabling the interrupt when the read function is called. So, maybe the transition from enabled to disabled each time may be trashing some bytes. That or there is a buffer issue with small requests.
Anyone else seen this issue with the LPUART driver? Any work around besides making my own driver?