From a6b94eaccf4ba56ab5f694292d65f9478c055119 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 10 Feb 2019 12:40:03 +0100 Subject: [PATCH 1/8] Make use of cstdint typedefs, fix warning, remove unused variable --- .../beidou_b1i_telemetry_decoder_cc.cc | 95 +++-- .../beidou_b1i_telemetry_decoder_cc.h | 26 +- src/core/system_parameters/Beidou_B1I.h | 331 +++++++++--------- 3 files changed, 225 insertions(+), 227 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc index 3a18185ec..8da254729 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc @@ -8,7 +8,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -73,7 +73,6 @@ beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc( d_secondary_code_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_B1I_SECONDARY_CODE_LENGTH * sizeof(int32_t), volk_gnsssdr_get_alignment())); d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; - d_subframe_length_symbols = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; // Setting samples of secondary code for (int32_t i = 0; i < BEIDOU_B1I_SECONDARY_CODE_LENGTH; i++) @@ -115,7 +114,7 @@ beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc( } } - d_subframe_symbols = static_cast(volk_gnsssdr_malloc(d_subframe_length_symbols * sizeof(double), volk_gnsssdr_get_alignment())); + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment())); d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble; // Generic settings @@ -154,15 +153,15 @@ beidou_b1i_telemetry_decoder_cc::~beidou_b1i_telemetry_decoder_cc() void beidou_b1i_telemetry_decoder_cc::decode_bch15_11_01(const int32_t *bits, int32_t *decbits) { - int bit, err, reg[4] = {1, 1, 1, 1}; - int errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2}; + int32_t bit, err, reg[4] = {1, 1, 1, 1}; + int32_t errind[15] = {14, 13, 10, 12, 6, 9, 4, 11, 0, 5, 7, 8, 1, 3, 2}; - for (unsigned int i = 0; i < 15; i++) + for (uint32_t i = 0; i < 15; i++) { decbits[i] = bits[i]; } - for (unsigned int i = 0; i < 15; i++) + for (uint32_t i = 0; i < 15; i++) { bit = reg[3]; reg[3] = reg[2]; @@ -180,6 +179,7 @@ void beidou_b1i_telemetry_decoder_cc::decode_bch15_11_01(const int32_t *bits, in } } + void beidou_b1i_telemetry_decoder_cc::decode_word( int32_t word_counter, const double *enc_word_symbols, @@ -189,31 +189,31 @@ void beidou_b1i_telemetry_decoder_cc::decode_word( if (word_counter == 1) { - for (unsigned int j = 0; j < 30; j++) + for (uint32_t j = 0; j < 30; j++) { - dec_word_symbols[j] = (int32_t)(enc_word_symbols[j] > 0) ? (1) : (-1); + dec_word_symbols[j] = static_cast(enc_word_symbols[j] > 0) ? (1) : (-1); } } else { - for (unsigned int r = 0; r < 2; r++) + for (uint32_t r = 0; r < 2; r++) { - for (unsigned int c = 0; c < 15; c++) + for (uint32_t c = 0; c < 15; c++) { - bitsbch[r * 15 + c] = (int32_t)(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1); + bitsbch[r * 15 + c] = static_cast(enc_word_symbols[c * 2 + r] > 0) ? (1) : (-1); } } decode_bch15_11_01(&bitsbch[0], first_branch); decode_bch15_11_01(&bitsbch[15], second_branch); - for (unsigned int j = 0; j < 11; j++) + for (uint32_t j = 0; j < 11; j++) { dec_word_symbols[j] = first_branch[j]; dec_word_symbols[j + 11] = second_branch[j]; } - for (unsigned int j = 0; j < 4; j++) + for (uint32_t j = 0; j < 4; j++) { dec_word_symbols[j + 22] = first_branch[11 + j]; dec_word_symbols[j + 26] = second_branch[11 + j]; @@ -222,7 +222,7 @@ void beidou_b1i_telemetry_decoder_cc::decode_word( } -void beidou_b1i_telemetry_decoder_cc::decode_subframe(double *frame_symbols, int32_t frame_length) +void beidou_b1i_telemetry_decoder_cc::decode_subframe(double *frame_symbols) { // 1. Transform from symbols to bits std::string data_bits; @@ -287,9 +287,9 @@ void beidou_b1i_telemetry_decoder_cc::decode_subframe(double *frame_symbols, int } if (d_nav.have_new_almanac() == true) { - // unsigned int slot_nbr = d_nav.i_alm_satellite_PRN; - // std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); - // this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + // uint32_t slot_nbr = d_nav.i_alm_satellite_PRN; + // std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); + // this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); LOG(INFO) << "BEIDOU DNAV Almanac have been received in channel" << d_channel << " from satellite " << d_satellite << std::endl; std::cout << "New BEIDOU B1I DNAV almanac received in channel " << d_channel << " from satellite " << d_satellite << std::endl; } @@ -321,7 +321,6 @@ void beidou_b1i_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satell d_secondary_code_symbols = nullptr; d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; - d_subframe_length_symbols = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; // Setting samples of preamble code int32_t n = 0; @@ -345,13 +344,13 @@ void beidou_b1i_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satell } } - d_subframe_symbols = static_cast(volk_gnsssdr_malloc(d_subframe_length_symbols * sizeof(double), volk_gnsssdr_get_alignment())); + d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment())); d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble; } } -void beidou_b1i_telemetry_decoder_cc::set_channel(int channel) +void beidou_b1i_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; LOG(INFO) << "Navigation channel set to " << channel; @@ -387,11 +386,11 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block - //1. Copy the current tracking output + Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block + // 1. Copy the current tracking output current_symbol = in[0][0]; - d_symbol_history.push_back(current_symbol.Prompt_I); //add new symbol to the symbol queue - d_sample_counter++; //count for the processed samples + d_symbol_history.push_back(current_symbol.Prompt_I); // add new symbol to the symbol queue + d_sample_counter++; // count for the processed samples consume_each(1); d_flag_preamble = false; @@ -399,7 +398,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ if (d_symbol_history.size() > d_required_symbols) { //******* preamble correlation ******** - for (int i = 0; i < d_samples_per_preamble; i++) + for (int32_t i = 0; i < d_samples_per_preamble; i++) { if (d_symbol_history.at(i) < 0) // symbols clipping { @@ -413,7 +412,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ } //******* frame sync ****************** - if (d_stat == 0) //no preamble information + if (d_stat == 0) // no preamble information { if (abs(corr_value) >= d_samples_per_preamble) { @@ -428,11 +427,11 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ { if (abs(corr_value) >= d_samples_per_preamble) { - //check preamble separation + // check preamble separation preamble_diff = static_cast(d_sample_counter - d_preamble_index); if (abs(preamble_diff - d_preamble_period_samples) == 0) { - //try to decode frame + // try to decode frame LOG(INFO) << "Starting BeiDou DNAV frame decoding for BeiDou B1I SAT " << this->d_satellite; d_preamble_index = d_sample_counter; //record the preamble sample stamp d_stat = 2; @@ -451,14 +450,14 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ { if (d_sample_counter == d_preamble_index + static_cast(d_preamble_period_samples)) { - //******* SAMPLES TO SYMBOLS ******* + // ******* SAMPLES TO SYMBOLS ******* if (corr_value > 0) //normal PLL lock { - int k = 0; - for (uint32_t i = 0; i < d_subframe_length_symbols; i++) + int32_t k = 0; + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) { d_subframe_symbols[i] = 0; - //integrate samples into symbols + // integrate samples into symbols for (uint32_t m = 0; m < d_samples_per_symbol; m++) { if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) @@ -476,13 +475,13 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ } } } - else //180 deg. inverted carrier phase PLL lock + else // 180 deg. inverted carrier phase PLL lock { - int k = 0; - for (uint32_t i = 0; i < d_subframe_length_symbols; i++) + int32_t k = 0; + for (uint32_t i = 0; i < BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS; i++) { d_subframe_symbols[i] = 0; - //integrate samples into symbols + // integrate samples into symbols for (uint32_t m = 0; m < d_samples_per_symbol; m++) { if (d_satellite.get_PRN() > 0 and d_satellite.get_PRN() < 6) @@ -501,14 +500,14 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ } } - //call the decoder - decode_subframe(d_subframe_symbols, d_subframe_length_symbols); + // call the decoder + decode_subframe(d_subframe_symbols); if (d_nav.flag_crc_test == true) { d_CRC_error_counter = 0; - d_flag_preamble = true; //valid preamble indicator (initialized to false every work()) - d_preamble_index = d_sample_counter; //record the preamble sample stamp (t_P) + d_flag_preamble = true; // valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; // record the preamble sample stamp (t_P) if (!d_flag_frame_sync) { d_flag_frame_sync = true; @@ -518,7 +517,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ else { d_CRC_error_counter++; - d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_preamble_index = d_sample_counter; // record the preamble sample stamp if (d_CRC_error_counter > CRC_ERROR_LIMIT) { LOG(INFO) << "BeiDou DNAV frame sync lost for SAT " << this->d_satellite; @@ -531,9 +530,9 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ } // UPDATE GNSS SYNCHRO DATA - //2. Add the telemetry decoder information + // 2. Add the telemetry decoder information if (this->d_flag_preamble == true and d_nav.flag_new_SOW_available == true) - //update TOW at the preamble instant + // update TOW at the preamble instant { // Reporting sow as gps time of week d_TOW_at_Preamble_ms = static_cast((d_nav.d_SOW + 14) * 1000.0); @@ -541,7 +540,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ flag_SOW_set = true; d_nav.flag_new_SOW_available = false; } - else //if there is not a new preamble, we define the TOW of the current symbol + else // if there is not a new preamble, we define the TOW of the current symbol { d_TOW_at_current_symbol_ms += static_cast(BEIDOU_B1I_CODE_PERIOD_MS); } @@ -565,11 +564,11 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ try { double tmp_double; - unsigned long int tmp_ulong_int; + uint64_t tmp_ulong_int; tmp_double = d_TOW_at_current_symbol_ms; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); tmp_ulong_int = current_symbol.Tracking_sample_counter; - d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(uint64_t)); tmp_double = 0; d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); } @@ -584,7 +583,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ { d_symbol_history.pop_front(); } - //3. Make the output (copy the object contents to the GNURadio reserved memory) + // 3. Make the output (copy the object contents to the GNURadio reserved memory) *out[0] = current_symbol; return 1; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h index e3ce59392..bd5eafb5a 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h @@ -9,7 +9,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -78,13 +78,12 @@ private: beidou_b1i_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); beidou_b1i_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); - void decode_subframe(double *symbols, int32_t frame_length); + void decode_subframe(double *symbols); void decode_word(int32_t word_counter, const double *enc_word_symbols, int32_t *dec_word_symbols); void decode_bch15_11_01(const int32_t *bits, int32_t *decbits); - //!< Preamble decoding - unsigned short int d_preambles_symbols[BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS]; + // Preamble decoding int32_t *d_preamble_samples; int32_t *d_secondary_code_symbols; uint32_t d_samples_per_symbol; @@ -92,20 +91,19 @@ private: int32_t d_samples_per_preamble; int32_t d_preamble_period_samples; double *d_subframe_symbols; - uint32_t d_subframe_length_symbols; uint32_t d_required_symbols; - //!< Storage for incoming data + // Storage for incoming data std::deque 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_preamble; //!< Flag indicating when preamble was found - int32_t d_CRC_error_counter; //!< Number of failed CRC operations - bool flag_SOW_set; //!< Indicates when time of week is set + // 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_preamble; // Flag indicating when preamble was found + 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 Beidou_Dnav_Navigation_Message d_nav; diff --git a/src/core/system_parameters/Beidou_B1I.h b/src/core/system_parameters/Beidou_B1I.h index f0b3a7bd9..76ac02f2c 100644 --- a/src/core/system_parameters/Beidou_B1I.h +++ b/src/core/system_parameters/Beidou_B1I.h @@ -33,6 +33,7 @@ #define GNSS_SDR_BEIDOU_B1I_H_ #include "MATH_CONSTANTS.h" +#include #include // std::pair #include @@ -51,9 +52,9 @@ const double BEIDOU_B1I_FREQ_HZ = 1.561098e9; //!< b1I [Hz] const double BEIDOU_B1I_CODE_RATE_HZ = 2.046e6; //!< beidou b1I code rate [chips/s] const double BEIDOU_B1I_CODE_LENGTH_CHIPS = 2046.0; //!< beidou b1I code length [chips] const double BEIDOU_B1I_CODE_PERIOD = 0.001; //!< beidou b1I code period [seconds] -const unsigned int BEIDOU_B1I_CODE_PERIOD_MS = 1; //!< GPS L1 C/A code period [ms] +const uint32_t BEIDOU_B1I_CODE_PERIOD_MS = 1; //!< beidou b1I L1 C/A code period [ms] const double BEIDOU_B1I_CHIP_PERIOD = 4.8875e-07; //!< beidou b1I chip period [seconds] -const int BEIDOU_B1I_SECONDARY_CODE_LENGTH = 20; +const int32_t BEIDOU_B1I_SECONDARY_CODE_LENGTH = 20; const std::string BEIDOU_B1I_SECONDARY_CODE = "00000100110101001110"; const std::string BEIDOU_B1I_SECONDARY_CODE_STR = "00000100110101001110"; const std::string BEIDOU_B1I_D2_SECONDARY_CODE_STR = "00"; @@ -73,29 +74,29 @@ const double BEIDOU_STARTOFFSET_ms = 68.802; //**************[ms] Initial sign. // OBSERVABLE HISTORY DEEP FOR INTERPOLATION -const int BEIDOU_B1I_HISTORY_DEEP = 100; // **************** +const int32_t BEIDOU_B1I_HISTORY_DEEP = 100; // **************** // NAVIGATION MESSAGE DEMODULATION AND DECODING -const int BEIDOU_B1I_PREAMBLE_LENGTH_BITS = 11; -const int BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** +const int32_t BEIDOU_B1I_PREAMBLE_LENGTH_BITS = 11; +const int32_t BEIDOU_B1I_PREAMBLE_LENGTH_SYMBOLS = 220; // ************** const double BEIDOU_B1I_PREAMBLE_DURATION_S = 0.220; -const int BEIDOU_B1I_PREAMBLE_DURATION_MS = 220; -const int BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND = 50; //!< D1 NAV message bit rate [bits/s] -const int BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT = 20; // ************* -const int BEIDOU_B1I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; //************!< NAV message bit rate [symbols/s] -const int BEIDOU_WORD_LENGTH = 4; //**************!< CRC + BEIDOU WORD (-2 -1 0 ... 29) Bits = 4 bytes -const int BEIDOU_SUBFRAME_LENGTH = 40; //**************!< BEIDOU_WORD_LENGTH x 10 = 40 bytes -const int BEIDOU_DNAV_SUBFRAME_DATA_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] -const int BEIDOU_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] -const int BEIDOU_SUBFRAME_MS = 6000; //!< Subframe duration [miliseconds] -const int BEIDOU_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] +const int32_t BEIDOU_B1I_PREAMBLE_DURATION_MS = 220; +const int32_t BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND = 50; //!< D1 NAV message bit rate [bits/s] +const int32_t BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT = 20; // ************* +const int32_t BEIDOU_B1I_TELEMETRY_RATE_SYMBOLS_SECOND = BEIDOU_B1I_TELEMETRY_RATE_BITS_SECOND * BEIDOU_B1I_TELEMETRY_SYMBOLS_PER_BIT; //************!< NAV message bit rate [symbols/s] +const int32_t BEIDOU_WORD_LENGTH = 4; //**************!< CRC + BEIDOU WORD (-2 -1 0 ... 29) Bits = 4 bytes +const int32_t BEIDOU_SUBFRAME_LENGTH = 40; //**************!< BEIDOU_WORD_LENGTH x 10 = 40 bytes +const int32_t BEIDOU_DNAV_SUBFRAME_DATA_BITS = 300; //!< Number of bits per subframe in the NAV message [bits] +const int32_t BEIDOU_SUBFRAME_SECONDS = 6; //!< Subframe duration [seconds] +const int32_t BEIDOU_SUBFRAME_MS = 6000; //!< Subframe duration [miliseconds] +const int32_t BEIDOU_WORD_BITS = 30; //!< Number of bits per word in the NAV message [bits] const std::string BEIDOU_DNAV_PREAMBLE = "11100010010"; -const int BEIDOU_DNAV_PREAMBLE_LENGTH_BITS = 11; -const int 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_LENGTH_BITS = 11; +const int32_t BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS = 11; // ************** +const uint32_t BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS = 300; +const uint32_t BEIDOU_DNAV_SUBFRAME_SYMBOLS = 300; const double BEIDOU_DNAV_DATA_BITS = 300; const double BEIDOU_DNAV_WORDS_SUBFRAME = 10; const double BEIDOU_DNAV_WORD_LENGTH_BITS = 30; @@ -106,10 +107,10 @@ const double BEIDOU_B1I_PREAMBLE_PERIOD_SYMBOLS = 300; // BEIDOU D1 NAVIGATION MESSAGE STRUCTURE // GENERAL -const std::vector > D1_PRE({{1, 11}}); -const std::vector > D1_FRAID({{16, 3}}); -const std::vector > D1_SOW({{19, 8}, {31, 12}}); -const std::vector > D1_PNUM({{44, 7}}); +const std::vector > D1_PRE({{1, 11}}); +const std::vector > D1_FRAID({{16, 3}}); +const std::vector > D1_SOW({{19, 8}, {31, 12}}); +const std::vector > D1_PNUM({{44, 7}}); // DNAV SCALE FACTORS // EPH @@ -164,183 +165,183 @@ const double D1_A0UTC_LSB = TWO_N30; const double D1_A1UTC_LSB = TWO_N50; // SUBFRAME 1 -const std::vector > D1_SAT_H1({{43, 1}}); -const std::vector > D1_AODC({{44, 5}}); -const std::vector > D1_URAI({{49, 4}}); -const std::vector > D1_WN({{61, 13}}); -const std::vector > D1_TOC({{74, 9}, {91, 8}}); -const std::vector > D1_TGD1({{99, 10}}); -const std::vector > D1_TGD2({{121, 6}}); -const std::vector > D1_ALPHA0({{127, 8}}); -const std::vector > D1_ALPHA1({{135, 8}}); -const std::vector > D1_ALPHA2({{151, 8}}); -const std::vector > D1_ALPHA3({{159, 8}}); -const std::vector > D1_BETA0({{167, 6}, {181, 2}}); -const std::vector > D1_BETA1({{183, 8}}); -const std::vector > D1_BETA2({{191, 8}}); -const std::vector > D1_BETA3({{199, 4}, {211, 4}}); -const std::vector > D1_A2({{215, 11}}); -const std::vector > D1_A0({{226, 7}, {241, 17}}); -const std::vector > D1_A1({{258, 5}, {271, 17}}); -const std::vector > D1_AODE({{288, 5}}); +const std::vector > D1_SAT_H1({{43, 1}}); +const std::vector > D1_AODC({{44, 5}}); +const std::vector > D1_URAI({{49, 4}}); +const std::vector > D1_WN({{61, 13}}); +const std::vector > D1_TOC({{74, 9}, {91, 8}}); +const std::vector > D1_TGD1({{99, 10}}); +const std::vector > D1_TGD2({{121, 6}}); +const std::vector > D1_ALPHA0({{127, 8}}); +const std::vector > D1_ALPHA1({{135, 8}}); +const std::vector > D1_ALPHA2({{151, 8}}); +const std::vector > D1_ALPHA3({{159, 8}}); +const std::vector > D1_BETA0({{167, 6}, {181, 2}}); +const std::vector > D1_BETA1({{183, 8}}); +const std::vector > D1_BETA2({{191, 8}}); +const std::vector > D1_BETA3({{199, 4}, {211, 4}}); +const std::vector > D1_A2({{215, 11}}); +const std::vector > D1_A0({{226, 7}, {241, 17}}); +const std::vector > D1_A1({{258, 5}, {271, 17}}); +const std::vector > D1_AODE({{288, 5}}); //SUBFRAME 2 -const std::vector > D1_DELTA_N({{43, 10}, {61, 6}}); -const std::vector > D1_CUC({{67, 16}, {91, 2}}); -const std::vector > D1_M0({{93, 20}, {121, 12}}); -const std::vector > D1_E({{133, 10}, {151, 22}}); -const std::vector > D1_CUS({{181, 18}}); -const std::vector > D1_CRC({{199, 4}, {211, 14}}); -const std::vector > D1_CRS({{225, 8}, {241, 10}}); -const std::vector > D1_SQRT_A({{251, 12}, {271, 20}}); -const std::vector > D1_TOE_SF2({{291, 2}}); +const std::vector > D1_DELTA_N({{43, 10}, {61, 6}}); +const std::vector > D1_CUC({{67, 16}, {91, 2}}); +const std::vector > D1_M0({{93, 20}, {121, 12}}); +const std::vector > D1_E({{133, 10}, {151, 22}}); +const std::vector > D1_CUS({{181, 18}}); +const std::vector > D1_CRC({{199, 4}, {211, 14}}); +const std::vector > D1_CRS({{225, 8}, {241, 10}}); +const std::vector > D1_SQRT_A({{251, 12}, {271, 20}}); +const std::vector > D1_TOE_SF2({{291, 2}}); //SUBFRAME 3 -const std::vector > D1_TOE_SF3({{43, 10}, {61, 5}}); -const std::vector > D1_I0({{66, 17}, {91, 15}}); -const std::vector > D1_CIC({{106, 7}, {121, 11}}); -const std::vector > D1_OMEGA_DOT({{132, 11}, {151, 13}}); -const std::vector > D1_CIS({{164, 9}, {181, 9}}); -const std::vector > D1_IDOT({{190, 13}, {211, 1}}); -const std::vector > D1_OMEGA0({{212, 21}, {241, 11}}); -const std::vector > D1_OMEGA({{252, 11}, {271, 21}}); +const std::vector > D1_TOE_SF3({{43, 10}, {61, 5}}); +const std::vector > D1_I0({{66, 17}, {91, 15}}); +const std::vector > D1_CIC({{106, 7}, {121, 11}}); +const std::vector > D1_OMEGA_DOT({{132, 11}, {151, 13}}); +const std::vector > D1_CIS({{164, 9}, {181, 9}}); +const std::vector > D1_IDOT({{190, 13}, {211, 1}}); +const std::vector > D1_OMEGA0({{212, 21}, {241, 11}}); +const std::vector > D1_OMEGA({{252, 11}, {271, 21}}); //SUBFRAME 4 AND PAGES 1 THROUGH 6 IN SUBFRAME 5 -const std::vector > D1_SQRT_A_ALMANAC({{51, 2}, {61, 22}}); -const std::vector > D1_A1_ALMANAC({{91, 11}}); -const std::vector > D1_A0_ALMANAC({{102, 11}}); -const std::vector > D1_OMEGA0_ALMANAC({{121, 22}, {151, 2}}); -const std::vector > D1_E_ALMANAC({{153, 17}}); -const std::vector > D1_DELTA_I({{170, 3}, {181, 13}}); -const std::vector > D1_TOA({{194, 8}}); -const std::vector > D1_OMEGA_DOT_ALMANAC({{202, 1}, {211, 16}}); -const std::vector > D1_OMEGA_ALMANAC({{227, 6}, {241, 18}}); -const std::vector > D1_M0_ALMANAC({{259, 4}, {271, 20}}); +const std::vector > D1_SQRT_A_ALMANAC({{51, 2}, {61, 22}}); +const std::vector > D1_A1_ALMANAC({{91, 11}}); +const std::vector > D1_A0_ALMANAC({{102, 11}}); +const std::vector > D1_OMEGA0_ALMANAC({{121, 22}, {151, 2}}); +const std::vector > D1_E_ALMANAC({{153, 17}}); +const std::vector > D1_DELTA_I({{170, 3}, {181, 13}}); +const std::vector > D1_TOA({{194, 8}}); +const std::vector > D1_OMEGA_DOT_ALMANAC({{202, 1}, {211, 16}}); +const std::vector > D1_OMEGA_ALMANAC({{227, 6}, {241, 18}}); +const std::vector > D1_M0_ALMANAC({{259, 4}, {271, 20}}); //SUBFRAME 5 PAGE 7 -const std::vector > D1_HEA1({{51, 2}, {61, 7}}); -const std::vector > D1_HEA2({{68, 9}}); -const std::vector > D1_HEA3({{77, 6}, {91, 3}}); -const std::vector > D1_HEA4({{94, 9}}); -const std::vector > D1_HEA5({{103, 9}}); -const std::vector > D1_HEA6({{112, 1}, {121, 8}}); -const std::vector > D1_HEA7({{129, 9}}); -const std::vector > D1_HEA8({{138, 5}, {151, 4}}); -const std::vector > D1_HEA9({{155, 9}}); -const std::vector > D1_HEA10({{164, 9}}); -const std::vector > D1_HEA11({{181, 9}}); -const std::vector > D1_HEA12({{190, 9}}); -const std::vector > D1_HEA13({{199, 4}, {211, 5}}); -const std::vector > D1_HEA14({{216, 9}}); -const std::vector > D1_HEA15({{225, 8}, {241, 1}}); -const std::vector > D1_HEA16({{242, 9}}); -const std::vector > D1_HEA17({{251, 9}}); -const std::vector > D1_HEA18({{260, 3}, {271, 6}}); -const std::vector > D1_HEA19({{277, 9}}); +const std::vector > D1_HEA1({{51, 2}, {61, 7}}); +const std::vector > D1_HEA2({{68, 9}}); +const std::vector > D1_HEA3({{77, 6}, {91, 3}}); +const std::vector > D1_HEA4({{94, 9}}); +const std::vector > D1_HEA5({{103, 9}}); +const std::vector > D1_HEA6({{112, 1}, {121, 8}}); +const std::vector > D1_HEA7({{129, 9}}); +const std::vector > D1_HEA8({{138, 5}, {151, 4}}); +const std::vector > D1_HEA9({{155, 9}}); +const std::vector > D1_HEA10({{164, 9}}); +const std::vector > D1_HEA11({{181, 9}}); +const std::vector > D1_HEA12({{190, 9}}); +const std::vector > D1_HEA13({{199, 4}, {211, 5}}); +const std::vector > D1_HEA14({{216, 9}}); +const std::vector > D1_HEA15({{225, 8}, {241, 1}}); +const std::vector > D1_HEA16({{242, 9}}); +const std::vector > D1_HEA17({{251, 9}}); +const std::vector > D1_HEA18({{260, 3}, {271, 6}}); +const std::vector > D1_HEA19({{277, 9}}); //SUBFRAME 5 PAGE 8 -const std::vector > D1_HEA20({{51, 2}, {61, 7}}); -const std::vector > D1_HEA21({{68, 9}}); -const std::vector > D1_HEA22({{77, 6}, {91, 3}}); -const std::vector > D1_HEA23({{94, 9}}); -const std::vector > D1_HEA24({{103, 9}}); -const std::vector > D1_HEA25({{112, 1}, {121, 8}}); -const std::vector > D1_HEA26({{129, 9}}); -const std::vector > D1_HEA27({{138, 5}, {151, 4}}); -const std::vector > D1_HEA28({{155, 9}}); -const std::vector > D1_HEA29({{164, 9}}); -const std::vector > D1_HEA30({{181, 9}}); -const std::vector > D1_WNA({{190, 8}}); -const std::vector > D1_TOA2({{198, 5}, {211, 3}}); +const std::vector > D1_HEA20({{51, 2}, {61, 7}}); +const std::vector > D1_HEA21({{68, 9}}); +const std::vector > D1_HEA22({{77, 6}, {91, 3}}); +const std::vector > D1_HEA23({{94, 9}}); +const std::vector > D1_HEA24({{103, 9}}); +const std::vector > D1_HEA25({{112, 1}, {121, 8}}); +const std::vector > D1_HEA26({{129, 9}}); +const std::vector > D1_HEA27({{138, 5}, {151, 4}}); +const std::vector > D1_HEA28({{155, 9}}); +const std::vector > D1_HEA29({{164, 9}}); +const std::vector > D1_HEA30({{181, 9}}); +const std::vector > D1_WNA({{190, 8}}); +const std::vector > D1_TOA2({{198, 5}, {211, 3}}); //SUBFRAME 5 PAGE 9 -const std::vector > D1_A0GPS({{97, 14}}); -const std::vector > D1_A1GPS({{111, 2}, {121, 14}}); -const std::vector > D1_A0GAL({{135, 8}, {151, 6}}); -const std::vector > D1_A1GAL({{157, 16}}); -const std::vector > D1_A0GLO({{181, 14}}); -const std::vector > D1_A1GLO({{195, 8}, {211, 8}}); +const std::vector > D1_A0GPS({{97, 14}}); +const std::vector > D1_A1GPS({{111, 2}, {121, 14}}); +const std::vector > D1_A0GAL({{135, 8}, {151, 6}}); +const std::vector > D1_A1GAL({{157, 16}}); +const std::vector > D1_A0GLO({{181, 14}}); +const std::vector > D1_A1GLO({{195, 8}, {211, 8}}); //SUBFRAME 5 PAGE 10 -const std::vector > D1_DELTA_T_LS({{51, 2}, {61, 6}}); -const std::vector > D1_DELTA_T_LSF({{67, 8}}); -const std::vector > D1_WN_LSF({{75, 8}}); -const std::vector > D1_A0UTC({{91, 22}, {121, 10}}); -const std::vector > D1_A1UTC({{131, 12}, {151, 12}}); -const std::vector > D1_DN({{163, 8}}); +const std::vector > D1_DELTA_T_LS({{51, 2}, {61, 6}}); +const std::vector > D1_DELTA_T_LSF({{67, 8}}); +const std::vector > D1_WN_LSF({{75, 8}}); +const std::vector > D1_A0UTC({{91, 22}, {121, 10}}); +const std::vector > D1_A1UTC({{131, 12}, {151, 12}}); +const std::vector > D1_DN({{163, 8}}); // D2 NAV Message Decoding Information -const std::vector > D2_PRE({{1, 11}}); -const std::vector > D2_FRAID({{16, 3}}); -const std::vector > D2_SOW({{19, 8}, {31, 12}}); -const std::vector > D2_PNUM({{43, 4}}); +const std::vector > D2_PRE({{1, 11}}); +const std::vector > D2_FRAID({{16, 3}}); +const std::vector > D2_SOW({{19, 8}, {31, 12}}); +const std::vector > D2_PNUM({{43, 4}}); // D2 NAV, SUBFRAME 1, PAGE 1 -const std::vector > D2_SAT_H1({{47, 1}}); -const std::vector > D2_AODC({{48, 5}}); -const std::vector > D2_URAI({{61, 4}}); -const std::vector > D2_WN({{65, 13}}); -const std::vector > D2_TOC({{78, 5}, {91, 12}}); -const std::vector > D2_TGD1({{103, 10}}); -const std::vector > D2_TGD2({{121, 10}}); +const std::vector > D2_SAT_H1({{47, 1}}); +const std::vector > D2_AODC({{48, 5}}); +const std::vector > D2_URAI({{61, 4}}); +const std::vector > D2_WN({{65, 13}}); +const std::vector > D2_TOC({{78, 5}, {91, 12}}); +const std::vector > D2_TGD1({{103, 10}}); +const std::vector > D2_TGD2({{121, 10}}); // D2 NAV, SUBFRAME 1, PAGE 2 -const std::vector > D2_ALPHA0({{47, 6}, {61, 2}}); -const std::vector > D2_ALPHA1({{63, 8}}); -const std::vector > D2_ALPHA2({{71, 8}}); -const std::vector > D2_ALPHA3({{79, 4}, {91, 4}}); -const std::vector > D2_BETA0({{95, 8}}); -const std::vector > D2_BETA1({{103, 8}}); -const std::vector > D2_BETA2({{111, 2}, {121, 6}}); -const std::vector > D2_BETA3({{127, 8}}); +const std::vector > D2_ALPHA0({{47, 6}, {61, 2}}); +const std::vector > D2_ALPHA1({{63, 8}}); +const std::vector > D2_ALPHA2({{71, 8}}); +const std::vector > D2_ALPHA3({{79, 4}, {91, 4}}); +const std::vector > D2_BETA0({{95, 8}}); +const std::vector > D2_BETA1({{103, 8}}); +const std::vector > D2_BETA2({{111, 2}, {121, 6}}); +const std::vector > D2_BETA3({{127, 8}}); // D2 NAV, SUBFRAME 1, PAGE 3 -const std::vector > D2_A0({{101, 12}, {121, 12}}); -const std::vector > D2_A1_MSB({{133, 4}}); -const std::vector > D2_A1_LSB({{47, 6}, {61, 12}}); -const std::vector > D2_A1({{279, 22}}); +const std::vector > D2_A0({{101, 12}, {121, 12}}); +const std::vector > D2_A1_MSB({{133, 4}}); +const std::vector > D2_A1_LSB({{47, 6}, {61, 12}}); +const std::vector > D2_A1({{279, 22}}); // D2 NAV, SUBFRAME 1, PAGE 4 -const std::vector > D2_A2({{73, 10}, {91, 1}}); -const std::vector > D2_AODE({{92, 5}}); -const std::vector > D2_DELTA_N({{97, 16}}); -const std::vector > D2_CUC_MSB({{121, 14}}); -const std::vector > D2_CUC_LSB({{47, 4}}); -const std::vector > D2_CUC({{283, 18}}); +const std::vector > D2_A2({{73, 10}, {91, 1}}); +const std::vector > D2_AODE({{92, 5}}); +const std::vector > D2_DELTA_N({{97, 16}}); +const std::vector > D2_CUC_MSB({{121, 14}}); +const std::vector > D2_CUC_LSB({{47, 4}}); +const std::vector > D2_CUC({{283, 18}}); // D2 NAV, SUBFRAME 1, PAGE 5 -const std::vector > D2_M0({{51, 2}, {61, 22}, {91, 8}}); -const std::vector > D2_CUS({{99, 14}, {121, 4}}); -const std::vector > D2_E_MSB({{125, 10}}); +const std::vector > D2_M0({{51, 2}, {61, 22}, {91, 8}}); +const std::vector > D2_CUS({{99, 14}, {121, 4}}); +const std::vector > D2_E_MSB({{125, 10}}); // D2 NAV, SUBFRAME 1, PAGE 6 -const std::vector > D2_E_LSB({{47, 6}, {61, 16}}); -const std::vector > D2_SQRT_A({{77, 6}, {91, 22}, {121, 4}}); -const std::vector > D2_CIC_MSB({{125, 10}}); -const std::vector > D2_CIC_LSB({{47, 6}, {61, 2}}); -const std::vector > D2_CIC({{283, 18}}); +const std::vector > D2_E_LSB({{47, 6}, {61, 16}}); +const std::vector > D2_SQRT_A({{77, 6}, {91, 22}, {121, 4}}); +const std::vector > D2_CIC_MSB({{125, 10}}); +const std::vector > D2_CIC_LSB({{47, 6}, {61, 2}}); +const std::vector > D2_CIC({{283, 18}}); // D2 NAV, SUBFRAME 1, PAGE 7 -const std::vector > D2_CIS({{63, 18}}); -const std::vector > D2_TOE({{81, 2}, {91, 15}}); -const std::vector > D2_I0_MSB({{106, 7}, {121, 14}}); -const std::vector > D2_I0_LSB({{47, 6}, {61, 5}}); -const std::vector > D2_I0({{269, 32}}); +const std::vector > D2_CIS({{63, 18}}); +const std::vector > D2_TOE({{81, 2}, {91, 15}}); +const std::vector > D2_I0_MSB({{106, 7}, {121, 14}}); +const std::vector > D2_I0_LSB({{47, 6}, {61, 5}}); +const std::vector > D2_I0({{269, 32}}); // D2 NAV, SUBFRAME 1, PAGE 8 -const std::vector > D2_CRC({{66, 17}, {91, 1}}); -const std::vector > D2_CRS({{92, 18}}); -const std::vector > D2_OMEGA_DOT_MSB({{110, 3}, {121, 16}}); -const std::vector > D2_OMEGA_DOT_LSB({{47, 5}}); -const std::vector > D2_OMEGA_DOT({{277, 24}}); +const std::vector > D2_CRC({{66, 17}, {91, 1}}); +const std::vector > D2_CRS({{92, 18}}); +const std::vector > D2_OMEGA_DOT_MSB({{110, 3}, {121, 16}}); +const std::vector > D2_OMEGA_DOT_LSB({{47, 5}}); +const std::vector > D2_OMEGA_DOT({{277, 24}}); // D2 NAV, SUBFRAME 1, PAGE 9 -const std::vector > D2_OMEGA0({{52, 1}, {61, 22}, {91, 9}}); -const std::vector > D2_OMEGA_MSB({{100, 13}, {121, 14}}); -const std::vector > D2_OMEGA_LSB({{47, 5}}); -const std::vector > D2_OMEGA({{269, 32}}); +const std::vector > D2_OMEGA0({{52, 1}, {61, 22}, {91, 9}}); +const std::vector > D2_OMEGA_MSB({{100, 13}, {121, 14}}); +const std::vector > D2_OMEGA_LSB({{47, 5}}); +const std::vector > D2_OMEGA({{269, 32}}); // D2 NAV, SUBFRAME 1, PAGE 10 -const std::vector > D2_IDOT({{52, 1}, {61, 13}}); +const std::vector > D2_IDOT({{52, 1}, {61, 13}}); #endif /* GNSS_SDR_BEIDOU_B1I_H_ */ From 21b5aeee9d7533273291ba7eba0377557f28f79b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 10 Feb 2019 12:45:23 +0100 Subject: [PATCH 2/8] Make use of cstdint type names --- .../libs/beidou_b1i_signal_processing.cc | 48 +++++----- .../libs/beidou_b1i_signal_processing.h | 23 ++--- .../beidou_dnav_navigation_message.cc | 94 ++++++++++++------- .../beidou_dnav_navigation_message.h | 68 +++++++------- 4 files changed, 128 insertions(+), 105 deletions(-) diff --git a/src/algorithms/libs/beidou_b1i_signal_processing.cc b/src/algorithms/libs/beidou_b1i_signal_processing.cc index 47230943a..b9618223e 100644 --- a/src/algorithms/libs/beidou_b1i_signal_processing.cc +++ b/src/algorithms/libs/beidou_b1i_signal_processing.cc @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -32,26 +32,26 @@ #include "beidou_b1i_signal_processing.h" -auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; -void beidou_b1i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift) +void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift) { - const unsigned int _code_length = 2046; + const uint32_t _code_length = 2046; bool G1[_code_length]; bool G2[_code_length]; bool G1_register[11] = {false, true, false, true, false, true, false, true, false, true, false}; bool G2_register[11] = {false, true, false, true, false, true, false, true, false, true, false}; bool feedback1, feedback2; bool aux; - unsigned int lcv, lcv2; - unsigned int delay; - signed int prn_idx; + uint32_t lcv, lcv2; + uint32_t delay; + int32_t prn_idx; /* G2 Delays as defined in GPS-ISD-200D */ - const signed int delays[33] = {712 /*PRN1*/, 1581, 1414, 1550, 581, 771, 1311, 1043, 1549, 359, 710, 1579, 1548, 1103, 579, 769, 358, 709, 1411, 1547, + const int32_t delays[33] = {712 /*PRN1*/, 1581, 1414, 1550, 581, 771, 1311, 1043, 1549, 359, 710, 1579, 1548, 1103, 579, 769, 358, 709, 1411, 1547, 1102, 578, 357, 1577, 1410, 1546, 1101, 707, 1576, 1409, 1545, 354 /*PRN32*/, 705}; - const signed int phase1[37] = {1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 8, 8, 8, 9, 9, 10}; - const signed int phase2[37] = {3, 4, 5, 6, 8, 9, 10, 11, 7, 4, 5, 6, 8, 9, 10, 11, 5, 6, 8, 9, 10, 11, 6, 8, 9, 10, 11, 8, 9, 10, 11, 9, 10, 11, 10, 11, 11}; + const int32_t phase1[37] = {1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 8, 8, 8, 9, 9, 10}; + const int32_t phase2[37] = {3, 4, 5, 6, 8, 9, 10, 11, 7, 4, 5, 6, 8, 9, 10, 11, 5, 6, 8, 9, 10, 11, 6, 8, 9, 10, 11, 8, 9, 10, 11, 9, 10, 11, 10, 11, 11}; // compute delay array index for given PRN number prn_idx = _prn - 1; @@ -110,28 +110,28 @@ void beidou_b1i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shi } -void beidou_b1i_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift) +void beidou_b1i_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift) { - unsigned int _code_length = 2046; - int b1i_code_int[_code_length]; + uint32_t _code_length = 2046; + int32_t b1i_code_int[_code_length]; beidou_b1i_code_gen_int(b1i_code_int, _prn, _chip_shift); - for (unsigned int ii = 0; ii < _code_length; ++ii) + for (uint32_t ii = 0; ii < _code_length; ++ii) { _dest[ii] = static_cast(b1i_code_int[ii]); } } -void beidou_b1i_code_gen_complex(std::complex* _dest, signed int _prn, unsigned int _chip_shift) +void beidou_b1i_code_gen_complex(std::complex* _dest, int32_t _prn, uint32_t _chip_shift) { - unsigned int _code_length = 2046; - int b1i_code_int[_code_length]; + uint32_t _code_length = 2046; + int32_t b1i_code_int[_code_length]; beidou_b1i_code_gen_int(b1i_code_int, _prn, _chip_shift); - for (unsigned int ii = 0; ii < _code_length; ++ii) + for (uint32_t ii = 0; ii < _code_length; ++ii) { _dest[ii] = std::complex(static_cast(b1i_code_int[ii]), 0.0f); } @@ -141,26 +141,26 @@ void beidou_b1i_code_gen_complex(std::complex* _dest, signed int _prn, un /* * Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency */ -void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, int _fs, unsigned int _chip_shift) +void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift) { // This function is based on the GNU software GPS for MATLAB in the Kay Borre book std::complex _code[2046]; - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; float aux; - const signed int _codeFreqBasis = 2046000; //Hz - const signed int _codeLength = 2046; + const int32_t _codeFreqBasis = 2046000; //Hz + const int32_t _codeLength = 2046; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec beidou_b1i_code_gen_complex(_code, _prn, _chip_shift); //generate C/A code 1 sample per chip - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= diff --git a/src/algorithms/libs/beidou_b1i_signal_processing.h b/src/algorithms/libs/beidou_b1i_signal_processing.h index 4c03328f0..16c842523 100644 --- a/src/algorithms/libs/beidou_b1i_signal_processing.h +++ b/src/algorithms/libs/beidou_b1i_signal_processing.h @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -30,25 +30,26 @@ * ------------------------------------------------------------------------- */ -#ifndef BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ -#define BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ +#ifndef GNSS_SDR_BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ +#define GNSS_SDR_BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ #include #include +#include -//!Generates int GPS L1 C/A code for the desired SV ID and code shift -void beidou_b1i_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates int32_t GPS L1 C/A code for the desired SV ID and code shift +void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift); -//!Generates float GPS L1 C/A code for the desired SV ID and code shift -void beidou_b1i_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates float GPS L1 C/A code for the desired SV ID and code shift +void beidou_b1i_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift); -//!Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency -void beidou_b1i_code_gen_complex(std::complex* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency +void beidou_b1i_code_gen_complex(std::complex* _dest, int32_t _prn, uint32_t _chip_shift); //! Generates N complex GPS L1 C/A codes for the desired SV ID and code shift -void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, int _fs, unsigned int _chip_shift, unsigned int _ncodes); +void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes); //! Generates complex GPS L1 C/A code for the desired SV ID and code shift -void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, int _fs, unsigned int _chip_shift); +void beidou_b1i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift); #endif /* BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ */ diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.cc b/src/core/system_parameters/beidou_dnav_navigation_message.cc index 7cebd5b6c..9a83d1598 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.cc +++ b/src/core/system_parameters/beidou_dnav_navigation_message.cc @@ -175,7 +175,7 @@ void Beidou_Dnav_Navigation_Message::reset() //Almanac d_Toa = 0; i_WN_A = 0; - for (int i = 1; i < 36; i++) + for (int32_t i = 1; i < 36; i++) { almanacHealth[i] = 0; } @@ -208,25 +208,30 @@ void Beidou_Dnav_Navigation_Message::reset() auto gnss_sat = Gnss_Satellite(); std::string _system("Beidou"); - for (unsigned int i = 1; i < 36; i++) + for (uint32_t i = 1; i < 36; i++) { satelliteBlock[i] = gnss_sat.what_block(_system, i); } } + Beidou_Dnav_Navigation_Message::Beidou_Dnav_Navigation_Message() { reset(); } -void Beidou_Dnav_Navigation_Message::print_beidou_word_bytes(unsigned int BEIDOU_word) + +void Beidou_Dnav_Navigation_Message::print_beidou_word_bytes(uint32_t BEIDOU_word) { std::cout << " Word ="; std::cout << std::bitset<32>(BEIDOU_word); std::cout << std::endl; } -bool Beidou_Dnav_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector>& parameter) + +bool Beidou_Dnav_Navigation_Message::read_navigation_bool( + std::bitset bits, + const std::vector>& parameter) { bool value; @@ -241,15 +246,18 @@ bool Beidou_Dnav_Navigation_Message::read_navigation_bool(std::bitset bits, const std::vector>& parameter) + +uint64_t Beidou_Dnav_Navigation_Message::read_navigation_unsigned( + std::bitset bits, + const std::vector>& parameter) { - unsigned long int value = 0; - int num_of_slices = parameter.size(); - for (int i = 0; i < num_of_slices; i++) + uint64_t value = 0ULL; + int32_t num_of_slices = parameter.size(); + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left + value <<= 1; // shift left if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1) { value += 1; // insert the bit @@ -259,30 +267,33 @@ unsigned long int Beidou_Dnav_Navigation_Message::read_navigation_unsigned(std:: return value; } -signed long int Beidou_Dnav_Navigation_Message::read_navigation_signed(std::bitset bits, const std::vector>& parameter) + +int64_t Beidou_Dnav_Navigation_Message::read_navigation_signed( + std::bitset bits, + const std::vector>& parameter) { - signed long int value = 0; - int num_of_slices = parameter.size(); + int64_t value = 0; + int32_t num_of_slices = parameter.size(); // Discriminate between 64 bits and 32 bits compiler - int long_int_size_bytes = sizeof(signed long int); + int32_t long_int_size_bytes = sizeof(int64_t); if (long_int_size_bytes == 8) // if a long int takes 8 bytes, we are in a 64 bits system { // read the MSB and perform the sign extension if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[0].first] == 1) { - value ^= 0xFFFFFFFFFFFFFFFF; //64 bits variable + value ^= 0xFFFFFFFFFFFFFFFF; // 64 bits variable } else { value &= 0; } - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left - value &= 0xFFFFFFFFFFFFFFFE; //reset the corresponding bit (for the 64 bits variable) + value <<= 1; // shift left + value &= 0xFFFFFFFFFFFFFFFE; // reset the corresponding bit (for the 64 bits variable) if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1) { value += 1; // insert the bit @@ -302,12 +313,12 @@ signed long int Beidou_Dnav_Navigation_Message::read_navigation_signed(std::bits value &= 0; } - for (int i = 0; i < num_of_slices; i++) + for (int32_t i = 0; i < num_of_slices; i++) { - for (int j = 0; j < parameter[i].second; j++) + for (int32_t j = 0; j < parameter[i].second; j++) { - value <<= 1; //shift left - value &= 0xFFFFFFFE; //reset the corresponding bit + value <<= 1; // shift left + value &= 0xFFFFFFFE; // reset the corresponding bit if (bits[BEIDOU_DNAV_SUBFRAME_DATA_BITS - parameter[i].first - j] == 1) { value += 1; // insert the bit @@ -318,6 +329,7 @@ signed long int Beidou_Dnav_Navigation_Message::read_navigation_signed(std::bits return value; } + double Beidou_Dnav_Navigation_Message::check_t(double time) { double corrTime; @@ -334,6 +346,7 @@ double Beidou_Dnav_Navigation_Message::check_t(double time) return corrTime; } + double Beidou_Dnav_Navigation_Message::sv_clock_correction(double transmitTime) { double dt; @@ -343,6 +356,7 @@ double Beidou_Dnav_Navigation_Message::sv_clock_correction(double transmitTime) return correctedTime; } + void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) { double tk; @@ -384,7 +398,7 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) E = M; // --- Iteratively compute eccentric anomaly ---------------------------- - for (int ii = 1; ii < 20; ii++) + for (int32_t ii = 1; ii < 20; ii++) { E_old = E; E = M + d_eccentricity * sin(E); @@ -437,9 +451,10 @@ void Beidou_Dnav_Navigation_Message::satellitePosition(double transmitTime) d_satvel_Z = d_satpos_Y * sin(i); } -int Beidou_Dnav_Navigation_Message::d1_subframe_decoder(std::string const& subframe) + +int32_t Beidou_Dnav_Navigation_Message::d1_subframe_decoder(std::string const& subframe) { - int subframe_ID = 0; + int32_t subframe_ID = 0; std::bitset subframe_bits(subframe); subframe_ID = static_cast(read_navigation_unsigned(subframe_bits, D1_FRAID)); @@ -505,8 +520,6 @@ int Beidou_Dnav_Navigation_Message::d1_subframe_decoder(std::string const& subfr break; case 2: // --- It is subframe 2 --- - - d_SOW_SF2 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); d_SOW = d_SOW_SF2; // Set transmission time @@ -541,7 +554,6 @@ int Beidou_Dnav_Navigation_Message::d1_subframe_decoder(std::string const& subfr break; case 3: // --- It is subframe 3 --- - d_SOW_SF3 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); d_SOW = d_SOW_SF3; // Set transmission time @@ -615,7 +627,7 @@ int Beidou_Dnav_Navigation_Message::d1_subframe_decoder(std::string const& subfr break; case 5: // --- It is subframe 5 --- - int SV_page_5; + int32_t SV_page_5; d_SOW_SF5 = static_cast(read_navigation_unsigned(subframe_bits, D1_SOW)); d_SOW = d_SOW_SF5; // Set transmission time @@ -731,10 +743,11 @@ int Beidou_Dnav_Navigation_Message::d1_subframe_decoder(std::string const& subfr return subframe_ID; } -int Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& subframe) + +int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& subframe) { - int subframe_ID = 0; - int page_ID = 0; + int32_t subframe_ID = 0; + int32_t page_ID = 0; std::bitset subframe_bits(subframe); @@ -920,6 +933,7 @@ int Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& subfr return subframe_ID; } + double Beidou_Dnav_Navigation_Message::utc_time(const double beidoutime_corrected) const { double t_utc; @@ -927,12 +941,12 @@ double Beidou_Dnav_Navigation_Message::utc_time(const double beidoutime_correcte double Delta_t_UTC = d_DeltaT_LS + d_A0UTC + d_A1UTC * (beidoutime_corrected); // Determine if the effectivity time of the leap second event is in the past - int weeksToLeapSecondEvent = i_WN_LSF - i_BEIDOU_week; + int32_t weeksToLeapSecondEvent = i_WN_LSF - i_BEIDOU_week; if ((weeksToLeapSecondEvent) >= 0) // is not in the past { //Detect if the effectivity time and user's time is within six hours = 6 * 60 *60 = 21600 s - int secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; + int32_t secondOfLeapSecondEvent = i_DN * 24 * 60 * 60; if (weeksToLeapSecondEvent > 0) { t_utc_daytime = fmod(beidoutime_corrected - Delta_t_UTC, 86400); @@ -947,7 +961,7 @@ double Beidou_Dnav_Navigation_Message::utc_time(const double beidoutime_correcte { if ((beidoutime_corrected - secondOfLeapSecondEvent) < (5 / 4) * 24 * 60 * 60) { - int W = fmod(beidoutime_corrected - Delta_t_UTC - 43200, 86400) + 43200; + int32_t W = fmod(beidoutime_corrected - Delta_t_UTC - 43200, 86400) + 43200; t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); } else @@ -967,6 +981,7 @@ double Beidou_Dnav_Navigation_Message::utc_time(const double beidoutime_correcte return t_utc; } + Beidou_Dnav_Ephemeris Beidou_Dnav_Navigation_Message::get_ephemeris() { Beidou_Dnav_Ephemeris eph; @@ -1064,6 +1079,7 @@ Beidou_Dnav_Ephemeris Beidou_Dnav_Navigation_Message::get_ephemeris() return eph; } + Beidou_Dnav_Iono Beidou_Dnav_Navigation_Message::get_iono() { Beidou_Dnav_Iono iono; @@ -1081,6 +1097,7 @@ Beidou_Dnav_Iono Beidou_Dnav_Navigation_Message::get_iono() return iono; } + Beidou_Dnav_Utc_Model Beidou_Dnav_Navigation_Message::get_utc_model() { Beidou_Dnav_Utc_Model utc_model; @@ -1105,6 +1122,7 @@ Beidou_Dnav_Utc_Model Beidou_Dnav_Navigation_Message::get_utc_model() return utc_model; } + bool Beidou_Dnav_Navigation_Message::have_new_ephemeris() // Check if we have a new ephemeris stored in the galileo navigation class { if (i_satellite_PRN > 0 and i_satellite_PRN < 6) @@ -1160,6 +1178,7 @@ bool Beidou_Dnav_Navigation_Message::have_new_ephemeris() // Check if we have a return false; } + bool Beidou_Dnav_Navigation_Message::have_new_iono() { // the condition on flag_utc_model is added to have a time stamp for iono @@ -1171,6 +1190,7 @@ bool Beidou_Dnav_Navigation_Message::have_new_iono() return false; } + bool Beidou_Dnav_Navigation_Message::have_new_utc_model() { if (flag_d1_sf5_p9 == true and flag_d1_sf5_p10 == true) @@ -1185,6 +1205,7 @@ bool Beidou_Dnav_Navigation_Message::have_new_utc_model() return false; } + bool Beidou_Dnav_Navigation_Message::have_new_almanac() { if ((flag_d1_sf4 == true) and (flag_d1_sf5 == true)) @@ -1199,6 +1220,7 @@ bool Beidou_Dnav_Navigation_Message::have_new_almanac() return false; } + bool Beidou_Dnav_Navigation_Message::satellite_validation() { bool flag_data_valid = false; diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.h b/src/core/system_parameters/beidou_dnav_navigation_message.h index 1525c7b4b..7212447cd 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.h +++ b/src/core/system_parameters/beidou_dnav_navigation_message.h @@ -54,10 +54,10 @@ class Beidou_Dnav_Navigation_Message { private: - unsigned long int read_navigation_unsigned(std::bitset bits, const std::vector>& parameter); - signed long int read_navigation_signed(std::bitset bits, const std::vector>& parameter); - bool read_navigation_bool(std::bitset bits, const std::vector>& parameter); - void print_beidou_word_bytes(unsigned int BEIDOU_word); + uint64_t read_navigation_unsigned(std::bitset bits, const std::vector>& parameter); + int64_t read_navigation_signed(std::bitset bits, const std::vector>& parameter); + bool read_navigation_bool(std::bitset bits, const std::vector>& parameter); + void print_beidou_word_bytes(uint32_t BEIDOU_word); /* * Accounts for the beginning or end of week crossover * @@ -130,15 +130,15 @@ public: double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] //broadcast orbit 5 double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] - int i_BEIDOU_week; //!< BeiDou week number, aka WN [week] + int32_t i_BEIDOU_week; //!< BeiDou week number, aka WN [week] //broadcast orbit 6 - int i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV - int i_SV_health; + int32_t i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV + int32_t i_SV_health; double d_TGD1; //!< Estimated Group Delay Differential in B1 [s] double d_TGD2; //!< Estimated Group Delay Differential in B2 [s] double d_AODC; //!< Age of Data, Clock //broadcast orbit 7 - // int i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] + // int32_t i_AODO; //!< Age of Data Offset (AODO) term for the navigation message correction table (NMCT) contained in subframe 4 (reference paragraph 20.3.3.5.1.9) [s] bool b_fit_interval_flag; //!< indicates the curve-fit interval used by the CS (Block II/IIA/IIR/IIR-M/IIF) and SS (Block IIIA) in determining the ephemeris parameters, as follows: 0 = 4 hours, 1 = greater than 4 hours. double d_spare1; @@ -149,29 +149,29 @@ public: double d_A_f2; //!< Clock correction parameters. Coefficient 2 of code phase offset model [s/s^2] // D2 NAV Message Decoding - unsigned long int d_A_f1_msb_bits; //!< Clock correction parameters, D2 NAV MSB - unsigned long int d_A_f1_lsb_bits; //!< Clock correction parameters, D2 NAV LSB - unsigned long int d_Cuc_msb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] - unsigned long int d_Cuc_lsb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] - unsigned long int d_eccentricity_msb; //!< Eccentricity [dimensionless] - unsigned long int d_eccentricity_lsb; //!< Eccentricity [dimensionless] - unsigned long int d_Cic_msb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] - unsigned long int d_Cic_lsb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] - unsigned long int d_eccentricity_msb_bits; //!< Eccentricity [dimensionless] - unsigned long int d_eccentricity_lsb_bits; - unsigned long int d_i_0_msb_bits; //!< Inclination Angle at Reference Time [semi-circles] - unsigned long int d_i_0_lsb_bits; //!< Inclination Angle at Reference Time [semi-circles] - unsigned long int d_OMEGA_msb_bits; //!< Argument of Perigee [semi-cicles] - unsigned long int d_OMEGA_lsb_bits; //!< Argument of Perigee [semi-cicles] - unsigned long int d_OMEGA_DOT_msb_bits; //!< Rate of Right Ascension [semi-circles/s] - unsigned long int d_OMEGA_DOT_lsb_bits; //!< Rate of Right Ascension [semi-circles/s] + uint64_t d_A_f1_msb_bits; //!< Clock correction parameters, D2 NAV MSB + uint64_t d_A_f1_lsb_bits; //!< Clock correction parameters, D2 NAV LSB + uint64_t d_Cuc_msb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + uint64_t d_Cuc_lsb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + uint64_t d_eccentricity_msb; //!< Eccentricity [dimensionless] + uint64_t d_eccentricity_lsb; //!< Eccentricity [dimensionless] + uint64_t d_Cic_msb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + uint64_t d_Cic_lsb_bits; //!< Amplitude of the Cosine Harmonic Correction Term to the Argument of Latitude [rad] + uint64_t d_eccentricity_msb_bits; //!< Eccentricity [dimensionless] + uint64_t d_eccentricity_lsb_bits; + uint64_t d_i_0_msb_bits; //!< Inclination Angle at Reference Time [semi-circles] + uint64_t d_i_0_lsb_bits; //!< Inclination Angle at Reference Time [semi-circles] + uint64_t d_OMEGA_msb_bits; //!< Argument of Perigee [semi-cicles] + uint64_t d_OMEGA_lsb_bits; //!< Argument of Perigee [semi-cicles] + uint64_t d_OMEGA_DOT_msb_bits; //!< Rate of Right Ascension [semi-circles/s] + uint64_t d_OMEGA_DOT_lsb_bits; //!< Rate of Right Ascension [semi-circles/s] // Almanac double d_Toa; //!< Almanac reference time [s] - int i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced - std::map almanacHealth; //!< Map that stores the health information stored in the almanac + int32_t i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced + std::map almanacHealth; //!< Map that stores the health information stored in the almanac - std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus + std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus // Flags @@ -201,8 +201,8 @@ public: double d_satpos_Z; //!< Earth-fixed coordinate z of the satellite [m]. The direction of the IERS (International Earth Rotation and Reference Systems Service) Reference Pole (IRP). // satellite identification info - int i_channel_ID; - unsigned int i_satellite_PRN; + int32_t i_channel_ID; + uint32_t i_satellite_PRN; // time synchro double d_subframe_timestamp_ms; //[ms] @@ -221,8 +221,8 @@ public: double d_A1UTC; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] double d_A0UTC; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. - int i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] - int i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] double d_A1GPS; double d_A0GPS; @@ -241,7 +241,7 @@ public: double d_OMEGA_DOT_ALMANAC; double d_OMEGA_ALMANAC; double d_M0_ALMANAC; - int almanac_WN; + int32_t almanac_WN; double d_toa2; // Satellite velocity @@ -272,12 +272,12 @@ public: /*! * \brief Decodes the BDS D1 NAV message */ - int d1_subframe_decoder(std::string const& subframe); + int32_t d1_subframe_decoder(std::string const& subframe); /*! * \brief Decodes the BDS D2 NAV message */ - int d2_subframe_decoder(std::string const& subframe); + int32_t d2_subframe_decoder(std::string const& subframe); /*! * \brief Computes the position of the satellite From 96338be94edc283f7896bf5a1b1c87473bfb67a9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 10 Feb 2019 12:53:22 +0100 Subject: [PATCH 3/8] Fix by clang-tidy --- src/core/receiver/gnss_block_factory.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index 8088e459c..fd8d0f09f 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -199,7 +199,7 @@ std::unique_ptr GNSSBlockFactory::GetSignalSource( } std::string implementation = configuration->property(role + ".implementation", default_implementation); LOG(INFO) << "Getting SignalSource with implementation " << implementation; - return GetBlock(configuration, role, implementation, 0, 1, std::move(queue)); + return GetBlock(configuration, role, implementation, 0, 1, queue); } From 35a6ecb4042083ef82827e1d3d8cfed798dfb16c Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 10 Feb 2019 13:22:49 +0100 Subject: [PATCH 4/8] Fix bug, better string comparison --- src/algorithms/libs/rtcm.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/algorithms/libs/rtcm.cc b/src/algorithms/libs/rtcm.cc index a5c02d4d4..9adda308a 100644 --- a/src/algorithms/libs/rtcm.cc +++ b/src/algorithms/libs/rtcm.cc @@ -3309,7 +3309,7 @@ std::map Rtcm::galileo_signal_map = [] { boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double obs_time) const { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); // NOLINT(google-runtime-int) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -3318,7 +3318,7 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_Ephemeris& eph, double boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, double obs_time) const { const double gps_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((gps_t + 604800 * static_cast(eph.i_GPS_week % 1024)) * 1000)); // NOLINT(google-runtime-int) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -3327,7 +3327,7 @@ boost::posix_time::ptime Rtcm::compute_GPS_time(const Gps_CNAV_Ephemeris& eph, d boost::posix_time::ptime Rtcm::compute_Galileo_time(const Galileo_Ephemeris& eph, double obs_time) const { double galileo_t = obs_time; - boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); + boost::posix_time::time_duration t = boost::posix_time::milliseconds(static_cast((galileo_t + 604800 * static_cast(eph.WN_5)) * 1000)); // NOLINT(google-runtime-int) boost::posix_time::ptime p_time(boost::gregorian::date(1999, 8, 22), t); return p_time; } @@ -5233,19 +5233,19 @@ int32_t Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) { lambda = GPS_C_m_s / GPS_L1_FREQ_HZ; } - if ((sig.compare("2S")) == 0 && (sys == "G")) + if ((sig == "2S") && (sys == "G")) { lambda = GPS_C_m_s / GPS_L2_FREQ_HZ; } - if ((sig.compare("5X")) == 0 && (sys == "E")) + if ((sig == "5X") && (sys == "E")) { lambda = GPS_C_m_s / Galileo_E5a_FREQ_HZ; } - if ((sig.compare("1B")) == 0 && (sys == "E")) + if ((sig == "1B") && (sys == "E")) { lambda = GPS_C_m_s / Galileo_E1_FREQ_HZ; } - if ((sig.compare("7X")) == 0 && (sys == "E")) + if ((sig == "7X") && (sys == "E")) { lambda = GPS_C_m_s / 1.207140e9; // Galileo_E1b_FREQ_HZ; } @@ -5303,7 +5303,7 @@ int32_t Rtcm::set_DF402(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& e lock_time_period_s = Rtcm::lock_time(ephCNAV, obs_time, gnss_synchro); } // TODO Should add system for galileo satellites - if (sig_.compare("1B") || sig_.compare("5X") || sig_.compare("7X") || sig_.compare("8X")) + if ((sig_ == "1B") || (sig_ == "5X") || (sig_ == "7X") || (sig_ == "8X")) { lock_time_period_s = Rtcm::lock_time(ephFNAV, obs_time, gnss_synchro); } @@ -5490,15 +5490,15 @@ int32_t Rtcm::set_DF407(const Gps_Ephemeris& ephNAV, const Gps_CNAV_Ephemeris& e std::string sig_(gnss_synchro.Signal); std::string sys_(&gnss_synchro.System, 1); - if ((sig_.compare("1C")) && (sys_ == "G")) + if ((sig_ == "1C") && (sys_ == "G")) { lock_time_period_s = Rtcm::lock_time(ephNAV, obs_time, gnss_synchro); } - if ((sig_.compare("2S")) && (sys_ == "G")) + if ((sig_ == "2S") && (sys_ == "G")) { lock_time_period_s = Rtcm::lock_time(ephCNAV, obs_time, gnss_synchro); } - if ((sig_.compare("1B") || sig_.compare("5X") || sig_.compare("7X") || sig_.compare("8X")) && (sys_ == "E")) + if (((sig_ == "1B") || (sig_ == "5X") || (sig_ == "7X") || (sig_ == "8X")) && (sys_ == "E")) { lock_time_period_s = Rtcm::lock_time(ephFNAV, obs_time, gnss_synchro); } From bf65447cdf7eff431bc150fcbe1b4e0d0302ba03 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 10 Feb 2019 13:23:36 +0100 Subject: [PATCH 5/8] Remove unused includes --- .../gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc | 2 -- .../gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc index bf97d8eb3..6d410efe1 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc @@ -45,8 +45,6 @@ #include "tcp_communication.h" #include "tcp_packet_data.h" #include "tracking_discriminators.h" -#include -#include #include #include #include diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index 451689741..020402421 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -43,8 +43,6 @@ #include "tcp_communication.h" #include "tcp_packet_data.h" #include "tracking_discriminators.h" -#include -#include #include #include #include From 6d9563ef0071a2823306371b6b8b378685f5a264 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 10 Feb 2019 13:24:25 +0100 Subject: [PATCH 6/8] Improvement by clang-tidy --- src/core/receiver/gnss_block_factory.cc | 2 +- src/core/receiver/gnss_block_factory.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index fd8d0f09f..ac0bb8aad 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -182,7 +182,7 @@ GNSSBlockFactory::~GNSSBlockFactory() = default; std::unique_ptr GNSSBlockFactory::GetSignalSource( - const std::shared_ptr& configuration, gr::msg_queue::sptr queue, int ID) + const std::shared_ptr& configuration, const gr::msg_queue::sptr& queue, int ID) { std::string default_implementation = "File_Signal_Source"; std::string role = "SignalSource"; //backwards compatibility for old conf files diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index 8ead87090..e3eb02226 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -58,7 +58,7 @@ public: GNSSBlockFactory(); virtual ~GNSSBlockFactory(); std::unique_ptr GetSignalSource(const std::shared_ptr& configuration, - gr::msg_queue::sptr queue, int ID = -1); + const gr::msg_queue::sptr& queue, int ID = -1); std::unique_ptr GetSignalConditioner(const std::shared_ptr& configuration, int ID = -1); From f0e2c7c48ddfbc4f293be09171b985a3b0a0e2f7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 10 Feb 2019 13:52:37 +0100 Subject: [PATCH 7/8] Small fixes --- src/tests/CMakeLists.txt | 4 ++++ src/utils/front-end-cal/CMakeLists.txt | 3 +++ 2 files changed, 7 insertions(+) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 8427d40cb..540d295da 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -615,6 +615,10 @@ if(NOT ENABLE_PACKAGING) target_include_directories(gnss_block_test PUBLIC ${CMAKE_SOURCE_DIR}/src/algorithms/libs) + if(ENABLE_FPGA) + target_compile_definitions(gnss_block_test PUBLIC -DENABLE_FPGA=1) + endif() + add_test(gnss_block_test gnss_block_test) set_property(TEST gnss_block_test PROPERTY TIMEOUT 60) diff --git a/src/utils/front-end-cal/CMakeLists.txt b/src/utils/front-end-cal/CMakeLists.txt index 2b39b6837..f5f6671af 100644 --- a/src/utils/front-end-cal/CMakeLists.txt +++ b/src/utils/front-end-cal/CMakeLists.txt @@ -29,6 +29,9 @@ target_link_libraries(front_end_cal_lib Threads::Threads acq_adapters Volkgnsssdr::volkgnsssdr ${ORC_LIBRARIES} + signal_source_adapters + signal_source_gr_blocks + signal_source_lib rx_core_lib gnss_sdr_flags gnss_rx From c46cdcb188304496ea9ed64bece987215f68558a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 10 Feb 2019 14:07:27 +0100 Subject: [PATCH 8/8] Better string comparison --- src/core/receiver/control_thread.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 455ba341f..57907e079 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -78,7 +78,7 @@ using google::LogMessage; ControlThread::ControlThread() { - if (!FLAGS_c.compare("-")) + if (FLAGS_c == "-") { configuration_ = std::make_shared(FLAGS_config_file); } @@ -776,7 +776,7 @@ void ControlThread::read_control_messages() // Apply the corresponding control actions void ControlThread::process_control_messages() { - for (auto & i : *control_messages_) + for (auto &i : *control_messages_) { if (stop_) break; if (i->who == 200) @@ -881,7 +881,7 @@ std::vector> ControlThread::get_visible_sats(time << "UTC, assuming RX position " << LLH(0) << " [deg], " << LLH(1) << " [deg], " << LLH(2) << " [m]" << std::endl; std::map gps_eph_map = pvt_ptr->get_gps_ephemeris(); - for (auto & it : gps_eph_map) + for (auto &it : gps_eph_map) { eph_t rtklib_eph = eph_to_rtklib(it.second); double r_sat[3]; @@ -904,7 +904,7 @@ std::vector> ControlThread::get_visible_sats(time } std::map gal_eph_map = pvt_ptr->get_galileo_ephemeris(); - for (auto & it : gal_eph_map) + for (auto &it : gal_eph_map) { eph_t rtklib_eph = eph_to_rtklib(it.second); double r_sat[3]; @@ -927,7 +927,7 @@ std::vector> ControlThread::get_visible_sats(time } std::map gps_alm_map = pvt_ptr->get_gps_almanac(); - for (auto & it : gps_alm_map) + for (auto &it : gps_alm_map) { alm_t rtklib_alm = alm_to_rtklib(it.second); double r_sat[3]; @@ -954,7 +954,7 @@ std::vector> ControlThread::get_visible_sats(time } std::map gal_alm_map = pvt_ptr->get_galileo_almanac(); - for (auto & it : gal_alm_map) + for (auto &it : gal_alm_map) { alm_t rtklib_alm = alm_to_rtklib(it.second); double r_sat[3];