Skip to content

Commit

Permalink
Add missing NMEA patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and nyalldawson committed Jun 24, 2020
1 parent f6fca0c commit 2f72542
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 15 deletions.
50 changes: 38 additions & 12 deletions external/nmea/parse.c
Expand Up @@ -277,19 +277,28 @@ int nmea_parse_GPGST( const char *buff, int buff_sz, nmeaGPGST *pack )

nmea_trace_buff( buff, buff_sz );

if ( 8 != nmea_scanf( buff, buff_sz,
"$GPGST,%s,%f,%f,%f,%f,%f,%f,%f*",
char type;

if ( 9 != nmea_scanf( buff, buff_sz,
"$G%CGST,%s,%f,%f,%f,%f,%f,%f,%f*",
&( type ),
&( time_buff[0] ),
&( pack->rms_pr ), &( pack->err_major ), &( pack->err_minor ), &( pack->err_ori ),
&( pack->sig_lat ), &( pack->sig_lon ), &( pack->sig_alt ) ) )
{
nmea_error( "GPGST parse error!" );
nmea_error( "G?GST parse error!" );
return 0;
}

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

if ( 0 != _nmea_parse_time( &time_buff[0], ( int )strlen( &time_buff[0] ), &( pack->utc ) ) )
{
nmea_error( "GPGST time parse error!" );
nmea_error( "G?GST time parse error!" );
return 0;
}

Expand Down Expand Up @@ -452,18 +461,26 @@ int nmea_parse_GPHDT( const char *buff, int buff_sz, nmeaGPHDT *pack )
nmea_trace_buff( buff, buff_sz );

char type;
char talker_id;

if ( 2 != nmea_scanf( buff, buff_sz,
"$GPHDT,%f,%C*",
if ( 3 != nmea_scanf( buff, buff_sz,
"$G%CHDT,%f,%C*",
&( talker_id ),
&( pack->heading ), &( type ) ) )
{
nmea_error( "GPHDT parse error!" );
nmea_error( "G?HDT parse error!" );
return 0;
}

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

if ( type != 'T' )
{
nmea_error( "GPHDT invalid type " );
nmea_error( "G?HDT invalid type " );
return 0;
}

Expand All @@ -485,14 +502,23 @@ int nmea_parse_GPVTG( const char *buff, int buff_sz, nmeaGPVTG *pack )

nmea_trace_buff( buff, buff_sz );

if ( 8 != nmea_scanf( buff, buff_sz,
"$GPVTG,%f,%C,%f,%C,%f,%C,%f,%C*",
char type;

if ( 9 != nmea_scanf( buff, buff_sz,
"$G%CVTG,%f,%C,%f,%C,%f,%C,%f,%C*",
&type,
&( pack->dir ), &( pack->dir_t ),
&( pack->dec ), &( pack->dec_m ),
&( pack->spn ), &( pack->spn_n ),
&( pack->spk ), &( pack->spk_k ) ) )
{
nmea_error( "GPVTG parse error!" );
nmea_error( "G?VTG parse error!" );
return 0;
}

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

Expand All @@ -501,7 +527,7 @@ int nmea_parse_GPVTG( const char *buff, int buff_sz, nmeaGPVTG *pack )
pack->spn_n != 'N' ||
pack->spk_k != 'K' )
{
nmea_error( "GPVTG parse error (format error)!" );
nmea_error( "G?VTG parse error (format error)!" );
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/gps/qgsnmeaconnection.cpp
Expand Up @@ -115,7 +115,7 @@ void QgsNmeaConnection::processStringBuffer()
mStatus = GPSDataReceived;
QgsDebugMsgLevel( QStringLiteral( "*******************GPS data received****************" ), 2 );
}
else if ( substring.startsWith( QLatin1String( "$GPVTG" ) ) )
else if ( substring.startsWith( QLatin1String( "$GPVTG" ) ) || substring.startsWith( QLatin1String( "$GNVTG" ) ) )
{
QgsDebugMsg( substring );
processVtgSentence( ba.data(), ba.length() );
Expand All @@ -129,14 +129,14 @@ void QgsNmeaConnection::processStringBuffer()
mStatus = GPSDataReceived;
QgsDebugMsg( QStringLiteral( "*******************GPS data received****************" ) );
}
else if ( substring.startsWith( QLatin1String( "$GPGST" ) ) )
else if ( substring.startsWith( QLatin1String( "$GPGST" ) ) || substring.startsWith( QLatin1String( "$GNGST" ) ) )
{
QgsDebugMsg( substring );
processGstSentence( ba.data(), ba.length() );
mStatus = GPSDataReceived;
QgsDebugMsg( QStringLiteral( "*******************GPS data received****************" ) );
}
else if ( substring.startsWith( QLatin1String( "$GPHDT" ) ) )
else if ( substring.startsWith( QLatin1String( "$GPHDT" ) ) || substring.startsWith( QLatin1String( "$GNHDT" ) ) )
{
QgsDebugMsgLevel( substring, 2 );
processHdtSentence( ba.data(), ba.length() );
Expand Down

0 comments on commit 2f72542

Please sign in to comment.