Tool/software: TI-RTOS
I've found a problem with the UART low level read code (UART_v0_readData) that causes data to become lost.
static inline int32_t UART_v0_readData(UART_Handle handle, int32_t size) { int32_t readIn; UART_V0_Object *object; UART_HwAttrs const *hwAttrs; object = handle->object; hwAttrs = handle->hwAttrs; readIn = (int32_t)UART_charGetNonBlocking_v0(hwAttrs->baseAddr); /* Receive chars until empty or done. */ while ((size != 0) && (readIn != -1)) { /* If data mode is set to TEXT replace return with a newline. */ if (object->params.readDataMode == UART_DATA_TEXT) { if ((uint8_t)readIn == (uint8_t)'\r') { /* Echo character if enabled. */ if (object->params.readEcho) { UART_charPut_v0(hwAttrs->baseAddr, (uint8_t)'\r'); } readIn = (int32_t)'\n'; } } UART_drv_log2("UART:(%p) Read character 0x%x", hwAttrs->baseAddr, (uint8_t)readIn); *(uint8_t *)object->readBuf = (uint8_t)readIn; object->readBuf = (uint8_t *)object->readBuf + 1; object->readCount++; size--; /* Echo character if enabled. */ if (object->params.readEcho) { UART_charPut_v0(hwAttrs->baseAddr, (uint8_t)readIn); } /* If read return mode is newline, finish if a newline was received. */ if ((object->params.readReturnMode == UART_RETURN_NEWLINE) && ((uint8_t)readIn == (uint8_t)'\n')) { UART_drv_log1("UART:(%p) Newline character received, " , hwAttrs->baseAddr); size = 0; break; } readIn = (int32_t)UART_charGetNonBlocking_v0(hwAttrs->baseAddr); } return (size); }
The issue is that the final "readIn = (int32_t)UART_charGetNonBlocking_v0(hwAttrs->baseAddr);" call reads another character from the UART at the end of the call, consuming and not processing it, thus losing the data.
This is resolved by inserting "if(size==0) break;" in the line above that line, as the final read should be conditional on more bytes being read into the buffer. This only affects where UART_RETURN_FULL is the return mode; UART_RETURN_NEWLINE is unaffected.