I don't have time to produce an isolated example case right now (I can later this week), but I hope it's obvious enough that someone might be able to figure out what's going on.
I have the following serial port code:
int16_t SerialPort::getByte(uint32_t timeout)
{
char rxChar;
if(rxQueue.receive(&rxChar, timeout / 1000))
{
receivedBytes++;
return (int16_t)rxChar;
}
else
return -1;
}