Skip to content

Commit

Permalink
Adds support for GNSS GNRMC messages
Browse files Browse the repository at this point in the history
(cherry-picked from 88bddb8)
  • Loading branch information
dzolo authored and dakcarto committed Jun 7, 2016
1 parent bb14031 commit 4371a66
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/core/gps/parse.c
Expand Up @@ -133,6 +133,7 @@ int nmea_pack_type( const char *buff, int buff_sz )
"GPGSV",
"GPRMC",
"GPVTG",
"GNRMC",
};

NMEA_ASSERT( buff );
Expand All @@ -149,6 +150,8 @@ int nmea_pack_type( const char *buff, int buff_sz )
return GPRMC;
else if ( 0 == memcmp( buff, pheads[4], 5 ) )
return GPVTG;
else if ( 0 == memcmp( buff, pheads[5], 5 ) )
return GPRMC;

return GPNON;
}
Expand Down Expand Up @@ -322,6 +325,7 @@ int nmea_parse_GPGSV( const char *buff, int buff_sz, nmeaGPGSV *pack )
int nmea_parse_GPRMC( const char *buff, int buff_sz, nmeaGPRMC *pack )
{
int nsen;
char type;
char time_buff[NMEA_TIMEPARSE_BUF];

NMEA_ASSERT( buff && pack );
Expand All @@ -331,19 +335,25 @@ int nmea_parse_GPRMC( const char *buff, int buff_sz, nmeaGPRMC *pack )
nmea_trace_buff( buff, buff_sz );

nsen = nmea_scanf( buff, buff_sz,
"$GPRMC,%s,%C,%f,%C,%f,%C,%f,%f,%2d%2d%2d,%f,%C,%C*",
&( time_buff[0] ),
"$G%CRMC,%s,%C,%f,%C,%f,%C,%f,%f,%2d%2d%2d,%f,%C,%C*",
&( type ), &( time_buff[0] ),
&( pack->status ), &( pack->lat ), &( pack->ns ), &( pack->lon ), &( pack->ew ),
&( pack->speed ), &( pack->direction ),
&( pack->utc.day ), &( pack->utc.mon ), &( pack->utc.year ),
&( pack->declination ), &( pack->declin_ew ), &( pack->mode ) );

if ( nsen != 13 && nsen != 14 )
if ( nsen != 14 && nsen != 15 )
{
nmea_error( "GPRMC parse error!" );
return 0;
}

if ( type != 'P' && type != 'N' )
{
nmea_error( "G?RMC invalid type " );
return 0;
}

if ( 0 != _nmea_parse_time( &time_buff[0], ( int )strlen( &time_buff[0] ), &( pack->utc ) ) )
{
nmea_error( "GPRMC time parse error!" );
Expand Down
2 changes: 1 addition & 1 deletion src/core/gps/qgsnmeaconnection.cpp
Expand Up @@ -103,7 +103,7 @@ void QgsNMEAConnection::processStringBuffer()
mStatus = GPSDataReceived;
QgsDebugMsg( "*******************GPS data received****************" );
}
else if ( substring.startsWith( "$GPRMC" ) )
else if ( substring.startsWith( "$GPRMC" ) || substring.startsWith( "$GNRMC" ) )
{
QgsDebugMsg( substring );
processRMCSentence( ba.data(), ba.length() );
Expand Down

0 comments on commit 4371a66

Please sign in to comment.