mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 07:13:03 +00:00 
			
		
		
		
	- Bug correction in Galileo telemetry decoder.
- Improved Galileo configuration to work with real-life captures (4 IOV SV) git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@434 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
		| @@ -277,9 +277,9 @@ Acquisition.implementation=Galileo_E1_PCPS_Ambiguous_Acquisition | |||||||
| ;#threshold: Acquisition threshold | ;#threshold: Acquisition threshold | ||||||
| ;Acquisition.threshold=0 | ;Acquisition.threshold=0 | ||||||
| ;#pfa: Acquisition false alarm probability. This option overrides the threshold option. Only use with implementations: [GPS_L1_CA_PCPS_Acquisition] or [Galileo_E1_PCPS_Ambiguous_Acquisition]  | ;#pfa: Acquisition false alarm probability. This option overrides the threshold option. Only use with implementations: [GPS_L1_CA_PCPS_Acquisition] or [Galileo_E1_PCPS_Ambiguous_Acquisition]  | ||||||
| Acquisition.pfa=0.00005 | Acquisition.pfa=0.00003 | ||||||
| ;#doppler_max: Maximum expected Doppler shift [Hz] | ;#doppler_max: Maximum expected Doppler shift [Hz] | ||||||
| Acquisition.doppler_max=10000 | Acquisition.doppler_max=15000 | ||||||
| ;#doppler_max: Doppler step in the grid search [Hz] | ;#doppler_max: Doppler step in the grid search [Hz] | ||||||
| Acquisition.doppler_step=125 | Acquisition.doppler_step=125 | ||||||
|  |  | ||||||
| @@ -288,7 +288,11 @@ Acquisition.doppler_step=125 | |||||||
| ;######### ACQUISITION CH 0 CONFIG ############ | ;######### ACQUISITION CH 0 CONFIG ############ | ||||||
|  |  | ||||||
| ;#repeat_satellite: Use only jointly with the satellite PRN ID option. The default value is false | ;#repeat_satellite: Use only jointly with the satellite PRN ID option. The default value is false | ||||||
| ;Acquisition0.repeat_satellite = false | Acquisition0.repeat_satellite = true | ||||||
|  | Acquisition1.repeat_satellite = true | ||||||
|  | Acquisition2.repeat_satellite = true | ||||||
|  | Acquisition3.repeat_satellite = true | ||||||
|  |  | ||||||
| ;#cboc: Only for [Galileo_E1_PCPS_Ambiguous_Acquisition]. This option allows you to choose between acquiring with CBOC signal [true] or sinboc(1,1) signal [false].  | ;#cboc: Only for [Galileo_E1_PCPS_Ambiguous_Acquisition]. This option allows you to choose between acquiring with CBOC signal [true] or sinboc(1,1) signal [false].  | ||||||
| ;#Use only if GNSS-SDR.internal_fs_hz is greater than or equal to 6138000 | ;#Use only if GNSS-SDR.internal_fs_hz is greater than or equal to 6138000 | ||||||
| Acquisition0.cboc=false | Acquisition0.cboc=false | ||||||
| @@ -314,7 +318,7 @@ Tracking.dump=true | |||||||
| Tracking.dump_filename=../data/veml_tracking_ch_ | Tracking.dump_filename=../data/veml_tracking_ch_ | ||||||
|  |  | ||||||
| ;#pll_bw_hz: PLL loop filter bandwidth [Hz] | ;#pll_bw_hz: PLL loop filter bandwidth [Hz] | ||||||
| Tracking.pll_bw_hz=15.0; | Tracking.pll_bw_hz=20.0; | ||||||
|  |  | ||||||
| ;#dll_bw_hz: DLL loop filter bandwidth [Hz] | ;#dll_bw_hz: DLL loop filter bandwidth [Hz] | ||||||
| Tracking.dll_bw_hz=2.0; | Tracking.dll_bw_hz=2.0; | ||||||
| @@ -341,7 +345,7 @@ TelemetryDecoder.dump=false | |||||||
| Observables.implementation=Galileo_E1B_Observables | Observables.implementation=Galileo_E1B_Observables | ||||||
|  |  | ||||||
| ;#dump: Enable or disable the Observables internal binary data file logging [true] or [false]  | ;#dump: Enable or disable the Observables internal binary data file logging [true] or [false]  | ||||||
| Observables.dump=true | Observables.dump=false | ||||||
|  |  | ||||||
| ;#dump_filename: Log path and filename. | ;#dump_filename: Log path and filename. | ||||||
| Observables.dump_filename=./observables.dat | Observables.dump_filename=./observables.dat | ||||||
|   | |||||||
| @@ -54,17 +54,17 @@ using google::LogMessage; | |||||||
|  |  | ||||||
| galileo_e1b_telemetry_decoder_cc_sptr | galileo_e1b_telemetry_decoder_cc_sptr | ||||||
| galileo_e1b_make_telemetry_decoder_cc(Gnss_Satellite satellite, long if_freq, long fs_in, unsigned | galileo_e1b_make_telemetry_decoder_cc(Gnss_Satellite satellite, long if_freq, long fs_in, unsigned | ||||||
|         int vector_length, boost::shared_ptr<gr::msg_queue> queue, bool dump) | 		int vector_length, boost::shared_ptr<gr::msg_queue> queue, bool dump) | ||||||
| { | { | ||||||
|     return galileo_e1b_telemetry_decoder_cc_sptr(new galileo_e1b_telemetry_decoder_cc(satellite, if_freq, | 	return galileo_e1b_telemetry_decoder_cc_sptr(new galileo_e1b_telemetry_decoder_cc(satellite, if_freq, | ||||||
|             fs_in, vector_length, queue, dump)); | 			fs_in, vector_length, queue, dump)); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| void galileo_e1b_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required) | void galileo_e1b_telemetry_decoder_cc::forecast (int noutput_items, gr_vector_int &ninput_items_required) | ||||||
| { | { | ||||||
|   ninput_items_required[0] = GALILEO_INAV_PAGE_SYMBOLS; //set the required sample history | 	ninput_items_required[0] = GALILEO_INAV_PAGE_SYMBOLS; //set the required sample history | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -121,70 +121,70 @@ void galileo_e1b_telemetry_decoder_cc::deinterleaver(int rows, int cols, double | |||||||
|  |  | ||||||
|  |  | ||||||
| galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( | galileo_e1b_telemetry_decoder_cc::galileo_e1b_telemetry_decoder_cc( | ||||||
|         Gnss_Satellite satellite, | 		Gnss_Satellite satellite, | ||||||
|         long if_freq, | 		long if_freq, | ||||||
|         long fs_in, | 		long fs_in, | ||||||
|         unsigned | 		unsigned | ||||||
|         int vector_length, | 		int vector_length, | ||||||
|         boost::shared_ptr<gr::msg_queue> queue, | 		boost::shared_ptr<gr::msg_queue> queue, | ||||||
|         bool dump) : | 		bool dump) : | ||||||
|         gr::block("galileo_e1b_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), | 		gr::block("galileo_e1b_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), | ||||||
|         gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) | 				gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) | ||||||
| { | { | ||||||
|     // initialize internal vars | 	// initialize internal vars | ||||||
|     d_queue = queue; | 	d_queue = queue; | ||||||
|     d_dump = dump; | 	d_dump = dump; | ||||||
|     d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); | 	d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); | ||||||
|     DLOG(INFO) << "GALILEO E1B TELEMETRY PROCESSING: satellite " << d_satellite; | 	DLOG(INFO) << "GALILEO E1B TELEMETRY PROCESSING: satellite " << d_satellite; | ||||||
|     d_vector_length = vector_length; | 	d_vector_length = vector_length; | ||||||
|     d_samples_per_symbol = ( Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS ) / Galileo_E1_B_SYMBOL_RATE_BPS; | 	d_samples_per_symbol = ( Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS ) / Galileo_E1_B_SYMBOL_RATE_BPS; | ||||||
|     d_fs_in = fs_in; | 	d_fs_in = fs_in; | ||||||
|  |  | ||||||
|     // set the preamble | 	// set the preamble | ||||||
|     unsigned short int preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS]=GALILEO_INAV_PREAMBLE; | 	unsigned short int preambles_bits[GALILEO_INAV_PREAMBLE_LENGTH_BITS]=GALILEO_INAV_PREAMBLE; | ||||||
|  |  | ||||||
|     d_symbols_per_preamble=GALILEO_INAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol; | 	d_symbols_per_preamble=GALILEO_INAV_PREAMBLE_LENGTH_BITS * d_samples_per_symbol; | ||||||
|  |  | ||||||
|     memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GALILEO_INAV_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int)); | 	memcpy((unsigned short int*)this->d_preambles_bits, (unsigned short int*)preambles_bits, GALILEO_INAV_PREAMBLE_LENGTH_BITS*sizeof(unsigned short int)); | ||||||
|  |  | ||||||
|     // preamble bits to sampled symbols | 	// preamble bits to sampled symbols | ||||||
|     d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * d_symbols_per_preamble); | 	d_preambles_symbols = (signed int*)malloc(sizeof(signed int) * d_symbols_per_preamble); | ||||||
|     int n = 0; | 	int n = 0; | ||||||
|     for (int i=0; i<GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++) | 	for (int i=0; i<GALILEO_INAV_PREAMBLE_LENGTH_BITS; i++) | ||||||
|         { | 	{ | ||||||
|             for (unsigned int j=0; j<d_samples_per_symbol; j++) | 		for (unsigned int j=0; j<d_samples_per_symbol; j++) | ||||||
|                 { | 		{ | ||||||
|                     if (d_preambles_bits[i] == 1) | 			if (d_preambles_bits[i] == 1) | ||||||
|                         { | 			{ | ||||||
|                             d_preambles_symbols[n] = 1; | 				d_preambles_symbols[n] = 1; | ||||||
|                         } | 			} | ||||||
|                     else | 			else | ||||||
|                         { | 			{ | ||||||
|                             d_preambles_symbols[n] = -1; | 				d_preambles_symbols[n] = -1; | ||||||
|                         } | 			} | ||||||
|                     n++; | 			n++; | ||||||
|                 } | 		} | ||||||
|         } | 	} | ||||||
|     d_sample_counter = 0; | 	d_sample_counter = 0; | ||||||
|     d_stat = 0; | 	d_stat = 0; | ||||||
|     d_preamble_index = 0; | 	d_preamble_index = 0; | ||||||
|  |  | ||||||
|     d_preamble_time_seconds = 0; | 	d_preamble_time_seconds = 0; | ||||||
|     d_flag_frame_sync = false; | 	d_flag_frame_sync = false; | ||||||
|  |  | ||||||
|     d_flag_parity = false; | 	d_flag_parity = false; | ||||||
|     d_TOW_at_Preamble= 0; | 	d_TOW_at_Preamble= 0; | ||||||
|     d_TOW_at_current_symbol = 0; | 	d_TOW_at_current_symbol = 0; | ||||||
|  |  | ||||||
|     d_CRC_error_counter=0; | 	d_CRC_error_counter=0; | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| galileo_e1b_telemetry_decoder_cc::~galileo_e1b_telemetry_decoder_cc() | galileo_e1b_telemetry_decoder_cc::~galileo_e1b_telemetry_decoder_cc() | ||||||
| { | { | ||||||
|     delete d_preambles_symbols; | 	delete d_preambles_symbols; | ||||||
|     d_dump_file.close(); | 	d_dump_file.close(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols,int frame_length) | void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols,int frame_length) | ||||||
| @@ -265,235 +265,235 @@ void galileo_e1b_telemetry_decoder_cc::decode_word(double *page_part_symbols,int | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| int galileo_e1b_telemetry_decoder_cc::general_work (int noutput_items, gr_vector_int &ninput_items, | int galileo_e1b_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) | 		gr_vector_const_void_star &input_items,	gr_vector_void_star &output_items) | ||||||
| { | { | ||||||
|     int corr_value = 0; | 	int corr_value = 0; | ||||||
|     int preamble_diff = 0; | 	int preamble_diff = 0; | ||||||
|  |  | ||||||
|     Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; | 	Gnss_Synchro **out = (Gnss_Synchro **) &output_items[0]; | ||||||
|     d_sample_counter++; //count for the processed samples | 	d_sample_counter++; //count for the processed samples | ||||||
|  |  | ||||||
|     // ########### Output the tracking data to navigation and PVT ########## | 	// ########### Output the tracking data to navigation and PVT ########## | ||||||
|     const Gnss_Synchro **in = (const Gnss_Synchro **)  &input_items[0]; //Get the input samples pointer | 	const Gnss_Synchro **in = (const Gnss_Synchro **)  &input_items[0]; //Get the input samples pointer | ||||||
|  |  | ||||||
|     // TODO Optimize me! | 	// TODO Optimize me! | ||||||
|     //******* preamble correlation ******** | 	//******* preamble correlation ******** | ||||||
|     for (int i=0; i<d_symbols_per_preamble; i++) | 	for (int i=0; i<d_symbols_per_preamble; i++) | ||||||
|         { | 	{ | ||||||
|             if (in[0][i].Prompt_I < 0)	// symbols clipping | 		if (in[0][i].Prompt_I < 0)	// symbols clipping | ||||||
|                 { | 		{ | ||||||
|                     corr_value -= d_preambles_symbols[i]; | 			corr_value -= d_preambles_symbols[i]; | ||||||
|                 } | 		} | ||||||
|             else | 		else | ||||||
|                 { | 		{ | ||||||
|                     corr_value += d_preambles_symbols[i]; | 			corr_value += d_preambles_symbols[i]; | ||||||
|                 } | 		} | ||||||
|         } | 	} | ||||||
|     d_flag_preamble = false; | 	d_flag_preamble = false; | ||||||
|  |  | ||||||
|     //******* frame sync ****************** | 	//******* frame sync ****************** | ||||||
|             if (d_stat == 0) //no preamble information | 	if (d_stat == 0) //no preamble information | ||||||
|                 { | 	{ | ||||||
|                 	if (abs(corr_value) >= d_symbols_per_preamble) | 		if (abs(corr_value) >= d_symbols_per_preamble) | ||||||
|                     { | 		{ | ||||||
| 						d_preamble_index = d_sample_counter;//record the preamble sample stamp | 			d_preamble_index = d_sample_counter;//record the preamble sample stamp | ||||||
| 						std::cout << "Preamble detection for Galileo SAT " << this->d_satellite << std::endl; | 			std::cout << "Preamble detection for Galileo SAT " << this->d_satellite << std::endl; | ||||||
| 						d_stat = 1; // enter into frame pre-detection status | 			d_stat = 1; // enter into frame pre-detection status | ||||||
|                     } | 		} | ||||||
|                 } | 	}else if (d_stat == 1) // posible preamble lock | ||||||
|             else if (d_stat == 1) // posible preamble lock | 	{ | ||||||
|                 { | 		if (abs(corr_value) >= d_symbols_per_preamble) | ||||||
| 							if (abs(corr_value) >= d_symbols_per_preamble) | 		{ | ||||||
| 							{ | 			//check preamble separation | ||||||
| 								//check preamble separation | 			preamble_diff = abs(d_sample_counter - d_preamble_index); | ||||||
| 								preamble_diff = abs(d_sample_counter - d_preamble_index); | 			if (abs(preamble_diff - GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) == 0) | ||||||
| 								if (abs(preamble_diff - GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) == 0) |  | ||||||
| 									{ |  | ||||||
| 										//try to decode frame |  | ||||||
| 										std::cout<<"Starting page decoder for Galileo SAT " << this->d_satellite<<std::endl; |  | ||||||
| 										d_preamble_index=d_sample_counter;//record the preamble sample stamp |  | ||||||
| 										d_stat=2; |  | ||||||
| 									} |  | ||||||
| 							}else{ |  | ||||||
| 									if (preamble_diff>GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) |  | ||||||
| 									{ |  | ||||||
| 										d_stat=0; // start again |  | ||||||
| 									} |  | ||||||
| 							} |  | ||||||
|                 }else if (d_stat==2) |  | ||||||
|                 { |  | ||||||
|                     	if (d_sample_counter==d_preamble_index+GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) |  | ||||||
|                     	{ |  | ||||||
|                     		// NEW Galileo page part is received |  | ||||||
|                     	    // 0. fetch the symbols into an array |  | ||||||
|                     	    int frame_length=GALILEO_INAV_PAGE_PART_SYMBOLS-d_symbols_per_preamble; |  | ||||||
|                     	    double page_part_symbols[frame_length]; |  | ||||||
|  |  | ||||||
|                     	    for (int i=0;i<frame_length;i++) |  | ||||||
|                     	    { |  | ||||||
|                     	    	if (corr_value>0) |  | ||||||
|                     	    	{ |  | ||||||
|                     	    		page_part_symbols[i]=in[0][i+d_symbols_per_preamble].Prompt_I; // because last symbol of the preamble is just received now! |  | ||||||
|  |  | ||||||
|                     	    	}else{ |  | ||||||
|                     	    		page_part_symbols[i]=-in[0][i+d_symbols_per_preamble].Prompt_I; // because last symbol of the preamble is just received now! |  | ||||||
|                     	    	} |  | ||||||
|                     	    } |  | ||||||
|                     	    //debug |  | ||||||
|                     	    //std::cout<<"ch["<<d_channel<<"] Decoder call at preamble index "<<d_sample_counter<<std::endl; |  | ||||||
| //                    	    std::cout<<"ch["<<d_channel<<"] frame symbols: "; |  | ||||||
| //                    	    for (int j=0;j<frame_length;j++) |  | ||||||
| //                    	    { |  | ||||||
| //                    	    	if (page_part_symbols[j]>0) |  | ||||||
| //                    	    	{ |  | ||||||
| //                    	    		std::cout<<"1"; |  | ||||||
| //                    	    	}else{ |  | ||||||
| //                    	    		std::cout<<"0"; |  | ||||||
| //                    	    	} |  | ||||||
| //                    	    } |  | ||||||
| //                    	    std::cout<<std::endl; |  | ||||||
|                     	    //end debug |  | ||||||
|                     	    //call the decoder |  | ||||||
|                     	    decode_word(page_part_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_preamble_time_seconds = in[0][0].Tracking_timestamp_secs;// - d_preamble_duration_seconds; //record the PRN start sample index associated to the preamble |  | ||||||
| 								if (!d_flag_frame_sync) |  | ||||||
| 								{ |  | ||||||
| 									d_flag_frame_sync = true; |  | ||||||
| 									std::cout <<" Frame sync SAT " << this->d_satellite << " with preamble start at " << d_preamble_time_seconds << " [s]" << std::endl; |  | ||||||
| 								} |  | ||||||
|                     	    }else{ |  | ||||||
|                     	    	d_CRC_error_counter++; |  | ||||||
|                     	    	d_preamble_index = d_sample_counter;  //record the preamble sample stamp |  | ||||||
|                     	    	if (d_CRC_error_counter>CRC_ERROR_LIMIT) |  | ||||||
|                     	    	{ |  | ||||||
|                     	    		std::cout << "Lost of frame sync SAT " << this->d_satellite << std::endl; |  | ||||||
|                     	    		d_flag_frame_sync=false; |  | ||||||
|                     	    		d_stat=0; |  | ||||||
|                     	    	} |  | ||||||
|                     	    } |  | ||||||
|                         } |  | ||||||
|         } |  | ||||||
|     consume_each(1); //one by one |  | ||||||
|     // UPDATE GNSS SYNCHRO DATA |  | ||||||
|     Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block |  | ||||||
|     //1. Copy the current tracking output |  | ||||||
|     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 |  | ||||||
|     	//flag preamble is true after the all page (even and odd) is recevived. I/NAV page period is 2 SECONDS |  | ||||||
|         { |  | ||||||
|             Prn_timestamp_at_preamble_ms = in[0][0].Tracking_timestamp_secs * 1000.0; |  | ||||||
|             if(d_nav.flag_TOW_5 == true) //page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) |  | ||||||
|             { |  | ||||||
|             	//std::cout<< "Using TOW_5 for timestamping" << std::endl; |  | ||||||
|             	d_TOW_at_Preamble = d_nav.TOW_5+GALILEO_INAV_PAGE_PART_SECONDS; //TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later |  | ||||||
| 				/* 1  sec (GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD) is added because |  | ||||||
| 				* if we have a TOW value it means that we are at the begining of the last page part |  | ||||||
| 				* (GNU Radio history keeps in a buffer the rest of the incomming frame part)*/ |  | ||||||
|             	 d_TOW_at_current_symbol = d_TOW_at_Preamble;// + GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD; |  | ||||||
|             	 d_nav.flag_TOW_5 = false; |  | ||||||
|            } |  | ||||||
|  |  | ||||||
|             else if(d_nav.flag_TOW_6 == true) //page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) |  | ||||||
| 			{ | 			{ | ||||||
|             	//std::cout<< "Using TOW_6 for timestamping" << std::endl; | 				//try to decode frame | ||||||
| 				d_TOW_at_Preamble = d_nav.TOW_6+GALILEO_INAV_PAGE_PART_SECONDS; | 				std::cout<<"Starting page decoder for Galileo SAT " << this->d_satellite<<std::endl; | ||||||
| 				//TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later | 				d_preamble_index=d_sample_counter;//record the preamble sample stamp | ||||||
| 				/* 1  sec (GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD) is added because | 				d_stat=2; | ||||||
| 				* if we have a TOW value it means that we are at the begining of the last page part |  | ||||||
| 				* (GNU Radio history keeps in a buffer the rest of the incomming frame part)*/ |  | ||||||
| 				d_TOW_at_current_symbol = d_TOW_at_Preamble;// + GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD; |  | ||||||
| 				d_nav.flag_TOW_6 = false; |  | ||||||
| 			} | 			} | ||||||
|             else | 			else{ | ||||||
|             { | 				if (preamble_diff>GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) | ||||||
|             	//this page has no timming information | 				{ | ||||||
|             	d_TOW_at_Preamble = d_TOW_at_Preamble + GALILEO_INAV_PAGE_SECONDS; | 					d_stat=0; // start again | ||||||
|             	d_TOW_at_current_symbol =  d_TOW_at_current_symbol + GALIELO_E1_CODE_PERIOD;// + GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD; | 				} | ||||||
|             } | 			} | ||||||
|  | 		} | ||||||
|  | 	}else if (d_stat==2) | ||||||
|  | 	{ | ||||||
|  | 		if (d_sample_counter==d_preamble_index+GALILEO_INAV_PREAMBLE_PERIOD_SYMBOLS) | ||||||
|  | 		{ | ||||||
|  | 			// NEW Galileo page part is received | ||||||
|  | 			// 0. fetch the symbols into an array | ||||||
|  | 			int frame_length=GALILEO_INAV_PAGE_PART_SYMBOLS-d_symbols_per_preamble; | ||||||
|  | 			double page_part_symbols[frame_length]; | ||||||
|  |  | ||||||
|         } | 			for (int i=0;i<frame_length;i++) | ||||||
|     else //if there is not a new preamble, we define the TOW of the current symbol | 			{ | ||||||
|         { | 				if (corr_value>0) | ||||||
|             d_TOW_at_current_symbol = d_TOW_at_current_symbol + GALIELO_E1_CODE_PERIOD; | 				{ | ||||||
|         } | 					page_part_symbols[i]=in[0][i+d_symbols_per_preamble].Prompt_I; // because last symbol of the preamble is just received now! | ||||||
|  |  | ||||||
|     //if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) | 				}else{ | ||||||
|     if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true) | 					page_part_symbols[i]=-in[0][i+d_symbols_per_preamble].Prompt_I; // because last symbol of the preamble is just received now! | ||||||
|     { | 				} | ||||||
|     	current_synchro_data.Flag_valid_word = true; | 			} | ||||||
|     }else{ | 			//debug | ||||||
|     	current_synchro_data.Flag_valid_word = false; | 			//std::cout<<"ch["<<d_channel<<"] Decoder call at preamble index "<<d_sample_counter<<std::endl; | ||||||
|     } | 			//                    	    std::cout<<"ch["<<d_channel<<"] frame symbols: "; | ||||||
|  | 			//                    	    for (int j=0;j<frame_length;j++) | ||||||
|  | 			//                    	    { | ||||||
|  | 			//                    	    	if (page_part_symbols[j]>0) | ||||||
|  | 			//                    	    	{ | ||||||
|  | 			//                    	    		std::cout<<"1"; | ||||||
|  | 			//                    	    	}else{ | ||||||
|  | 			//                    	    		std::cout<<"0"; | ||||||
|  | 			//                    	    	} | ||||||
|  | 			//                    	    } | ||||||
|  | 			//                    	    std::cout<<std::endl; | ||||||
|  | 			//end debug | ||||||
|  | 			//call the decoder | ||||||
|  | 			decode_word(page_part_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_preamble_time_seconds = in[0][0].Tracking_timestamp_secs;// - d_preamble_duration_seconds; //record the PRN start sample index associated to the preamble | ||||||
|  | 				if (!d_flag_frame_sync) | ||||||
|  | 				{ | ||||||
|  | 					d_flag_frame_sync = true; | ||||||
|  | 					std::cout <<" Frame sync SAT " << this->d_satellite << " with preamble start at " << d_preamble_time_seconds << " [s]" << std::endl; | ||||||
|  | 				} | ||||||
|  | 			}else{ | ||||||
|  | 				d_CRC_error_counter++; | ||||||
|  | 				d_preamble_index = d_sample_counter;  //record the preamble sample stamp | ||||||
|  | 				if (d_CRC_error_counter>CRC_ERROR_LIMIT) | ||||||
|  | 				{ | ||||||
|  | 					std::cout << "Lost of frame sync SAT " << this->d_satellite << std::endl; | ||||||
|  | 					d_flag_frame_sync=false; | ||||||
|  | 					d_stat=0; | ||||||
|  | 				} | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	consume_each(1); //one by one | ||||||
|  | 	// UPDATE GNSS SYNCHRO DATA | ||||||
|  | 	Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block | ||||||
|  | 	//1. Copy the current tracking output | ||||||
|  | 	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 | ||||||
|  | 		//flag preamble is true after the all page (even and odd) is recevived. I/NAV page period is 2 SECONDS | ||||||
|  | 	{ | ||||||
|  | 		Prn_timestamp_at_preamble_ms = in[0][0].Tracking_timestamp_secs * 1000.0; | ||||||
|  | 		if(d_nav.flag_TOW_5 == true) //page 5 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) | ||||||
|  | 		{ | ||||||
|  | 			//std::cout<< "Using TOW_5 for timestamping" << std::endl; | ||||||
|  | 			d_TOW_at_Preamble = d_nav.TOW_5+GALILEO_INAV_PAGE_PART_SECONDS; //TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later | ||||||
|  | 			/* 1  sec (GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD) is added because | ||||||
|  | 			 * if we have a TOW value it means that we are at the begining of the last page part | ||||||
|  | 			 * (GNU Radio history keeps in a buffer the rest of the incomming frame part)*/ | ||||||
|  | 			d_TOW_at_current_symbol = d_TOW_at_Preamble;// + GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD; | ||||||
|  | 			d_nav.flag_TOW_5 = false; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|     current_synchro_data.d_TOW = d_TOW_at_Preamble; | 		else if(d_nav.flag_TOW_6 == true) //page 6 arrived and decoded, so we are in the odd page (since Tow refers to the even page, we have to add 1 sec) | ||||||
|     current_synchro_data.d_TOW_at_current_symbol = d_TOW_at_current_symbol; | 		{ | ||||||
|     current_synchro_data.Flag_preamble = d_flag_preamble; | 			//std::cout<< "Using TOW_6 for timestamping" << std::endl; | ||||||
|     current_synchro_data.Prn_timestamp_ms = in[0][0].Tracking_timestamp_secs * 1000.0; | 			d_TOW_at_Preamble = d_nav.TOW_6+GALILEO_INAV_PAGE_PART_SECONDS; | ||||||
|     current_synchro_data.Prn_timestamp_at_preamble_ms = Prn_timestamp_at_preamble_ms; | 			//TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later | ||||||
|  | 			/* 1  sec (GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD) is added because | ||||||
|  | 			 * if we have a TOW value it means that we are at the begining of the last page part | ||||||
|  | 			 * (GNU Radio history keeps in a buffer the rest of the incomming frame part)*/ | ||||||
|  | 			d_TOW_at_current_symbol = d_TOW_at_Preamble;// + GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD; | ||||||
|  | 			d_nav.flag_TOW_6 = false; | ||||||
|  | 		} | ||||||
|  | 		else | ||||||
|  | 		{ | ||||||
|  | 			//this page has no timming information | ||||||
|  | 			d_TOW_at_Preamble = d_TOW_at_Preamble + GALILEO_INAV_PAGE_SECONDS; | ||||||
|  | 			d_TOW_at_current_symbol =  d_TOW_at_current_symbol + GALIELO_E1_CODE_PERIOD;// + GALILEO_INAV_PAGE_PART_SYMBOLS*GALIELO_E1_CODE_PERIOD; | ||||||
|  | 		} | ||||||
|  |  | ||||||
|     if(d_dump == true) | 	} | ||||||
|         { | 	else //if there is not a new preamble, we define the TOW of the current symbol | ||||||
|             // MULTIPLEXED FILE RECORDING - Record results to file | 	{ | ||||||
|             try | 		d_TOW_at_current_symbol = d_TOW_at_current_symbol + GALIELO_E1_CODE_PERIOD; | ||||||
|             { | 	} | ||||||
|                     double tmp_double; |  | ||||||
|                     tmp_double = d_TOW_at_current_symbol; | 	//if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) | ||||||
|                     d_dump_file.write((char*)&tmp_double, sizeof(double)); | 	if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true) | ||||||
|                     tmp_double = current_synchro_data.Prn_timestamp_ms; | 	{ | ||||||
|                     d_dump_file.write((char*)&tmp_double, sizeof(double)); | 		current_synchro_data.Flag_valid_word = true; | ||||||
|                     tmp_double = d_TOW_at_Preamble; | 	}else{ | ||||||
|                     d_dump_file.write((char*)&tmp_double, sizeof(double)); | 		current_synchro_data.Flag_valid_word = false; | ||||||
|             } | 	} | ||||||
|             catch (const std::ifstream::failure& e) |  | ||||||
|             { | 	current_synchro_data.d_TOW = d_TOW_at_Preamble; | ||||||
|                     std::cout << "Exception writing observables dump file " << e.what() << std::endl; | 	current_synchro_data.d_TOW_at_current_symbol = d_TOW_at_current_symbol; | ||||||
|             } | 	current_synchro_data.Flag_preamble = d_flag_preamble; | ||||||
|         } | 	current_synchro_data.Prn_timestamp_ms = in[0][0].Tracking_timestamp_secs * 1000.0; | ||||||
|     //3. Make the output (copy the object contents to the GNURadio reserved memory) | 	current_synchro_data.Prn_timestamp_at_preamble_ms = Prn_timestamp_at_preamble_ms; | ||||||
|     *out[0] = current_synchro_data; |  | ||||||
|     return 1; | 	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) | ||||||
|  | 		{ | ||||||
|  | 			std::cout << "Exception writing observables dump file " << e.what() << std::endl; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	//3. Make the output (copy the object contents to the GNURadio reserved memory) | ||||||
|  | 	*out[0] = current_synchro_data; | ||||||
|  | 	return 1; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void galileo_e1b_telemetry_decoder_cc::set_satellite(Gnss_Satellite satellite) | void galileo_e1b_telemetry_decoder_cc::set_satellite(Gnss_Satellite satellite) | ||||||
| { | { | ||||||
|     d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); | 	d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); | ||||||
|     DLOG(INFO) << "Setting decoder Finite State Machine to satellite "  << d_satellite; | 	DLOG(INFO) << "Setting decoder Finite State Machine to satellite "  << d_satellite; | ||||||
|     DLOG(INFO) << "Navigation Satellite set to " << d_satellite; | 	DLOG(INFO) << "Navigation Satellite set to " << d_satellite; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void galileo_e1b_telemetry_decoder_cc::set_channel(int channel) | void galileo_e1b_telemetry_decoder_cc::set_channel(int channel) | ||||||
| { | { | ||||||
|     d_channel = channel; | 	d_channel = channel; | ||||||
|     DLOG(INFO) << "Navigation channel set to " << channel; | 	DLOG(INFO) << "Navigation channel set to " << channel; | ||||||
|     // ############# ENABLE DATA FILE LOG ################# | 	// ############# ENABLE DATA FILE LOG ################# | ||||||
|     if (d_dump == true) | 	if (d_dump == true) | ||||||
|         { | 	{ | ||||||
|             if (d_dump_file.is_open() == false) | 		if (d_dump_file.is_open() == false) | ||||||
|                 { | 		{ | ||||||
|                     try | 			try | ||||||
|                     { | 			{ | ||||||
|                             d_dump_filename = "telemetry"; | 				d_dump_filename = "telemetry"; | ||||||
|                             d_dump_filename.append(boost::lexical_cast<std::string>(d_channel)); | 				d_dump_filename.append(boost::lexical_cast<std::string>(d_channel)); | ||||||
|                             d_dump_filename.append(".dat"); | 				d_dump_filename.append(".dat"); | ||||||
|                             d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit ); | 				d_dump_file.exceptions ( std::ifstream::failbit | std::ifstream::badbit ); | ||||||
|                             d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); | 				d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); | ||||||
|                             std::cout << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; | 				std::cout << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; | ||||||
|                     } | 			} | ||||||
|                     catch (const std::ifstream::failure& e) | 			catch (const std::ifstream::failure& e) | ||||||
|                     { | 			{ | ||||||
|                             std::cout << "channel " << d_channel << " Exception opening trk dump file " << e.what() << std::endl; | 				std::cout << "channel " << d_channel << " Exception opening trk dump file " << e.what() << std::endl; | ||||||
|                     } | 			} | ||||||
|                 } | 		} | ||||||
|         } | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| void galileo_e1b_telemetry_decoder_cc::set_ephemeris_queue(concurrent_queue<Galileo_Ephemeris> *ephemeris_queue) | void galileo_e1b_telemetry_decoder_cc::set_ephemeris_queue(concurrent_queue<Galileo_Ephemeris> *ephemeris_queue) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Javier Arribas
					Javier Arribas