diff --git a/src/core/system_parameters/GLONASS_L1_L2_CA.h b/src/core/system_parameters/GLONASS_L1_L2_CA.h index e893f7df7..042754742 100644 --- a/src/core/system_parameters/GLONASS_L1_L2_CA.h +++ b/src/core/system_parameters/GLONASS_L1_L2_CA.h @@ -238,6 +238,7 @@ const std::vector GLONASS_GNAV_CRC_M_INDEX{20, 21, 22, 23, 24, 25, 26, const std::vector GLONASS_GNAV_CRC_N_INDEX{35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65}; const std::vector GLONASS_GNAV_CRC_P_INDEX{66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; const std::vector GLONASS_GNAV_CRC_Q_INDEX{9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85}; +const std::vector GLONASS_GNAV_ECC_LOCATOR{0, 0, 1, 8, 2, 9, 10, 11, 3, 12, 13, 14, 15, 16, 17, 18, 4, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 5, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 6, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84}; // GLONASS GNAV NAVIGATION MESSAGE STRUCTURE // NAVIGATION MESSAGE FIELDS POSITIONS diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index 3f1bcd12e..94ddd9073 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -36,7 +36,7 @@ Glonass_Gnav_Navigation_Message::Glonass_Gnav_Navigation_Message() } -bool Glonass_Gnav_Navigation_Message::CRC_test(const std::bitset& bits) const +bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset& bits) const { uint32_t sum_bits = 0; int32_t sum_hamming = 0; @@ -128,7 +128,28 @@ bool Glonass_Gnav_Navigation_Message::CRC_test(const std::bitset string_bits(frame_string); + std::bitset string_bits(frame_string); // Perform data verification and exit code if error in bit sequence flag_CRC_test = CRC_test(string_bits); diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.h b/src/core/system_parameters/glonass_gnav_navigation_message.h index fcad9c79f..c51264ad8 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.h +++ b/src/core/system_parameters/glonass_gnav_navigation_message.h @@ -55,7 +55,7 @@ public: * \brief Compute CRC for GLONASS GNAV strings * \param bits Bits of the string message where to compute CRC */ - bool CRC_test(const std::bitset& bits) const; + bool CRC_test(std::bitset& bits) const; /*! * \brief Computes the frame number being decoded given the satellite slot number diff --git a/src/tests/unit-tests/system-parameters/glonass_gnav_crc_test.cc b/src/tests/unit-tests/system-parameters/glonass_gnav_crc_test.cc index 88fc61e04..2280219d1 100644 --- a/src/tests/unit-tests/system-parameters/glonass_gnav_crc_test.cc +++ b/src/tests/unit-tests/system-parameters/glonass_gnav_crc_test.cc @@ -17,14 +17,14 @@ #include "glonass_gnav_navigation_message.h" #include -#include +#include TEST(GlonassCrcTest, GnssSdrCRCTest) { // test data std::string string1Real_14_18_00("0000100000111001001001000011101010101100010101001000001001011101010101110011110110101"); std::string string1Real_14_18_30("0000100000111001001011000011101010101100010101001000001001011101010101110011100001010"); - std::string string1Wrong_14_18_00("0000100000111001001001000011101010101100010101001000001001011101010101110011100001010"); + std::string string1Wrong_14_18_00("0000100000111001001001100011101010101100010101001000001001011101010101110011100001010"); auto gnav_msg = Glonass_Gnav_Navigation_Message(); std::bitset bits; @@ -34,4 +34,12 @@ TEST(GlonassCrcTest, GnssSdrCRCTest) ASSERT_TRUE(gnav_msg.CRC_test(bits)); bits = std::bitset(string1Wrong_14_18_00); ASSERT_FALSE(gnav_msg.CRC_test(bits)); + bits = std::bitset(string1Real_14_18_30); + for (int k = 8; k < 85; k++) + { + std::bitset corrupt_bits = bits; + corrupt_bits[k] = corrupt_bits[k] ? false : true; + ASSERT_TRUE(gnav_msg.CRC_test(corrupt_bits)); + ASSERT_TRUE(corrupt_bits == bits); + } }