1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-14 09:16:51 +00:00

Modernize code

Automatize memory management
De-clutter clan-tidy warnings by fixing obvious issues
This commit is contained in:
Carles Fernandez 2019-07-19 18:23:36 +02:00
parent 7fa7f5f6dc
commit 0ddb063784
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
36 changed files with 288 additions and 419 deletions

View File

@ -40,9 +40,9 @@
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <array>
#include <exception>
#include <sstream>
#include <utility>
galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make_acquisition_caf_cc(
@ -310,9 +310,8 @@ void galileo_e5a_noncoherentIQ_acquisition_caf_cc::init()
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = GALILEO_TWO_PI * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size);
std::array<float, 1> _phase{};
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase.data(), d_fft_size);
}
/* CAF Filtering to resolve doppler ambiguity. Phase and quadrature must be processed

View File

@ -34,9 +34,9 @@
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <array>
#include <exception>
#include <sstream>
#include <utility>
galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc(
@ -192,9 +192,8 @@ void galileo_pcps_8ms_acquisition_cc::init()
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
int32_t doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = static_cast<float>(GALILEO_TWO_PI) * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size);
std::array<float, 1> _phase{};
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase.data(), d_fft_size);
}
}
@ -358,7 +357,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items,
std::streamsize n = 2 * sizeof(float) * (d_fft_size); // complex file write
filename.str("");
filename << "../data/test_statistics_" << d_gnss_synchro->System
<< "_" << d_gnss_synchro->Signal << "_sat_"
<< "_" << d_gnss_synchro->Signal[0] << d_gnss_synchro->Signal[1] << "_sat_"
<< d_gnss_synchro->PRN << "_doppler_" << doppler << ".dat";
d_dump_file.open(filename.str().c_str(), std::ios::out | std::ios::binary);
d_dump_file.write(reinterpret_cast<char *>(d_ifft->get_outbuf()), n); //write directly |abs(x)|^2 in this Doppler bin?

View File

@ -284,9 +284,8 @@ void pcps_acquisition::update_local_carrier(gsl::span<gr_complex> carrier_vector
{
phase_step_rad = GPS_TWO_PI * freq / static_cast<float>(acq_parameters.fs_in);
}
float _phase[1];
_phase[0] = 0.0;
volk_gnsssdr_s32f_sincos_32fc(carrier_vector.data(), -phase_step_rad, _phase, carrier_vector.length());
std::array<float, 1> _phase{};
volk_gnsssdr_s32f_sincos_32fc(carrier_vector.data(), -phase_step_rad, _phase.data(), carrier_vector.length());
}

View File

@ -158,11 +158,11 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con
unsigned int pcps_acquisition_fine_doppler_cc::nextPowerOf2(unsigned int n)
{
n--;
n |= n >> 1;
n |= n >> 2;
n |= n >> 4;
n |= n >> 8;
n |= n >> 16;
n |= n >> 1U;
n |= n >> 2U;
n |= n >> 4U;
n |= n >> 8U;
n |= n >> 16U;
n++;
return n;
}

View File

@ -38,6 +38,7 @@
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <array>
#include <exception>
#include <sstream>
#include <utility>
@ -233,9 +234,8 @@ void pcps_assisted_acquisition_cc::redefine_grid()
// doppler search steps
// compute the carrier doppler wipe-off signal and store it
phase_step_rad = static_cast<float>(GPS_TWO_PI) * doppler_hz / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase, d_fft_size);
std::array<float, 1> _phase{};
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index].data(), -phase_step_rad, _phase.data(), d_fft_size);
}
}

View File

@ -206,9 +206,8 @@ void pcps_cccwsr_acquisition_cc::init()
int32_t doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = GPS_TWO_PI * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size);
std::array<float, 1> _phase{};
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase.data(), d_fft_size);
}
}

View File

@ -57,11 +57,11 @@
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm>
#include <array>
#include <exception>
#include <fstream>
#include <iostream>
#include <sstream>
#include <utility>
pcps_opencl_acquisition_cc_sptr pcps_make_opencl_acquisition_cc(
@ -324,9 +324,8 @@ void pcps_opencl_acquisition_cc::init()
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = static_cast<float>(GPS_TWO_PI) * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size);
std::array<float, 1> _phase{};
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase.data(), d_fft_size);
if (d_opencl == 0)
{

View File

@ -38,7 +38,6 @@
#include <cmath>
#include <exception>
#include <sstream>
#include <utility>
pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc(
@ -235,9 +234,8 @@ void pcps_quicksync_acquisition_cc::init()
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
int32_t doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = GPS_TWO_PI * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_samples_per_code * d_folding_factor);
std::array<float, 1> _phase{};
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase.data(), d_samples_per_code * d_folding_factor);
}
// DLOG(INFO) << "end init";
}

View File

@ -54,9 +54,9 @@
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <array>
#include <exception>
#include <sstream>
#include <utility>
pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc(
@ -211,9 +211,8 @@ void pcps_tong_acquisition_cc::init()
int32_t doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = GPS_TWO_PI * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase, d_fft_size);
std::array<float, 1> _phase{};
volk_gnsssdr_s32f_sincos_32fc(d_grid_doppler_wipeoffs[doppler_index], -phase_step_rad, _phase.data(), d_fft_size);
d_grid_data[doppler_index] = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));

View File

@ -28,7 +28,6 @@ add_library(signal_generator_gr_blocks
target_link_libraries(signal_generator_gr_blocks
PUBLIC
Boost::boost
Gnuradio::runtime
core_system_parameters
PRIVATE

View File

@ -97,7 +97,7 @@ void signal_generator_c::init()
{
work_counter_ = 0;
complex_phase_ = static_cast<gr_complex *>(volk_gnsssdr_malloc(vector_length_ * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
complex_phase_.reserve(vector_length_);
// True if Galileo satellites are present
bool galileo_signal = std::find(system_.begin(), system_.end(), "E") != system_.end();
@ -152,13 +152,13 @@ void signal_generator_c::init()
void signal_generator_c::generate_codes()
{
sampled_code_data_.reset(new gr_complex *[num_sats_]);
sampled_code_pilot_.reset(new gr_complex *[num_sats_]);
//sampled_code_data_.reset(new gr_complex *[num_sats_]);
//sampled_code_pilot_.reset(new gr_complex *[num_sats_]);
sampled_code_data_ = std::vector<std::vector<gr_complex>>(num_sats_, std::vector<gr_complex>(vector_length_));
sampled_code_pilot_ = std::vector<std::vector<gr_complex>>(num_sats_, std::vector<gr_complex>(vector_length_));
for (unsigned int sat = 0; sat < num_sats_; sat++)
{
sampled_code_data_[sat] = static_cast<gr_complex *>(std::malloc(vector_length_ * sizeof(gr_complex)));
std::array<gr_complex, 64000> code{}; //[samples_per_code_[sat]];
if (system_[sat] == "G")
@ -211,7 +211,7 @@ void signal_generator_c::generate_codes()
{
std::array<char, 3> signal = {{'5', 'X', '\0'}};
galileo_e5_a_code_gen_complex_sampled(gsl::span<gr_complex>(sampled_code_data_[sat], vector_length_), signal, PRN_[sat], fs_in_,
galileo_e5_a_code_gen_complex_sampled(sampled_code_data_[sat], signal, PRN_[sat], fs_in_,
static_cast<int>(GALILEO_E5A_CODE_LENGTH_CHIPS) - delay_chips_[sat]);
//noise
if (noise_flag_)
@ -248,11 +248,10 @@ void signal_generator_c::generate_codes()
}
// Generate E1C signal (25 code-periods, with secondary code)
sampled_code_pilot_[sat] = static_cast<gr_complex *>(std::malloc(vector_length_ * sizeof(gr_complex)));
std::array<char, 3> signal_1C = {{'1', 'C', '\0'}};
galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(sampled_code_pilot_[sat], vector_length_), signal_1C, cboc, PRN_[sat], fs_in_,
galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(sampled_code_pilot_[sat].data(), vector_length_), signal_1C, cboc, PRN_[sat], fs_in_,
static_cast<int>(GALILEO_E1_B_CODE_LENGTH_CHIPS) - delay_chips_[sat], true);
// Obtain the desired CN0 assuming that Pn = 1.
@ -269,20 +268,6 @@ void signal_generator_c::generate_codes()
}
signal_generator_c::~signal_generator_c()
{
/* for (unsigned int sat = 0; sat < num_sats_; sat++)
{
std::free(sampled_code_data_[sat]);
if (system_[sat] == "E" && signal_[sat].at(0) != '5')
{
std::free(sampled_code_pilot_[sat]);
}
} */
volk_gnsssdr_free(complex_phase_);
}
int signal_generator_c::general_work(int noutput_items __attribute__((unused)),
gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items __attribute__((unused)),
@ -306,9 +291,9 @@ int signal_generator_c::general_work(int noutput_items __attribute__((unused)),
for (unsigned int sat = 0; sat < num_sats_; sat++)
{
float phase_step_rad = -static_cast<float>(GPS_TWO_PI) * doppler_Hz_[sat] / static_cast<float>(fs_in_);
float _phase[1];
std::array<float, 1> _phase{};
_phase[0] = -start_phase_rad_[sat];
volk_gnsssdr_s32f_sincos_32fc(complex_phase_, -phase_step_rad, _phase, vector_length_);
volk_gnsssdr_s32f_sincos_32fc(complex_phase_.data(), -phase_step_rad, _phase.data(), vector_length_);
start_phase_rad_[sat] += vector_length_ * phase_step_rad;
out_idx = 0;
@ -346,7 +331,7 @@ int signal_generator_c::general_work(int noutput_items __attribute__((unused)),
phase_step_rad = -static_cast<float>(GPS_TWO_PI) * (freq + (DFRQ1_GLO * GLONASS_PRN.at(PRN_[sat])) + doppler_Hz_[sat]) / static_cast<float>(fs_in_);
// std::cout << "sat " << PRN_[sat] << " SG - Freq = " << (freq + (DFRQ1_GLO * GLONASS_PRN.at(PRN_[sat]))) << " Doppler = " << doppler_Hz_[sat] << std::endl;
_phase[0] = -start_phase_rad_[sat];
volk_gnsssdr_s32f_sincos_32fc(complex_phase_, -phase_step_rad, _phase, vector_length_);
volk_gnsssdr_s32f_sincos_32fc(complex_phase_.data(), -phase_step_rad, _phase.data(), vector_length_);
unsigned int delay_samples = (delay_chips_[sat] % static_cast<int>(GLONASS_L1_CA_CODE_LENGTH_CHIPS)) * samples_per_code_[sat] / GLONASS_L1_CA_CODE_LENGTH_CHIPS;

View File

@ -32,7 +32,6 @@
#define GNSS_SDR_SIGNAL_GENERATOR_C_H
#include "gnss_signal.h"
#include <boost/scoped_array.hpp>
#include <gnuradio/block.h>
#include <random>
#include <string>
@ -83,7 +82,7 @@ signal_generator_c_sptr signal_make_generator_c(
class signal_generator_c : public gr::block
{
public:
~signal_generator_c(); // public destructor
~signal_generator_c() = default; // public destructor
// Where all the action really happens
int general_work(int noutput_items,
@ -146,9 +145,9 @@ private:
std::vector<signed int> current_data_bit_int_;
std::vector<signed int> data_modulation_;
std::vector<signed int> pilot_modulation_;
boost::scoped_array<gr_complex *> sampled_code_data_;
boost::scoped_array<gr_complex *> sampled_code_pilot_;
gr_complex *complex_phase_;
std::vector<std::vector<gr_complex>> sampled_code_data_;
std::vector<std::vector<gr_complex>> sampled_code_pilot_;
std::vector<gr_complex> complex_phase_;
unsigned int work_counter_;
std::random_device r;
std::default_random_engine e1;

View File

@ -56,7 +56,6 @@ target_link_libraries(telemetry_decoder_gr_blocks
telemetry_decoder_libs
core_system_parameters
Gnuradio::runtime
Volkgnsssdr::volkgnsssdr
Boost::boost
PRIVATE
Gflags::gflags

View File

@ -42,12 +42,10 @@
#include <gnuradio/io_signature.h>
#include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <array>
#include <cstdlib> // for abs
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#include <cstdlib> // for abs
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#define CRC_ERROR_LIMIT 8
@ -64,7 +62,7 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{
//prevent telemetry symbols accumulation in output buffers
// prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1);
// Ephemeris data port out
this->message_port_register_out(pmt::mp("telemetry"));
@ -78,7 +76,6 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
d_symbol_duration_ms = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS;
d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS;
// Setting samples of preamble code
@ -94,7 +91,6 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
}
}
d_subframe_symbols = static_cast<float *>(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment()));
d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble;
d_symbol_history.set_capacity(d_required_symbols);
@ -118,9 +114,6 @@ beidou_b1i_telemetry_decoder_gs::beidou_b1i_telemetry_decoder_gs(
beidou_b1i_telemetry_decoder_gs::~beidou_b1i_telemetry_decoder_gs()
{
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_subframe_symbols);
if (d_dump_file.is_open() == true)
{
try
@ -299,13 +292,8 @@ void beidou_b1i_telemetry_decoder_gs::set_satellite(const Gnss_Satellite &satell
// Update tel dec parameters for D2 NAV Messages
if (sat_prn > 0 and sat_prn < 6)
{
// Clear values from previous declaration
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_subframe_symbols);
d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS;
// Setting samples of preamble code
@ -322,20 +310,15 @@ void beidou_b1i_telemetry_decoder_gs::set_satellite(const Gnss_Satellite &satell
}
d_symbol_duration_ms = BEIDOU_B1I_GEO_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS;
d_subframe_symbols = static_cast<float *>(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment()));
d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble;
d_symbol_history.set_capacity(d_required_symbols);
}
else
{
// Clear values from previous declaration
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_subframe_symbols);
//back to normal satellites
d_symbol_duration_ms = BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B1I_CODE_PERIOD_MS;
d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS;
// Setting samples of preamble code
@ -351,7 +334,6 @@ void beidou_b1i_telemetry_decoder_gs::set_satellite(const Gnss_Satellite &satell
}
}
d_subframe_symbols = static_cast<float *>(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment()));
d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble;
d_symbol_history.set_capacity(d_required_symbols);
}
@ -470,7 +452,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
}
// call the decoder
decode_subframe(d_subframe_symbols);
decode_subframe(d_subframe_symbols.data());
if (d_nav.flag_crc_test == true)
{
@ -527,7 +509,7 @@ int beidou_b1i_telemetry_decoder_gs::general_work(int noutput_items __attribute_
}
// call the decoder
decode_subframe(d_subframe_symbols);
decode_subframe(d_subframe_symbols.data());
if (d_nav.flag_crc_test == true)
{

View File

@ -43,6 +43,7 @@
#include <cstdint>
#include <fstream>
#include <string>
#include <array>
class beidou_b1i_telemetry_decoder_gs;
@ -63,7 +64,7 @@ public:
void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN
void set_channel(int channel); //!< Set receiver's channel
void reset();
/*!
* \brief This is where all signal processing takes place
*/
@ -79,13 +80,12 @@ private:
void decode_word(int32_t word_counter, const float *enc_word_symbols, int32_t *dec_word_symbols);
void decode_bch15_11_01(const int32_t *bits, int32_t *decbits);
// Preamble decoding
int32_t *d_preamble_samples;
std::array<int32_t, BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS> d_preamble_samples{};
int32_t d_symbols_per_preamble;
int32_t d_samples_per_preamble;
int32_t d_preamble_period_samples;
float *d_subframe_symbols;
std::array<float, BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS> d_subframe_symbols{};
uint32_t d_required_symbols;
// Storage for incoming data
@ -100,7 +100,7 @@ private:
int32_t d_CRC_error_counter; // Number of failed CRC operations
bool flag_SOW_set; // Indicates when time of week is set
//!< Navigation Message variable
// Navigation Message variable
Beidou_Dnav_Navigation_Message d_nav;
// Values to populate gnss synchronization structure

View File

@ -41,12 +41,10 @@
#include <gnuradio/io_signature.h>
#include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <array>
#include <cstdlib> // for abs
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#include <cstdlib> // for abs
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#define CRC_ERROR_LIMIT 8
@ -64,7 +62,7 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{
//prevent telemetry symbols accumulation in output buffers
// prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1);
// Ephemeris data port out
this->message_port_register_out(pmt::mp("telemetry"));
@ -78,7 +76,6 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
d_symbol_duration_ms = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B3I_CODE_PERIOD_MS;
d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS;
// Setting samples of preamble code
@ -94,7 +91,6 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
}
}
d_subframe_symbols = static_cast<float *>(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment()));
d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble;
d_symbol_history.set_capacity(d_required_symbols);
@ -118,9 +114,6 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs(
beidou_b3i_telemetry_decoder_gs::~beidou_b3i_telemetry_decoder_gs()
{
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_subframe_symbols);
if (d_dump_file.is_open() == true)
{
try
@ -317,15 +310,8 @@ void beidou_b3i_telemetry_decoder_gs::set_satellite(
// Update tel dec parameters for D2 NAV Messages
if (sat_prn > 0 and sat_prn < 6)
{
// Clear values from previous declaration
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_subframe_symbols);
d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t),
volk_gnsssdr_get_alignment()));
d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS;
// Setting samples of preamble code
@ -341,22 +327,15 @@ void beidou_b3i_telemetry_decoder_gs::set_satellite(
}
}
d_symbol_duration_ms = BEIDOU_B3I_GEO_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B3I_CODE_PERIOD_MS;
d_subframe_symbols = static_cast<float *>(volk_gnsssdr_malloc(
BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float),
volk_gnsssdr_get_alignment()));
d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble;
d_symbol_history.set_capacity(d_required_symbols);
}
else
{
// Clear values from previous declaration
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_subframe_symbols);
//back to normal satellites
// back to normal satellites
d_symbol_duration_ms = BEIDOU_B3I_TELEMETRY_SYMBOLS_PER_BIT * BEIDOU_B3I_CODE_PERIOD_MS;
d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS;
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS;
// Setting samples of preamble code
@ -372,7 +351,6 @@ void beidou_b3i_telemetry_decoder_gs::set_satellite(
}
}
d_subframe_symbols = static_cast<float *>(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(float), volk_gnsssdr_get_alignment()));
d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS + d_samples_per_preamble;
d_symbol_history.set_capacity(d_required_symbols);
}
@ -498,7 +476,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work(
}
// call the decoder
decode_subframe(d_subframe_symbols);
decode_subframe(d_subframe_symbols.data());
if (d_nav.flag_crc_test == true)
{
@ -558,7 +536,7 @@ int beidou_b3i_telemetry_decoder_gs::general_work(
}
// call the decoder
decode_subframe(d_subframe_symbols);
decode_subframe(d_subframe_symbols.data());
if (d_nav.flag_crc_test == true)
{

View File

@ -40,14 +40,15 @@
#include <cstdint>
#include <fstream>
#include <string>
#include <array>
class beidou_b3i_telemetry_decoder_gs;
using beidou_b3i_telemetry_decoder_gs_sptr =
boost::shared_ptr<beidou_b3i_telemetry_decoder_gs>;
beidou_b3i_telemetry_decoder_gs_sptr
beidou_b3i_make_telemetry_decoder_gs(const Gnss_Satellite &satellite,
beidou_b3i_telemetry_decoder_gs_sptr beidou_b3i_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite,
bool dump);
/*!
@ -81,11 +82,11 @@ private:
void decode_bch15_11_01(const int32_t *bits, int32_t *decbits);
// Preamble decoding
int32_t *d_preamble_samples;
std::array<int32_t, BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS> d_preamble_samples{};
int32_t d_symbols_per_preamble;
int32_t d_samples_per_preamble;
int32_t d_preamble_period_samples;
float *d_subframe_symbols;
std::array<float, BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS> d_subframe_symbols{};
uint32_t d_required_symbols;
// Storage for incoming data

View File

@ -43,12 +43,11 @@
#include <gnuradio/io_signature.h>
#include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <cmath> // for fmod
#include <cstdlib> // for abs
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#include <cmath> // for fmod
#include <cstdlib> // for abs
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#define CRC_ERROR_LIMIT 6
@ -66,7 +65,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
bool dump) : gr::block("galileo_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{
//prevent telemetry symbols accumulation in output buffers
// prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1);
// Ephemeris data port out
this->message_port_register_out(pmt::mp("telemetry"));
@ -75,7 +74,6 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_last_valid_preamble = 0;
d_sent_tlm_failed_msg = false;
// initialize internal vars
d_dump = dump;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
@ -93,7 +91,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_preamble_period_symbols = GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS;
d_required_symbols = static_cast<uint32_t>(GALILEO_INAV_PAGE_SYMBOLS) + d_samples_per_preamble;
// preamble bits to sampled symbols
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
d_preamble_samples.reserve(d_samples_per_preamble);
d_frame_length_symbols = GALILEO_INAV_PAGE_PART_SYMBOLS - GALILEO_INAV_PREAMBLE_LENGTH_BITS;
CodeLength = GALILEO_INAV_PAGE_PART_SYMBOLS - GALILEO_INAV_PREAMBLE_LENGTH_BITS;
DataLength = (CodeLength / nn) - mm;
@ -110,7 +108,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_preamble_period_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE;
d_required_symbols = static_cast<uint32_t>(GALILEO_FNAV_SYMBOLS_PER_PAGE) + d_samples_per_preamble;
// preamble bits to sampled symbols
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
d_preamble_samples.reserve(d_samples_per_preamble);
d_frame_length_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
CodeLength = GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS;
DataLength = (CodeLength / nn) - mm;
@ -121,7 +119,6 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
d_bits_per_preamble = 0;
d_samples_per_preamble = 0;
d_preamble_period_symbols = 0;
d_preamble_samples = nullptr;
d_PRN_code_period_ms = 0U;
d_required_symbols = 0U;
d_frame_length_symbols = 0U;
@ -131,7 +128,7 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
std::cout << "Galileo unified telemetry decoder error: Unknown frame type " << std::endl;
}
d_page_part_symbols = static_cast<double *>(volk_gnsssdr_malloc(d_frame_length_symbols * sizeof(double), volk_gnsssdr_get_alignment()));
d_page_part_symbols.reserve(d_frame_length_symbols);
for (int32_t i = 0; i < d_bits_per_preamble; i++)
{
switch (d_frame_type)
@ -184,24 +181,18 @@ galileo_telemetry_decoder_gs::galileo_telemetry_decoder_gs(
int32_t max_states = 1U << static_cast<uint32_t>(mm); // 2^mm
g_encoder[0] = 121; // Polynomial G1
g_encoder[1] = 91; // Polynomial G2
out0 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
out1 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
state0 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
state1 = static_cast<int32_t *>(volk_gnsssdr_malloc(max_states * sizeof(int32_t), volk_gnsssdr_get_alignment()));
out0.reserve(max_states);
out1.reserve(max_states);
state0.reserve(max_states);
state1.reserve(max_states);
// create appropriate transition matrices
nsc_transit(out0, state0, 0, g_encoder, KK, nn);
nsc_transit(out1, state1, 1, g_encoder, KK, nn);
nsc_transit(out0.data(), state0.data(), 0, g_encoder.data(), KK, nn);
nsc_transit(out1.data(), state1.data(), 1, g_encoder.data(), KK, nn);
}
galileo_telemetry_decoder_gs::~galileo_telemetry_decoder_gs()
{
volk_gnsssdr_free(d_preamble_samples);
volk_gnsssdr_free(d_page_part_symbols);
volk_gnsssdr_free(out0);
volk_gnsssdr_free(out1);
volk_gnsssdr_free(state0);
volk_gnsssdr_free(state1);
if (d_dump_file.is_open() == true)
{
try
@ -218,7 +209,7 @@ galileo_telemetry_decoder_gs::~galileo_telemetry_decoder_gs()
void galileo_telemetry_decoder_gs::viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits)
{
Viterbi(page_part_bits, out0, state0, out1, state1,
Viterbi(page_part_bits, out0.data(), state0.data(), out1.data(), state1.data(),
page_part_symbols, KK, nn, DataLength);
}
@ -238,8 +229,8 @@ void galileo_telemetry_decoder_gs::deinterleaver(int32_t rows, int32_t cols, con
void galileo_telemetry_decoder_gs::decode_INAV_word(double *page_part_symbols, int32_t frame_length)
{
// 1. De-interleave
auto *page_part_symbols_deint = static_cast<double *>(volk_gnsssdr_malloc(frame_length * sizeof(double), volk_gnsssdr_get_alignment()));
deinterleaver(GALILEO_INAV_INTERLEAVER_ROWS, GALILEO_INAV_INTERLEAVER_COLS, page_part_symbols, page_part_symbols_deint);
std::vector<double> page_part_symbols_deint(frame_length);
deinterleaver(GALILEO_INAV_INTERLEAVER_ROWS, GALILEO_INAV_INTERLEAVER_COLS, page_part_symbols, page_part_symbols_deint.data());
// 2. Viterbi decoder
// 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder)
@ -252,9 +243,8 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(double *page_part_symbols, i
}
}
auto *page_part_bits = static_cast<int32_t *>(volk_gnsssdr_malloc((frame_length / 2) * sizeof(int32_t), volk_gnsssdr_get_alignment()));
viterbi_decoder(page_part_symbols_deint, page_part_bits);
volk_gnsssdr_free(page_part_symbols_deint);
std::vector<int32_t> page_part_bits(frame_length / 2);
viterbi_decoder(page_part_symbols_deint.data(), page_part_bits.data());
// 3. Call the Galileo page decoder
std::string page_String;
@ -290,7 +280,6 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(double *page_part_symbols, i
d_inav_nav.split_page(page_String, flag_even_word_arrived);
flag_even_word_arrived = 1;
}
volk_gnsssdr_free(page_part_bits);
// 4. Push the new navigation data to the queues
if (d_inav_nav.have_new_ephemeris() == true)
@ -332,8 +321,8 @@ void galileo_telemetry_decoder_gs::decode_INAV_word(double *page_part_symbols, i
void galileo_telemetry_decoder_gs::decode_FNAV_word(double *page_symbols, int32_t frame_length)
{
// 1. De-interleave
auto *page_symbols_deint = static_cast<double *>(volk_gnsssdr_malloc(frame_length * sizeof(double), volk_gnsssdr_get_alignment()));
deinterleaver(GALILEO_FNAV_INTERLEAVER_ROWS, GALILEO_FNAV_INTERLEAVER_COLS, page_symbols, page_symbols_deint);
std::vector<double> page_symbols_deint(frame_length);
deinterleaver(GALILEO_FNAV_INTERLEAVER_ROWS, GALILEO_FNAV_INTERLEAVER_COLS, page_symbols, page_symbols_deint.data());
// 2. Viterbi decoder
// 2.1 Take into account the NOT gate in G2 polynomial (Galileo ICD Figure 13, FEC encoder)
@ -345,9 +334,8 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(double *page_symbols, int32_
page_symbols_deint[i] = -page_symbols_deint[i];
}
}
auto *page_bits = static_cast<int32_t *>(volk_gnsssdr_malloc((frame_length / 2) * sizeof(int32_t), volk_gnsssdr_get_alignment()));
viterbi_decoder(page_symbols_deint, page_bits);
volk_gnsssdr_free(page_symbols_deint);
std::vector<int32_t> page_bits(frame_length / 2);
viterbi_decoder(page_symbols_deint.data(), page_bits.data());
// 3. Call the Galileo page decoder
std::string page_String;
@ -362,7 +350,6 @@ void galileo_telemetry_decoder_gs::decode_FNAV_word(double *page_symbols, int32_
page_String.push_back('0');
}
}
volk_gnsssdr_free(page_bits);
// DECODE COMPLETE WORD (even + odd) and TEST CRC
d_fnav_nav.split_page(page_String);
@ -462,7 +449,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
d_symbol_history.push_back(current_symbol.Prompt_I);
break;
}
case 2: //FNAV
case 2: // FNAV
{
d_symbol_history.push_back(current_symbol.Prompt_Q);
break;
@ -494,7 +481,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
{
case 0: // no preamble information
{
//correlate with preamble
// correlate with preamble
int32_t corr_value = 0;
if (d_symbol_history.size() > d_required_symbols)
{
@ -522,7 +509,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
case 1: // possible preamble lock
{
//correlate with preamble
// correlate with preamble
int32_t corr_value = 0;
int32_t preamble_diff = 0;
if (d_symbol_history.size() > d_required_symbols)
@ -594,7 +581,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
d_page_part_symbols[i] = -d_symbol_history.at(i + d_samples_per_preamble); // because last symbol of the preamble is just received now!
}
}
decode_INAV_word(d_page_part_symbols, d_frame_length_symbols);
decode_INAV_word(d_page_part_symbols.data(), d_frame_length_symbols);
break;
case 2: // FNAV
// NEW Galileo page part is received
@ -619,7 +606,7 @@ int galileo_telemetry_decoder_gs::general_work(int noutput_items __attribute__((
}
}
}
decode_FNAV_word(d_page_part_symbols, d_frame_length_symbols);
decode_FNAV_word(d_page_part_symbols.data(), d_frame_length_symbols);
break;
default:
return -1;

View File

@ -43,6 +43,8 @@
#include <cstdint>
#include <fstream>
#include <string>
#include <vector>
#include <array>
class galileo_telemetry_decoder_gs;
@ -84,11 +86,11 @@ private:
int32_t d_bits_per_preamble;
int32_t d_samples_per_preamble;
int32_t d_preamble_period_symbols;
int32_t *d_preamble_samples;
std::vector<int32_t> d_preamble_samples;
uint32_t d_PRN_code_period_ms;
uint32_t d_required_symbols;
uint32_t d_frame_length_symbols;
double *d_page_part_symbols;
std::vector<double> d_page_part_symbols;
boost::circular_buffer<float> d_symbol_history;
@ -118,14 +120,17 @@ private:
uint32_t d_TOW_at_current_symbol_ms;
bool flag_TOW_set;
double delta_t; //GPS-GALILEO time offset
double delta_t; // GPS-GALILEO time offset
std::string d_dump_filename;
std::ofstream d_dump_file;
// vars for Viterbi decoder
int32_t *out0, *out1, *state0, *state1;
int32_t g_encoder[2]{};
std::vector<int32_t> out0;
std::vector<int32_t> out1;
std::vector<int32_t> state0;
std::vector<int32_t> state1;
std::array<int32_t,2> g_encoder{};
const int32_t nn = 2; // Coding rate 1/n
const int32_t KK = 7; // Constraint Length
int32_t mm = KK - 1;

View File

@ -38,13 +38,11 @@
#include <gnuradio/io_signature.h>
#include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp
#include <array>
#include <cmath> // for floor, round
#include <cstdlib> // for abs, malloc
#include <cstring> // for memcpy
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#include <cmath> // for floor, round
#include <cstdlib> // for abs
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#define CRC_ERROR_LIMIT 6
@ -61,7 +59,7 @@ glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs(
bool dump) : gr::block("glonass_l1_ca_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{
//prevent telemetry symbols accumulation in output buffers
// prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1);
// Ephemeris data port out
this->message_port_register_out(pmt::mp("telemetry"));
@ -71,19 +69,8 @@ glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs(
d_dump = dump;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
LOG(INFO) << "Initializing GLONASS L1 CA TELEMETRY DECODING";
// Define the number of sampes per symbol. Notice that GLONASS has 2 rates,
// one for the navigation data and the other for the preamble information
d_samples_per_symbol = (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS) / GLONASS_L1_CA_SYMBOL_RATE_BPS;
// Set the preamble information
std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> preambles_bits{GLONASS_GNAV_PREAMBLE};
// Since preamble rate is different than navigation data rate we use a constant
d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
memcpy(static_cast<uint16_t *>(this->d_preambles_bits), preambles_bits.data(), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t));
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<int32_t *>(malloc(sizeof(int32_t) * d_symbols_per_preamble));
int32_t n = 0;
for (uint16_t d_preambles_bit : d_preambles_bits)
{
@ -120,7 +107,6 @@ glonass_l1_ca_telemetry_decoder_gs::glonass_l1_ca_telemetry_decoder_gs(
glonass_l1_ca_telemetry_decoder_gs::~glonass_l1_ca_telemetry_decoder_gs()
{
delete d_preambles_symbols;
if (d_dump_file.is_open() == true)
{
try

View File

@ -41,6 +41,7 @@
#include <boost/shared_ptr.hpp> // for boost::shared_ptr
#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 <string>
@ -50,7 +51,9 @@ class glonass_l1_ca_telemetry_decoder_gs;
using glonass_l1_ca_telemetry_decoder_gs_sptr = boost::shared_ptr<glonass_l1_ca_telemetry_decoder_gs>;
glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite,
bool dump);
/*!
* \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1
@ -75,43 +78,45 @@ public:
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
private:
friend glonass_l1_ca_telemetry_decoder_gs_sptr
glonass_l1_ca_make_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
friend glonass_l1_ca_telemetry_decoder_gs_sptr glonass_l1_ca_make_telemetry_decoder_gs(
const Gnss_Satellite &satellite,
bool dump);
glonass_l1_ca_telemetry_decoder_gs(const Gnss_Satellite &satellite, bool dump);
void decode_string(const double *symbols, int32_t frame_length);
//!< Help with coherent tracking
// Help with coherent tracking
double d_preamble_time_samples;
//!< Preamble decoding
uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]{};
int32_t *d_preambles_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;
// Preamble decoding
const std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> d_preambles_bits{GLONASS_GNAV_PREAMBLE};
std::array<int32_t, GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS> d_preambles_symbols{};
uint32_t d_samples_per_symbol = (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS) / GLONASS_L1_CA_SYMBOL_RATE_BPS;
const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
//!< Storage for incoming data
// Storage for incoming data
boost::circular_buffer<Gnss_Synchro> d_symbol_history;
//!< Variables for internal functionality
uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed
uint64_t d_preamble_index; //!< Index of sample number where preamble was found
uint32_t d_stat; //!< Status of decoder
bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved
bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check)
bool d_flag_preamble; //!< Flag indicating when preamble was found
int32_t d_CRC_error_counter; //!< Number of failed CRC operations
bool flag_TOW_set; //!< Indicates when time of week is set
double delta_t; //!< GPS-GLONASS time offset
// Variables for internal functionality
uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
uint64_t d_preamble_index; // Index of sample number where preamble was found
uint32_t d_stat; // Status of decoder
bool d_flag_frame_sync; // Indicate when a frame sync is achieved
bool d_flag_parity; // Flag indicating when parity check was achieved (crc check)
bool d_flag_preamble; // Flag indicating when preamble was found
int32_t d_CRC_error_counter; // Number of failed CRC operations
bool flag_TOW_set; // Indicates when time of week is set
double delta_t; // GPS-GLONASS time offset
//!< Navigation Message variable
// Navigation Message variable
Glonass_Gnav_Navigation_Message d_nav;
//!< Values to populate gnss synchronization structure
// Values to populate gnss synchronization structure
double d_TOW_at_current_symbol;
bool Flag_valid_word;
//!< Satellite Information and logging capacity
// Satellite Information and logging capacity
Gnss_Satellite d_satellite;
int32_t d_channel;
bool d_dump;

View File

@ -38,13 +38,11 @@
#include <gnuradio/io_signature.h>
#include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp
#include <array>
#include <cmath> // for floor, round
#include <cstdlib> // for abs, malloc
#include <cstring> // for memcpy
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#include <cmath> // for floor, round
#include <cstdlib> // for abs
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr, make_shared
#define CRC_ERROR_LIMIT 6
@ -61,7 +59,7 @@ glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
bool dump) : gr::block("glonass_l2_ca_telemetry_decoder_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{
//prevent telemetry symbols accumulation in output buffers
// prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1);
// Ephemeris data port out
this->message_port_register_out(pmt::mp("telemetry"));
@ -71,19 +69,8 @@ glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
d_dump = dump;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
LOG(INFO) << "Initializing GLONASS L2 CA TELEMETRY DECODING";
// Define the number of sampes per symbol. Notice that GLONASS has 2 rates,
// one for the navigation data and the other for the preamble information
d_samples_per_symbol = (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS) / GLONASS_L2_CA_SYMBOL_RATE_BPS;
// Set the preamble information
std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> preambles_bits{GLONASS_GNAV_PREAMBLE};
// Since preamble rate is different than navigation data rate we use a constant
d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
memcpy(static_cast<uint16_t *>(this->d_preambles_bits), preambles_bits.data(), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(uint16_t));
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<int32_t *>(malloc(sizeof(int32_t) * d_symbols_per_preamble));
int32_t n = 0;
for (uint16_t d_preambles_bit : d_preambles_bits)
{
@ -105,9 +92,7 @@ glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
d_sample_counter = 0ULL;
d_stat = 0;
d_preamble_index = 0ULL;
d_flag_frame_sync = false;
d_flag_parity = false;
d_TOW_at_current_symbol = 0;
Flag_valid_word = false;
@ -122,7 +107,6 @@ glonass_l2_ca_telemetry_decoder_gs::glonass_l2_ca_telemetry_decoder_gs(
glonass_l2_ca_telemetry_decoder_gs::~glonass_l2_ca_telemetry_decoder_gs()
{
delete d_preambles_symbols;
if (d_dump_file.is_open() == true)
{
try

View File

@ -40,6 +40,7 @@
#include <boost/shared_ptr.hpp> // for boost::shared_ptr
#include <gnuradio/block.h>
#include <gnuradio/types.h> // for gr_vector_const_void_star
#include <array>
#include <cstdint>
#include <fstream>
#include <string>
@ -79,37 +80,37 @@ private:
void decode_string(const double *symbols, int32_t frame_length);
//!< Help with coherent tracking
// Help with coherent tracking
double d_preamble_time_samples;
//!< Preamble decoding
uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]{};
int32_t *d_preambles_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;
// Preamble decoding
const std::array<uint16_t, GLONASS_GNAV_PREAMBLE_LENGTH_BITS> d_preambles_bits{GLONASS_GNAV_PREAMBLE};
std::array<int32_t, GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS> d_preambles_symbols{};
uint32_t d_samples_per_symbol = (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS) / GLONASS_L2_CA_SYMBOL_RATE_BPS;
const int32_t d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS;
//!< Storage for incoming data
// Storage for incoming data
boost::circular_buffer<Gnss_Synchro> d_symbol_history;
//!< Variables for internal functionality
uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed
uint64_t d_preamble_index; //!< Index of sample number where preamble was found
uint32_t d_stat; //!< Status of decoder
bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved
bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check)
bool d_flag_preamble; //!< Flag indicating when preamble was found
int32_t d_CRC_error_counter; //!< Number of failed CRC operations
bool flag_TOW_set; //!< Indicates when time of week is set
double delta_t; //!< GPS-GLONASS time offset
// Variables for internal functionality
uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed
uint64_t d_preamble_index; // Index of sample number where preamble was found
uint32_t d_stat; // Status of decoder
bool d_flag_frame_sync; // Indicate when a frame sync is achieved
bool d_flag_parity; // Flag indicating when parity check was achieved (crc check)
bool d_flag_preamble; // Flag indicating when preamble was found
int32_t d_CRC_error_counter; // Number of failed CRC operations
bool flag_TOW_set; // Indicates when time of week is set
double delta_t; // GPS-GLONASS time offset
//!< Navigation Message variable
// Navigation Message variable
Glonass_Gnav_Navigation_Message d_nav;
//!< Values to populate gnss synchronization structure
// Values to populate gnss synchronization structure
double d_TOW_at_current_symbol;
bool Flag_valid_word;
//!< Satellite Information and logging capacity
// Satellite Information and logging capacity
Gnss_Satellite d_satellite;
int32_t d_channel;
bool d_dump;

View File

@ -37,13 +37,11 @@
#include <gnuradio/io_signature.h>
#include <pmt/pmt.h> // for make_any
#include <pmt/pmt_sugar.h> // for mp
#include <volk_gnsssdr/volk_gnsssdr.h>
#include <array>
#include <cmath> // for round
#include <cstring> // for memcpy
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr
#include <cmath> // for round
#include <cstring> // for memcpy
#include <exception> // for exception
#include <iostream> // for cout
#include <memory> // for shared_ptr
#ifndef _rotl
@ -63,7 +61,7 @@ gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
bool dump) : gr::block("gps_navigation_gs", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
{
//prevent telemetry symbols accumulation in output buffers
// prevent telemetry symbols accumulation in output buffers
this->set_max_noutput_items(1);
// Ephemeris data port out
@ -73,7 +71,6 @@ gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
d_last_valid_preamble = 0;
d_sent_tlm_failed_msg = false;
// initialize internal vars
d_dump = dump;
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
@ -85,7 +82,6 @@ gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
// set the preamble
d_required_symbols = GPS_SUBFRAME_BITS;
// preamble bits to sampled symbols
d_preamble_samples = static_cast<int32_t *>(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment()));
d_frame_length_symbols = GPS_SUBFRAME_BITS * GPS_CA_TELEMETRY_SYMBOLS_PER_BIT;
d_max_symbols_without_valid_frame = d_required_symbols * 20; // rise alarm 120 segs without valid tlm
int32_t n = 0;
@ -123,7 +119,6 @@ gps_l1_ca_telemetry_decoder_gs::gps_l1_ca_telemetry_decoder_gs(
gps_l1_ca_telemetry_decoder_gs::~gps_l1_ca_telemetry_decoder_gs()
{
volk_gnsssdr_free(d_preamble_samples);
if (d_dump_file.is_open() == true)
{
try

View File

@ -39,6 +39,7 @@
#include <boost/shared_ptr.hpp> // for boost::shared_ptr
#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 <string> // for string
@ -80,7 +81,7 @@ private:
int32_t d_bits_per_preamble;
int32_t d_samples_per_preamble;
int32_t d_preamble_period_symbols;
int32_t *d_preamble_samples;
std::array<int32_t, GPS_CA_PREAMBLE_LENGTH_BITS> d_preamble_samples;
uint32_t d_required_symbols;
uint32_t d_frame_length_symbols;
bool flag_PLL_180_deg_phase_locked;

View File

@ -33,13 +33,13 @@
#include "fec.h"
#include <stdlib.h>
static inline int parity(int x)
static inline unsigned int parity(unsigned int x)
{
x ^= x >> 16;
x ^= x >> 8;
x ^= x >> 4;
x &= 0xf;
return (0x6996 >> x) & 1;
x ^= x >> 16U;
x ^= x >> 8U;
x ^= x >> 4U;
x &= 0xFU;
return (0x6996U >> x) & 1U;
}
@ -101,12 +101,12 @@ void v27_init(v27_t *v, v27_decision_t *decisions, unsigned int decisions_count,
m1 = v->old_metrics[(i) + 32] + (510 - metric); \
decision = (signed int)(m0 - m1) > 0; \
v->new_metrics[2 * (i)] = decision ? m1 : m0; \
d->w[(i) / 16] |= decision << ((2 * (i)) & 31); \
d->w[(i) / 16] |= decision << ((2U * (i)) & 31U); \
m0 -= (metric + metric - 510); \
m1 += (metric + metric - 510); \
decision = (signed int)(m0 - m1) > 0; \
v->new_metrics[2 * (i) + 1] = decision ? m1 : m0; \
d->w[(i) / 16] |= decision << ((2 * (i) + 1) & 31); \
d->w[(i) / 16] |= decision << ((2U * (i) + 1U) & 31U); \
}
/** Update a v27_t decoder with a block of symbols.
@ -130,44 +130,44 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits)
sym0 = *syms++;
sym1 = *syms++;
BFLY(0);
BFLY(1);
BFLY(2);
BFLY(3);
BFLY(4);
BFLY(5);
BFLY(6);
BFLY(7);
BFLY(8);
BFLY(9);
BFLY(10);
BFLY(11);
BFLY(12);
BFLY(13);
BFLY(14);
BFLY(15);
BFLY(16);
BFLY(17);
BFLY(18);
BFLY(19);
BFLY(20);
BFLY(21);
BFLY(22);
BFLY(23);
BFLY(24);
BFLY(25);
BFLY(26);
BFLY(27);
BFLY(28);
BFLY(29);
BFLY(30);
BFLY(31);
BFLY(0U);
BFLY(1U);
BFLY(2U);
BFLY(3U);
BFLY(4U);
BFLY(5U);
BFLY(6U);
BFLY(7U);
BFLY(8U);
BFLY(9U);
BFLY(10U);
BFLY(11U);
BFLY(12U);
BFLY(13U);
BFLY(14U);
BFLY(15U);
BFLY(16U);
BFLY(17U);
BFLY(18U);
BFLY(19U);
BFLY(20U);
BFLY(21U);
BFLY(22U);
BFLY(23U);
BFLY(24U);
BFLY(25U);
BFLY(26U);
BFLY(27U);
BFLY(28U);
BFLY(29U);
BFLY(30U);
BFLY(31U);
/* Normalize metrics if they are nearing overflow */
if (v->new_metrics[0] > (1 << 30))
if (v->new_metrics[0] > (1U << 30U))
{
int i;
unsigned int minmetric = 1 << 31;
unsigned int minmetric = 1U << 31U;
for (i = 0; i < 64; i++)
{
@ -210,11 +210,11 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits)
void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits,
unsigned char final_state)
{
int k;
unsigned int k;
unsigned int decisions_index = v->decisions_index;
final_state %= 64;
final_state <<= 2;
final_state <<= 2U;
while (nbits-- != 0)
{
@ -222,12 +222,12 @@ void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits,
decisions_index = (decisions_index == 0) ? v->decisions_count - 1 : decisions_index - 1;
v27_decision_t *d = &v->decisions[decisions_index];
k = (d->w[(final_state >> 2) / 32] >> ((final_state >> 2) % 32)) & 1;
k = (d->w[(final_state >> 2U) / 32] >> ((final_state >> 2U) % 32)) & 1U;
/* The store into data[] only needs to be done every 8 bits.
* But this avoids a conditional branch, and the writes will
* combine in the cache anyway
*/
data[nbits >> 3] = final_state = (final_state >> 1) | (k << 7);
data[nbits >> 3U] = final_state = (final_state >> 1U) | (k << 7U);
}
}

View File

@ -51,17 +51,17 @@ Viterbi_Decoder::Viterbi_Decoder(const int g_encoder[], const int KK, const int
// derived code properties
d_mm = d_KK - 1;
d_states = 1 << d_mm; /* 2^mm */
d_number_symbols = 1 << d_nn; /* 2^nn */
d_states = 1U << d_mm; /* 2^mm */
d_number_symbols = 1U << d_nn; /* 2^nn */
/* create appropriate transition matrices (trellis) */
d_out0 = new int[d_states];
d_out1 = new int[d_states];
d_state0 = new int[d_states];
d_state1 = new int[d_states];
d_out0.reserve(d_states);
d_out1.reserve(d_states);
d_state0.reserve(d_states);
d_state1.reserve(d_states);
nsc_transit(d_out0, d_state0, 0, g_encoder, d_KK, d_nn);
nsc_transit(d_out1, d_state1, 1, g_encoder, d_KK, d_nn);
nsc_transit(d_out0.data(), d_state0.data(), 0, g_encoder, d_KK, d_nn);
nsc_transit(d_out1.data(), d_state1.data(), 1, g_encoder, d_KK, d_nn);
// initialise trellis state
d_trellis_state_is_initialised = false;
@ -69,21 +69,6 @@ Viterbi_Decoder::Viterbi_Decoder(const int g_encoder[], const int KK, const int
}
Viterbi_Decoder::~Viterbi_Decoder()
{
// trellis definition
delete[] d_out0;
delete[] d_out1;
delete[] d_state0;
delete[] d_state1;
// init trellis state
delete[] d_pm_t;
delete[] d_rec_array;
delete[] d_metric_c;
}
void Viterbi_Decoder::reset()
{
init_trellis_state();
@ -153,16 +138,16 @@ void Viterbi_Decoder::init_trellis_state()
if (d_trellis_state_is_initialised)
{
// init trellis state
delete[] d_pm_t;
delete[] d_rec_array;
delete[] d_metric_c;
d_pm_t.clear();
d_rec_array.clear();
d_metric_c.clear();
}
// reserve new trellis state memory
d_pm_t = new float[d_states];
d_pm_t.reserve(d_states);
d_trellis_paths = std::deque<Prev>();
d_rec_array = new float[d_nn];
d_metric_c = new float[d_number_symbols];
d_rec_array.reserve(d_nn);
d_metric_c.reserve(d_number_symbols);
d_trellis_state_is_initialised = true;
/* initialize trellis */
@ -182,7 +167,7 @@ int Viterbi_Decoder::do_acs(const double sym[], int nbits)
int t, i, state_at_t;
float metric;
float max_val;
auto* pm_t_next = new float[d_states];
std::vector<float> pm_t_next(d_states);
/* t:
* - state: state at t
@ -208,7 +193,7 @@ int Viterbi_Decoder::do_acs(const double sym[], int nbits)
/* precompute all possible branch metrics */
for (i = 0; i < d_number_symbols; i++)
{
d_metric_c[i] = gamma(d_rec_array, i, d_nn);
d_metric_c[i] = gamma(d_rec_array.data(), i, d_nn);
VLOG(LMORE) << "metric for (tx_sym=" << i << "|ry_sym=(" << d_rec_array[0] << ", " << d_rec_array[1] << ") = " << d_metric_c[i];
}
@ -267,8 +252,6 @@ int Viterbi_Decoder::do_acs(const double sym[], int nbits)
}
}
delete[] pm_t_next;
return t;
}
@ -362,16 +345,15 @@ float Viterbi_Decoder::gamma(const float rec_array[], int symbol, int nn)
{
float rm = 0;
int i;
int mask;
unsigned int mask = 1U;
float txsym;
mask = 1;
for (i = 0; i < nn; i++)
{
//if (symbol & mask) rm += rec_array[nn - i - 1];
txsym = symbol & mask ? 1 : -1;
rm += txsym * rec_array[nn - i - 1];
mask = mask << 1;
mask = mask << 1U;
}
//rm = rm > 50 ? rm : -1000;
@ -384,7 +366,7 @@ void Viterbi_Decoder::nsc_transit(int output_p[], int trans_p[], int input, cons
{
int nextstate[1];
int state, states;
states = (1 << (KK - 1)); /* The number of states: 2^mm */
states = (1U << (KK - 1)); /* The number of states: 2^mm */
/* Determine the output and next state for each possible starting state */
for (state = 0; state < states; state++)
@ -452,11 +434,11 @@ int Viterbi_Decoder::nsc_enc_bit(int state_out_p[], int input, int state_in,
int Viterbi_Decoder::parity_counter(int symbol, int length)
{
int counter;
int temp_parity = 0;
unsigned int temp_parity = 0;
for (counter = 0; counter < length; counter++)
{
temp_parity = temp_parity ^ (symbol & 1);
symbol = symbol >> 1;
temp_parity = temp_parity ^ (symbol & 1U);
symbol = symbol >> 1U;
}
return (temp_parity);
}

View File

@ -34,6 +34,7 @@
#include <cstddef> // for size_t
#include <deque>
#include <vector>
/*!
* \brief Class that implements a Viterbi decoder
@ -42,7 +43,7 @@ class Viterbi_Decoder
{
public:
Viterbi_Decoder(const int g_encoder[], const int KK, const int nn);
~Viterbi_Decoder();
~Viterbi_Decoder() = default;
void reset();
/*!
@ -94,16 +95,16 @@ private:
int d_number_symbols;
// trellis definition
int* d_out0;
int* d_state0;
int* d_out1;
int* d_state1;
std::vector<int> d_out0;
std::vector<int> d_state0;
std::vector<int> d_out1;
std::vector<int> d_state1;
// trellis state
float* d_pm_t;
std::vector<float> d_pm_t;
std::deque<Prev> d_trellis_paths;
float* d_metric_c; /* Set of all possible branch metrics */
float* d_rec_array; /* Received values for one trellis section */
std::vector<float> d_metric_c; /* Set of all possible branch metrics */
std::vector<float> d_rec_array; /* Received values for one trellis section */
bool d_trellis_state_is_initialised;
// measures

View File

@ -542,19 +542,11 @@ void dll_pll_veml_tracking::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg)
int tlm_event;
tlm_event = boost::any_cast<int>(pmt::any_ref(msg));
switch (tlm_event)
if (tlm_event == 1)
{
case 1: // tlm fault in current channel
{
DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel;
gr::thread::scoped_lock lock(d_setlock);
d_carrier_lock_fail_counter = 200000; //force loss-of-lock condition
break;
}
default:
{
break;
}
DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel;
gr::thread::scoped_lock lock(d_setlock);
d_carrier_lock_fail_counter = 200000; //force loss-of-lock condition
}
}
}

View File

@ -446,6 +446,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &
d_sample_counter_next = 0ULL;
}
void dll_pll_veml_tracking_fpga::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg)
{
try
@ -455,19 +456,12 @@ void dll_pll_veml_tracking_fpga::msg_handler_telemetry_to_trk(const pmt::pmt_t &
int tlm_event;
tlm_event = boost::any_cast<int>(pmt::any_ref(msg));
switch (tlm_event)
if (tlm_event == 1)
{
case 1: //tlm fault in current channel
{
DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel;
gr::thread::scoped_lock lock(d_setlock);
d_carrier_lock_fail_counter = 10000; //force loss-of-lock condition
break;
}
default:
{
break;
}
DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel;
gr::thread::scoped_lock lock(d_setlock);
d_carrier_lock_fail_counter = 10000; //force loss-of-lock condition
break;
}
}
}

