mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-08 08:20:33 +00:00
Merge branch 'ism' of github.com:carlesfernandez/gnss-sdr into ism
This commit is contained in:
commit
db78d104bf
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "galileo_ism.h"
|
#include "galileo_ism.h"
|
||||||
#include <boost/crc.hpp>
|
|
||||||
#include <boost/dynamic_bitset.hpp>
|
#include <boost/dynamic_bitset.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -176,15 +175,12 @@ uint16_t Galileo_ISM::get_Tvalidity_hours() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Galileo_ISM::check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits) const
|
bool Galileo_ISM::check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits)
|
||||||
{
|
{
|
||||||
boost::dynamic_bitset<unsigned char> frame_bits(bits.to_string().substr(0, GALILEO_ISM_CRC_DATA_BITS));
|
boost::dynamic_bitset<unsigned char> frame_bits(bits.to_string().substr(0, GALILEO_ISM_CRC_DATA_BITS));
|
||||||
|
|
||||||
std::vector<unsigned char> bytes;
|
std::vector<unsigned char> bytes;
|
||||||
boost::to_block_range(frame_bits, std::back_inserter(bytes));
|
boost::to_block_range(frame_bits, std::back_inserter(bytes));
|
||||||
std::reverse(bytes.begin(), bytes.end());
|
std::reverse(bytes.begin(), bytes.end());
|
||||||
|
|
||||||
boost::crc_32_type crc32_ism;
|
|
||||||
crc32_ism.process_bytes(bytes.data(), GALILEO_ISM_CRC_DATA_BYTES);
|
crc32_ism.process_bytes(bytes.data(), GALILEO_ISM_CRC_DATA_BYTES);
|
||||||
const uint32_t crc_computed = crc32_ism.checksum();
|
const uint32_t crc_computed = crc32_ism.checksum();
|
||||||
if (this->ism_crc == crc_computed)
|
if (this->ism_crc == crc_computed)
|
||||||
@ -193,4 +189,12 @@ bool Galileo_ISM::check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits) c
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t Galileo_ISM::compute_crc(const std::vector<uint8_t>& data)
|
||||||
|
{
|
||||||
|
crc32_ism.process_bytes(data.data(), data.size());
|
||||||
|
uint32_t result = crc32_ism.checksum();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -19,9 +19,11 @@
|
|||||||
#define GNSS_SDR_GALILEO_ISM_H
|
#define GNSS_SDR_GALILEO_ISM_H
|
||||||
|
|
||||||
#include "Galileo_INAV.h"
|
#include "Galileo_INAV.h"
|
||||||
|
#include <boost/crc.hpp>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/** \addtogroup Core
|
/** \addtogroup Core
|
||||||
* \{ */
|
* \{ */
|
||||||
@ -41,7 +43,7 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
Galileo_ISM() = default;
|
Galileo_ISM() : crc32_ism(0x814141AB, 0, 0, false, false) {};
|
||||||
|
|
||||||
void set_ism_constellation_id(uint8_t const_id);
|
void set_ism_constellation_id(uint8_t const_id);
|
||||||
void set_ism_service_level_id(uint8_t sl_id);
|
void set_ism_service_level_id(uint8_t sl_id);
|
||||||
@ -57,7 +59,7 @@ public:
|
|||||||
void set_ism_Tvalidity(uint8_t tvalidity);
|
void set_ism_Tvalidity(uint8_t tvalidity);
|
||||||
void set_ism_crc(uint32_t crc);
|
void set_ism_crc(uint32_t crc);
|
||||||
|
|
||||||
bool check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits) const;
|
bool check_ism_crc(const std::bitset<GALILEO_DATA_JK_BITS>& bits);
|
||||||
|
|
||||||
double get_pconst_value() const;
|
double get_pconst_value() const;
|
||||||
double get_psat_value() const;
|
double get_psat_value() const;
|
||||||
@ -67,8 +69,11 @@ public:
|
|||||||
uint16_t get_WN_ISM() const;
|
uint16_t get_WN_ISM() const;
|
||||||
uint16_t get_t0_ISM() const;
|
uint16_t get_t0_ISM() const;
|
||||||
uint16_t get_Tvalidity_hours() const;
|
uint16_t get_Tvalidity_hours() const;
|
||||||
|
uint32_t compute_crc(const std::vector<uint8_t>& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
boost::crc_basic<32> crc32_ism;
|
||||||
|
|
||||||
// ICD 2.1 Table 97
|
// ICD 2.1 Table 97
|
||||||
std::unordered_map<uint8_t, double> ISM_PCONST_MAP = {
|
std::unordered_map<uint8_t, double> ISM_PCONST_MAP = {
|
||||||
{0, 1.0e-8},
|
{0, 1.0e-8},
|
||||||
@ -145,7 +150,6 @@ private:
|
|||||||
{14, 3.75},
|
{14, 3.75},
|
||||||
{15, 4.00}};
|
{15, 4.00}};
|
||||||
|
|
||||||
|
|
||||||
// ICD 2.1 Table 101
|
// ICD 2.1 Table 101
|
||||||
std::unordered_map<uint8_t, float> ISM_BNOM_MAP = {
|
std::unordered_map<uint8_t, float> ISM_BNOM_MAP = {
|
||||||
{0, 0.0},
|
{0, 0.0},
|
||||||
@ -165,7 +169,6 @@ private:
|
|||||||
{14, 2.0},
|
{14, 2.0},
|
||||||
{15, 2.4}};
|
{15, 2.4}};
|
||||||
|
|
||||||
|
|
||||||
// ICD 2.1 Table 102
|
// ICD 2.1 Table 102
|
||||||
std::unordered_map<uint8_t, uint16_t> ISM_TVALIDITY_MAP = {
|
std::unordered_map<uint8_t, uint16_t> ISM_TVALIDITY_MAP = {
|
||||||
{0, 1},
|
{0, 1},
|
||||||
|
43
src/tests/unit-tests/system-parameters/galileo_ism_test.cc
Normal file
43
src/tests/unit-tests/system-parameters/galileo_ism_test.cc
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*!
|
||||||
|
* \file galileo_ism_test.cc
|
||||||
|
* \brief Tests for Galileo Integrity Support Message
|
||||||
|
* \author Carles Fernandez-Prades, 2024. cfernandez(at)cttc.es
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
||||||
|
* This file is part of GNSS-SDR.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*
|
||||||
|
* -----------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "galileo_ism.h"
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <bitset>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
TEST(GalileoISMTest, CRC)
|
||||||
|
{
|
||||||
|
Galileo_ISM gal_ism{};
|
||||||
|
uint32_t expected_crc = 3002390191;
|
||||||
|
std::bitset<96> input{"010110000010101010101010101010101010101010101010101010101010101010101010101010101010101010101010"};
|
||||||
|
std::vector<uint8_t> data_bytes;
|
||||||
|
for (size_t i = 0; i < input.size(); i += 8)
|
||||||
|
{
|
||||||
|
std::bitset<8> byte;
|
||||||
|
for (size_t j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
byte[j] = input[i + j];
|
||||||
|
}
|
||||||
|
data_bytes.push_back(static_cast<uint8_t>(byte.to_ulong()));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::reverse(data_bytes.begin(), data_bytes.end());
|
||||||
|
auto computed_crc = gal_ism.compute_crc(data_bytes);
|
||||||
|
EXPECT_TRUE(computed_crc == expected_crc);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user