You do not have a problem. It's how it all works.
See, functionally the same as your code:
////////////////////////////////////////////////////////////////////////////
void fGPS_Parse( void *pvParameters )
{
// int iBit = 1;
for (;;)
{
xEventGroupWaitBits (eg, evtGPS_Parse, pdTRUE, pdTRUE, portMAX_DELAY) ;
if ( xSemaphoreTake( sema_GPS_Gate, xTicksToWait0 ) == pdTRUE )
{
//query GPS: has a new complete chunk of data been received?
if ( GPSSerial.available() > 1 )
{
if ( GPS.encode(GPSSerial.read()) )
{
if ( GPS.location.isValid())
{
if ( xSemaphoreTake( sema_Posit, xSemaphoreTicksToWait ) == pdTRUE )
{
xPosit.Lat = GPS.location.lat();// store data into structure
xPosit.Lon = GPS.location.lng();
xSemaphoreGive( sema_Posit );
}
} // if ( GPS.location.isValid())
if (GPS.speed.isValid())
{
if ( xSemaphoreTake( sema_Posit, xSemaphoreTicksToWait ) == pdTRUE )
{
xPosit.MPH = GPS.speed.mph();
xPosit.KPH = GPS.speed.kmph();
xSemaphoreGive( sema_Posit );
}
} // if (GPS.speed.isValid())
if (GPS.time.isValid())
{
if ( xSemaphoreTake( sema_Time, xSemaphoreTicksToWait ) == pdTRUE )
{
xTime.iSeconds = GPS.time.second();
xTime.iMinutes = GPS.time.minute();
xTime.iHours = GPS.time.hour();
xSemaphoreGive( sema_Time );
}
} // if (GPS.time.isValid())
if (GPS.date.isValid())
{
if ( xSemaphoreTake( sema_Date, xSemaphoreTicksToWait ) == pdTRUE )
{
xDate.iMonth = GPS.date. month();
xDate.iDay = GPS.date.day();
xDate.iYear = GPS.date.year();
xSemaphoreGive( sema_Date );
}
} // if (GPS.date.isValid())
if ( GPS.altitude.isValid() )
{
if ( xSemaphoreTake( sema_Posit, xSemaphoreTicksToWait ) == pdTRUE )
{
xPosit.Alti = GPS.altitude.meters();
xSemaphoreGive( sema_Posit );
}
} // if ( GPS.altitude.isValid() )
if ( GPS.course.isUpdated() )
{
if ( xSemaphoreTake( sema_Posit, xSemaphoreTicksToWait ) == pdTRUE )
{
xPosit.Hdg = GPS.course.deg();
xSemaphoreGive( sema_Posit );
}
} // if ( GPS.course.isUpdated() )
if ( xSemaphoreTake( sema_Posit, xSemaphoreTicksToWait ) == pdTRUE )
{
xQueueOverwrite( xQ_Posit, (void *) &xPosit );
xSemaphoreGive( sema_Posit );
}
} // if ( GPS.encode(GPSSerial.read()))
} // if ( GPSSerial.available() > 0 )
xSemaphoreGive( sema_GPS_Gate );
}
} // for (;;)
vTaskDelete( NULL );
} // void fGPS_Parse( void *pvParameters )
It's how it works.