Skip to content

Commit

Permalink
[gps] Support GNGSV messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 5, 2019
1 parent 2234d92 commit 07915f7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 13 additions & 4 deletions external/nmea/parse.c
Expand Up @@ -350,12 +350,15 @@ int nmea_parse_GPGSV( const char *buff, int buff_sz, nmeaGPGSV *pack )

nmea_trace_buff( buff, buff_sz );

char type;

nsen = nmea_scanf( buff, buff_sz,
"$GPGSV,%d,%d,%d,"
"$G%CGSV,%d,%d,%d,"
"%d,%d,%d,%d,"
"%d,%d,%d,%d,"
"%d,%d,%d,%d,"
"%d,%d,%d,%d*",
&( type ),
&( pack->pack_count ), &( pack->pack_index ), &( pack->sat_count ),
&( pack->sat_data[0].id ), &( pack->sat_data[0].elv ), &( pack->sat_data[0].azimuth ), &( pack->sat_data[0].sig ),
&( pack->sat_data[1].id ), &( pack->sat_data[1].elv ), &( pack->sat_data[1].azimuth ), &( pack->sat_data[1].sig ),
Expand All @@ -366,9 +369,15 @@ int nmea_parse_GPGSV( const char *buff, int buff_sz, nmeaGPGSV *pack )
nsat = ( nsat + NMEA_SATINPACK > pack->sat_count ) ? pack->sat_count - nsat : NMEA_SATINPACK;
nsat = nsat * 4 + 3 /* first three sentence`s */;

if ( nsen < nsat || nsen > ( NMEA_SATINPACK * 4 + 3 ) )
if ( nsen - 1 < nsat || nsen - 1 > ( NMEA_SATINPACK * 4 + 3 ) )
{
nmea_error( "G?GSV parse error!" );
return 0;
}

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

Expand Down Expand Up @@ -404,7 +413,7 @@ int nmea_parse_GPRMC( const char *buff, int buff_sz, nmeaGPRMC *pack )

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

Expand Down
6 changes: 3 additions & 3 deletions src/core/gps/qgsnmeaconnection.cpp
Expand Up @@ -108,12 +108,12 @@ void QgsNmeaConnection::processStringBuffer()
mStatus = GPSDataReceived;
QgsDebugMsgLevel( QStringLiteral( "*******************GPS data received****************" ), 2 );
}
else if ( substring.startsWith( QLatin1String( "$GPGSV" ) ) )
else if ( substring.startsWith( QLatin1String( "$GPGSV" ) ) || substring.startsWith( QLatin1String( "$GNGSV" ) ) )
{
QgsDebugMsg( substring );
QgsDebugMsgLevel( substring, 2 );
processGsvSentence( ba.data(), ba.length() );
mStatus = GPSDataReceived;
QgsDebugMsg( QStringLiteral( "*******************GPS data received****************" ) );
QgsDebugMsgLevel( QStringLiteral( "*******************GPS data received****************" ), 2 );
}
else if ( substring.startsWith( QLatin1String( "$GPVTG" ) ) )
{
Expand Down

0 comments on commit 07915f7

Please sign in to comment.