1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

Add more consistancy in Telemetry messages

This commit is contained in:
Carles Fernandez 2017-06-12 19:22:52 +02:00
parent 0b3a8a081d
commit 37998c11a4
4 changed files with 117 additions and 112 deletions

View File

@ -208,13 +208,13 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols,int
d_nav.split_page(page_String, flag_even_word_arrived);
if(d_nav.flag_CRC_test == true)
{
LOG(INFO) << "Galileo CRC correct on channel " << d_channel << " from satellite " << d_satellite;
std::cout << "Galileo CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl;
LOG(INFO) << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite;
//std::cout << "Galileo E1 CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl;
}
else
{
std::cout << "Galileo CRC error on channel " << d_channel << " from satellite " << d_satellite << std::endl;
LOG(INFO) << "Galileo CRC error on channel " << d_channel << " from satellite " << d_satellite;
std::cout << "Galileo E1 CRC error on channel " << d_channel << " from satellite " << d_satellite << std::endl;
LOG(INFO) << "Galileo E1 CRC error on channel " << d_channel << " from satellite " << d_satellite;
}
flag_even_word_arrived = 0;
}
@ -230,7 +230,7 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols,int
{
// get object for this SV (mandatory)
std::shared_ptr<Galileo_Ephemeris> tmp_obj = std::make_shared<Galileo_Ephemeris>(d_nav.get_ephemeris());
std::cout << "New Galileo E1 I/NAV message received: ephemeris from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
@ -238,12 +238,14 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols,int
{
// get object for this SV (mandatory)
std::shared_ptr<Galileo_Iono> tmp_obj = std::make_shared<Galileo_Iono>(d_nav.get_iono());
std::cout << "New Galileo E1 I/NAV message received: iono/GST model parameters from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_nav.have_new_utc_model() == true)
{
// get object for this SV (mandatory)
std::shared_ptr<Galileo_Utc_Model> tmp_obj = std::make_shared<Galileo_Utc_Model>(d_nav.get_utc_model());
std::cout << "New Galileo E1 I/NAV message received: UTC model parameters from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_nav.have_new_almanac() == true)
@ -251,7 +253,7 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols,int
std::shared_ptr<Galileo_Almanac> tmp_obj= std::make_shared<Galileo_Almanac>(d_nav.get_almanac());
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
//debug
std::cout << "Galileo almanac received!" << std::endl;
std::cout << "Galileo E1 I/NAV almanac received!" << std::endl;
DLOG(INFO) << "GPS_to_Galileo time conversion:";
DLOG(INFO) << "A0G=" << tmp_obj->A_0G_10;
DLOG(INFO) << "A1G=" << tmp_obj->A_1G_10;
@ -310,7 +312,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
if (abs(corr_value) >= d_symbols_per_preamble)
{
d_preamble_index = d_sample_counter;//record the preamble sample stamp
LOG(INFO) << "Preamble detection for Galileo SAT " << this->d_satellite;
LOG(INFO) << "Preamble detection for Galileo satellite " << this->d_satellite;
d_stat = 1; // enter into frame pre-detection status
}
}
@ -323,7 +325,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items __attribut
if (abs(preamble_diff - GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) == 0)
{
//try to decode frame
LOG(INFO) << "Starting page decoder for Galileo SAT " << this->d_satellite;
LOG(INFO) << "Starting page decoder for Galileo satellite " << this->d_satellite;
d_preamble_index = d_sample_counter; //record the preamble sample stamp
d_stat = 2;
}

View File

@ -149,34 +149,38 @@ void galileo_e5a_telemetry_decoder_cc::decode_word(double *page_symbols,int fram
d_nav.split_page(page_String);
if(d_nav.flag_CRC_test == true)
{
LOG(INFO) << "Galileo CRC correct on channel " << d_channel << " from satellite " << d_satellite;
std::cout << "Galileo CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl;
LOG(INFO) << "Galileo E5a CRC correct on channel " << d_channel << " from satellite " << d_satellite;
//std::cout << "Galileo E5a CRC correct on channel " << d_channel << " from satellite " << d_satellite << std::endl;
}
else
{
std::cout << "Galileo CRC error on channel " << d_channel << " from satellite " << d_satellite << std::endl;
LOG(INFO)<< "Galileo CRC error on channel " << d_channel << " from satellite " << d_satellite;
std::cout << "Galileo E5a CRC error on channel " << d_channel << " from satellite " << d_satellite << std::endl;
LOG(INFO)<< "Galileo E5a CRC error on channel " << d_channel << " from satellite " << d_satellite;
}
// 4. Push the new navigation data to the queues
if (d_nav.have_new_ephemeris() == true)
{
std::shared_ptr<Galileo_Ephemeris> tmp_obj= std::make_shared<Galileo_Ephemeris>(d_nav.get_ephemeris());
std::shared_ptr<Galileo_Ephemeris> tmp_obj = std::make_shared<Galileo_Ephemeris>(d_nav.get_ephemeris());
std::cout << "New Galileo E5a F/NAV message received: ephemeris from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_nav.have_new_iono_and_GST() == true)
{
std::shared_ptr<Galileo_Iono> tmp_obj= std::make_shared<Galileo_Iono>(d_nav.get_iono());
std::shared_ptr<Galileo_Iono> tmp_obj = std::make_shared<Galileo_Iono>(d_nav.get_iono());
std::cout << "New Galileo E5a F/NAV message received: iono/GST model parameters from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_nav.have_new_utc_model() == true)
{
std::shared_ptr<Galileo_Utc_Model> tmp_obj= std::make_shared<Galileo_Utc_Model>(d_nav.get_utc_model());
std::shared_ptr<Galileo_Utc_Model> tmp_obj = std::make_shared<Galileo_Utc_Model>(d_nav.get_utc_model());
std::cout << "New Galileo E5a F/NAV message received: UTC model parameters from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
}
galileo_e5a_telemetry_decoder_cc::galileo_e5a_telemetry_decoder_cc(
Gnss_Satellite satellite, bool dump) : gr::block("galileo_e5a_telemetry_decoder_cc",
gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)),
@ -232,7 +236,7 @@ galileo_e5a_telemetry_decoder_cc::~galileo_e5a_telemetry_decoder_cc()
int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)),
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items)
{
const Gnss_Synchro *in = (const Gnss_Synchro *) input_items[0]; // input
Gnss_Synchro *out = (Gnss_Synchro *) output_items[0]; // output
@ -293,16 +297,16 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items __attribut
d_symbol_counter++;
d_prompt_counter = 0;
// **** Attempt Preamble correlation ****
bool corr_flag=true;
bool corr_flag = true;
int corr_sign = 0; // sequence can be found inverted
// 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];
corr_sign = -d_preamble_bits[0];
}
else
{
corr_sign=d_preamble_bits[0];
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++)
@ -310,21 +314,21 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items __attribut
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;
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;
corr_flag = false;
break;
}
}
//
if (corr_flag==true) // preamble fully correlates
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;
LOG(INFO) << "Preamble detection in E5a for Galileo satellite " << 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
}
@ -365,11 +369,11 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items __attribut
// 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];
corr_sign = -d_preamble_bits[0];
}
else
{
corr_sign=d_preamble_bits[0];
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++)
@ -377,18 +381,18 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items __attribut
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;
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;
corr_flag = false;
break;
}
}
if (corr_flag==true) // NEW PREAMBLE RECEIVED. DECODE PAGE
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
@ -402,7 +406,8 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items __attribut
{
d_flag_frame_sync = true;
DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at "
<< in[0].Tracking_sample_counter << " [samples]"; }
<< in[0].Tracking_sample_counter << " [samples]";
}
d_symbol_counter = 0; // d_page_symbols start right after preamble and finish at the end of next preamble.
}
else
@ -495,14 +500,14 @@ int galileo_e5a_telemetry_decoder_cc::general_work (int noutput_items __attribut
// MULTIPLEXED FILE RECORDING - Record results to file
try
{
double tmp_double;
unsigned long int tmp_ulong_int;
tmp_double = d_TOW_at_current_symbol;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_ulong_int = current_synchro_data.Tracking_sample_counter;
d_dump_file.write((char*)&tmp_ulong_int, sizeof(unsigned long int));
tmp_double = d_TOW_at_Preamble;
d_dump_file.write((char*)&tmp_double, sizeof(double));
double tmp_double;
unsigned long int tmp_ulong_int;
tmp_double = d_TOW_at_current_symbol;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_ulong_int = current_synchro_data.Tracking_sample_counter;
d_dump_file.write((char*)&tmp_ulong_int, sizeof(unsigned long int));
tmp_double = d_TOW_at_Preamble;
d_dump_file.write((char*)&tmp_double, sizeof(double));
}
catch (const std::ifstream::failure & e)
{

View File

@ -65,8 +65,8 @@ gps_l2c_telemetry_decoder_cc::gps_l2c_telemetry_decoder_cc(
d_flag_valid_word = false;
d_TOW_at_current_symbol = 0;
d_TOW_at_Preamble = 0;
d_state=0; //initial state
d_crc_error_count=0;
d_state = 0; //initial state
d_crc_error_count = 0;
//initialize the CNAV frame decoder (libswiftcnav)
cnav_msg_decoder_init(&d_cnav_decoder);
@ -91,7 +91,7 @@ int gps_l2c_telemetry_decoder_cc::general_work (int noutput_items __attribute__(
u32 delay = 0;
//add the symbol to the decoder
u8 symbol_clip=(u8)(in[0].Prompt_I>0) * 255;
u8 symbol_clip = (u8)(in[0].Prompt_I > 0) * 255;
flag_new_cnav_frame = cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay);
consume_each(1); //one by one
@ -105,79 +105,80 @@ int gps_l2c_telemetry_decoder_cc::general_work (int noutput_items __attribute__(
//2. Add the telemetry decoder information
//check if new CNAV frame is available
if (flag_new_cnav_frame == true)
{
std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS> raw_bits;
//Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder
for (u32 i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS ; i++) {
raw_bits[GPS_L2_CNAV_DATA_PAGE_BITS-1-i]=((msg.raw_msg[i/8] >> (7 - i%8)) & 1u);
}
d_CNAV_Message.decode_page(raw_bits);
//Push the new navigation data to the queues
if (d_CNAV_Message.have_new_ephemeris() == true)
{
// get ephemeris object for this SV
std::shared_ptr<Gps_CNAV_Ephemeris> tmp_obj= std::make_shared<Gps_CNAV_Ephemeris>(d_CNAV_Message.get_ephemeris());
std::cout << "New GPS CNAV Ephemeris received for SV " << tmp_obj->i_satellite_PRN << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_CNAV_Message.have_new_iono() == true)
{
std::shared_ptr<Gps_CNAV_Iono> tmp_obj= std::make_shared<Gps_CNAV_Iono>(d_CNAV_Message.get_iono());
std::cout << "New GPS CNAV IONO model received for SV " << d_satellite.get_PRN() << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_CNAV_Message.have_new_utc_model() == true)
{
std::shared_ptr<Gps_CNAV_Utc_Model> tmp_obj= std::make_shared<Gps_CNAV_Utc_Model>(d_CNAV_Message.get_utc_model());
std::cout << "New GPS CNAV UTC model received for SV " << d_satellite.get_PRN() << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
//update TOW at the preamble instant
d_TOW_at_Preamble=(int)msg.tow;
//std::cout<<"["<<(int)msg.prn<<"] deco delay: "<<delay<<"[symbols]"<<std::endl;
//* The time of the last input symbol can be computed from the message ToW and
//* delay by the formulae:
//* \code
//* symbolTime_ms = msg->tow * 6000 + *pdelay * 20
d_TOW_at_current_symbol=((double)msg.tow) * 6.0 + ((double)delay) * GPS_L2_M_PERIOD +12*GPS_L2_M_PERIOD;
d_TOW_at_current_symbol=floor(d_TOW_at_current_symbol*1000.0)/1000.0;
d_flag_valid_word=true;
}
else
{
d_TOW_at_current_symbol +=GPS_L2_M_PERIOD;
if (current_synchro_data.Flag_valid_symbol_output==false)
{
d_flag_valid_word=false;
}
}
current_synchro_data.TOW_at_current_symbol_s = d_TOW_at_current_symbol;
current_synchro_data.Flag_valid_word=d_flag_valid_word;
std::bitset<GPS_L2_CNAV_DATA_PAGE_BITS> raw_bits;
//Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder
for (u32 i = 0; i < GPS_L2_CNAV_DATA_PAGE_BITS ; i++)
{
raw_bits[GPS_L2_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i/8] >> (7 - i%8)) & 1u);
}
// if (flag_PLL_180_deg_phase_locked == true)
// {
// //correct the accumulated phase for the Costas loop phase shift, if required
// current_synchro_data.Carrier_phase_rads += GPS_PI;
// }
d_CNAV_Message.decode_page(raw_bits);
//Push the new navigation data to the queues
if (d_CNAV_Message.have_new_ephemeris() == true)
{
// get ephemeris object for this SV
std::shared_ptr<Gps_CNAV_Ephemeris> tmp_obj = std::make_shared<Gps_CNAV_Ephemeris>(d_CNAV_Message.get_ephemeris());
std::cout << "New GPS CNAV message received: ephemeris from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_CNAV_Message.have_new_iono() == true)
{
std::shared_ptr<Gps_CNAV_Iono> tmp_obj = std::make_shared<Gps_CNAV_Iono>(d_CNAV_Message.get_iono());
std::cout << "New GPS CNAV message received: iono model parameters from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
if (d_CNAV_Message.have_new_utc_model() == true)
{
std::shared_ptr<Gps_CNAV_Utc_Model> tmp_obj = std::make_shared<Gps_CNAV_Utc_Model>(d_CNAV_Message.get_utc_model());
std::cout << "New GPS CNAV message received: UTC model parameters from satellite " << d_satellite << std::endl;
this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj));
}
//update TOW at the preamble instant
d_TOW_at_Preamble = (int)msg.tow;
//std::cout<<"["<<(int)msg.prn<<"] deco delay: "<<delay<<"[symbols]"<<std::endl;
//* The time of the last input symbol can be computed from the message ToW and
//* delay by the formulae:
//* \code
//* symbolTime_ms = msg->tow * 6000 + *pdelay * 20
d_TOW_at_current_symbol = ((double)msg.tow) * 6.0 + ((double)delay) * GPS_L2_M_PERIOD + 12 * GPS_L2_M_PERIOD;
d_TOW_at_current_symbol = floor(d_TOW_at_current_symbol * 1000.0) / 1000.0;
d_flag_valid_word = true;
}
else
{
d_TOW_at_current_symbol += GPS_L2_M_PERIOD;
if (current_synchro_data.Flag_valid_symbol_output == false)
{
d_flag_valid_word = false;
}
}
current_synchro_data.TOW_at_current_symbol_s = d_TOW_at_current_symbol;
current_synchro_data.Flag_valid_word = d_flag_valid_word;
// if (flag_PLL_180_deg_phase_locked == true)
// {
// //correct the accumulated phase for the Costas loop phase shift, if required
// current_synchro_data.Carrier_phase_rads += GPS_PI;
// }
if(d_dump == true)
{
// MULTIPLEXED FILE RECORDING - Record results to file
try
{
double tmp_double;
unsigned long int tmp_ulong_int;
tmp_double = d_TOW_at_current_symbol;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_ulong_int = current_synchro_data.Tracking_sample_counter;
d_dump_file.write((char*)&tmp_ulong_int, sizeof(unsigned long int));
tmp_double = d_TOW_at_Preamble;
d_dump_file.write((char*)&tmp_double, sizeof(double));
double tmp_double;
unsigned long int tmp_ulong_int;
tmp_double = d_TOW_at_current_symbol;
d_dump_file.write((char*)&tmp_double, sizeof(double));
tmp_ulong_int = current_synchro_data.Tracking_sample_counter;
d_dump_file.write((char*)&tmp_ulong_int, sizeof(unsigned long int));
tmp_double = d_TOW_at_Preamble;
d_dump_file.write((char*)&tmp_double, sizeof(double));
}
catch (const std::ifstream::failure & e)
{
@ -185,14 +186,12 @@ int gps_l2c_telemetry_decoder_cc::general_work (int noutput_items __attribute__(
}
}
//3. Make the output (copy the object contents to the GNURadio reserved memory)
out[0] = current_synchro_data;
return 1;
}
void gps_l2c_telemetry_decoder_cc::set_satellite(Gnss_Satellite satellite)
{
d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN());
@ -200,7 +199,6 @@ void gps_l2c_telemetry_decoder_cc::set_satellite(Gnss_Satellite satellite)
}
void gps_l2c_telemetry_decoder_cc::set_channel(int channel)
{
d_channel = channel;

View File

@ -238,8 +238,8 @@ GpsL1CaSubframeFsm::GpsL1CaSubframeFsm()
d_nav.reset();
i_channel_ID = 0;
i_satellite_PRN = 0;
d_subframe_ID=0;
d_flag_new_subframe=false;
d_subframe_ID = 0;
d_flag_new_subframe = false;
initiate(); //start the FSM
}
@ -253,14 +253,14 @@ void GpsL1CaSubframeFsm::gps_word_to_subframe(int position)
void GpsL1CaSubframeFsm::clear_flag_new_subframe()
{
d_flag_new_subframe=false;
d_flag_new_subframe = false;
}
void GpsL1CaSubframeFsm::gps_subframe_to_nav_msg()
{
//int subframe_ID;
// NEW GPS SUBFRAME HAS ARRIVED!
d_subframe_ID = d_nav.subframe_decoder(this->d_subframe); //decode the subframe
std::cout << "NAV Message: received subframe "
std::cout << "New GPS NAV message received: subframe "
<< d_subframe_ID << " from satellite "
<< Gnss_Satellite(std::string("GPS"), i_satellite_PRN) << std::endl;
d_nav.i_satellite_PRN = i_satellite_PRN;