From 813b2a9d04073803eeca28a0586e5d5203641194 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 4 May 2018 13:39:45 +0200 Subject: [PATCH] Fix bug in GPS L5 and Galileo E5a decoding --- .../galileo_e5a_telemetry_decoder_cc.cc | 53 +++++++++---------- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 9 ++-- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc index 647647698..41bf44833 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc @@ -81,7 +81,6 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int fra { double page_symbols_deint[frame_length]; // 1. De-interleave - deinterleaver(GALILEO_FNAV_INTERLEAVER_ROWS, GALILEO_FNAV_INTERLEAVER_COLS, page_symbols, page_symbols_deint); // 2. Viterbi decoder @@ -116,7 +115,6 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols, int fra if (d_nav.flag_CRC_test == true) { LOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite; - //std::cout << "Galileo E5a CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl; } else { @@ -191,19 +189,19 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc( delta_t = 0.0; d_symbol_counter = 0; d_prompt_acum = 0.0; - flag_bit_start = false; + flag_bit_start = true; new_symbol = false; required_symbols = GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS; // vars for Viterbi decoder - int max_states = 1 << mm; /* 2^mm */ - g_encoder[0] = 121; // Polynomial G1 - g_encoder[1] = 91; // Polynomial G2 + int max_states = 1 << mm; // 2^mm + g_encoder[0] = 121; // Polynomial G1 + g_encoder[1] = 91; // Polynomial G2 out0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); out1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); state0 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); state1 = static_cast(volk_gnsssdr_malloc(max_states * sizeof(int), volk_gnsssdr_get_alignment())); - /* create appropriate transition matrices */ + // create appropriate transition matrices nsc_transit(out0, state0, 0, g_encoder, KK, nn); nsc_transit(out1, state1, 1, g_encoder, KK, nn); } @@ -241,7 +239,7 @@ void galileo_e5a_telemetry_decoder_cc::set_channel(int channel) { d_channel = channel; LOG(INFO) << "Navigation channel set to " << channel; - // ############# ENABLE DATA FILE LOG ################# + // Enable data file logging if (d_dump == true) { if (d_dump_file.is_open() == false) @@ -272,7 +270,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute Gnss_Synchro *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer const Gnss_Synchro *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer - //1. Copy the current tracking output + // 1. Copy the current tracking output Gnss_Synchro current_sample = in[0]; d_symbol_counter++; if (flag_bit_start) @@ -281,7 +279,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute if (d_symbol_counter == GALILEO_FNAV_CODES_PER_SYMBOL) { current_sample.Prompt_I = d_prompt_acum / static_cast(GALILEO_FNAV_CODES_PER_SYMBOL); - d_symbol_history.push_back(current_sample); //add new symbol to the symbol queue + d_symbol_history.push_back(current_sample); // add new symbol to the symbol queue d_prompt_acum = 0.0; d_symbol_counter = 0; new_symbol = true; @@ -323,14 +321,14 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute } } } - d_sample_counter++; //count for the processed samples + d_sample_counter++; // count for the processed samples consume_each(1); d_flag_preamble = false; if ((d_symbol_history.size() > required_symbols) && new_symbol) { - //******* preamble correlation ******** + // ****************** Preamble orrelation ****************** corr_value = 0; for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++) { @@ -344,13 +342,12 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute } } } - - //******* frame sync ****************** - if ((d_stat == 0) && new_symbol) //no preamble information + // ****************** Frame sync ****************** + if ((d_stat == 0) && new_symbol) // no preamble information { if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS) { - d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_preamble_index = d_sample_counter; // record the preamble sample stamp LOG(INFO) << "Preamble detection for Galileo E5a satellite " << d_satellite; d_stat = 1; // enter into frame pre-detection status } @@ -359,13 +356,13 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute { if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS) { - //check preamble separation + // check preamble separation preamble_diff = d_sample_counter - d_preamble_index; if (preamble_diff == GALILEO_FNAV_CODES_PER_PAGE) { - //try to decode frame + // try to decode frame LOG(INFO) << "Starting page decoder for Galileo E5a satellite " << d_satellite; - d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_preamble_index = d_sample_counter; // record the preamble sample stamp d_stat = 2; } else if (preamble_diff > GALILEO_FNAV_CODES_PER_PAGE) @@ -397,13 +394,13 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute page_symbols[i] = corr_sign * d_symbol_history.at(i + GALILEO_FNAV_PREAMBLE_LENGTH_BITS).Prompt_I; // because last symbol of the preamble is just received now! } - //call the decoder + // call the decoder decode_word(page_symbols, frame_length); 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; @@ -414,7 +411,7 @@ int galileo_e5a_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 > GALILEO_E5A_CRC_ERROR_LIMIT) { LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; @@ -428,10 +425,10 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute new_symbol = false; // UPDATE GNSS SYNCHRO DATA - //Add the telemetry decoder information + // Add the telemetry decoder information if (d_flag_preamble and d_nav.flag_TOW_set) - //update TOW at the preamble instant - //We expect a preamble each 10 seconds (FNAV page period) + // update TOW at the preamble instant + // We expect a preamble each 10 seconds (FNAV page period) { if (d_nav.flag_TOW_1 == true) { @@ -458,7 +455,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute d_TOW_at_current_symbol += GALILEO_E5a_CODE_PERIOD; } } - 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 += GALILEO_E5a_CODE_PERIOD; } @@ -499,7 +496,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute { d_symbol_history.pop_front(); } - //3. Make the output + // 3. Make the output if (current_sample.Flag_valid_word) { out[0] = current_sample; diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index 515e21ada..372aec4ff 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -144,21 +144,20 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_correlation_length_ms = 1; d_code_samples_per_chip = 1; d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); - // GPS L5 does not have pilot secondary code d_secondary = true; - interchange_iq = false; if (trk_parameters.track_pilot) { d_secondary_code_length = static_cast(GPS_L5q_NH_CODE_LENGTH); d_secondary_code_string = const_cast(&GPS_L5q_NH_CODE_STR); signal_pretty_name = signal_pretty_name + "Q"; - //interchange_iq = true; + interchange_iq = true; } else { d_secondary_code_length = static_cast(GPS_L5i_NH_CODE_LENGTH); d_secondary_code_string = const_cast(&GPS_L5i_NH_CODE_STR); signal_pretty_name = signal_pretty_name + "I"; + interchange_iq = false; } } else @@ -212,18 +211,18 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl d_code_samples_per_chip = 1; d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); d_secondary = true; - interchange_iq = false; if (trk_parameters.track_pilot) { d_secondary_code_length = static_cast(Galileo_E5a_Q_SECONDARY_CODE_LENGTH); signal_pretty_name = signal_pretty_name + "Q"; - // interchange_iq = true; + interchange_iq = true; } else { d_secondary_code_length = static_cast(Galileo_E5a_I_SECONDARY_CODE_LENGTH); d_secondary_code_string = const_cast(&Galileo_E5a_I_SECONDARY_CODE); signal_pretty_name = signal_pretty_name + "I"; + interchange_iq = false; } } else