diff --git a/ALM.CPP b/ALM.CPP index afd7e1a..56d39ec 100644 --- a/ALM.CPP +++ b/ALM.CPP @@ -89,21 +89,21 @@ bool ALM::Parse( SENTENCE const& sentence ) noexcept return( false ); } - NumberOfMessages = (uint16_t) sentence.Integer( 1 ); - MessageNumber = (uint16_t) sentence.Integer( 2 ); - PRNNumber = (uint16_t) sentence.Integer( 3 ); - WeekNumber = (uint16_t) sentence.Integer( 4 ); - SVHealth = (uint16_t) ::HexValue( sentence.Field( 5 ) ); - Eccentricity = (uint16_t) ::HexValue( sentence.Field( 6 ) ); - AlmanacReferenceTime = (uint16_t) ::HexValue( sentence.Field( 7 ) ); - InclinationAngle = (uint16_t) ::HexValue( sentence.Field( 8 ) ); - RateOfRightAscension = (uint16_t) ::HexValue( sentence.Field( 9 ) ); + NumberOfMessages = static_cast(sentence.Integer( 1 )); + MessageNumber = static_cast(sentence.Integer( 2 )); + PRNNumber = static_cast(sentence.Integer( 3 )); + WeekNumber = static_cast(sentence.Integer( 4 )); + SVHealth = static_cast(::HexValue( sentence.Field( 5 ) )); + Eccentricity = static_cast(::HexValue( sentence.Field( 6 ) )); + AlmanacReferenceTime = static_cast(::HexValue( sentence.Field( 7 ) )); + InclinationAngle = static_cast(::HexValue( sentence.Field( 8 ) )); + RateOfRightAscension = static_cast(::HexValue( sentence.Field( 9 ) )); RootOfSemiMajorAxis = ::HexValue( sentence.Field( 10 ) ); ArgumentOfPerigee = ::HexValue( sentence.Field( 11 ) ); LongitudeOfAscensionNode = ::HexValue( sentence.Field( 12 ) ); MeanAnomaly = ::HexValue( sentence.Field( 13 ) ); - F0ClockParameter = (uint16_t) ::HexValue( sentence.Field( 14 ) ); - F1ClockParameter = (uint16_t) ::HexValue( sentence.Field( 15 ) ); + F0ClockParameter = static_cast(::HexValue( sentence.Field( 14 ) )); + F1ClockParameter = static_cast(::HexValue( sentence.Field( 15 ) )); return( true ); } diff --git a/DCN.CPP b/DCN.CPP index 8930ffa..4feca32 100644 --- a/DCN.CPP +++ b/DCN.CPP @@ -96,7 +96,7 @@ bool DCN::Parse( SENTENCE const& sentence ) noexcept PurpleLineNavigationUse = sentence.Boolean( 13 ); PositionUncertaintyNauticalMiles = sentence.Double( 14 ); - int temp_integer = sentence.Integer( 16 ); + auto const temp_integer = sentence.Integer( 16 ); switch( temp_integer ) { diff --git a/FSI.CPP b/FSI.CPP index c655922..30af12c 100644 --- a/FSI.CPP +++ b/FSI.CPP @@ -71,7 +71,7 @@ bool FSI::Parse( SENTENCE const& sentence ) noexcept TransmittingFrequency = sentence.Double( 1 ); ReceivingFrequency = sentence.Double( 2 ); Mode = sentence.CommunicationsMode( 3 ); - PowerLevel = (short) sentence.Integer( 4 ); + PowerLevel = static_cast(sentence.Integer( 4 )); return( true ); } diff --git a/GSA.CPP b/GSA.CPP index 453fb8b..b0ffeec 100644 --- a/GSA.CPP +++ b/GSA.CPP @@ -110,7 +110,7 @@ bool GSA::Parse( SENTENCE const& sentence ) noexcept OperatingMode = GSA::OPERATING_MODE::UnknownOperatingMode; } - std::size_t index = sentence.Integer( 2 ); + auto index = sentence.Integer( 2 ); switch( index ) { diff --git a/GSV.CPP b/GSV.CPP index 55687ba..f3d9a4c 100644 --- a/GSV.CPP +++ b/GSV.CPP @@ -85,7 +85,7 @@ bool GSV::Parse( SENTENCE const& sentence ) noexcept return( false ); } - int const message_number = sentence.Integer( 2 ); + auto const message_number = sentence.Integer( 2 ); NumberOfSatellites = sentence.Integer( 3 ); @@ -93,7 +93,13 @@ bool GSV::Parse( SENTENCE const& sentence ) noexcept while( index < 4 ) { - SatellitesInView[ ( ( message_number - 1 ) * 4 ) + index ].Parse( ( index * 4 ) + 4, sentence ); + auto const array_index = ((message_number - 1) * 4) + index; + + if (array_index < std::size(SatellitesInView)) + { + SatellitesInView[array_index].Parse((index * 4) + 4, sentence); + } + index++; } diff --git a/GSV.HPP b/GSV.HPP index da61d0e..44b2dc7 100644 --- a/GSV.HPP +++ b/GSV.HPP @@ -45,7 +45,7 @@ class GSV : public RESPONSE */ int NumberOfSatellites{ 0 }; - SATELLITE_DATA SatellitesInView[ 12 ]; + SATELLITE_DATA SatellitesInView[ 36 ]; /* ** Methods diff --git a/GXA.CPP b/GXA.CPP index fd8ac59..b5d2b81 100644 --- a/GXA.CPP +++ b/GXA.CPP @@ -76,7 +76,7 @@ bool GXA::Parse( SENTENCE const& sentence ) noexcept Time = sentence.Time( 1 ); Position.Parse( 2, 3, 4, 5, sentence ); WaypointID = sentence.Field( 6 ); - SatelliteNumber = (uint16_t) sentence.Integer( 7 ); + SatelliteNumber = static_cast(sentence.Integer( 7 )); return( true ); } diff --git a/NMEA0183.H b/NMEA0183.H index 4b9d717..1d00c37 100644 --- a/NMEA0183.H +++ b/NMEA0183.H @@ -132,6 +132,17 @@ enum class TRANSDUCER_TYPE VolumeTransducer = 'V' }; +enum class FAA_MODE +{ + ModeUnknown = 0, + Autonomous = 'A', + Differential = 'D', + Estimated = 'E', + NotValid = 'N', + Simulated = 'S', + Manual = 'M' +}; + /* ** Misc Function Prototypes */ diff --git a/RMA.CPP b/RMA.CPP index 3a772a1..9555c25 100644 --- a/RMA.CPP +++ b/RMA.CPP @@ -72,7 +72,7 @@ bool RMA::Parse( SENTENCE const& sentence ) noexcept ** First we check the checksum... */ - NMEA0183_BOOLEAN const check = sentence.IsChecksumBad( 12 ); + auto const check = sentence.IsChecksumBad( 12 ); if ( check == NMEA0183_BOOLEAN::True ) { diff --git a/RMB.CPP b/RMB.CPP index 52573f8..e6e1c79 100644 --- a/RMB.CPP +++ b/RMB.CPP @@ -77,7 +77,7 @@ bool RMB::Parse( SENTENCE const& sentence ) noexcept ** First we check the checksum... */ - NMEA0183_BOOLEAN const check = sentence.IsChecksumBad( 14 ); + auto const check = sentence.IsChecksumBad( 14 ); if ( check == NMEA0183_BOOLEAN::True ) { diff --git a/RMC.CPP b/RMC.CPP index 079f7c0..fd7f785 100644 --- a/RMC.CPP +++ b/RMC.CPP @@ -44,6 +44,7 @@ void RMC::Empty( void ) noexcept Date.clear(); MagneticVariation = 0.0; MagneticVariationDirection = EASTWEST::EW_Unknown; + FAAMode = FAA_MODE::ModeUnknown; } bool RMC::Parse( SENTENCE const& sentence ) noexcept @@ -67,26 +68,38 @@ bool RMC::Parse( SENTENCE const& sentence ) noexcept ** 9) Date, ddmmyy ** 10) Magnetic Variation, degrees ** 11) E or W - ** 12) Checksum + ** 12) FAA Mode (version 2.3) + ** 13) Checksum */ /* ** First we check the checksum... */ - NMEA0183_BOOLEAN const check = sentence.IsChecksumBad( 12 ); + int checksum_field = 12; - if ( check == NMEA0183_BOOLEAN::True ) + // Version 2.3 of the standard has things different + + FAAMode = sentence.FAAMode(12); + + if (FAAMode != FAA_MODE::ModeUnknown) + { + checksum_field = 13; + } + + auto const check = sentence.IsChecksumBad(checksum_field); + + if (check == NMEA0183_BOOLEAN::True) { SetErrorMessage(STRING_VIEW("Invalid Checksum")); - return( false ); + return(false); } - - if ( check == NMEA0183_BOOLEAN::NMEA_Unknown ) + + if (check == NMEA0183_BOOLEAN::NMEA_Unknown) { SetErrorMessage(STRING_VIEW("Missing Checksum")); - return( false ); - } + return(false); + } UTCTime = sentence.Field( 1 ); Time = sentence.Time( 1 ); diff --git a/RMC.HPP b/RMC.HPP index 845e068..9a3a736 100644 --- a/RMC.HPP +++ b/RMC.HPP @@ -53,6 +53,7 @@ class RMC : public RESPONSE std::string Date; double MagneticVariation{ 0.0 }; EASTWEST MagneticVariationDirection{ EASTWEST::EW_Unknown }; + FAA_MODE FAAMode{ FAA_MODE::ModeUnknown }; /* ** Methods diff --git a/RSD.CPP b/RSD.CPP index a2d985b..65b3664 100644 --- a/RSD.CPP +++ b/RSD.CPP @@ -73,7 +73,7 @@ bool RSD::Parse( SENTENCE const& sentence ) noexcept RangeScale = sentence.Double( 11 ); RangeUnits = sentence.Field( 12 ); - int temp_integer = sentence.Integer( 13 ); + auto const temp_integer = sentence.Integer( 13 ); switch( temp_integer ) { diff --git a/SENTENCE.CPP b/SENTENCE.CPP index bcfbb1a..87eaed2 100644 --- a/SENTENCE.CPP +++ b/SENTENCE.CPP @@ -7,7 +7,7 @@ Dr. Richard Garwin The MIT License (MIT) -Copyright (c) 1996-2019 Sam Blackburn +Copyright (c) 1996-2021 Sam Blackburn Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -119,7 +119,7 @@ uint8_t SENTENCE::ComputeChecksum( void ) const noexcept { uint8_t checksum_value = 0; - std::size_t const string_length = Sentence.length(); + auto const string_length = Sentence.length(); std::size_t index = 1; // Skip over the $ at the begining of the sentence while( index < string_length and @@ -183,7 +183,7 @@ std::string_view SENTENCE::Field( int desired_field_number ) const noexcept std::size_t index = 1; // Skip over the $ at the begining of the sentence int current_field_number = 0; - std::size_t const string_length = Sentence.length(); + auto const string_length = Sentence.length(); while( current_field_number < desired_field_number and index < string_length ) { @@ -219,7 +219,7 @@ uint16_t SENTENCE::GetNumberOfDataFields( void ) const noexcept std::size_t index = 1; // Skip over the $ at the begining of the sentence int current_field_number = 0; - std::size_t const string_length = Sentence.length(); + auto const string_length = Sentence.length(); while( index < string_length ) { @@ -241,7 +241,7 @@ uint16_t SENTENCE::GetNumberOfDataFields( void ) const noexcept void SENTENCE::Finish( void ) noexcept { - uint8_t const checksum = ComputeChecksum(); + auto const checksum = ComputeChecksum(); char temp_string[ 10 ]; @@ -376,7 +376,7 @@ REFERENCE SENTENCE::Reference( int field_number ) const noexcept time_t SENTENCE::Time( int field_number ) const noexcept { - time_t return_value = time(nullptr); + auto return_value = time(nullptr); auto temp_string = Field( field_number ); @@ -464,6 +464,47 @@ TRANSDUCER_TYPE SENTENCE::TransducerType( int field_number ) const noexcept } } +FAA_MODE SENTENCE::FAAMode(int field_number) const noexcept +{ + auto field_data = Field(field_number); + + if (field_data.length() == 1) + { + if (field_data[0] == 'A') + { + return(FAA_MODE::Autonomous); + } + else if (field_data[0] == 'D') + { + return(FAA_MODE::Differential); + } + else if (field_data[0] == 'E') + { + return(FAA_MODE::Estimated); + } + else if (field_data[0] == 'N') + { + return(FAA_MODE::NotValid); + } + else if (field_data[0] == 'S') + { + return(FAA_MODE::Simulated); + } + else if (field_data[0] == 'M') + { + return(FAA_MODE::Manual); + } + else + { + return(FAA_MODE::ModeUnknown); + } + } + else + { + return(FAA_MODE::ModeUnknown); + } +} + /* ** Operators */ diff --git a/SENTENCE.HPP b/SENTENCE.HPP index 2998e55..dafb741 100644 --- a/SENTENCE.HPP +++ b/SENTENCE.HPP @@ -67,6 +67,7 @@ class SENTENCE virtual REFERENCE Reference( int field_number ) const noexcept; virtual time_t Time( int field_number ) const noexcept; virtual TRANSDUCER_TYPE TransducerType( int field_number ) const noexcept; + virtual FAA_MODE FAAMode(int field_number) const noexcept; /* ** Operators diff --git a/ZFI.CPP b/ZFI.CPP index 8040f62..028ce79 100644 --- a/ZFI.CPP +++ b/ZFI.CPP @@ -72,7 +72,7 @@ bool ZFI::Parse( SENTENCE const& sentence ) noexcept return( false ); } - time_t temp_time = time(nullptr); + auto temp_time = time(nullptr); auto tm_p = gmtime(&temp_time); diff --git a/ZLZ.CPP b/ZLZ.CPP index a86802a..c511971 100644 --- a/ZLZ.CPP +++ b/ZLZ.CPP @@ -73,7 +73,7 @@ bool ZLZ::Parse( SENTENCE const& sentence ) noexcept return( false ); } - time_t temp_time = time(nullptr); + auto temp_time = time(nullptr); auto tm_p = gmtime(&temp_time); diff --git a/ZPI.CPP b/ZPI.CPP index ea27c6e..1ce3cfd 100644 --- a/ZPI.CPP +++ b/ZPI.CPP @@ -72,7 +72,7 @@ bool ZPI::Parse( SENTENCE const& sentence ) noexcept return( false ); } - time_t temp_time = time(nullptr); + auto temp_time = time(nullptr); auto tm_p = gmtime(&temp_time); diff --git a/ZTA.CPP b/ZTA.CPP index 0494ef7..d752472 100644 --- a/ZTA.CPP +++ b/ZTA.CPP @@ -72,7 +72,7 @@ bool ZTA::Parse( SENTENCE const& sentence ) noexcept return( false ); } - time_t temp_time = time(nullptr); + auto temp_time = time(nullptr); auto tm_p = gmtime(&temp_time); diff --git a/ZTE.CPP b/ZTE.CPP index 60aa714..9521cb9 100644 --- a/ZTE.CPP +++ b/ZTE.CPP @@ -72,7 +72,7 @@ bool ZTE::Parse( SENTENCE const& sentence ) noexcept return( false ); } - time_t temp_time = time(nullptr); + auto temp_time = time(nullptr); auto tm_p = gmtime(&temp_time); diff --git a/ZTI.CPP b/ZTI.CPP index bf82833..d20ed85 100644 --- a/ZTI.CPP +++ b/ZTI.CPP @@ -72,7 +72,7 @@ bool ZTI::Parse( SENTENCE const& sentence ) noexcept return( false ); } - time_t temp_time = time(nullptr); + auto temp_time = time(nullptr); auto tm_p = gmtime(&temp_time); diff --git a/ZWP.CPP b/ZWP.CPP index 2e94a0c..6160f07 100644 --- a/ZWP.CPP +++ b/ZWP.CPP @@ -72,7 +72,7 @@ bool ZWP::Parse( SENTENCE const& sentence ) noexcept return( false ); } - time_t temp_time = time(nullptr); + auto temp_time = time(nullptr); auto tm_p = gmtime(&temp_time); diff --git a/ZZU.CPP b/ZZU.CPP index 7bbc3c4..b1924ff 100644 --- a/ZZU.CPP +++ b/ZZU.CPP @@ -67,7 +67,7 @@ bool ZZU::Parse( SENTENCE const& sentence ) noexcept return( false ); } - time_t temp_time = time(nullptr); + auto temp_time = time(nullptr); auto tm_p = gmtime(&temp_time);