mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-31 03:14:56 +00:00
Implement GLONASS string error correction
Signed-off-by: Vladislav P <vladisslav2011@gmail.com>
This commit is contained in:
parent
f09da3ded6
commit
e4a3a060ee
@ -238,6 +238,7 @@ const std::vector<int32_t> GLONASS_GNAV_CRC_M_INDEX{20, 21, 22, 23, 24, 25, 26,
|
||||
const std::vector<int32_t> 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<int32_t> 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<int32_t> 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<int32_t> 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
|
||||
|
@ -36,7 +36,7 @@ Glonass_Gnav_Navigation_Message::Glonass_Gnav_Navigation_Message()
|
||||
}
|
||||
|
||||
|
||||
bool Glonass_Gnav_Navigation_Message::CRC_test(const std::bitset<GLONASS_GNAV_STRING_BITS>& bits) const
|
||||
bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset<GLONASS_GNAV_STRING_BITS>& 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<GLONASS_GNAV_ST
|
||||
return true;
|
||||
}
|
||||
|
||||
// All other conditions are assumed errors. TODO: Add correction for case B
|
||||
if (C_Sigma && (sum_bits & 1))
|
||||
{
|
||||
int32_t syndrome = C1;
|
||||
syndrome |= (C2 ? 2 : 0);
|
||||
syndrome |= (C3 ? 4 : 0);
|
||||
syndrome |= (C4 ? 8 : 0);
|
||||
syndrome |= (C5 ? 16 : 0);
|
||||
syndrome |= (C6 ? 32 : 0);
|
||||
syndrome |= (C7 ? 64 : 0);
|
||||
if (syndrome < 85)
|
||||
{
|
||||
const int32_t locator = GLONASS_GNAV_ECC_LOCATOR[syndrome];
|
||||
bits[locator] = !bits[locator];
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// All other conditions are assumed errors.
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -238,7 +259,7 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame
|
||||
uint64_t P_1_tmp = 0;
|
||||
|
||||
// Unpack bytes to bits
|
||||
const std::bitset<GLONASS_GNAV_STRING_BITS> string_bits(frame_string);
|
||||
std::bitset<GLONASS_GNAV_STRING_BITS> string_bits(frame_string);
|
||||
|
||||
// Perform data verification and exit code if error in bit sequence
|
||||
flag_CRC_test = CRC_test(string_bits);
|
||||
|
@ -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<GLONASS_GNAV_STRING_BITS>& bits) const;
|
||||
bool CRC_test(std::bitset<GLONASS_GNAV_STRING_BITS>& bits) const;
|
||||
|
||||
/*!
|
||||
* \brief Computes the frame number being decoded given the satellite slot number
|
||||
|
@ -17,14 +17,14 @@
|
||||
|
||||
#include "glonass_gnav_navigation_message.h"
|
||||
#include <bitset>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
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<GLONASS_GNAV_STRING_BITS> bits;
|
||||
@ -34,4 +34,12 @@ TEST(GlonassCrcTest, GnssSdrCRCTest)
|
||||
ASSERT_TRUE(gnav_msg.CRC_test(bits));
|
||||
bits = std::bitset<GLONASS_GNAV_STRING_BITS>(string1Wrong_14_18_00);
|
||||
ASSERT_FALSE(gnav_msg.CRC_test(bits));
|
||||
bits = std::bitset<GLONASS_GNAV_STRING_BITS>(string1Real_14_18_30);
|
||||
for (int k = 8; k < 85; k++)
|
||||
{
|
||||
std::bitset<GLONASS_GNAV_STRING_BITS> corrupt_bits = bits;
|
||||
corrupt_bits[k] = corrupt_bits[k] ? false : true;
|
||||
ASSERT_TRUE(gnav_msg.CRC_test(corrupt_bits));
|
||||
ASSERT_TRUE(corrupt_bits == bits);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user