Code: Select all
static THD_FUNCTION(ThreadGPS, arg)
{
msg_t c;
eventflags_t flags;
event_listener_t elGPSdata;
(void)arg;
sdStart(GPS, &gpsconfig);
chRegSetThreadName("gpsd");
chEvtRegisterMask(chnGetEventSource(GPS),
&elGPSdata,
EVENT_MASK(1));
while( TRUE )
{
chEvtWaitAll(EVENT_MASK(1));
flags = chEvtGetAndClearFlags(&elGPSdata);
if(flags & SD_OVERRUN_ERROR)
{
TGL_DEBUG(DBG_MASK_GPS, "$ GPS - Overrun!\r\n");
}
if(flags & CHN_INPUT_AVAILABLE)
{
do
{
c = chnGetTimeout( GPS, TIME_IMMEDIATE );
if ( c != Q_TIMEOUT )
{
decodeNMEAstateMachine( (char)c );
}
}
while (c != Q_TIMEOUT);
}
}
}
All of a sudden, the events stop firing and i stop receiving data.
If i break on the interrupt, that is still firing, and tracing it through to
Code: Select all
void sdIncomingDataI(SerialDriver *sdp, uint8_t b) {
osalDbgCheckClassI();
osalDbgCheck(sdp != NULL);
if (iqIsEmptyI(&sdp->iqueue))
chnAddFlagsI(sdp, CHN_INPUT_AVAILABLE);
if (iqPutI(&sdp->iqueue, b) < Q_OK)
chnAddFlagsI(sdp, SD_OVERRUN_ERROR);
it fails the iqIsEmptyI test and thus never sets flag CHN_INPUT_AVAILABLE.
So this says to me the buffer is full, and yes i can see in my debug SD_OVERRUN_ERROR was set some time prior to this happening.
But also interesting chnAddFlagsI(sdp, SD_OVERRUN_ERROR); is called but the event never fires in the once it locks.
When in this state q_counter = 512, this is same as my buffer size.
So the question is what is the correct way to recover from this issue ?