Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update VTG parsing for NMEA0183 version 2.3 and later #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RMC.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ RMC const& RMC::operator = ( RMC const& source ) noexcept
Date = source.Date;
MagneticVariation = source.MagneticVariation;
MagneticVariationDirection = source.MagneticVariationDirection;
FAAMode = source.FAAMode;

return( *this );
}
24 changes: 22 additions & 2 deletions VTG.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,31 @@ bool VTG::Parse( SENTENCE const& sentence ) noexcept
/*
** First we check the checksum...
*/

int checksum_field = 9;

// Version 2.3 of the standard has things different

FAAMode = sentence.FAAMode(9);

if (FAAMode != FAA_MODE::ModeUnknown)
{
checksum_field = 10;
}

auto const check = sentence.IsChecksumBad(checksum_field);

if ( sentence.IsChecksumBad( 9 ) == NMEA0183_BOOLEAN::True )
if ( check == NMEA0183_BOOLEAN::True )
{
SetErrorMessage(STRING_VIEW("Invalid Checksum"));
return( false );
}
}

if (check == NMEA0183_BOOLEAN::NMEA_Unknown)
{
SetErrorMessage(STRING_VIEW("Missing Checksum"));
return(false);
}

TrackDegreesTrue = sentence.Double( 1 );
TrackDegreesMagnetic = sentence.Double( 3 );
Expand Down Expand Up @@ -108,6 +127,7 @@ VTG const& VTG::operator = ( VTG const& source ) noexcept
TrackDegreesMagnetic = source.TrackDegreesMagnetic;
SpeedKnots = source.SpeedKnots;
SpeedKilometersPerHour = source.SpeedKilometersPerHour;
FAAMode = source.FAAMode;

return( *this );
}
9 changes: 5 additions & 4 deletions VTG.HPP
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ class VTG : public RESPONSE
** Data
*/

double TrackDegreesTrue{ 0.0 };
double TrackDegreesMagnetic{ 0.0 };
double SpeedKnots{ 0.0 };
double SpeedKilometersPerHour{ 0.0 };
double TrackDegreesTrue{ 0.0 };
double TrackDegreesMagnetic{ 0.0 };
double SpeedKnots{ 0.0 };
double SpeedKilometersPerHour{ 0.0 };
FAA_MODE FAAMode{ FAA_MODE::ModeUnknown };

/*
** Methods
Expand Down