From 557a7f7265d23733abc7b31be3407f8b3c30b6eb Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 28 Aug 2024 11:13:54 +0200 Subject: [PATCH] Add work on ISM --- src/core/system_parameters/galileo_ism.cc | 34 ++++++++++++++++++++++- src/core/system_parameters/galileo_ism.h | 19 +++++++------ src/tests/test_main.cc | 3 ++ 3 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/core/system_parameters/galileo_ism.cc b/src/core/system_parameters/galileo_ism.cc index 847a4ecd6..24b5b6d82 100644 --- a/src/core/system_parameters/galileo_ism.cc +++ b/src/core/system_parameters/galileo_ism.cc @@ -184,7 +184,7 @@ bool Galileo_ISM::check_ism_crc(const std::bitset& bits) c boost::to_block_range(frame_bits, std::back_inserter(bytes)); std::reverse(bytes.begin(), bytes.end()); - boost::crc_32_type crc32_ism; + boost::crc_optimal<32, 0xC0A0A0D5, 0xFFFFFFFF, 0xFFFFFFFF, true, true> crc32_ism; crc32_ism.process_bytes(bytes.data(), GALILEO_ISM_CRC_DATA_BYTES); const uint32_t crc_computed = crc32_ism.checksum(); if (this->ism_crc == crc_computed) @@ -193,4 +193,36 @@ bool Galileo_ISM::check_ism_crc(const std::bitset& bits) c } return false; +} + + +bool Galileo_ISM::ism_apply_to_sat(uint32_t prn) const +{ + if (prn == 0 || prn > 63) + { + return false; + } + std::bitset<32> bs(this->ism_mask); + if (this->ism_mask_msb == 0) + { + if (prn <= 32) + { + return bs[prn - 1]; + } + else + { + return false; + } + } + else + { + if (prn > 32) + { + return bs[prn - 32]; + } + else + { + return false; + } + } } \ No newline at end of file diff --git a/src/core/system_parameters/galileo_ism.h b/src/core/system_parameters/galileo_ism.h index 12436a606..2066fe0ac 100644 --- a/src/core/system_parameters/galileo_ism.h +++ b/src/core/system_parameters/galileo_ism.h @@ -57,16 +57,17 @@ public: void set_ism_Tvalidity(uint8_t tvalidity); void set_ism_crc(uint32_t crc); - bool check_ism_crc(const std::bitset& bits) const; + bool check_ism_crc(const std::bitset& bits) const; //!< Requires ism_crc to be already set + bool ism_apply_to_sat(uint32_t prn) const; //!< Returns true if ISM parameters apply to the prn satellite, false otherwise - double get_pconst_value() const; - double get_psat_value() const; - float get_ura_m() const; - float get_ure_m() const; - float get_bnom_m() const; - uint16_t get_WN_ISM() const; - uint16_t get_t0_ISM() const; - uint16_t get_Tvalidity_hours() const; + double get_pconst_value() const; //!< A priori constellation fault probability + double get_psat_value() const; //!< A priori satellite fault probability + float get_ura_m() const; //!< User Range Accuracy, in m, used for integrity + float get_ure_m() const; //!< User Range Error, in m, used for accuracy + float get_bnom_m() const; //!< Maximum nominal bias for a satellite, in m + uint16_t get_WN_ISM() const; //!< ISM Week Number, in weeks + uint16_t get_t0_ISM() const; //!< ISM Time of Week, in seconds + uint16_t get_Tvalidity_hours() const; //!< Validity duration of ISM content, in hours private: // ICD 2.1 Table 97 diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index 3769756aa..00f1f9458 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -95,6 +95,9 @@ DECLARE_string(log_dir); #include "unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc" #include "unit-tests/system-parameters/glonass_gnav_nav_message_test.cc" #include "unit-tests/system-parameters/has_decoding_test.cc" +#include "unit-tests/system-parameters/galileo_ism_test.cc" + + #ifndef EXCLUDE_TESTS_REQUIRING_BINARIES #include "unit-tests/control-plane/control_thread_test.cc"