1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-31 11:19:18 +00:00

Prepare for boost::any to std::any transition

Replace private member d_sample_counter by the more accurate name of d_symbol_counter
Remove clauses in switch statements for code uniformity
Fix terminal color for Galileo E5b received almanac
This commit is contained in:
Carles Fernandez 2022-06-11 14:26:42 +02:00
parent 5ec7548886
commit 7317bf4f7f
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
3 changed files with 462 additions and 499 deletions

View File

@ -60,6 +60,7 @@ target_link_libraries(telemetry_decoder_gr_blocks
PRIVATE
Gflags::gflags
Glog::glog
Gnuradio::pmt
)
if(GNURADIO_USES_STD_POINTERS)

View File

@ -3,7 +3,7 @@
* \brief Implementation of a Galileo unified INAV and FNAV message demodulator
* block
* \author Javier Arribas 2018. jarribas(at)cttc.es
* \author Carles Fernandez, 2021. cfernandez(at)cttc.es
* \author Carles Fernandez, 2021-2022. cfernandez(at)cttc.es
*
*
* -----------------------------------------------------------------------------
@ -11,7 +11,7 @@
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
@ -77,7 +77,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))),
d_dump_filename(conf.dump_filename),
d_delta_t(0),
d_sample_counter(0ULL),
d_symbol_counter(0ULL),
d_preamble_index(0ULL),
d_last_valid_preamble(0ULL),
d_received_sample_counter(0),
@ -165,9 +165,8 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
switch (d_frame_type)
{
case 1: // INAV
{
d_PRN_code_period_ms = GALILEO_E1_CODE_PERIOD_MS; // for Galileo E5b is also 4 ms
d_bits_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS;
d_PRN_code_period_ms = GALILEO_E1_CODE_PERIOD_MS; // for Galileo E5b is also 4 ms
// set the preamble
d_samples_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS;
d_preamble_period_symbols = GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS;
@ -184,9 +183,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_inav_nav.enable_reed_solomon();
}
break;
}
case 2: // FNAV
{
d_PRN_code_period_ms = static_cast<uint32_t>(GALILEO_E5A_CODE_PERIOD_MS * GALILEO_E5A_I_SECONDARY_CODE_LENGTH);
d_bits_per_preamble = GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
// set the preamble
@ -200,9 +197,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_datalength = (d_codelength / nn) - d_mm;
d_max_symbols_without_valid_frame = GALILEO_FNAV_SYMBOLS_PER_PAGE * 5; // rise alarm 100 seconds without valid tlm
break;
}
case 3: // CNAV
{
d_PRN_code_period_ms = GALILEO_E6_CODE_PERIOD_MS;
d_bits_per_preamble = GALILEO_CNAV_PREAMBLE_LENGTH_BITS;
d_samples_per_preamble = GALILEO_CNAV_PREAMBLE_LENGTH_BITS;
@ -214,7 +209,6 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_datalength = (d_codelength / nn) - d_mm;
d_max_symbols_without_valid_frame = GALILEO_CNAV_SYMBOLS_PER_PAGE * 60;
break;
}
default:
d_bits_per_preamble = 0;
d_samples_per_preamble = 0;
@ -235,7 +229,6 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
switch (d_frame_type)
{
case 1: // INAV
{
if (GALILEO_INAV_PREAMBLE[i] == '1')
{
d_preamble_samples[i] = 1;
@ -245,9 +238,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_preamble_samples[i] = -1;
}
break;
}
case 2: // FNAV for E5a-I
{
if (GALILEO_FNAV_PREAMBLE[i] == '1')
{
d_preamble_samples[i] = 1;
@ -257,9 +248,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_preamble_samples[i] = -1;
}
break;
}
case 3: // CNAV for E6
{
if (GALILEO_CNAV_PREAMBLE[i] == '1')
{
d_preamble_samples[i] = 1;
@ -271,7 +260,6 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
break;
}
}
}
d_symbol_history.set_capacity(d_required_symbols + 1);
@ -476,6 +464,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in
}
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_inav_nav.have_new_utc_model() == true)
{
// get object for this SV (mandatory)
@ -492,6 +481,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in
d_delta_t = tmp_obj->A_0G + tmp_obj->A_1G * (static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0 - tmp_obj->t_0G + 604800 * (std::fmod(static_cast<float>(d_inav_nav.get_Galileo_week() - tmp_obj->WN_0G), 64.0)));
DLOG(INFO) << "delta_t=" << d_delta_t << "[s]";
}
if (d_inav_nav.have_new_almanac() == true)
{
const std::shared_ptr<Galileo_Almanac_Helper> tmp_obj = std::make_shared<Galileo_Almanac_Helper>(d_inav_nav.get_almanac());
@ -503,7 +493,7 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(float *page_part_symbols, in
}
else if (d_band == '7')
{
std::cout << "Galileo E5b I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << '\n';
std::cout << TEXT_BLUE << "Galileo E5b I/NAV almanac received in channel " << d_channel << " from satellite " << d_satellite << TEXT_RESET << '\n';
}
DLOG(INFO) << "Current parameters:";
DLOG(INFO) << "d_TOW_at_current_symbol_ms=" << d_TOW_at_current_symbol_ms;
@ -570,12 +560,14 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(float *page_symbols, int32_t
std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": ephemeris from satellite " << d_satellite << TEXT_RESET << '\n';
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_fnav_nav.have_new_iono_and_GST() == true)
{
const std::shared_ptr<Galileo_Iono> tmp_obj = std::make_shared<Galileo_Iono>(d_fnav_nav.get_iono());
std::cout << TEXT_MAGENTA << "New Galileo E5a F/NAV message received in channel " << d_channel << ": iono/GST model parameters from satellite " << d_satellite << TEXT_RESET << '\n';
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_fnav_nav.have_new_utc_model() == true)
{
const std::shared_ptr<Galileo_Utc_Model> tmp_obj = std::make_shared<Galileo_Utc_Model>(d_fnav_nav.get_utc_model());
@ -637,7 +629,6 @@ void galileo_telemetry_decoder_gs::decode_CNAV_word(uint64_t time_stamp, float *
if (is_page_dummy != d_cnav_dummy_page)
{
d_cnav_dummy_page = is_page_dummy;
std::cout << TEXT_MAGENTA << "Receiving Galileo E6 CNAV dummy pages in channel "
<< d_channel << " from satellite " << d_satellite
<< TEXT_RESET << '\n';
@ -668,7 +659,7 @@ void galileo_telemetry_decoder_gs::set_satellite(const Gnss_Satellite &satellite
{
gr::thread::scoped_lock lock(d_setlock);
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
d_last_valid_preamble = d_sample_counter;
d_last_valid_preamble = d_symbol_counter;
d_sent_tlm_failed_msg = false;
d_received_tow_ms = std::numeric_limits<uint32_t>::max();
d_E6_TOW_set = false;
@ -693,7 +684,7 @@ void galileo_telemetry_decoder_gs::reset()
d_fnav_nav.set_flag_TOW_set(false);
d_inav_nav.set_flag_TOW_set(false);
d_inav_nav.set_TOW0_flag(false);
d_last_valid_preamble = d_sample_counter;
d_last_valid_preamble = d_symbol_counter;
d_sent_tlm_failed_msg = false;
d_E6_TOW_set = false;
d_stat = 0;
@ -761,7 +752,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
// add new symbol to the symbol queue
d_symbol_history.push_back(current_symbol.Prompt_I);
d_sample_counter++; // count for the processed symbols
d_symbol_counter++; // counter for the processed symbols
// Time Tags from signal source (optional feature)
std::vector<gr::tag_t> tags_vec;
@ -774,7 +765,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
{
if (pmt::any_ref(it.value).type().hash_code() == typeid(const std::shared_ptr<GnssTime>).hash_code())
{
const auto timetag = boost::any_cast<const std::shared_ptr<GnssTime>>(pmt::any_ref(it.value));
const auto timetag = wht::any_cast<const std::shared_ptr<GnssTime>>(pmt::any_ref(it.value));
// std::cout << "Old tow: " << d_current_timetag.tow_ms << " new tow: " << timetag->tow_ms << "\n";
d_current_timetag = *timetag;
d_valid_timetag = true;
@ -784,7 +775,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
std::cout << "hash code not match\n";
}
}
catch (const boost::bad_any_cast &e)
catch (const wht::bad_any_cast &e)
{
std::cout << "msg Bad any_cast: " << e.what();
}
@ -812,7 +803,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
// check if there is a problem with the telemetry of the current satellite
if (d_sent_tlm_failed_msg == false)
{
if ((d_sample_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame)
if ((d_symbol_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame)
{
const int message = 1; // bad telemetry
DLOG(INFO) << "sent msg sat " << this->d_satellite;
@ -822,12 +813,11 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
// ******* frame sync ******************
int32_t corr_value = 0;
switch (d_stat)
{
case 0: // no preamble information
{
// correlate with preamble
int32_t corr_value = 0;
if (d_symbol_history.size() > d_required_symbols)
{
// ******* preamble correlation ********
@ -844,18 +834,14 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
if (std::abs(corr_value) >= d_samples_per_preamble)
{
d_preamble_index = d_sample_counter; // record the preamble sample stamp
d_preamble_index = d_symbol_counter; // record the preamble sample stamp
LOG(INFO) << "Preamble detection for Galileo satellite " << this->d_satellite << " in channel " << this->d_channel;
d_stat = 1; // enter into frame pre-detection status
}
}
break;
}
case 1: // possible preamble lock
{
// correlate with preamble
int32_t corr_value = 0;
if (d_symbol_history.size() > d_required_symbols)
{
// ******* preamble correlation ********
@ -873,12 +859,12 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
if (std::abs(corr_value) >= d_samples_per_preamble)
{
// check preamble separation
const auto preamble_diff = static_cast<int32_t>(d_sample_counter - d_preamble_index);
const auto preamble_diff = static_cast<int32_t>(d_symbol_counter - d_preamble_index);
if (std::abs(preamble_diff - d_preamble_period_symbols) == 0)
{
// try to decode frame
DLOG(INFO) << "Starting page decoder for Galileo satellite " << this->d_satellite;
d_preamble_index = d_sample_counter; // record the preamble sample stamp
d_preamble_index = d_symbol_counter; // record the preamble sample stamp
d_CRC_error_counter = 0;
if (corr_value < 0)
{
@ -900,10 +886,8 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
}
break;
}
case 2: // preamble acquired
{
if (d_sample_counter == d_preamble_index + static_cast<uint64_t>(d_preamble_period_symbols))
if (d_symbol_counter == d_preamble_index + static_cast<uint64_t>(d_preamble_period_symbols))
{
// call the decoder
// NEW Galileo page part is received
@ -944,13 +928,13 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
d_Tlm_CRC_Stats->update_CRC_stats(crc_ok);
}
d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P)
d_preamble_index = d_symbol_counter; // record the preamble sample stamp (t_P)
if (crc_ok)
{
d_CRC_error_counter = 0;
d_flag_preamble = true; // valid preamble indicator (initialized to false every work())
gr::thread::scoped_lock lock(d_setlock);
d_last_valid_preamble = d_sample_counter;
d_last_valid_preamble = d_symbol_counter;
if (!d_flag_frame_sync)
{
d_flag_frame_sync = true;
@ -983,7 +967,6 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
break;
}
}
// UPDATE GNSS SYNCHRO DATA
// 2. Add the telemetry decoder information
@ -993,7 +976,6 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
switch (d_frame_type)
{
case 1: // INAV
{
if (d_inav_nav.get_flag_TOW_set() == true)
{
if (d_inav_nav.is_TOW5_set() == true) // page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec)
@ -1089,9 +1071,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
d_nav_msg_packet.nav_message = "";
}
break;
}
case 2: // FNAV
{
if (d_fnav_nav.get_flag_TOW_set() == true)
{
if (d_fnav_nav.is_TOW1_set() == true)
@ -1158,9 +1138,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
d_nav_msg_packet.nav_message = "";
}
break;
}
case 3: // CNAV
{
if (d_valid_timetag == true)
{
int rx_tow_at_preamble = d_current_timetag.tow_ms;
@ -1174,7 +1152,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
d_E6_TOW_set = true;
}
}
if (!d_valid_timetag)
else
{
if (d_received_tow_ms < 604800000)
{
@ -1185,7 +1163,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
d_E6_TOW_set = true;
}
}
if (d_E6_TOW_set && d_enable_navdata_monitor && !d_nav_msg_packet.nav_message.empty())
if (d_enable_navdata_monitor && d_E6_TOW_set && !d_nav_msg_packet.nav_message.empty())
{
d_nav_msg_packet.system = std::string(1, current_symbol.System);
d_nav_msg_packet.signal = std::string(current_symbol.Signal);
@ -1197,29 +1175,23 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
}
}
}
else // if there is not a new preamble, we define the TOW of the current symbol
{
switch (d_frame_type)
{
case 1: // INAV
{
if (d_inav_nav.get_flag_TOW_set() == true)
{
d_TOW_at_current_symbol_ms += d_PRN_code_period_ms;
}
break;
}
case 2: // FNAV
{
if (d_fnav_nav.get_flag_TOW_set() == true)
{
d_TOW_at_current_symbol_ms += d_PRN_code_period_ms;
}
break;
}
case 3: // CNAV
{
if (d_E6_TOW_set == true)
{
d_TOW_at_current_symbol_ms += d_PRN_code_period_ms;
@ -1227,41 +1199,32 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
break;
}
}
}
switch (d_frame_type)
{
case 1: // INAV
{
if (d_inav_nav.get_flag_TOW_set() == true)
{
if (d_inav_nav.get_flag_GGTO() == true) // all GGTO parameters arrived
{
d_delta_t = d_inav_nav.get_A0G() + d_inav_nav.get_A1G() * (static_cast<double>(d_TOW_at_current_symbol_ms) / 1000.0 - d_inav_nav.get_t0G() + 604800.0 * (std::fmod(static_cast<float>(d_inav_nav.get_Galileo_week() - d_inav_nav.get_WN0G()), 64.0)));
}
current_symbol.Flag_valid_word = true;
}
break;
}
case 2: // FNAV
{
if (d_fnav_nav.get_flag_TOW_set() == true)
{
current_symbol.Flag_valid_word = true;
}
break;
}
case 3: // CNAV
{
if (d_E6_TOW_set == true)
{
current_symbol.Flag_valid_word = true;
}
break;
}
}
if (current_symbol.Flag_valid_word == true)
{

View File

@ -3,7 +3,7 @@
* \brief Implementation of a Galileo unified INAV and FNAV message demodulator
* block
* \author Javier Arribas 2018. jarribas(at)cttc.es
* \author Carles Fernandez, 2021. cfernandez(at)cttc.es
* \author Carles Fernandez, 2021-2022. cfernandez(at)cttc.es
*
*
* -----------------------------------------------------------------------------
@ -11,7 +11,7 @@
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
* Copyright (C) 2010-2022 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
@ -72,7 +72,6 @@ public:
int general_work(int noutput_items, gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override;
private:
friend galileo_telemetry_decoder_gs_sptr galileo_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite,
@ -110,7 +109,7 @@ private:
double d_delta_t; // GPS-GALILEO time offset
uint64_t d_sample_counter;
uint64_t d_symbol_counter;
uint64_t d_preamble_index;
uint64_t d_last_valid_preamble;
uint64_t d_received_sample_counter;