0 - data and interaction (ucos Console is moved to UART 9)
1 - RFID reader 0
2 - RFID reader 1
5 - RFID reader 2
7 - RFID reader 3
My main loop polls each UART in turn. Things seem to work fine except reader 3 on UART7 misses bytes in the _middle_ of its reader's reply. This is the real data from a spy connection:
02 00 08 00 69 00 b3 57
but this is what the software reads:
02000800B357
It's pretty consistent - I just did it 5 times in a row and saw the same string every time.
I've reade elsewhere that the ucos UART buffers are 1500 bytes, so I am not taxing the system here. Breakpoints are bad in this case since all the UARTs start reading bad when I break on the read of UART 7. Code is below. Can anyone spot a mistake?
Thanks,
Larry
For the 4 reader UARTS, the loop is:
Code: Select all
for (int rix = 0; rix < MAX_READERS; rix++)
{
RfidReaders[rix].Tick();
}
Code: Select all
if (RfidRxBufCount < (int)(sizeof(RfidRxBuf) - 1))
{
int rc = dataavail(RfidSerialFd);
if (rc > 0)
{
rc = ReadWithTimeout(RfidSerialFd, (char*)&RfidRxBuf[RfidRxBufCount], CFG_RXBUFLEN - RfidRxBufCount, 1); // 200 uS for one byte, 500 uS for many, if data is available
}
if (rc > 0)
{
if (Index == 3)
{
char buf[64];
UtilsByteArrayToHexString(buf, &RfidRxBuf[RfidRxBufCount], rc);
sprintf(WebErrorMessage, "Reader 3 said: %s", buf); //deleteme
}
ret = true;
RfidRxBufCount += rc; // point to next empty space
}
}