Add CRC check success rate reporting to all telemetry decoders

Added as std::unique_ptr to minimize memory footprint if not used
C++ logic operators translated to && and ||
This commit is contained in:
Carles Fernandez 2021-09-13 23:19:37 +02:00
parent 69db42f3ee
commit c3fe1bcc79
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
18 changed files with 280 additions and 51 deletions

View File

@ -23,6 +23,17 @@ All notable changes to GNSS-SDR will be documented in this file.
the configuration file. Format described in the `nav_message.proto` file. A
simple listener application written in C++ is included in
`src/utils/nav-listener` as a example.
- Extract successful rate of the CRC check in the decoding of navigation
messages. This can be enbled by setting
`TelemetryDecoder_XX.dump_crc_stats=true` and, optionally,
`TelemetryDecoder_XX.dump_crc_stats_filename=./crc_stats` in the configuration
file. At the end of the processing (or exiting with `q` + `[Enter]`), the CRC
check success rate will be reported in a file.
See the definitions of concepts and metrics at
https://gnss-sdr.org/design-forces/
 
## [GNSS-SDR v0.0.15](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.15) - 2021-08-23

View File

@ -72,6 +72,11 @@ target_include_directories(telemetry_decoder_gr_blocks
${CMAKE_SOURCE_DIR}/src/core/interfaces
)
target_include_directories(telemetry_decoder_gr_blocks
PRIVATE
${CMAKE_SOURCE_DIR}/src/algorithms/libs # for gnss_sdr_make_unique.h
)
if(has_rotl)
target_compile_definitions(telemetry_decoder_gr_blocks
PRIVATE -DCOMPILER_HAS_ROTL=1

View File

@ -23,6 +23,7 @@
#include "beidou_dnav_iono.h"
#include "beidou_dnav_utc_model.h"
#include "display.h"
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "gnss_synchro.h"
#include "tlm_utils.h"
#include <glog/logging.h>
@ -109,6 +110,18 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
d_flag_preamble = false;
d_channel = 0;
flag_SOW_set = false;
d_dump_crc_stats = conf.dump_crc_stats;
d_dump_crc_stats = conf.dump_crc_stats;
if (d_dump_crc_stats)
{
// initialize the telemetry CRC statistics class
d_Tlm_CRC_Stats = std::make_unique<Tlm_CRC_Stats>();
d_Tlm_CRC_Stats->initialize(conf.dump_crc_stats_filename);
}
else
{
d_Tlm_CRC_Stats = nullptr;
}
}
@ -178,7 +191,7 @@ void beidou_b1i_telemetry_decoder_gs::decode_bch15_11_01(const int32_t *bits, st
err = reg[0] + reg[1] * 2 + reg[2] * 4 + reg[3] * 8;
if (err > 0 and err < 16)
if (err > 0 && err < 16)
{
decbits[errind[err - 1]] *= -1;
}
@ -254,7 +267,7 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols)
d_nav_msg_packet.nav_message = data_bits;
}
if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6)
if (d_satellite.get_PRN() > 0 && d_satellite.get_PRN() < 6)
{
d_nav.d2_subframe_decoder(data_bits);
}
@ -264,7 +277,8 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols)
}
// 3. Check operation executed correctly
if (d_nav.get_flag_CRC_test() == true)
bool crc_ok = d_nav.get_flag_CRC_test();
if (crc_ok)
{
DLOG(INFO) << "BeiDou DNAV CRC correct in channel " << d_channel
<< " from satellite " << d_satellite;
@ -274,6 +288,11 @@ void beidou_b1i_telemetry_decoder_gs::decode_subframe(float *frame_symbols)
DLOG(INFO) << "BeiDou DNAV CRC error in channel " << d_channel
<< " from satellite " << d_satellite;
}
if (d_dump_crc_stats)
{
// update CRC statistics
d_Tlm_CRC_Stats->update_CRC_stats(crc_ok);
}
// 4. Push the new navigation data to the queues
if (d_nav.have_new_ephemeris() == true)
{
@ -323,7 +342,7 @@ void beidou_b1i_telemetry_decoder_gs::set_satellite(const Gnss_Satellite &satell
d_nav.set_signal_type(1); // BDS: data source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q)
// Update tel dec parameters for D2 NAV Messages
if (sat_prn > 0 and sat_prn < 6)
if (sat_prn > 0 && sat_prn < 6)
{
d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
@ -396,6 +415,12 @@ void beidou_b1i_telemetry_decoder_gs::set_channel(int32_t channel)
}
}
}
if (d_dump_crc_stats)
{
// set the channel number for the telemetry CRC statistics
// disable the telemetry CRC statistics if there is a problem opening the output file
d_dump_crc_stats = d_Tlm_CRC_Stats->set_channel(d_channel);
}
}
@ -570,7 +595,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
}
// UPDATE GNSS SYNCHRO DATA
// 2. Add the telemetry decoder information
if (this->d_flag_preamble == true and d_nav.get_flag_new_SOW_available() == true)
if (this->d_flag_preamble == true && d_nav.get_flag_new_SOW_available() == true)
// update TOW at the preamble instant
{
// Reporting sow as gps time of week
@ -582,7 +607,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
flag_SOW_set = true;
d_nav.set_flag_new_SOW_available(false);
if (last_d_TOW_at_current_symbol_ms != 0 and abs(static_cast<int64_t>(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms)) > static_cast<int64_t>(d_symbol_duration_ms))
if (last_d_TOW_at_current_symbol_ms != 0 && abs(static_cast<int64_t>(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms)) > static_cast<int64_t>(d_symbol_duration_ms))
{
LOG(INFO) << "Warning: BEIDOU B1I TOW update in ch " << d_channel
<< " does not match the TLM TOW counter " << static_cast<int64_t>(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms) << " ms \n";

View File

@ -25,12 +25,14 @@
#include "gnss_satellite.h"
#include "nav_message_packet.h"
#include "tlm_conf.h"
#include "tlm_crc_stats.h"
#include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <array>
#include <cstdint>
#include <fstream>
#include <memory> // for std::unique_ptr
#include <string>
/** \addtogroup Telemetry_Decoder
@ -89,6 +91,7 @@ private:
Beidou_Dnav_Navigation_Message d_nav;
Nav_Message_Packet d_nav_msg_packet;
std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
// Satellite Information and logging capacity
Gnss_Satellite d_satellite;
@ -123,6 +126,7 @@ private:
bool d_dump_mat;
bool d_remove_dat;
bool d_enable_navdata_monitor;
bool d_dump_crc_stats;
};

View File

@ -22,6 +22,7 @@
#include "beidou_dnav_iono.h"
#include "beidou_dnav_utc_model.h"
#include "display.h"
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "gnss_synchro.h"
#include "tlm_utils.h"
#include <glog/logging.h>
@ -108,6 +109,17 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
d_flag_preamble = false;
d_channel = 0;
flag_SOW_set = false;
d_dump_crc_stats = conf.dump_crc_stats;
if (d_dump_crc_stats)
{
// initialize the telemetry CRC statistics class
d_Tlm_CRC_Stats = std::make_unique<Tlm_CRC_Stats>();
d_Tlm_CRC_Stats->initialize(conf.dump_crc_stats_filename);
}
else
{
d_Tlm_CRC_Stats = nullptr;
}
}
@ -178,7 +190,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_bch15_11_01(const int32_t *bits,
err = reg[0] + reg[1] * 2 + reg[2] * 4 + reg[3] * 8;
if (err > 0 and err < 16)
if (err > 0 && err < 16)
{
decbits[errind[err - 1]] *= -1;
}
@ -254,7 +266,7 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols)
d_nav_msg_packet.nav_message = data_bits;
}
if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6)
if (d_satellite.get_PRN() > 0 && d_satellite.get_PRN() < 6)
{
d_nav.d2_subframe_decoder(data_bits);
}
@ -264,7 +276,8 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols)
}
// 3. Check operation executed correctly
if (d_nav.get_flag_CRC_test() == true)
bool crc_ok = d_nav.get_flag_CRC_test();
if (crc_ok)
{
DLOG(INFO) << "BeiDou DNAV CRC correct in channel " << d_channel
<< " from satellite " << d_satellite;
@ -274,6 +287,11 @@ void beidou_b3i_telemetry_decoder_gs::decode_subframe(float *frame_symbols)
DLOG(INFO) << "BeiDou DNAV CRC error in channel " << d_channel
<< " from satellite " << d_satellite;
}
if (d_dump_crc_stats)
{
// update CRC statistics
d_Tlm_CRC_Stats->update_CRC_stats(crc_ok);
}
// 4. Push the new navigation data to the queues
if (d_nav.have_new_ephemeris() == true)
{
@ -340,7 +358,7 @@ void beidou_b3i_telemetry_decoder_gs::set_satellite(
d_nav.set_signal_type(5); // BDS: data source (0:unknown,1:B1I,2:B1Q,3:B2I,4:B2Q,5:B3I,6:B3Q)
// Update tel dec parameters for D2 NAV Messages
if (sat_prn > 0 and sat_prn < 6)
if (sat_prn > 0 && sat_prn < 6)
{
d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
@ -416,6 +434,12 @@ void beidou_b3i_telemetry_decoder_gs::set_channel(int32_t channel)
}
}
}
if (d_dump_crc_stats)
{
// set the channel number for the telemetry CRC statistics
// disable the telemetry CRC statistics if there is a problem opening the output file
d_dump_crc_stats = d_Tlm_CRC_Stats->set_channel(d_channel);
}
}
@ -599,7 +623,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work(
}
// UPDATE GNSS SYNCHRO DATA
// 2. Add the telemetry decoder information
if (this->d_flag_preamble == true and d_nav.get_flag_new_SOW_available() == true)
if (this->d_flag_preamble == true && d_nav.get_flag_new_SOW_available() == true)
// update TOW at the preamble instant
{
// Reporting sow as gps time of week
@ -611,7 +635,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work(
flag_SOW_set = true;
d_nav.set_flag_new_SOW_available(false);
if (last_d_TOW_at_current_symbol_ms != 0 and abs(static_cast<int64_t>(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms)) > static_cast<int64_t>(d_symbol_duration_ms))
if (last_d_TOW_at_current_symbol_ms != 0 && abs(static_cast<int64_t>(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms)) > static_cast<int64_t>(d_symbol_duration_ms))
{
LOG(INFO) << "Warning: BEIDOU B3I TOW update in ch " << d_channel
<< " does not match the TLM TOW counter " << static_cast<int64_t>(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms) << " ms \n";

View File

@ -22,12 +22,14 @@
#include "gnss_satellite.h"
#include "nav_message_packet.h"
#include "tlm_conf.h"
#include "tlm_crc_stats.h"
#include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <array>
#include <cstdint>
#include <fstream>
#include <memory> // for std::unique_ptr
#include <string>
@ -85,10 +87,10 @@ private:
// Navigation Message variable
Beidou_Dnav_Navigation_Message d_nav;
Gnss_Satellite d_satellite;
Nav_Message_Packet d_nav_msg_packet;
Gnss_Satellite d_satellite;
std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
std::string d_dump_filename;
std::ofstream d_dump_file;
@ -120,6 +122,7 @@ private:
bool d_dump_mat;
bool d_remove_dat;
bool d_enable_navdata_monitor;
bool d_dump_crc_stats;
};

View File

@ -29,6 +29,7 @@
#include "galileo_has_page.h" // For Galileo_HAS_page
#include "galileo_iono.h" // for Galileo_Iono
#include "galileo_utc_model.h" // for Galileo_Utc_Model
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "gnss_synchro.h"
#include "tlm_crc_stats.h"
#include "tlm_utils.h"
@ -91,7 +92,12 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
if (d_dump_crc_stats)
{
// initialize the telemetry CRC statistics class
d_Tlm_CRC_Stats.initialize(conf.dump_crc_stats_filename);
d_Tlm_CRC_Stats = std::make_unique<Tlm_CRC_Stats>();
d_Tlm_CRC_Stats->initialize(conf.dump_crc_stats_filename);
}
else
{
d_Tlm_CRC_Stats = nullptr;
}
switch (d_frame_type)
{
@ -643,7 +649,7 @@ void galileo_telemetry_decoder_gs::set_channel(int32_t channel)
{
// set the channel number for the telemetry CRC statistics
// disable the telemetry CRC statistics if there is a problem opening the output file
d_dump_crc_stats = d_Tlm_CRC_Stats.set_channel(d_channel);
d_dump_crc_stats = d_Tlm_CRC_Stats->set_channel(d_channel);
}
}
@ -816,15 +822,15 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
return -1;
break;
}
bool crc_ok = (d_inav_nav.get_flag_CRC_test() || d_fnav_nav.get_flag_CRC_test() || d_cnav_nav.get_flag_CRC_test());
if (d_dump_crc_stats)
{
// update CRC statistics
d_Tlm_CRC_Stats.update_CRC_stats(d_inav_nav.get_flag_CRC_test() or d_fnav_nav.get_flag_CRC_test() or d_cnav_nav.get_flag_CRC_test());
d_Tlm_CRC_Stats->update_CRC_stats(crc_ok);
}
d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P)
if (d_inav_nav.get_flag_CRC_test() == true or d_fnav_nav.get_flag_CRC_test() == true or d_cnav_nav.get_flag_CRC_test() == true)
if (crc_ok)
{
d_CRC_error_counter = 0;
d_flag_preamble = true; // valid preamble indicator (initialized to false every work())
@ -839,7 +845,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
else
{
d_CRC_error_counter++;
if ((d_CRC_error_counter > CRC_ERROR_LIMIT) and (d_frame_type != 3))
if ((d_CRC_error_counter > CRC_ERROR_LIMIT) && (d_frame_type != 3))
{
DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite;
gr::thread::scoped_lock lock(d_setlock);
@ -1024,7 +1030,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
}
if (d_inav_nav.get_flag_TOW_set() == true or d_fnav_nav.get_flag_TOW_set() == true or d_cnav_nav.get_flag_CRC_test() == true)
if (d_inav_nav.get_flag_TOW_set() == true || d_fnav_nav.get_flag_TOW_set() == true || d_cnav_nav.get_flag_CRC_test() == true)
{
current_symbol.TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms;
// todo: Galileo to GPS time conversion should be moved to observable block.

View File

@ -33,6 +33,7 @@
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <cstdint>
#include <fstream>
#include <memory> // for std::unique_ptr
#include <string>
#include <vector>
@ -107,11 +108,8 @@ private:
Galileo_Inav_Message d_inav_nav;
Galileo_Fnav_Message d_fnav_nav;
// CRC statistics
bool d_dump_crc_stats;
Tlm_CRC_Stats d_Tlm_CRC_Stats;
Nav_Message_Packet d_nav_msg_packet;
std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
double d_delta_t; // GPS-GALILEO time offset
@ -151,6 +149,7 @@ private:
bool d_cnav_dummy_page;
bool d_print_cnav_page;
bool d_enable_navdata_monitor;
bool d_dump_crc_stats;
};

View File

@ -20,6 +20,7 @@
#include "glonass_gnav_almanac.h"
#include "glonass_gnav_ephemeris.h"
#include "glonass_gnav_utc_model.h"
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "tlm_utils.h"
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
@ -101,6 +102,18 @@ glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs(
d_channel = 0;
flag_TOW_set = false;
d_preamble_time_samples = 0;
d_dump_crc_stats = conf.dump_crc_stats;
if (d_dump_crc_stats)
{
// initialize the telemetry CRC statistics class
d_Tlm_CRC_Stats = std::make_unique<Tlm_CRC_Stats>();
d_Tlm_CRC_Stats->initialize(conf.dump_crc_stats_filename);
}
else
{
d_Tlm_CRC_Stats = nullptr;
}
}
@ -204,7 +217,8 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo
d_nav.string_decoder(data_bits);
// 3. Check operation executed correctly
if (d_nav.get_flag_CRC_test() == true)
bool crc_ok = d_nav.get_flag_CRC_test();
if (crc_ok)
{
LOG(INFO) << "GLONASS GNAV CRC correct in channel " << d_channel << " from satellite " << d_satellite;
}
@ -212,6 +226,12 @@ void glonass_l1_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo
{
LOG(INFO) << "GLONASS GNAV CRC error in channel " << d_channel << " from satellite " << d_satellite;
}
if (d_dump_crc_stats)
{
// update CRC statistics
d_Tlm_CRC_Stats->update_CRC_stats(crc_ok);
}
// 4. Push the new navigation data to the queues
if (d_nav.have_new_ephemeris() == true)
{
@ -281,6 +301,12 @@ void glonass_l1_ca_telemetry_decoder_gs::set_channel(int32_t channel)
}
}
}
if (d_dump_crc_stats)
{
// set the channel number for the telemetry CRC statistics
// disable the telemetry CRC statistics if there is a problem opening the output file
d_dump_crc_stats = d_Tlm_CRC_Stats->set_channel(d_channel);
}
}
@ -381,7 +407,8 @@ int glonass_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
// call the decoder
decode_string(string_symbols.data(), string_length);
if (d_nav.get_flag_CRC_test() == true)
bool crc_ok = d_nav.get_flag_CRC_test();
if (crc_ok == true)
{
d_CRC_error_counter = 0;
d_flag_preamble = true; // valid preamble indicator (initialized to false every work())
@ -409,7 +436,7 @@ int glonass_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
// UPDATE GNSS SYNCHRO DATA
// 2. Add the telemetry decoder information
if (this->d_flag_preamble == true and d_nav.get_flag_TOW_new() == true)
if (this->d_flag_preamble == true && d_nav.get_flag_TOW_new() == true)
// update TOW at the preamble instant
{
d_TOW_at_current_symbol = floor((d_nav.get_ephemeris().d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S) * 1000) / 1000;
@ -420,9 +447,9 @@ int glonass_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
d_TOW_at_current_symbol = d_TOW_at_current_symbol + GLONASS_L1_CA_CODE_PERIOD_S;
}
// if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.get_flag_CRC_test() == true)
// if (d_flag_frame_sync == true && d_nav.flag_TOW_set==true && d_nav.get_flag_CRC_test() == true)
// if(d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) // all GGTO parameters arrived
// if(d_nav.flag_GGTO_1 == true && d_nav.flag_GGTO_2 == true && d_nav.flag_GGTO_3 == true && d_nav.flag_GGTO_4 == true) // all GGTO parameters arrived
// {
// delta_t = d_nav.A_0G + d_nav.A_1G * (d_TOW_at_current_symbol - d_nav.t_0G + 604800.0 * (fmod((d_nav.WN_0 - d_nav.WN_0G), 64)));
// }
@ -430,7 +457,7 @@ int glonass_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
current_symbol.PRN = this->d_satellite.get_PRN();
current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0);
if (d_flag_frame_sync == true and d_nav.is_flag_TOW_set() == true)
if (d_flag_frame_sync == true && d_nav.is_flag_TOW_set() == true)
{
current_symbol.Flag_valid_word = true;
if (d_enable_navdata_monitor && !d_nav_msg_packet.nav_message.empty())

View File

@ -26,12 +26,14 @@
#include "gnss_synchro.h"
#include "nav_message_packet.h"
#include "tlm_conf.h"
#include "tlm_crc_stats.h"
#include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <array>
#include <cstdint>
#include <fstream> // for ofstream
#include <memory> // for std::unique_ptr
#include <string>
/** \addtogroup Telemetry_Decoder
@ -94,10 +96,11 @@ private:
// Navigation Message variable
Glonass_Gnav_Navigation_Message d_nav;
Nav_Message_Packet d_nav_msg_packet;
Gnss_Satellite d_satellite;
Nav_Message_Packet d_nav_msg_packet;
std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
std::string d_dump_filename;
std::ofstream d_dump_file;
@ -122,6 +125,7 @@ private:
bool d_dump_mat;
bool d_remove_dat;
bool d_enable_navdata_monitor;
bool d_dump_crc_stats;
};

View File

@ -20,6 +20,7 @@
#include "glonass_gnav_almanac.h"
#include "glonass_gnav_ephemeris.h"
#include "glonass_gnav_utc_model.h"
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "tlm_utils.h"
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
@ -101,6 +102,18 @@ glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
d_channel = 0;
flag_TOW_set = false;
d_preamble_time_samples = 0;
d_dump_crc_stats = conf.dump_crc_stats;
if (d_dump_crc_stats)
{
// initialize the telemetry CRC statistics class
d_Tlm_CRC_Stats = std::make_unique<Tlm_CRC_Stats>();
d_Tlm_CRC_Stats->initialize(conf.dump_crc_stats_filename);
}
else
{
d_Tlm_CRC_Stats = nullptr;
}
}
@ -204,7 +217,8 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo
d_nav.string_decoder(data_bits);
// 3. Check operation executed correctly
if (d_nav.get_flag_CRC_test() == true)
bool crc_ok = d_nav.get_flag_CRC_test();
if (crc_ok)
{
LOG(INFO) << "GLONASS GNAV CRC correct in channel " << d_channel << " from satellite " << d_satellite;
}
@ -212,6 +226,12 @@ void glonass_l2_ca_telemetry_decoder_gs::decode_string(const double *frame_symbo
{
LOG(INFO) << "GLONASS GNAV CRC error in channel " << d_channel << " from satellite " << d_satellite;
}
if (d_dump_crc_stats)
{
// update CRC statistics
d_Tlm_CRC_Stats->update_CRC_stats(crc_ok);
}
// 4. Push the new navigation data to the queues
if (d_nav.have_new_ephemeris() == true)
{
@ -280,6 +300,12 @@ void glonass_l2_ca_telemetry_decoder_gs::set_channel(int32_t channel)
}
}
}
if (d_dump_crc_stats)
{
// set the channel number for the telemetry CRC statistics
// disable the telemetry CRC statistics if there is a problem opening the output file
d_dump_crc_stats = d_Tlm_CRC_Stats->set_channel(d_channel);
}
}
@ -408,7 +434,7 @@ int glonass_l2_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
// UPDATE GNSS SYNCHRO DATA
// 2. Add the telemetry decoder information
if (this->d_flag_preamble == true and d_nav.get_flag_TOW_new() == true)
if (this->d_flag_preamble == true && d_nav.get_flag_TOW_new() == true)
// update TOW at the preamble instant
{
d_TOW_at_current_symbol = floor((d_nav.get_ephemeris().d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S) * 1000) / 1000;
@ -419,9 +445,9 @@ int glonass_l2_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
d_TOW_at_current_symbol = d_TOW_at_current_symbol + GLONASS_L2_CA_CODE_PERIOD_S;
}
// if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.get_flag_CRC_test() == true)
// if (d_flag_frame_sync == true && d_nav.flag_TOW_set==true && d_nav.get_flag_CRC_test() == true)
// if(d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) // all GGTO parameters arrived
// if(d_nav.flag_GGTO_1 == true && d_nav.flag_GGTO_2 == true && d_nav.flag_GGTO_3 == true && d_nav.flag_GGTO_4 == true) // all GGTO parameters arrived
// {
// delta_t = d_nav.A_0G + d_nav.A_1G * (d_TOW_at_current_symbol - d_nav.t_0G + 604800.0 * (fmod((d_nav.WN_0 - d_nav.WN_0G), 64)));
// }
@ -429,10 +455,10 @@ int glonass_l2_ca_telemetry_decoder_gs::general_work(int noutput_items __attribu
current_symbol.PRN = this->d_satellite.get_PRN();
current_symbol.TOW_at_current_symbol_ms = round(d_TOW_at_current_symbol * 1000.0);
if (d_flag_frame_sync == true and d_nav.is_flag_TOW_set() == true)
if (d_flag_frame_sync == true && d_nav.is_flag_TOW_set() == true)
{
current_symbol.Flag_valid_word = true;
if (d_flag_frame_sync == true and d_nav.is_flag_TOW_set() == true)
if (d_flag_frame_sync == true && d_nav.is_flag_TOW_set() == true)
{
current_symbol.Flag_valid_word = true;
if (d_enable_navdata_monitor && !d_nav_msg_packet.nav_message.empty())

View File

@ -25,12 +25,14 @@
#include "gnss_synchro.h"
#include "nav_message_packet.h"
#include "tlm_conf.h"
#include "tlm_crc_stats.h"
#include <boost/circular_buffer.hpp>
#include <gnuradio/block.h>
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <array>
#include <cstdint>
#include <fstream>
#include <memory> // for std::unique_ptr
#include <string>
/** \addtogroup Telemetry_Decoder
@ -88,10 +90,10 @@ private:
// Navigation Message variable
Glonass_Gnav_Navigation_Message d_nav;
Gnss_Satellite d_satellite;
Nav_Message_Packet d_nav_msg_packet;
Gnss_Satellite d_satellite;
std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
std::string d_dump_filename;
std::ofstream d_dump_file;
@ -116,6 +118,7 @@ private:
bool d_dump_mat;
bool d_remove_dat;
bool d_enable_navdata_monitor;
bool d_dump_crc_stats;
};

View File

@ -19,9 +19,10 @@
*/
#include "gps_l1_ca_telemetry_decoder_gs.h"
#include "gps_ephemeris.h" // for Gps_Ephemeris
#include "gps_iono.h" // for Gps_Iono
#include "gps_utc_model.h" // for Gps_Utc_Model
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "gps_ephemeris.h" // for Gps_Ephemeris
#include "gps_iono.h" // for Gps_Iono
#include "gps_utc_model.h" // for Gps_Utc_Model
#include "tlm_utils.h"
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
@ -128,6 +129,18 @@ gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
d_flag_PLL_180_deg_phase_locked = false;
d_prev_GPS_frame_4bytes = 0;
d_symbol_history.set_capacity(d_required_symbols);
d_dump_crc_stats = conf.dump_crc_stats;
if (d_dump_crc_stats)
{
// initialize the telemetry CRC statistics class
d_Tlm_CRC_Stats = std::make_unique<Tlm_CRC_Stats>();
d_Tlm_CRC_Stats->initialize(conf.dump_crc_stats_filename);
}
else
{
d_Tlm_CRC_Stats = nullptr;
}
}
@ -229,6 +242,12 @@ void gps_l1_ca_telemetry_decoder_gs::set_channel(int32_t channel)
}
}
}
if (d_dump_crc_stats)
{
// set the channel number for the telemetry CRC statistics
// disable the telemetry CRC statistics if there is a problem opening the output file
d_dump_crc_stats = d_Tlm_CRC_Stats->set_channel(d_channel);
}
}
@ -273,7 +292,13 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe()
GPS_frame_4bytes ^= 0x3FFFFFC0U; // invert the data bits (using XOR)
}
// check parity. If ANY word inside the subframe fails the parity, set subframe_synchro_confirmation = false
if (not gps_l1_ca_telemetry_decoder_gs::gps_word_parityCheck(GPS_frame_4bytes))
bool crc_ok = gps_l1_ca_telemetry_decoder_gs::gps_word_parityCheck(GPS_frame_4bytes);
if (d_dump_crc_stats)
{
// update CRC statistics
d_Tlm_CRC_Stats->update_CRC_stats(crc_ok);
}
if (!crc_ok)
{
subframe_synchro_confirmation = false;
}
@ -311,7 +336,7 @@ bool gps_l1_ca_telemetry_decoder_gs::decode_subframe()
d_nav_msg_packet.nav_message = subframe_bits.to_string();
}
const int32_t subframe_ID = d_nav.subframe_decoder(subframe.data()); // decode the subframe
if (subframe_ID > 0 and subframe_ID < 6)
if (subframe_ID > 0 && subframe_ID < 6)
{
std::cout << "New GPS NAV message received in channel " << this->d_channel << ": "
<< "subframe "
@ -398,7 +423,7 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__
consume_each(1);
d_flag_preamble = false;
// check if there is a problem with the telemetry of the current satellite
if (d_stat < 2 and d_sent_tlm_failed_msg == false)
if (d_stat < 2 && d_sent_tlm_failed_msg == false)
{
if ((d_sample_counter - d_last_valid_preamble) > d_max_symbols_without_valid_frame)
{

View File

@ -24,12 +24,14 @@
#include "gps_navigation_message.h"
#include "nav_message_packet.h"
#include "tlm_conf.h"
#include "tlm_crc_stats.h"
#include <boost/circular_buffer.hpp>
#include <gnuradio/block.h> // for block
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <array> // for array
#include <cstdint> // for int32_t
#include <fstream> // for ofstream
#include <memory> // for std::unique_ptr
#include <string> // for string
/** \addtogroup Telemetry_Decoder
@ -77,6 +79,7 @@ private:
Gps_Navigation_Message d_nav;
Gnss_Satellite d_satellite;
Nav_Message_Packet d_nav_msg_packet;
std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
std::array<int32_t, GPS_CA_PREAMBLE_LENGTH_BITS> d_preamble_samples{};
@ -113,6 +116,7 @@ private:
bool d_dump_mat;
bool d_remove_dat;
bool d_enable_navdata_monitor;
bool d_dump_crc_stats;
};

View File

@ -18,6 +18,7 @@
#include "gps_l2c_telemetry_decoder_gs.h"
#include "GPS_L2C.h" // for GPS_L2_CNAV_DATA_PAGE_BITS, GPS_L...
#include "display.h"
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "gnss_synchro.h"
#include "gps_cnav_ephemeris.h" // for Gps_CNAV_Ephemeris
#include "gps_cnav_iono.h" // for Gps_CNAV_Iono
@ -87,6 +88,18 @@ gps_l2c_telemetry_decoder_gs::gps_l2c_telemetry_decoder_gs(
d_sample_counter = 0;
d_flag_PLL_180_deg_phase_locked = false;
d_dump_crc_stats = conf.dump_crc_stats;
if (d_dump_crc_stats)
{
// initialize the telemetry CRC statistics class
d_Tlm_CRC_Stats = std::make_unique<Tlm_CRC_Stats>();
d_Tlm_CRC_Stats->initialize(conf.dump_crc_stats_filename);
}
else
{
d_Tlm_CRC_Stats = nullptr;
}
}
@ -158,6 +171,12 @@ void gps_l2c_telemetry_decoder_gs::set_channel(int channel)
}
}
}
if (d_dump_crc_stats)
{
// set the channel number for the telemetry CRC statistics
// disable the telemetry CRC statistics if there is a problem opening the output file
d_dump_crc_stats = d_Tlm_CRC_Stats->set_channel(d_channel);
}
}
@ -183,6 +202,13 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
// add the symbol to the decoder
const uint8_t symbol_clip = static_cast<uint8_t>(in[0].Prompt_I > 0) * 255;
flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay);
if (d_dump_crc_stats && (d_cnav_decoder.part1.message_lock || d_cnav_decoder.part2.message_lock))
{
// update CRC statistics
d_Tlm_CRC_Stats->update_CRC_stats((d_cnav_decoder.part1.crc_ok || d_cnav_decoder.part2.crc_ok));
d_cnav_decoder.part1.message_lock = false;
d_cnav_decoder.part2.message_lock = false;
}
consume_each(1); // one by one
@ -208,7 +234,7 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
// check if new CNAV frame is available
if (flag_new_cnav_frame == true)
{
if (d_cnav_decoder.part1.invert == true or d_cnav_decoder.part2.invert == true)
if (d_cnav_decoder.part1.invert == true || d_cnav_decoder.part2.invert == true)
{
d_flag_PLL_180_deg_phase_locked = true;
}

View File

@ -23,10 +23,12 @@
#include "gps_cnav_navigation_message.h"
#include "nav_message_packet.h"
#include "tlm_conf.h"
#include "tlm_crc_stats.h"
#include <gnuradio/block.h>
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <cstdint>
#include <fstream>
#include <memory> // for std::unique_ptr
#include <string>
extern "C"
@ -79,6 +81,7 @@ private:
Gps_CNAV_Navigation_Message d_CNAV_Message;
Nav_Message_Packet d_nav_msg_packet;
std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
std::string d_dump_filename;
std::ofstream d_dump_file;
@ -102,6 +105,7 @@ private:
bool d_dump_mat;
bool d_remove_dat;
bool d_enable_navdata_monitor;
bool d_dump_crc_stats;
};

View File

@ -17,6 +17,7 @@
#include "gps_l5_telemetry_decoder_gs.h"
#include "display.h"
#include "gnss_sdr_make_unique.h" // for std::make_unique in C++11
#include "gnss_synchro.h"
#include "gps_cnav_ephemeris.h"
#include "gps_cnav_iono.h"
@ -81,6 +82,18 @@ gps_l5_telemetry_decoder_gs::gps_l5_telemetry_decoder_gs(
d_sample_counter = 0;
d_flag_PLL_180_deg_phase_locked = false;
d_dump_crc_stats = conf.dump_crc_stats;
if (d_dump_crc_stats)
{
// initialize the telemetry CRC statistics class
d_Tlm_CRC_Stats = std::make_unique<Tlm_CRC_Stats>();
d_Tlm_CRC_Stats->initialize(conf.dump_crc_stats_filename);
}
else
{
d_Tlm_CRC_Stats = nullptr;
}
}
@ -154,6 +167,13 @@ void gps_l5_telemetry_decoder_gs::set_channel(int32_t channel)
}
}
}
if (d_dump_crc_stats)
{
// set the channel number for the telemetry CRC statistics
// disable the telemetry CRC statistics if there is a problem opening the output file
d_dump_crc_stats = d_Tlm_CRC_Stats->set_channel(d_channel);
}
}
@ -197,9 +217,18 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u
const auto symbol_clip = static_cast<uint8_t>(current_synchro_data.Prompt_Q > 0) * 255;
// 2. Add the telemetry decoder information
// check if new CNAV frame is available
if (cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay) == true)
bool new_page = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay);
if (d_dump_crc_stats && (d_cnav_decoder.part1.message_lock || d_cnav_decoder.part2.message_lock))
{
if (d_cnav_decoder.part1.invert == true or d_cnav_decoder.part2.invert == true)
// update CRC statistics
d_Tlm_CRC_Stats->update_CRC_stats((d_cnav_decoder.part1.crc_ok || d_cnav_decoder.part2.crc_ok));
d_cnav_decoder.part1.message_lock = false;
d_cnav_decoder.part2.message_lock = false;
}
if (new_page)
{
if (d_cnav_decoder.part1.invert == true || d_cnav_decoder.part2.invert == true)
{
d_flag_PLL_180_deg_phase_locked = true;
}
@ -254,7 +283,7 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u
// check TOW update consistency
const uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms;
d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5I_SYMBOL_PERIOD_MS;
if (last_d_TOW_at_current_symbol_ms != 0 and std::llabs(static_cast<int64_t>(d_TOW_at_current_symbol_ms) - static_cast<int64_t>(last_d_TOW_at_current_symbol_ms)) > static_cast<int64_t>(GPS_L5I_SYMBOL_PERIOD_MS))
if (last_d_TOW_at_current_symbol_ms != 0 && std::llabs(static_cast<int64_t>(d_TOW_at_current_symbol_ms) - static_cast<int64_t>(last_d_TOW_at_current_symbol_ms)) > static_cast<int64_t>(GPS_L5I_SYMBOL_PERIOD_MS))
{
DLOG(INFO) << "Warning: GPS L5 TOW update in ch " << d_channel
<< " does not match the TLM TOW counter " << static_cast<int64_t>(d_TOW_at_current_symbol_ms) - static_cast<int64_t>(last_d_TOW_at_current_symbol_ms) << " ms "

View File

@ -23,11 +23,13 @@
#include "gps_cnav_navigation_message.h" // for Gps_CNAV_Navigation_Message
#include "nav_message_packet.h"
#include "tlm_conf.h"
#include "tlm_crc_stats.h"
#include <boost/circular_buffer.hpp>
#include <gnuradio/block.h>
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <cstdint>
#include <fstream>
#include <memory> // for std::unique_ptr
#include <string>
extern "C"
@ -77,6 +79,7 @@ private:
Gps_CNAV_Navigation_Message d_CNAV_Message;
Nav_Message_Packet d_nav_msg_packet;
std::unique_ptr<Tlm_CRC_Stats> d_Tlm_CRC_Stats;
std::string d_dump_filename;
std::ofstream d_dump_file;
@ -97,6 +100,7 @@ private:
bool d_dump_mat;
bool d_remove_dat;
bool d_enable_navdata_monitor;
bool d_dump_crc_stats;
};