Skip to content

Commit

Permalink
Remaining nmea0183 related updates in demo_pi_sample
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusyurtturk authored and leamas committed Oct 25, 2024
1 parent 0f04f20 commit f3daceb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 30 deletions.
1 change: 1 addition & 0 deletions plugins/demo_pi_sample/src/nmea0183/RMB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class RMB : public RESPONSE
double BearingToDestinationDegreesTrue;
double DestinationClosingVelocityKnots;
NMEA0183_BOOLEAN IsArrivalCircleEntered;
wxString FAAModeIndicator;

/*
** Methods
Expand Down
1 change: 1 addition & 0 deletions plugins/demo_pi_sample/src/nmea0183/RMC.HPP
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class RMC : public RESPONSE
wxString Date;
double MagneticVariation;
EASTWEST MagneticVariationDirection;
wxString FAAModeIndicator;

/*
** Methods
Expand Down
3 changes: 2 additions & 1 deletion plugins/demo_pi_sample/src/nmea0183/gsv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ GSV::~GSV()

void GSV::Empty( void )
{
MessageNumber = 0;
SatsInView = 0;
}

Expand Down Expand Up @@ -101,7 +102,7 @@ bool GSV::Parse( const SENTENCE& sentence )
** Ignore the checksum...
*/


MessageNumber = sentence.Integer( 2 );
SatsInView = sentence.Integer( 3 );

return( TRUE );
Expand Down
3 changes: 2 additions & 1 deletion plugins/demo_pi_sample/src/nmea0183/gsv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class GSV : public RESPONSE
** Data
*/

int SatsInView;
int MessageNumber;
int SatsInView;

/*
** Methods
Expand Down
29 changes: 23 additions & 6 deletions plugins/demo_pi_sample/src/nmea0183/rmb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ bool RMB::Parse( const SENTENCE& sentence )
** 1) Status, V = Navigation receiver warning
** 2) Cross Track error - nautical miles
** 3) Direction to Steer, Left or Right
** 4) TO Waypoint ID
** 5) FROM Waypoint ID
** 4) FROM Waypoint ID
** 5) TO Waypoint ID
** 6) Destination Waypoint Latitude
** 7) N or S
** 8) Destination Waypoint Longitude
Expand All @@ -92,30 +92,44 @@ bool RMB::Parse( const SENTENCE& sentence )
** 11) Bearing to destination in degrees True
** 12) Destination closing velocity in knots
** 13) Arrival Status, A = Arrival Circle Entered
** Version 2.0
** 14) Checksum
Version 2.3
** 14) FAA Mode Indicatior, The value can be A=autonomous, D=differential, E=Estimated, N=not valid, S=Simulator, optional, may be NULL
** 15) Checksum
*/

/*
** First we check the checksum...
*/

NMEA0183_BOOLEAN check = sentence.IsChecksumBad( 14 );
int nFields = sentence.GetNumberOfDataFields();
NMEA0183_BOOLEAN check = sentence.IsChecksumBad(nFields + 1);

if ( check == NTrue )
{
SetErrorMessage( _T("Invalid Checksum") );
return( FALSE );
}

// If sentence is at least Version 2.3, check the extra FAA mode indicator field
bool mode_valid = true;
if (nFields >= 14) {
wxString mode_string = sentence.Field(14);
if (!mode_string.StartsWith(_T("*"))) {
if ((mode_string == _T("N")) || (mode_string == _T("S"))) // Not valid, or simulator mode
mode_valid = false;
}
}

/*
if ( check == Unknown0183 )
{
SetErrorMessage( _T("Missing Checksum") );
return( FALSE );
}
*/

IsDataValid = sentence.Boolean( 1 );
IsDataValid = mode_valid ? sentence.Boolean( 1 ) : NFalse;
CrossTrackError = sentence.Double( 2 );
DirectionToSteer = sentence.LeftOrRight( 3 );
From = sentence.Field( 4 );
Expand Down Expand Up @@ -145,13 +159,15 @@ bool RMB::Write( SENTENCE& sentence )
else
sentence += _T("R");


