Be warned that function Chip_UART_ReadBlocking in LPCopen version 2.10 for LPC17xx is broken, for six years now - as it looks to me that doesn't exist a newer release.
The short function is the following:
int Chip_UART_ReadBlocking(LPC_USART_T *pUART, void *data, int numBytes)
{
int pass, readBytes = 0;
uint8_t *p8 = (uint8_t *) data;
while (readBytes < numBytes) {
pass = Chip_UART_Read(pUART, p8, numBytes);
numBytes -= pass;
readBytes += pass;
p8 += pass;
}
return readBytes;
}
What happens here is that if the data read is coming in more than one read (because remote host is slow, or even because it's fragmented while reading FIFO) the first read can make readBytes > numBytes and the loop will end prematurely.
Take as example reading 10 bytes of data in two passes, the first of 6 bytes: next 4 bytes won't be read.
Besides writing a complete alternative, it could save modifying the control loop as follows
while (0 < numBytes) {
I guess that this blocking function is less likey to be used than Chip_UART_Read itself, with a good external timeout limit. I discovered it while using it for a quick intervention in a test, that became eventually a long and complex debug session, as I thought the issue was on my side of code.
Hello Luca,
Hope you are doing well.
Thank you for reporting this and providing this information on our community. As you mention the release is 6 years old and there are no plans to update these libraries as they are for older generation microcontrollers who are coming close to the end of their longevity program. Regardless, it is good information to share with the community who are still using these libraries and microcontrollers. Our current drivers used on the SDK for our newer generations have been updated and modified, I believe the section that references to what you are reporting in the new drivers is as 0<numbytes.
Best Regards,
Sabina
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------