diff --git a/src/core/system_parameters/Galileo_E1.h b/src/core/system_parameters/Galileo_E1.h index 9fa7e761c..e0c0ef2be 100644 --- a/src/core/system_parameters/Galileo_E1.h +++ b/src/core/system_parameters/Galileo_E1.h @@ -65,6 +65,8 @@ const int GALILEO_INAV_INTERLEAVER_COLS = 30; const int GALILEO_PAGE_TYPE_BITS = 6; const int GALILEO_DATA_JK_BITS =128; +const int GALILEO_DATA_FRAME_BITS =196; +const int GALILEO_DATA_FRAME_BYTES =25; const std::vector> type({{1,6}}); const std::vector> PAGE_TYPE_bit({{1,6}});; diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc index 4f3a53eba..e8147c14d 100644 --- a/src/core/system_parameters/galileo_navigation_message.cc +++ b/src/core/system_parameters/galileo_navigation_message.cc @@ -30,13 +30,20 @@ */ #include "galileo_navigation_message.h" -#include "boost/date_time/posix_time/posix_time.hpp" +#include +#include // for boost::crc_basic, boost::crc_optimal +#include + + #include #include #include using namespace std; +typedef boost::crc_optimal<24, 0x1864CFBu, 0x0, 0x0, false, false> CRC_Galileo_INAV_type; + + void Galileo_Navigation_Message::reset() { flag_even_word = 0; @@ -188,6 +195,37 @@ Galileo_Navigation_Message::Galileo_Navigation_Message() reset(); } + +bool Galileo_Navigation_Message::CRC_test(std::bitset bits,boost::uint32_t checksum) +{ + + CRC_Galileo_INAV_type CRC_Galileo; + + boost::uint32_t crc_computed; + // Galileo INAV frame for CRC is not an integer multiple of bytes + // it needs to be filled with zeroes at the start of the frame. + // This operation is done in the transformation from bits to bytes + // using boost::dynamic_bitset. + // ToDo: Use boost::dynamic_bitset for all the bitset operations in this class + + boost::dynamic_bitset frame_bits(std::string(bits.to_string())); + + std::vector bytes; + boost::to_block_range(frame_bits, std::back_inserter(bytes)); + std::reverse(bytes.begin(),bytes.end()); + + + CRC_Galileo.process_bytes( bytes.data(), GALILEO_DATA_FRAME_BYTES ); + + crc_computed=CRC_Galileo.checksum(); + if (checksum==crc_computed){ + return true; + }else{ + return false; + } + + +} unsigned long int Galileo_Navigation_Message::read_navigation_unsigned(std::bitset bits, const std::vector > parameter) { unsigned long int value = 0; @@ -312,6 +350,10 @@ bool Galileo_Navigation_Message::read_navigation_bool(std::bitset #include #include -#include "boost/assign.hpp" +#include +#include // for boost::uint16_t #include #include @@ -51,6 +52,7 @@ class Galileo_Navigation_Message { private: + bool CRC_test(std::bitset bits,boost::uint32_t checksum); bool read_navigation_bool(std::bitset bits, const std::vector > parameter); //void print_galileo_word_bytes(unsigned int GPS_word); unsigned long int read_navigation_unsigned(std::bitset bits, const std::vector< std::pair > parameter);