View File

@ -46,13 +46,11 @@ const double BEIDOU_DNAV_F = -4.442807309e-10; //!< Constant, [s/(m)^
const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_BITS = 11;
const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS = 11; // **************
const double BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS = 300;
const double BEIDOU_DNAV_SUBFRAME_SYMBOLS = 300;
const int32_t BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS = 300;
const uint32_t BEIDOU_DNAV_SUBFRAME_SYMBOLS = 300;
const int32_t BEIDOU_DNAV_SUBFRAME_DATA_BITS = 300; //!< Number of bits per subframe in the NAV message [bits]
const double BEIDOU_DNAV_WORDS_SUBFRAME = 10;
const double BEIDOU_DNAV_WORD_LENGTH_BITS = 30;
const double BEIDOU_D1NAV_SYMBOL_RATE_SPS = 50;
const double BEIDOU_D2NAV_SYMBOL_RATE_SPS = 500;
const uint32_t BEIDOU_DNAV_WORDS_SUBFRAME = 10;
const uint32_t BEIDOU_DNAV_WORD_LENGTH_BITS = 30;
const std::string BEIDOU_DNAV_PREAMBLE = "11100010010";
// Number of leap seconds passed from the start of the GPS epoch up to the start of BeiDou epoch

View File

@ -256,10 +256,10 @@ uint64_t Beidou_Dnav_Navigation_Message::read_navigation_unsigned(
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; //shift left
value <<= 1U; // shift left
if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1)
{
value += 1; // insert the bit
value += 1U; // insert the bit
}
}
}
@ -544,7 +544,7 @@ int32_t Beidou_Dnav_Navigation_Message::d1_subframe_decoder(std::string const& s
d_sqrt_A = d_sqrt_A * D1_SQRT_A_LSB;
d_Toe_sf2 = static_cast<double>(read_navigation_unsigned(subframe_bits, D1_TOE_SF2));
d_Toe_sf2 = static_cast<double>((static_cast<int>(d_Toe_sf2) << 15));
d_Toe_sf2 = static_cast<double>((static_cast<uint32_t>(d_Toe_sf2) << 15U));
// Set system flags for message reception
flag_d1_sf2 = true;
@ -800,7 +800,7 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s
d_A_f0 = static_cast<double>(read_navigation_signed(subframe_bits, D2_A0)) * D1_A0_LSB;
d_A_f1_msb_bits = (read_navigation_unsigned(subframe_bits, D2_A1_MSB));
// Adjust for lsb in next page
d_A_f1_msb_bits = d_A_f1_msb_bits << 18;
d_A_f1_msb_bits = d_A_f1_msb_bits << 18ULL;
// Set system flags for message reception
flag_sf1_p3 = true;
@ -815,7 +815,7 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s
d_Delta_n = static_cast<double>(read_navigation_signed(subframe_bits, D2_DELTA_N)) * D1_DELTA_N_LSB;
d_Cuc_msb_bits = (read_navigation_unsigned(subframe_bits, D2_CUC_MSB));
// Adjust for lsb in next page
d_Cuc_msb_bits = d_Cuc_msb_bits << 4;
d_Cuc_msb_bits = d_Cuc_msb_bits << 4U;
// Set system flags for message reception
flag_sf1_p4 = true;
@ -830,8 +830,8 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s
d_eccentricity_msb = static_cast<double>(read_navigation_unsigned(subframe_bits, D2_E_MSB));
d_eccentricity_msb_bits = (read_navigation_unsigned(subframe_bits, D2_E_MSB));
// Adjust for lsb in next page (shift number of lsb to the left)
d_eccentricity_msb = static_cast<uint64_t>((static_cast<uint64_t>(d_eccentricity_msb) << 22));
d_eccentricity_msb_bits = d_eccentricity_msb_bits << 22;
d_eccentricity_msb = static_cast<uint64_t>((static_cast<uint64_t>(d_eccentricity_msb) << 22U));
d_eccentricity_msb_bits = d_eccentricity_msb_bits << 22U;
// Set system flags for message reception
flag_sf1_p5 = true;
@ -845,7 +845,7 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s
d_sqrt_A = static_cast<double>(read_navigation_unsigned(subframe_bits, D2_SQRT_A)) * D1_SQRT_A_LSB;
d_Cic_msb_bits = (read_navigation_unsigned(subframe_bits, D2_CIC_MSB));
// Adjust for lsb in next page (shift number of lsb to the left)
d_Cic_msb_bits = d_Cic_msb_bits << 8;
d_Cic_msb_bits = d_Cic_msb_bits << 8U;
// Set system flags for message reception
flag_sf1_p6 = true;
@ -859,7 +859,7 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s
d_Toe = static_cast<double>(read_navigation_unsigned(subframe_bits, D2_TOE)) * D1_TOE_LSB;
d_i_0_msb_bits = (read_navigation_unsigned(subframe_bits, D2_I0_MSB));
// Adjust for lsb in next page (shift number of lsb to the left)
d_i_0_msb_bits = d_i_0_msb_bits << 11;
d_i_0_msb_bits = d_i_0_msb_bits << 11U;
// Set system flags for message reception
flag_sf1_p7 = true;
@ -873,7 +873,7 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s
d_Crs = static_cast<double>(read_navigation_signed(subframe_bits, D2_CRS)) * D1_CRS_LSB;
d_OMEGA_DOT_msb_bits = (read_navigation_unsigned(subframe_bits, D2_OMEGA_DOT_MSB));
// Adjust for lsb in next page (shift number of lsb to the left)
d_OMEGA_DOT_msb_bits = d_OMEGA_DOT_msb_bits << 5;
d_OMEGA_DOT_msb_bits = d_OMEGA_DOT_msb_bits << 5ULL;
// Set system flags for message reception
flag_sf1_p8 = true;
@ -886,7 +886,7 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s
d_OMEGA0 = static_cast<double>(read_navigation_signed(subframe_bits, D2_OMEGA0)) * D1_OMEGA0_LSB;
d_OMEGA_msb_bits = (read_navigation_unsigned(subframe_bits, D2_OMEGA_MSB));
// Adjust for lsb in next page (shift number of lsb to the left)
d_OMEGA_msb_bits = d_OMEGA_msb_bits << 5;
d_OMEGA_msb_bits = d_OMEGA_msb_bits << 5U;
// Set system flags for message reception
flag_sf1_p9 = true;

View File

@ -439,7 +439,7 @@ uint64_t Galileo_Fnav_Message::read_navigation_unsigned(std::bitset<GALILEO_FNAV
{
for (int j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value <<= 1U; // shift left
if (static_cast<int>(bits[GALILEO_FNAV_DATA_FRAME_BITS - parameter[i].first - j]) == 1)
{
value += 1; // insert the bit

View File

@ -266,7 +266,7 @@ uint64_t Galileo_Navigation_Message::read_navigation_unsigned(std::bitset<GALILE
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value <<= 1U; // shift left
if (static_cast<int>(bits[GALILEO_DATA_JK_BITS - parameter[i].first - j]) == 1)
{
value += 1; // insert the bit
@ -285,7 +285,7 @@ uint64_t Galileo_Navigation_Message::read_page_type_unsigned(std::bitset<GALILEO
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value <<= 1U; // shift left
if (static_cast<int>(bits[GALILEO_PAGE_TYPE_BITS - parameter[i].first - j]) == 1)
{
value += 1ULL; // insert the bit
@ -965,6 +965,9 @@ int32_t Galileo_Navigation_Message::page_jk_decoder(const char* data_jk)
DLOG(INFO) << "TOW_0= " << TOW_0;
DLOG(INFO) << "flag_tow_set" << flag_TOW_set;
break;
default:
break;
}
return page_number;
}

View File

@ -111,7 +111,7 @@ Glonass_Gnav_Navigation_Message::Glonass_Gnav_Navigation_Message()
bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset<GLONASS_GNAV_STRING_BITS> bits)
{
int32_t sum_bits = 0;
uint32_t sum_bits = 0;
int32_t sum_hamming = 0;
int32_t C1 = 0;
int32_t C2 = 0;
@ -121,12 +121,12 @@ bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset<GLONASS_GNAV_STRING_B
int32_t C6 = 0;
int32_t C7 = 0;
int32_t C_Sigma = 0;
std::vector<int32_t> string_bits(GLONASS_GNAV_STRING_BITS);
std::vector<uint32_t> string_bits(GLONASS_GNAV_STRING_BITS);
// Populate data and hamming code vectors
for (int32_t i = 0; i < static_cast<int32_t>(GLONASS_GNAV_STRING_BITS); i++)
for (int32_t i = 0; i < string_bits.size(); i++)
{
string_bits[i] = static_cast<int32_t>(bits[i]);
string_bits[i] = static_cast<uint32_t>(bits[i]);
}
// Compute C1 term
@ -239,7 +239,7 @@ uint64_t Glonass_Gnav_Navigation_Message::read_navigation_unsigned(std::bitset<G
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value <<= 1ULL; // shift left
if (bits[GLONASS_GNAV_STRING_BITS - parameter[i].first - j] == 1)
{
value += 1ULL; // insert the bit

View File

@ -96,7 +96,7 @@ uint64_t Gps_CNAV_Navigation_Message::read_navigation_unsigned(std::bitset<GPS_C
{
for (int32_t j = 0; j < parameter[i].second; j++)
{
value <<= 1; // shift left
value <<= 1ULL; // shift left
if (static_cast<int>(bits[GPS_CNAV_DATA_PAGE_BITS - parameter[i].first - j]) == 1)
{
value += 1ULL; // insert the bit