mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-11-17 23:55:15 +00:00
Cleaning includes
This commit is contained in:
@@ -31,10 +31,9 @@
|
||||
|
||||
|
||||
#include "galileo_e1b_telemetry_decoder_cc.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
@@ -34,20 +34,17 @@
|
||||
*/
|
||||
|
||||
#include "galileo_e5a_telemetry_decoder_cc.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <glog/logging.h>
|
||||
#include "control_message_factory.h"
|
||||
//#include "galileo_navigation_message.h"
|
||||
#include "galileo_fnav_message.h"
|
||||
#include "gnss_synchro.h"
|
||||
#include "convolutional.h"
|
||||
//#include <volk/volk.h>
|
||||
//#include "galileo_e1b_telemetry_decoder_cc.h"
|
||||
|
||||
|
||||
#define CRC_ERROR_LIMIT 6
|
||||
|
||||
@@ -60,6 +57,7 @@ galileo_e5a_make_telemetry_decoder_cc(Gnss_Satellite satellite, boost::shared_pt
|
||||
return galileo_e5a_telemetry_decoder_cc_sptr(new galileo_e5a_telemetry_decoder_cc(satellite, queue, dump));
|
||||
}
|
||||
|
||||
|
||||
void galileo_e5a_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required)
|
||||
{
|
||||
//ninput_items_required[0] = GALILEO_FNAV_SAMPLES_PER_PAGE; // set the required sample history
|
||||
@@ -69,9 +67,10 @@ void galileo_e5a_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_in
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void galileo_e5a_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int *page_part_bits)
|
||||
{
|
||||
// int CodeLength = 240;
|
||||
// int CodeLength = 240;
|
||||
int CodeLength = 488;
|
||||
int DataLength;
|
||||
int nn, KK, mm, max_states;
|
||||
@@ -81,8 +80,8 @@ void galileo_e5a_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols
|
||||
KK = 7; // Constraint Length
|
||||
g_encoder[0] = 121; // Polynomial G1
|
||||
g_encoder[1] = 91; // Polynomial G2
|
||||
// g_encoder[0] = 171; // Polynomial G1
|
||||
// g_encoder[1] = 133; // Polynomial G2
|
||||
// g_encoder[0] = 171; // Polynomial G1
|
||||
// g_encoder[1] = 133; // Polynomial G2
|
||||
|
||||
mm = KK - 1;
|
||||
max_states = 1 << mm; // 2^mm
|
||||
@@ -121,6 +120,7 @@ void galileo_e5a_telemetry_decoder_cc::deinterleaver(int rows, int cols, double
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols,int frame_length)
|
||||
{
|
||||
double page_symbols_deint[frame_length];
|
||||
@@ -169,25 +169,25 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols,int fram
|
||||
}
|
||||
|
||||
// 4. Push the new navigation data to the queues
|
||||
if (d_nav.have_new_ephemeris() == true)
|
||||
{
|
||||
// get ephemeris object for this SV
|
||||
Galileo_Ephemeris ephemeris = d_nav.get_ephemeris();//notice that the read operation will clear the valid flag
|
||||
//std::cout<<"New Galileo Ephemeris received for SV "<<d_satellite.get_PRN()<<std::endl;
|
||||
d_ephemeris_queue->push(ephemeris);
|
||||
}
|
||||
if (d_nav.have_new_iono_and_GST() == true)
|
||||
{
|
||||
Galileo_Iono iono = d_nav.get_iono(); //notice that the read operation will clear the valid flag
|
||||
//std::cout<<"New Galileo IONO model (and UTC) received for SV "<<d_satellite.get_PRN()<<std::endl;
|
||||
d_iono_queue->push(iono);
|
||||
}
|
||||
if (d_nav.have_new_utc_model() == true)
|
||||
{
|
||||
Galileo_Utc_Model utc_model = d_nav.get_utc_model(); //notice that the read operation will clear the valid flag
|
||||
//std::cout<<"New Galileo UTC model received for SV "<<d_satellite.get_PRN()<<std::endl;
|
||||
d_utc_model_queue->push(utc_model);
|
||||
}
|
||||
if (d_nav.have_new_ephemeris() == true)
|
||||
{
|
||||
// get ephemeris object for this SV
|
||||
Galileo_Ephemeris ephemeris = d_nav.get_ephemeris();//notice that the read operation will clear the valid flag
|
||||
//std::cout<<"New Galileo Ephemeris received for SV "<<d_satellite.get_PRN()<<std::endl;
|
||||
d_ephemeris_queue->push(ephemeris);
|
||||
}
|
||||
if (d_nav.have_new_iono_and_GST() == true)
|
||||
{
|
||||
Galileo_Iono iono = d_nav.get_iono(); //notice that the read operation will clear the valid flag
|
||||
//std::cout<<"New Galileo IONO model (and UTC) received for SV "<<d_satellite.get_PRN()<<std::endl;
|
||||
d_iono_queue->push(iono);
|
||||
}
|
||||
if (d_nav.have_new_utc_model() == true)
|
||||
{
|
||||
Galileo_Utc_Model utc_model = d_nav.get_utc_model(); //notice that the read operation will clear the valid flag
|
||||
//std::cout<<"New Galileo UTC model received for SV "<<d_satellite.get_PRN()<<std::endl;
|
||||
d_utc_model_queue->push(utc_model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -195,8 +195,8 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
|
||||
Gnss_Satellite satellite,
|
||||
boost::shared_ptr<gr::msg_queue> queue,
|
||||
bool dump) :
|
||||
gr::block("galileo_e5a_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
|
||||
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
|
||||
gr::block("galileo_e5a_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
|
||||
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)))
|
||||
{
|
||||
// initialize internal vars
|
||||
d_queue = queue;
|
||||
@@ -208,38 +208,38 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
|
||||
// set the preamble
|
||||
//unsigned short int preambles_bits[GALILEO_FNAV_PREAMBLE_LENGTH_BITS] = GALILEO_FNAV_PREAMBLE;
|
||||
for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
{
|
||||
if (GALILEO_FNAV_PREAMBLE.at(i) == '0')
|
||||
{
|
||||
d_preamble_bits[i] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_preamble_bits[i] = -1;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (GALILEO_FNAV_PREAMBLE.at(i) == '0')
|
||||
{
|
||||
d_preamble_bits[i] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_preamble_bits[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GALILEO_FNAV_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int));
|
||||
// memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GALILEO_FNAV_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int));
|
||||
|
||||
// // preamble bits to sampled symbols
|
||||
// d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * GALILEO_FNAV_SAMPLES_PER_PREAMBLE);
|
||||
// int n = 0;
|
||||
// for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
// {
|
||||
// for (unsigned int j = 0; j < GALILEO_FNAV_SAMPLES_PER_SYMBOL; j++)
|
||||
// {
|
||||
// if (d_preambles_bits[i] == 1)
|
||||
// {
|
||||
// d_preambles_symbols[n] = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// d_preambles_symbols[n] = -1;
|
||||
// }
|
||||
// n++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // preamble bits to sampled symbols
|
||||
// d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * GALILEO_FNAV_SAMPLES_PER_PREAMBLE);
|
||||
// int n = 0;
|
||||
// for (int i = 0; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
// {
|
||||
// for (unsigned int j = 0; j < GALILEO_FNAV_SAMPLES_PER_SYMBOL; j++)
|
||||
// {
|
||||
// if (d_preambles_bits[i] == 1)
|
||||
// {
|
||||
// d_preambles_symbols[n] = 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// d_preambles_symbols[n] = -1;
|
||||
// }
|
||||
// n++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
d_sample_counter = 0;
|
||||
d_state = 0;
|
||||
d_preamble_lock = false;
|
||||
@@ -266,11 +266,13 @@ galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
|
||||
flag_TOW_set = false;
|
||||
}
|
||||
|
||||
|
||||
galileo_e5a_telemetry_decoder_cc::~galileo_e5a_telemetry_decoder_cc()
|
||||
{
|
||||
d_dump_file.close();
|
||||
}
|
||||
|
||||
|
||||
int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_int &ninput_items,
|
||||
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
|
||||
{
|
||||
@@ -287,211 +289,211 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items, gr_vector
|
||||
*/
|
||||
switch (d_state)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (in[0][0].Prompt_I != 0)
|
||||
{
|
||||
d_current_symbol += in[0][0].Prompt_I;
|
||||
if (d_prompt_counter == GALILEO_FNAV_CODES_PER_SYMBOL - 1)
|
||||
{
|
||||
if (d_current_symbol > 0)
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = -1;
|
||||
}
|
||||
d_current_symbol = 0;
|
||||
d_symbol_counter++;
|
||||
d_prompt_counter = 0;
|
||||
if (d_symbol_counter == GALILEO_FNAV_PREAMBLE_LENGTH_BITS-1)
|
||||
{
|
||||
d_state = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_prompt_counter++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
d_current_symbol += in[0][0].Prompt_I;
|
||||
if (d_prompt_counter == GALILEO_FNAV_CODES_PER_SYMBOL - 1)
|
||||
{
|
||||
if (d_current_symbol > 0)
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = -1;
|
||||
}
|
||||
// d_page_symbols[d_symbol_counter] = d_current_symbol_float/(float)GALILEO_FNAV_CODES_PER_SYMBOL;
|
||||
d_current_symbol = 0;
|
||||
d_symbol_counter++;
|
||||
d_prompt_counter = 0;
|
||||
// **** Attempt Preamble correlation ****
|
||||
bool corr_flag=true;
|
||||
int corr_sign = 0; // sequence can be found inverted
|
||||
// corr_sign = d_preamble_bits[0] * d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
|
||||
// for (int i = 1; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
// {
|
||||
// if ((d_preamble_bits[i] * d_page_symbols[i + d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS]) != corr_sign)
|
||||
// {
|
||||
// //exit for if one bit doesn't correlate
|
||||
// corr_flag=false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// check if the preamble starts positive correlated or negative correlated
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS] < 0) // symbols clipping
|
||||
{
|
||||
corr_sign=-d_preamble_bits[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
corr_sign=d_preamble_bits[0];
|
||||
}
|
||||
// the preamble is fully correlated only if maintains corr_sign along the whole sequence
|
||||
for (int i = 1; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
{
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS + i] < 0 && d_preamble_bits[i]+corr_sign != 0)
|
||||
{
|
||||
//exit for
|
||||
corr_flag=false;
|
||||
break;
|
||||
}
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS + i] > 0 && d_preamble_bits[i]+corr_sign == 0)
|
||||
{
|
||||
//exit for
|
||||
corr_flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (corr_flag==true) // preamble fully correlates
|
||||
{
|
||||
d_preamble_index = d_sample_counter - GALILEO_FNAV_CODES_PER_PREAMBLE;//record the preamble sample stamp. Remember correlation appears at the end of the preamble in this design
|
||||
LOG(INFO) << "Preamble detection for Galileo SAT " << this->d_satellite << std::endl;
|
||||
d_symbol_counter = 0; // d_page_symbols start right after preamble and finish at the end of next preamble.
|
||||
d_state = 2; // preamble lock
|
||||
}
|
||||
if (d_symbol_counter >= GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS)
|
||||
{
|
||||
d_symbol_counter = GALILEO_FNAV_PREAMBLE_LENGTH_BITS; // prevents overflow
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_prompt_counter++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
d_current_symbol += in[0][0].Prompt_I;
|
||||
if (d_prompt_counter == GALILEO_FNAV_CODES_PER_SYMBOL - 1)
|
||||
{
|
||||
if (d_current_symbol > 0)
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = -1;
|
||||
}
|
||||
// d_page_symbols[d_symbol_counter] = d_current_symbol_float/(float)GALILEO_FNAV_CODES_PER_SYMBOL;
|
||||
d_current_symbol = 0;
|
||||
d_symbol_counter++;
|
||||
d_prompt_counter = 0;
|
||||
// At the right sample stamp, check preamble synchro
|
||||
if (d_sample_counter == d_preamble_index + GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE)
|
||||
{
|
||||
// **** Attempt Preamble correlation ****
|
||||
bool corr_flag = true;
|
||||
int corr_sign = 0; // sequence can be found inverted
|
||||
// corr_sign = d_preamble_bits[0] * d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
|
||||
// for (int i = 1; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
// {
|
||||
// if ((d_preamble_bits[i] * d_page_symbols[i + d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS]) != corr_sign)
|
||||
// {
|
||||
// //exit for if one bit doesn't correlate
|
||||
// corr_flag=false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// check if the preamble starts positive correlated or negative correlated
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS] < 0) // symbols clipping
|
||||
{
|
||||
corr_sign=-d_preamble_bits[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
corr_sign=d_preamble_bits[0];
|
||||
}
|
||||
// the preamble is fully correlated only if maintains corr_sign along the whole sequence
|
||||
for (int i = 1; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
{
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS + i] < 0 && d_preamble_bits[i]+corr_sign != 0)
|
||||
{
|
||||
//exit for
|
||||
corr_flag=false;
|
||||
break;
|
||||
}
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS + i] > 0 && d_preamble_bits[i]+corr_sign == 0)
|
||||
{
|
||||
//exit for
|
||||
corr_flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (corr_flag==true) // NEW PREAMBLE RECEIVED. DECODE PAGE
|
||||
{
|
||||
d_preamble_index = d_sample_counter - GALILEO_FNAV_CODES_PER_PREAMBLE;//record the preamble sample stamp
|
||||
// DECODE WORD
|
||||
decode_word(d_page_symbols, GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS);
|
||||
// CHECK CRC
|
||||
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_time_seconds = in[0][0].Tracking_timestamp_secs - (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); //record the PRN start sample index associated to the preamble start.
|
||||
if (!d_flag_frame_sync)
|
||||
{
|
||||
d_flag_frame_sync = true;
|
||||
LOG(INFO) <<" Frame sync SAT " << this->d_satellite << " with preamble start at " << d_preamble_time_seconds << " [s]";
|
||||
}
|
||||
d_symbol_counter = 0; // d_page_symbols start right after preamble and finish at the end of next preamble.
|
||||
}
|
||||
else
|
||||
{
|
||||
d_CRC_error_counter++;
|
||||
if (d_CRC_error_counter > CRC_ERROR_LIMIT)
|
||||
{
|
||||
LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite;
|
||||
d_state = 1;
|
||||
d_symbol_counter = GALILEO_FNAV_PREAMBLE_LENGTH_BITS; // prevents overflow
|
||||
d_flag_frame_sync = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_symbol_counter = 0; // d_page_symbols start right after preamble and finish at the end of next preamble.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_prompt_counter++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0:
|
||||
{
|
||||
if (in[0][0].Prompt_I != 0)
|
||||
{
|
||||
d_current_symbol += in[0][0].Prompt_I;
|
||||
if (d_prompt_counter == GALILEO_FNAV_CODES_PER_SYMBOL - 1)
|
||||
{
|
||||
if (d_current_symbol > 0)
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = -1;
|
||||
}
|
||||
d_current_symbol = 0;
|
||||
d_symbol_counter++;
|
||||
d_prompt_counter = 0;
|
||||
if (d_symbol_counter == GALILEO_FNAV_PREAMBLE_LENGTH_BITS - 1)
|
||||
{
|
||||
d_state = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_prompt_counter++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
d_current_symbol += in[0][0].Prompt_I;
|
||||
if (d_prompt_counter == GALILEO_FNAV_CODES_PER_SYMBOL - 1)
|
||||
{
|
||||
if (d_current_symbol > 0)
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = -1;
|
||||
}
|
||||
// d_page_symbols[d_symbol_counter] = d_current_symbol_float/(float)GALILEO_FNAV_CODES_PER_SYMBOL;
|
||||
d_current_symbol = 0;
|
||||
d_symbol_counter++;
|
||||
d_prompt_counter = 0;
|
||||
// **** Attempt Preamble correlation ****
|
||||
bool corr_flag=true;
|
||||
int corr_sign = 0; // sequence can be found inverted
|
||||
// corr_sign = d_preamble_bits[0] * d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
|
||||
// for (int i = 1; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
// {
|
||||
// if ((d_preamble_bits[i] * d_page_symbols[i + d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS]) != corr_sign)
|
||||
// {
|
||||
// //exit for if one bit doesn't correlate
|
||||
// corr_flag = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// check if the preamble starts positive correlated or negative correlated
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS] < 0) // symbols clipping
|
||||
{
|
||||
corr_sign=-d_preamble_bits[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
corr_sign=d_preamble_bits[0];
|
||||
}
|
||||
// the preamble is fully correlated only if maintains corr_sign along the whole sequence
|
||||
for (int i = 1; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
{
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS + i] < 0 && d_preamble_bits[i]+corr_sign != 0)
|
||||
{
|
||||
//exit for
|
||||
corr_flag=false;
|
||||
break;
|
||||
}
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS + i] > 0 && d_preamble_bits[i]+corr_sign == 0)
|
||||
{
|
||||
//exit for
|
||||
corr_flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//
|
||||
if (corr_flag==true) // preamble fully correlates
|
||||
{
|
||||
d_preamble_index = d_sample_counter - GALILEO_FNAV_CODES_PER_PREAMBLE;//record the preamble sample stamp. Remember correlation appears at the end of the preamble in this design
|
||||
LOG(INFO) << "Preamble detection for Galileo SAT " << this->d_satellite << std::endl;
|
||||
d_symbol_counter = 0; // d_page_symbols start right after preamble and finish at the end of next preamble.
|
||||
d_state = 2; // preamble lock
|
||||
}
|
||||
if (d_symbol_counter >= GALILEO_FNAV_SYMBOLS_PER_PAGE + GALILEO_FNAV_PREAMBLE_LENGTH_BITS)
|
||||
{
|
||||
d_symbol_counter = GALILEO_FNAV_PREAMBLE_LENGTH_BITS; // prevents overflow
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_prompt_counter++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
d_current_symbol += in[0][0].Prompt_I;
|
||||
if (d_prompt_counter == GALILEO_FNAV_CODES_PER_SYMBOL - 1)
|
||||
{
|
||||
if (d_current_symbol > 0)
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_page_symbols[d_symbol_counter] = -1;
|
||||
}
|
||||
// d_page_symbols[d_symbol_counter] = d_current_symbol_float/(float)GALILEO_FNAV_CODES_PER_SYMBOL;
|
||||
d_current_symbol = 0;
|
||||
d_symbol_counter++;
|
||||
d_prompt_counter = 0;
|
||||
// At the right sample stamp, check preamble synchro
|
||||
if (d_sample_counter == d_preamble_index + GALILEO_FNAV_CODES_PER_PAGE + GALILEO_FNAV_CODES_PER_PREAMBLE)
|
||||
{
|
||||
// **** Attempt Preamble correlation ****
|
||||
bool corr_flag = true;
|
||||
int corr_sign = 0; // sequence can be found inverted
|
||||
// corr_sign = d_preamble_bits[0] * d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS];
|
||||
// for (int i = 1; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
// {
|
||||
// if ((d_preamble_bits[i] * d_page_symbols[i + d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS]) != corr_sign)
|
||||
// {
|
||||
// //exit for if one bit doesn't correlate
|
||||
// corr_flag = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// check if the preamble starts positive correlated or negative correlated
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS] < 0) // symbols clipping
|
||||
{
|
||||
corr_sign=-d_preamble_bits[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
corr_sign=d_preamble_bits[0];
|
||||
}
|
||||
// the preamble is fully correlated only if maintains corr_sign along the whole sequence
|
||||
for (int i = 1; i < GALILEO_FNAV_PREAMBLE_LENGTH_BITS; i++)
|
||||
{
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS + i] < 0 && d_preamble_bits[i]+corr_sign != 0)
|
||||
{
|
||||
//exit for
|
||||
corr_flag=false;
|
||||
break;
|
||||
}
|
||||
if (d_page_symbols[d_symbol_counter - GALILEO_FNAV_PREAMBLE_LENGTH_BITS + i] > 0 && d_preamble_bits[i]+corr_sign == 0)
|
||||
{
|
||||
//exit for
|
||||
corr_flag=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (corr_flag==true) // NEW PREAMBLE RECEIVED. DECODE PAGE
|
||||
{
|
||||
d_preamble_index = d_sample_counter - GALILEO_FNAV_CODES_PER_PREAMBLE;//record the preamble sample stamp
|
||||
// DECODE WORD
|
||||
decode_word(d_page_symbols, GALILEO_FNAV_SYMBOLS_PER_PAGE - GALILEO_FNAV_PREAMBLE_LENGTH_BITS);
|
||||
// CHECK CRC
|
||||
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_time_seconds = in[0][0].Tracking_timestamp_secs - (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD); //record the PRN start sample index associated to the preamble start.
|
||||
if (!d_flag_frame_sync)
|
||||
{
|
||||
d_flag_frame_sync = true;
|
||||
LOG(INFO) <<" Frame sync SAT " << this->d_satellite << " with preamble start at " << d_preamble_time_seconds << " [s]";
|
||||
}
|
||||
d_symbol_counter = 0; // d_page_symbols start right after preamble and finish at the end of next preamble.
|
||||
}
|
||||
else
|
||||
{
|
||||
d_CRC_error_counter++;
|
||||
if (d_CRC_error_counter > CRC_ERROR_LIMIT)
|
||||
{
|
||||
LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite;
|
||||
d_state = 1;
|
||||
d_symbol_counter = GALILEO_FNAV_PREAMBLE_LENGTH_BITS; // prevents overflow
|
||||
d_flag_frame_sync = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
d_symbol_counter = 0; // d_page_symbols start right after preamble and finish at the end of next preamble.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
d_prompt_counter++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
consume_each(1);
|
||||
|
||||
@@ -501,57 +503,57 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items, gr_vector
|
||||
current_synchro_data = in[0][0];
|
||||
//2. Add the telemetry decoder information
|
||||
if (this->d_flag_preamble == true and d_nav.flag_TOW_set == true)
|
||||
//update TOW at the preamble instant
|
||||
//We expect a preamble each 10 seconds (FNAV page period)
|
||||
{
|
||||
Prn_timestamp_at_preamble_ms = d_preamble_time_seconds * 1000;
|
||||
//Prn_timestamp_at_preamble_ms = in[0][0].Tracking_timestamp_secs * 1000.0;
|
||||
if (d_nav.flag_TOW_1 == true)
|
||||
{
|
||||
d_TOW_at_Preamble = d_nav.FNAV_TOW_1;
|
||||
d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD);
|
||||
d_nav.flag_TOW_1 = false;
|
||||
}
|
||||
if (d_nav.flag_TOW_2 == true)
|
||||
{
|
||||
d_TOW_at_Preamble = d_nav.FNAV_TOW_2;
|
||||
d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD);
|
||||
d_nav.flag_TOW_2 = false;
|
||||
}
|
||||
if (d_nav.flag_TOW_3 == true)
|
||||
{
|
||||
d_TOW_at_Preamble = d_nav.FNAV_TOW_3;
|
||||
d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD);
|
||||
d_nav.flag_TOW_3 = false;
|
||||
}
|
||||
if (d_nav.flag_TOW_4 == true)
|
||||
{
|
||||
d_TOW_at_Preamble = d_nav.FNAV_TOW_4;
|
||||
d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD);
|
||||
d_nav.flag_TOW_4 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//this page has no timming information
|
||||
d_TOW_at_Preamble = d_TOW_at_Preamble + GALILEO_FNAV_SECONDS_PER_PAGE;
|
||||
d_TOW_at_current_symbol = d_TOW_at_current_symbol + GALILEO_E5a_CODE_PERIOD;
|
||||
}
|
||||
//update TOW at the preamble instant
|
||||
//We expect a preamble each 10 seconds (FNAV page period)
|
||||
{
|
||||
Prn_timestamp_at_preamble_ms = d_preamble_time_seconds * 1000;
|
||||
//Prn_timestamp_at_preamble_ms = in[0][0].Tracking_timestamp_secs * 1000.0;
|
||||
if (d_nav.flag_TOW_1 == true)
|
||||
{
|
||||
d_TOW_at_Preamble = d_nav.FNAV_TOW_1;
|
||||
d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD);
|
||||
d_nav.flag_TOW_1 = false;
|
||||
}
|
||||
if (d_nav.flag_TOW_2 == true)
|
||||
{
|
||||
d_TOW_at_Preamble = d_nav.FNAV_TOW_2;
|
||||
d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD);
|
||||
d_nav.flag_TOW_2 = false;
|
||||
}
|
||||
if (d_nav.flag_TOW_3 == true)
|
||||
{
|
||||
d_TOW_at_Preamble = d_nav.FNAV_TOW_3;
|
||||
d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD);
|
||||
d_nav.flag_TOW_3 = false;
|
||||
}
|
||||
if (d_nav.flag_TOW_4 == true)
|
||||
{
|
||||
d_TOW_at_Preamble = d_nav.FNAV_TOW_4;
|
||||
d_TOW_at_current_symbol = d_TOW_at_Preamble + (static_cast<double>(GALILEO_FNAV_CODES_PER_PAGE+GALILEO_FNAV_CODES_PER_PREAMBLE) * GALILEO_E5a_CODE_PERIOD);
|
||||
d_nav.flag_TOW_4 = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//this page has no timming information
|
||||
d_TOW_at_Preamble = d_TOW_at_Preamble + GALILEO_FNAV_SECONDS_PER_PAGE;
|
||||
d_TOW_at_current_symbol = 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
|
||||
{
|
||||
d_TOW_at_current_symbol = d_TOW_at_current_symbol + GALILEO_E5a_CODE_PERIOD;
|
||||
}
|
||||
{
|
||||
d_TOW_at_current_symbol = d_TOW_at_current_symbol + GALILEO_E5a_CODE_PERIOD;
|
||||
}
|
||||
|
||||
//if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true)
|
||||
if (d_flag_frame_sync == true and d_nav.flag_TOW_set == true)
|
||||
{
|
||||
current_synchro_data.Flag_valid_word = true;
|
||||
}
|
||||
{
|
||||
current_synchro_data.Flag_valid_word = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_synchro_data.Flag_valid_word = false;
|
||||
}
|
||||
{
|
||||
current_synchro_data.Flag_valid_word = false;
|
||||
}
|
||||
|
||||
current_synchro_data.d_TOW = d_TOW_at_Preamble;
|
||||
current_synchro_data.d_TOW_at_current_symbol = d_TOW_at_current_symbol;
|
||||
@@ -560,23 +562,23 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items, gr_vector
|
||||
current_synchro_data.Prn_timestamp_at_preamble_ms = Prn_timestamp_at_preamble_ms;
|
||||
|
||||
if(d_dump == true)
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
try
|
||||
{
|
||||
double tmp_double;
|
||||
tmp_double = d_TOW_at_current_symbol;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = current_synchro_data.Prn_timestamp_ms;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = d_TOW_at_Preamble;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
}
|
||||
catch (const std::ifstream::failure& e)
|
||||
{
|
||||
LOG(WARNING) << "Exception writing observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
{
|
||||
// MULTIPLEXED FILE RECORDING - Record results to file
|
||||
try
|
||||
{
|
||||
double tmp_double;
|
||||
tmp_double = d_TOW_at_current_symbol;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = current_synchro_data.Prn_timestamp_ms;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
tmp_double = d_TOW_at_Preamble;
|
||||
d_dump_file.write((char*)&tmp_double, sizeof(double));
|
||||
}
|
||||
catch (const std::ifstream::failure& e)
|
||||
{
|
||||
LOG(WARNING) << "Exception writing observables dump file " << e.what();
|
||||
}
|
||||
}
|
||||
d_sample_counter++; //count for the processed samples
|
||||
//3. Make the output (copy the object contents to the GNURadio reserved memory)
|
||||
*out[0] = current_synchro_data;
|
||||
@@ -587,6 +589,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items, gr_vector
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void galileo_e5a_telemetry_decoder_cc::set_satellite(Gnss_Satellite satellite)
|
||||
{
|
||||
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
|
||||
@@ -621,6 +624,7 @@ void galileo_e5a_telemetry_decoder_cc::set_channel(int channel)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void galileo_e5a_telemetry_decoder_cc::set_ephemeris_queue(concurrent_queue<Galileo_Ephemeris> *ephemeris_queue)
|
||||
{
|
||||
d_ephemeris_queue = ephemeris_queue;
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
|
||||
#include "gps_l1_ca_telemetry_decoder_cc.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <gnuradio/io_signature.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
Reference in New Issue
Block a user