sentence += From;
sentence += To;
sentence += DestinationPosition;
sentence += RangeToDestinationNauticalMiles;
sentence += BearingToDestinationDegreesTrue;
sentence += DestinationClosingVelocityKnots;
sentence += IsArrivalCircleEntered;
sentence += FAAModeIndicator;

sentence.Finish();

Expand All @@ -173,6 +189,7 @@ const RMB& RMB::operator = ( const RMB& source )
BearingToDestinationDegreesTrue = source.BearingToDestinationDegreesTrue;
DestinationClosingVelocityKnots = source.DestinationClosingVelocityKnots;
IsArrivalCircleEntered = source.IsArrivalCircleEntered;
FAAModeIndicator = source.FAAModeIndicator;

return( *this );
}
38 changes: 17 additions & 21 deletions plugins/demo_pi_sample/src/nmea0183/rmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,51 +96,46 @@ bool RMC::Parse( const SENTENCE& sentence )
** 12) Checksum
** Version 2.3
** 12) Mode (D or A), optional, may be NULL
** 12) The value can be A=autonomous, D=differential, E=Estimated, N=not valid, S=Simulator, optional, may be NULL
** 13) Checksum
*/

/*
** First we check the checksum...
*/

NMEA0183_BOOLEAN check = sentence.IsChecksumBad( 12 );
int nFields = sentence.GetNumberOfDataFields( );

NMEA0183_BOOLEAN check = sentence.IsChecksumBad( nFields + 1 );

if ( check == NTrue )
{
/*
** This may be an NMEA Version 2.3 sentence, with "Mode" field
** This may be an NMEA Version 3+ sentence, with added fields
*/
wxString checksum_in_sentence = sentence.Field( 12 );
wxString checksum_in_sentence = sentence.Field( nFields + 1 );
if(checksum_in_sentence.StartsWith(_T("*"))) // Field is a valid erroneous checksum
{
SetErrorMessage( _T("Invalid Checksum") );
return( FALSE );
}
else
{
check = sentence.IsChecksumBad( 13 );
if( check == NTrue)
{
SetErrorMessage( _T("Invalid Checksum") );
return( FALSE );
}
}
}

// Is this a 2.3 message?
bool bext_valid = true;
wxString checksum_in_sentence = sentence.Field( 12 );
if(!checksum_in_sentence.StartsWith(_T("*"))) {
if(checksum_in_sentence == _T("N") )
bext_valid = false;
// If sentence is at least Version 2.3, check the extra mode indicator field
bool mode_valid = true;
if(nFields >= 12){
wxString mode_string = sentence.Field( 12 );
if(!mode_string.StartsWith(_T("*"))) {
if((mode_string == _T("N")) || (mode_string == _T("S"))) // Not valid, or simulator mode
mode_valid = false;
}
}


UTCTime = sentence.Field( 1 );

IsDataValid = sentence.Boolean( 2 );
if( !bext_valid )
if( !mode_valid )
IsDataValid = NFalse;

Position.Parse( 3, 4, 5, 6, sentence );
Expand Down Expand Up @@ -177,7 +172,7 @@ bool RMC::Write( SENTENCE& sentence )
sentence += MagneticVariation;
sentence += MagneticVariationDirection;
}

sentence += FAAModeIndicator;
sentence.Finish();

return( TRUE );
Expand All @@ -195,6 +190,7 @@ const RMC& RMC::operator = ( const RMC& source )
Date = source.Date;
MagneticVariation = source.MagneticVariation;
MagneticVariationDirection = source.MagneticVariationDirection;
FAAModeIndicator = source.FAAModeIndicator;

return( *this );
}
2 changes: 1 addition & 1 deletion plugins/demo_pi_sample/src/nmea0183/rte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool RTE::Parse( const SENTENCE& sentence )
/*
** RTE - Routes
**
** 1 2 3 4 5 x n
** 1 2 3 4 5 x n
** | | | | | | |
** $--RTE,x.x,x.x,a,c--c,c--c, ..... c--c*hh<CR><LF>
**
Expand Down

0 comments on commit f3daceb

Please sign in to comment.