Skip to content

Commit 4371a66

Browse files
dzolodakcarto
authored andcommitted
Adds support for GNSS GNRMC messages
(cherry-picked from 88bddb8)
1 parent bb14031 commit 4371a66

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/core/gps/parse.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ int nmea_pack_type( const char *buff, int buff_sz )
133133
"GPGSV",
134134
"GPRMC",
135135
"GPVTG",
136+
"GNRMC",
136137
};
137138

138139
NMEA_ASSERT( buff );
@@ -149,6 +150,8 @@ int nmea_pack_type( const char *buff, int buff_sz )
149150
return GPRMC;
150151
else if ( 0 == memcmp( buff, pheads[4], 5 ) )
151152
return GPVTG;
153+
else if ( 0 == memcmp( buff, pheads[5], 5 ) )
154+
return GPRMC;
152155

153156
return GPNON;
154157
}
@@ -322,6 +325,7 @@ int nmea_parse_GPGSV( const char *buff, int buff_sz, nmeaGPGSV *pack )
322325
int nmea_parse_GPRMC( const char *buff, int buff_sz, nmeaGPRMC *pack )
323326
{
324327
int nsen;
328+
char type;
325329
char time_buff[NMEA_TIMEPARSE_BUF];
326330

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

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

341-
if ( nsen != 13 && nsen != 14 )
345+
if ( nsen != 14 && nsen != 15 )
342346
{
343347
nmea_error( "GPRMC parse error!" );
344348
return 0;
345349
}
346350

351+
if ( type != 'P' && type != 'N' )
352+
{
353+
nmea_error( "G?RMC invalid type " );
354+
return 0;
355+
}
356+
347357
if ( 0 != _nmea_parse_time( &time_buff[0], ( int )strlen( &time_buff[0] ), &( pack->utc ) ) )
348358
{
349359
nmea_error( "GPRMC time parse error!" );

src/core/gps/qgsnmeaconnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void QgsNMEAConnection::processStringBuffer()
103103
mStatus = GPSDataReceived;
104104
QgsDebugMsg( "*******************GPS data received****************" );
105105
}
106-
else if ( substring.startsWith( "$GPRMC" ) )
106+
else if ( substring.startsWith( "$GPRMC" ) || substring.startsWith( "$GNRMC" ) )
107107
{
108108
QgsDebugMsg( substring );
109109
processRMCSentence( ba.data(), ba.length() );

0 commit comments

Comments
 (0)