mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Code cleaning
git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@265 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
		| @@ -7,7 +7,7 @@ | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
|  * Copyright (C) 2010-2012  (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * GNSS-SDR is a software defined Global Navigation | ||||
|  *          Satellite Systems receiver | ||||
| @@ -38,8 +38,7 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn, | ||||
| { | ||||
|     std::string _galileo_signal = _Signal; | ||||
|     signed int prn = _prn - 1; | ||||
|     int index; | ||||
|     index=0; | ||||
|     int index = 0; | ||||
|     //int* dest = _dest; | ||||
|  | ||||
|     /* A simple error check */ | ||||
| @@ -71,19 +70,18 @@ galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn, | ||||
|         { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void | ||||
| galileo_e1_sinboc_11_gen(std::complex<float>* _dest, int* _prn, | ||||
|         unsigned int _length_out) | ||||
| { | ||||
|     const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; | ||||
|     unsigned int _period = (unsigned int) (_length_out / _length_in); | ||||
|  | ||||
|     for (unsigned int i = 0; i < _length_in; i++) | ||||
|         { | ||||
|  | ||||
|             for (unsigned int j = 0; j < (_period / 2); j++) | ||||
|                 _dest[i * _period + j] = std::complex<float>((float) _prn[i], | ||||
|                         0.0); | ||||
| @@ -92,9 +90,10 @@ galileo_e1_sinboc_11_gen(std::complex<float>* _dest, int* _prn, | ||||
|                 _dest[i * _period + j] = std::complex<float>((float) (-_prn[i]), | ||||
|                         0.0); | ||||
|         } | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void | ||||
| galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn, | ||||
|         unsigned int _length_out) | ||||
| @@ -104,17 +103,17 @@ galileo_e1_sinboc_61_gen(std::complex<float>* _dest, int* _prn, | ||||
|  | ||||
|     for (unsigned int i = 0; i < _length_in; i++) | ||||
|         { | ||||
|  | ||||
|             for (unsigned int j = 0; j < _period; j += 2) | ||||
|                 _dest[i * _period + j] = std::complex<float>((float) _prn[i], | ||||
|                         0.0); | ||||
|  | ||||
|             for (unsigned int j = 1; j < _period; j += 2) | ||||
|                 _dest[i * _period + j] = std::complex<float>((float) (-_prn[i]), | ||||
|                         0.0); | ||||
|         } | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void | ||||
| galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3]) | ||||
| { | ||||
| @@ -127,7 +126,6 @@ galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3]) | ||||
|     std::complex<float> sinboc_61[_codeLength]; | ||||
|  | ||||
|     galileo_e1_sinboc_11_gen(sinboc_11, _prn, _codeLength); //generate sinboc(1,1) 12 samples per chip | ||||
|  | ||||
|     galileo_e1_sinboc_61_gen(sinboc_61, _prn, _codeLength); //generate sinboc(6,1) 12 samples per chip | ||||
|  | ||||
|     if (_galileo_signal.rfind("1B") != std::string::npos && _galileo_signal.length() >= 2) | ||||
| @@ -148,13 +146,13 @@ galileo_e1_gen(std::complex<float>* _dest, int* _prn, char _Signal[3]) | ||||
|         return; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void | ||||
| galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3], | ||||
|         bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift) | ||||
| { | ||||
|  | ||||
|     // This function is based on the GNU software GPS for MATLAB in the Kay Borre book | ||||
|  | ||||
|     unsigned int _samplesPerCode; | ||||
|     const unsigned int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz | ||||
|     unsigned int _codeLength = Galileo_E1_B_CODE_LENGTH_CHIPS; | ||||
| @@ -165,15 +163,11 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3], | ||||
|  | ||||
|     if (_cboc == true) | ||||
|         { | ||||
|  | ||||
|             _codeLength = 12 * Galileo_E1_B_CODE_LENGTH_CHIPS; | ||||
|  | ||||
|             if (_fs != 12 * _codeFreqBasis) | ||||
|                 { | ||||
|                     std::complex<float> _signal_E1[_codeLength]; | ||||
|  | ||||
|                     galileo_e1_gen(_signal_E1, primary_code_E1_chips, _Signal); //generate cboc 12 samples per chip | ||||
|  | ||||
|                     resampler(_signal_E1, _dest, 12 * _codeFreqBasis, _fs, | ||||
|                             _codeLength, _samplesPerCode); //resamples code to fs | ||||
|                 } | ||||
| @@ -181,19 +175,14 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3], | ||||
|                 { | ||||
|                     galileo_e1_gen(_dest, primary_code_E1_chips, _Signal); //generate cboc 12 samples per chip | ||||
|                 } | ||||
|  | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|  | ||||
|             //--- Find number of samples per spreading code ---------------------------- | ||||
|  | ||||
|             _codeLength = 2 * Galileo_E1_B_CODE_LENGTH_CHIPS; | ||||
|  | ||||
|             if (_fs != 2 * _codeFreqBasis) | ||||
|                 { | ||||
|                     std::complex<float> _signal_E1[_codeLength]; | ||||
|  | ||||
|                     galileo_e1_sinboc_11_gen(_signal_E1, primary_code_E1_chips, | ||||
|                             _codeLength); //generate sinboc(1,1) 2 samples per chip | ||||
|                     resampler(_signal_E1, _dest, 2 * _codeFreqBasis, _fs, | ||||
| @@ -203,7 +192,6 @@ galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3], | ||||
|                 { | ||||
|                     galileo_e1_sinboc_11_gen(_dest, primary_code_E1_chips, | ||||
|                             _codeLength); //generate sinboc(1,1) 2 samples per chip                } | ||||
|  | ||||
|                 } | ||||
|         } | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
|  * Copyright (C) 2010-2012  (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * GNSS-SDR is a software defined Global Navigation | ||||
|  *          Satellite Systems receiver | ||||
| @@ -29,8 +29,8 @@ | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #ifndef GALILEO_E1_SIGNAL_PROCESSING_H_ | ||||
| #define GALILEO_E1_SIGNAL_PROCESSING_H_ | ||||
| #ifndef GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ | ||||
| #define GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ | ||||
|  | ||||
| #include <complex> | ||||
| #include <iostream> | ||||
| @@ -71,4 +71,4 @@ void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signa | ||||
|         bool _cboc, unsigned int _prn, signed int _fs, | ||||
|         unsigned int _chip_shift); | ||||
|  | ||||
| #endif /* GALILEO_E1_SIGNAL_PROCESSING_H_ */ | ||||
| #endif /* GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ */ | ||||
|   | ||||
| @@ -46,6 +46,8 @@ gnss_sdr_valve::gnss_sdr_valve (size_t sizeof_stream_item, | ||||
|                 d_nitems (nitems), d_ncopied_items (0), d_queue(queue) | ||||
| {} | ||||
|  | ||||
|  | ||||
|  | ||||
| gr_block_sptr gnss_sdr_make_valve (size_t sizeof_stream_item, | ||||
|         int nitems, | ||||
|         gr_msg_queue_sptr queue) | ||||
| @@ -53,6 +55,8 @@ gr_block_sptr gnss_sdr_make_valve (size_t sizeof_stream_item, | ||||
|     return gr_block_sptr (new gnss_sdr_valve (sizeof_stream_item, nitems, queue)); | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| int gnss_sdr_valve::work (int noutput_items, | ||||
|         gr_vector_const_void_star &input_items, | ||||
|         gr_vector_void_star &output_items) | ||||
| @@ -63,17 +67,12 @@ int gnss_sdr_valve::work (int noutput_items, | ||||
|             ControlMessageFactory* cmf = new ControlMessageFactory(); | ||||
|             d_queue->handle(cmf->GetQueueMessage(200,0)); | ||||
|             delete cmf; | ||||
|  | ||||
|             return -1;				// Done! | ||||
|             return -1;	// Done! | ||||
|         } | ||||
|  | ||||
|     unsigned n = std::min (d_nitems - d_ncopied_items, noutput_items); | ||||
|  | ||||
|     unsigned n = std::min(d_nitems - d_ncopied_items, noutput_items); | ||||
|     if (n == 0) | ||||
|         return 0; | ||||
|  | ||||
|     memcpy (output_items[0], input_items[0], n * input_signature()->sizeof_stream_item (0)); | ||||
|     d_ncopied_items += n; | ||||
|  | ||||
|     return n; | ||||
| } | ||||
|   | ||||
| @@ -6,7 +6,7 @@ | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
|  * Copyright (C) 2010-2012  (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * GNSS-SDR is a software defined Global Navigation | ||||
|  *          Satellite Systems receiver | ||||
| @@ -30,8 +30,6 @@ | ||||
|  */ | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| #ifndef GNSS_SDR_GNSS_SDR_VALVE_H_ | ||||
| #define GNSS_SDR_GNSS_SDR_VALVE_H_ | ||||
|  | ||||
| @@ -45,20 +43,17 @@ gr_block_sptr gnss_sdr_make_valve (size_t sizeof_stream_item, | ||||
|  | ||||
| class gnss_sdr_valve : public gr_sync_block | ||||
| { | ||||
|  | ||||
|     friend gr_block_sptr gnss_sdr_make_valve(size_t sizeof_stream_item, | ||||
|             int nitems, | ||||
|             gr_msg_queue_sptr queue); | ||||
|     gnss_sdr_valve (size_t sizeof_stream_item, | ||||
|             int nitems, | ||||
|             gr_msg_queue_sptr queue); | ||||
|  | ||||
|     int	d_nitems; | ||||
|     int	d_ncopied_items; | ||||
|     gr_msg_queue_sptr d_queue; | ||||
|  | ||||
| public: | ||||
|  | ||||
|     int work (int noutput_items, | ||||
|             gr_vector_const_void_star &input_items, | ||||
|             gr_vector_void_star &output_items); | ||||
|   | ||||
| @@ -32,59 +32,56 @@ | ||||
|  */ | ||||
|  | ||||
| #include "gnss_signal_processing.h" | ||||
| #include <gr_fxpt.h> | ||||
| #include <gr_fxpt.h>  // fixed point sine and cosine | ||||
|  | ||||
|  | ||||
| void complex_exp_gen(std::complex<float>* _dest, double _f, double _fs, unsigned int _samps) | ||||
| { | ||||
| 	//old | ||||
| 	//double phase = 0; | ||||
| 	//const double phase_step = (GPS_TWO_PI * _f) / _fs; | ||||
|  | ||||
| 	//new Fixed Point NCO (faster) | ||||
| 	int phase_i=0; | ||||
| 	int phase_step_i; | ||||
| 	float phase_step_f =(float)((GPS_TWO_PI * _f) / _fs); | ||||
| 	phase_step_i=gr_fxpt::float_to_fixed(phase_step_f); | ||||
|     //old | ||||
|     //double phase = 0; | ||||
|     //const double phase_step = (GPS_TWO_PI * _f) / _fs; | ||||
|     //new Fixed Point NCO (faster) | ||||
|     int phase_i = 0; | ||||
|     int phase_step_i; | ||||
|     float phase_step_f = (float)((GPS_TWO_PI * _f) / _fs); | ||||
|     phase_step_i = gr_fxpt::float_to_fixed(phase_step_f); | ||||
|     float sin_f,cos_f; | ||||
|  | ||||
| 	for(unsigned int i = 0; i < _samps; i++) | ||||
| 	{ | ||||
| 		//old | ||||
| 		//_dest[i] = std::complex<float>(cos(phase), sin(phase)); | ||||
| 		//phase += phase_step; | ||||
|  | ||||
| 		//new Fixed Point NCO (faster) | ||||
| 		gr_fxpt::sincos(phase_i,&sin_f,&cos_f); | ||||
| 		_dest[i] = std::complex<float>(cos_f, sin_f); | ||||
| 		phase_i += phase_step_i; | ||||
| 	} | ||||
|     for(unsigned int i = 0; i < _samps; i++) | ||||
|         { | ||||
|             //old | ||||
|             //_dest[i] = std::complex<float>(cos(phase), sin(phase)); | ||||
|             //phase += phase_step; | ||||
|             //new Fixed Point NCO (faster) | ||||
|             gr_fxpt::sincos(phase_i,&sin_f,&cos_f); | ||||
|             _dest[i] = std::complex<float>(cos_f, sin_f); | ||||
|             phase_i += phase_step_i; | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs, unsigned int _samps) | ||||
| { | ||||
| 	//old | ||||
| 	//double phase = 0; | ||||
| 	//const double phase_step = (GPS_TWO_PI * _f) / _fs; | ||||
|  | ||||
| 	//new Fixed Point NCO (faster) | ||||
| 	int phase_i=0; | ||||
| 	int phase_step_i; | ||||
| 	float phase_step_f =(float)((GPS_TWO_PI * _f) / _fs); | ||||
| 	phase_step_i=gr_fxpt::float_to_fixed(phase_step_f); | ||||
|     //old | ||||
|     //double phase = 0; | ||||
|     //const double phase_step = (GPS_TWO_PI * _f) / _fs; | ||||
|     //new Fixed Point NCO (faster) | ||||
|     int phase_i = 0; | ||||
|     int phase_step_i; | ||||
|     float phase_step_f = (float)((GPS_TWO_PI * _f) / _fs); | ||||
|     phase_step_i = gr_fxpt::float_to_fixed(phase_step_f); | ||||
|     float sin_f,cos_f; | ||||
|  | ||||
| 	for(unsigned int i = 0; i < _samps; i++) | ||||
| 	{ | ||||
| 		//old | ||||
| 		//_dest[i] = std::complex<float>(cos(phase), sin(phase)); | ||||
| 		//phase += phase_step; | ||||
|  | ||||
| 		//new Fixed Point NCO (faster) | ||||
| 		gr_fxpt::sincos(phase_i,&sin_f,&cos_f); | ||||
| 		_dest[i] = std::complex<float>(cos_f, -sin_f); | ||||
| 		phase_i += phase_step_i; | ||||
| 	} | ||||
|     for(unsigned int i = 0; i < _samps; i++) | ||||
|         { | ||||
|             //old | ||||
|             //_dest[i] = std::complex<float>(cos(phase), sin(phase)); | ||||
|             //phase += phase_step; | ||||
|             //new Fixed Point NCO (faster) | ||||
|             gr_fxpt::sincos(phase_i,&sin_f,&cos_f); | ||||
|             _dest[i] = std::complex<float>(cos_f, -sin_f); | ||||
|             phase_i += phase_step_i; | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -93,110 +90,110 @@ void hex_to_binary_converter(int * _dest, char _from) | ||||
| 	switch(_from) | ||||
| 	{ | ||||
| 		case '0': | ||||
| 			*(_dest)=1; | ||||
| 			*(_dest+1)=1; | ||||
| 			*(_dest+2)=1; | ||||
| 			*(_dest+3)=1; | ||||
| 			*(_dest) = 1; | ||||
| 			*(_dest+1) = 1; | ||||
| 			*(_dest+2) = 1; | ||||
| 			*(_dest+3) = 1; | ||||
| 			break; | ||||
| 		case '1': | ||||
| 			*(_dest)=1; | ||||
| 			*(_dest+1)=1; | ||||
| 			*(_dest+2)=1; | ||||
| 			*(_dest+3)=-1; | ||||
| 			*(_dest) = 1; | ||||
| 			*(_dest+1) = 1; | ||||
| 			*(_dest+2) = 1; | ||||
| 			*(_dest+3) = -1; | ||||
| 			break; | ||||
| 		case '2': | ||||
| 			*(_dest)=1; | ||||
| 			*(_dest+1)=1; | ||||
| 			*(_dest+2)=-1; | ||||
| 			*(_dest+3)=1; | ||||
| 			*(_dest) = 1; | ||||
| 			*(_dest+1) = 1; | ||||
| 			*(_dest+2) = -1; | ||||
| 			*(_dest+3) = 1; | ||||
| 			break; | ||||
| 		case '3': | ||||
| 			*(_dest)=1; | ||||
| 			*(_dest+1)=1; | ||||
| 			*(_dest+2)=-1; | ||||
| 			*(_dest+3)=-1; | ||||
| 			*(_dest) = 1; | ||||
| 			*(_dest+1) = 1; | ||||
| 			*(_dest+2) = -1; | ||||
| 			*(_dest+3) = -1; | ||||
| 			break; | ||||
| 		case '4': | ||||
| 			*(_dest)=1; | ||||
| 			*(_dest+1)=-1; | ||||
| 			*(_dest+2)=1; | ||||
| 			*(_dest+3)=1; | ||||
| 			*(_dest) = 1; | ||||
| 			*(_dest+1) = -1; | ||||
| 			*(_dest+2) = 1; | ||||
| 			*(_dest+3) = 1; | ||||
| 			break; | ||||
| 		case '5': | ||||
| 			*(_dest)=1; | ||||
| 			*(_dest+1)=-1; | ||||
| 			*(_dest+2)=1; | ||||
| 			*(_dest+3)=-1; | ||||
| 			*(_dest) = 1; | ||||
| 			*(_dest+1) = -1; | ||||
| 			*(_dest+2) = 1; | ||||
| 			*(_dest+3) = -1; | ||||
| 			break; | ||||
| 		case '6': | ||||
| 			*(_dest)=1; | ||||
| 			*(_dest+1)=-1; | ||||
| 			*(_dest+2)=-1; | ||||
| 			*(_dest+3)=1; | ||||
| 			*(_dest) = 1; | ||||
| 			*(_dest+1) = -1; | ||||
| 			*(_dest+2) = -1; | ||||
| 			*(_dest+3) = 1; | ||||
| 			break; | ||||
| 		case '7': | ||||
| 			*(_dest)=1; | ||||
| 			*(_dest+1)=-1; | ||||
| 			*(_dest+2)=-1; | ||||
| 			*(_dest+3)=-1; | ||||
| 			*(_dest) = 1; | ||||
| 			*(_dest+1) = -1; | ||||
| 			*(_dest+2) = -1; | ||||
| 			*(_dest+3) = -1; | ||||
| 			break; | ||||
| 		case '8': | ||||
| 			*(_dest)=-1; | ||||
| 			*(_dest+1)=1; | ||||
| 			*(_dest+2)=1; | ||||
| 			*(_dest+3)=1; | ||||
| 			*(_dest) = -1; | ||||
| 			*(_dest+1) = 1; | ||||
| 			*(_dest+2) = 1; | ||||
| 			*(_dest+3) = 1; | ||||
| 			break; | ||||
| 		case '9': | ||||
| 			*(_dest)=-1; | ||||
| 			*(_dest+1)=1; | ||||
| 			*(_dest+2)=1; | ||||
| 			*(_dest+3)=-1; | ||||
| 			*(_dest) = -1; | ||||
| 			*(_dest+1) = 1; | ||||
| 			*(_dest+2) = 1; | ||||
| 			*(_dest+3) = -1; | ||||
| 			break; | ||||
| 		case 'A': | ||||
| 			*(_dest)=-1; | ||||
| 			*(_dest+1)=1; | ||||
| 			*(_dest+2)=-1; | ||||
| 			*(_dest+3)=1; | ||||
| 			*(_dest) = -1; | ||||
| 			*(_dest+1) = 1; | ||||
| 			*(_dest+2) = -1; | ||||
| 			*(_dest+3) = 1; | ||||
| 			break; | ||||
| 		case 'B': | ||||
| 			*(_dest)=-1; | ||||
| 			*(_dest+1)=1; | ||||
| 			*(_dest+2)=-1; | ||||
| 			*(_dest+3)=-1; | ||||
| 			*(_dest) = -1; | ||||
| 			*(_dest+1) = 1; | ||||
| 			*(_dest+2) = -1; | ||||
| 			*(_dest+3) = -1; | ||||
| 			break; | ||||
| 		case 'C': | ||||
| 			*(_dest)=-1; | ||||
| 			*(_dest+1)=-1; | ||||
| 			*(_dest+2)=1; | ||||
| 			*(_dest+3)=1; | ||||
| 			*(_dest) = -1; | ||||
| 			*(_dest+1) = -1; | ||||
| 			*(_dest+2) = 1; | ||||
| 			*(_dest+3) = 1; | ||||
| 			break; | ||||
| 		case 'D': | ||||
| 			*(_dest)=-1; | ||||
| 			*(_dest+1)=-1; | ||||
| 			*(_dest+2)=1; | ||||
| 			*(_dest+3)=-1; | ||||
| 			*(_dest) = -1; | ||||
| 			*(_dest+1) = -1; | ||||
| 			*(_dest+2) = 1; | ||||
| 			*(_dest+3) = -1; | ||||
| 			break; | ||||
| 		case 'E': | ||||
| 			*(_dest)=-1; | ||||
| 			*(_dest+1)=-1; | ||||
| 			*(_dest+2)=-1; | ||||
| 			*(_dest+3)=1; | ||||
| 			*(_dest) = -1; | ||||
| 			*(_dest+1) = -1; | ||||
| 			*(_dest+2) = -1; | ||||
| 			*(_dest+3) = 1; | ||||
| 			break; | ||||
| 		case 'F': | ||||
| 			*(_dest)=-1; | ||||
| 			*(_dest+1)=-1; | ||||
| 			*(_dest+2)=-1; | ||||
| 			*(_dest+3)=-1; | ||||
| 			*(_dest) = -1; | ||||
| 			*(_dest+1) = -1; | ||||
| 			*(_dest+2) = -1; | ||||
| 			*(_dest+3) = -1; | ||||
| 			break; | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| void resampler(std::complex<float>* _from, std::complex<float>* _dest, float _fs_in, | ||||
| 		float _fs_out, unsigned int _length_in, unsigned int _length_out) | ||||
|         float _fs_out, unsigned int _length_in, unsigned int _length_out) | ||||
| { | ||||
| 	unsigned int _codeValueIndex; | ||||
| 	//--- Find time constants -------------------------------------------------- | ||||
|     unsigned int _codeValueIndex; | ||||
|     //--- Find time constants -------------------------------------------------- | ||||
|     const float _t_in = 1/_fs_in;  // Incoming sampling  period in sec | ||||
|     const float _t_out = 1/_fs_out;   // Out sampling period in sec | ||||
|     for (unsigned int i=0; i<_length_out; i++) | ||||
| @@ -211,7 +208,7 @@ void resampler(std::complex<float>* _from, std::complex<float>* _dest, float _fs | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     //if repeat the chip -> upsample by nearest neighbourhood interpolation | ||||
|                     //if repeat the chip -> upsample by nearest neighborhood interpolation | ||||
|                     _dest[i] = _from[_codeValueIndex]; | ||||
|                 } | ||||
|         } | ||||
|   | ||||
| @@ -32,8 +32,8 @@ | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #ifndef GNSS_SIGNAL_PROCESSING_H_ | ||||
| #define GNSS_SIGNAL_PROCESSING_H_ | ||||
| #ifndef GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ | ||||
| #define GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ | ||||
|  | ||||
| #include <complex> | ||||
| #include <iostream> | ||||
| @@ -59,7 +59,6 @@ void complex_exp_gen_conj(std::complex<float>* _dest, double _f, double _fs, | ||||
|  *  to binary (the output are 4 ints with +1 or -1 values). | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| void hex_to_binary_converter(int * _dest, char _from); | ||||
|  | ||||
| /*! | ||||
| @@ -70,4 +69,4 @@ void resampler(std::complex<float>* _from, std::complex<float>* _dest, | ||||
|         float _fs_in, float _fs_out, unsigned int _length_in, | ||||
|         unsigned int _length_out); | ||||
|  | ||||
| #endif /* GNSS_SIGNAL_PROCESSING_H_ */ | ||||
| #endif /* GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ */ | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
|  * Copyright (C) 2010-2012  (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * GNSS-SDR is a software defined Global Navigation | ||||
|  *          Satellite Systems receiver | ||||
| @@ -31,7 +31,6 @@ | ||||
|  */ | ||||
|  | ||||
| #include "gps_sdr_signal_processing.h" | ||||
|  | ||||
| #include <math.h> | ||||
| #include <stdlib.h> | ||||
| #include <cmath> | ||||
| @@ -39,77 +38,72 @@ | ||||
|  | ||||
| void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift) | ||||
| { | ||||
|     unsigned int G1[1023]; | ||||
|     unsigned int G2[1023]; | ||||
|     unsigned int G1_register[10], G2_register[10]; | ||||
|     unsigned int feedback1, feedback2; | ||||
|     unsigned int lcv, lcv2; | ||||
|     unsigned int delay; | ||||
|     signed int prn = _prn-1; //Move the PRN code to fit an array indices | ||||
|  | ||||
| 	unsigned int G1[1023]; | ||||
| 	unsigned int G2[1023]; | ||||
| 	unsigned int G1_register[10], G2_register[10]; | ||||
| 	unsigned int feedback1, feedback2; | ||||
| 	unsigned int lcv, lcv2; | ||||
| 	unsigned int delay; | ||||
| 	signed int prn = _prn-1; //Move the PRN code to fit an array indices | ||||
|     /* G2 Delays as defined in GPS-ISD-200D */ | ||||
|     signed int delays[51] = {5, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254 ,255, 256, 257, 258, 469, 470, 471, 472, | ||||
|             473, 474, 509, 512, 513, 514, 515, 516, 859, 860, 861, 862, 145, 175, 52, 21, 237, 235, 886, 657, 634, 762, | ||||
|             355, 1012, 176, 603, 130, 359, 595, 68, 386}; | ||||
|  | ||||
| 	/* G2 Delays as defined in GPS-ISD-200D */ | ||||
| 	signed int delays[51] = {5, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254 ,255, 256, 257, 258, 469, 470, 471, 472, | ||||
| 		473, 474, 509, 512, 513, 514, 515, 516, 859, 860, 861, 862, 145, 175, 52, 21, 237, 235, 886, 657, 634, 762, | ||||
| 		355, 1012, 176, 603, 130, 359, 595, 68, 386}; | ||||
|     /* A simple error check */ | ||||
|     if((prn < 0) || (prn > 51)) | ||||
|         return; | ||||
|  | ||||
| 	/* A simple error check */ | ||||
| 	if((prn < 0) || (prn > 51)) | ||||
| 		return; | ||||
|     for(lcv = 0; lcv < 10; lcv++) | ||||
|         { | ||||
|             G1_register[lcv] = 1; | ||||
|             G2_register[lcv] = 1; | ||||
|         } | ||||
|  | ||||
| 	for(lcv = 0; lcv < 10; lcv++) | ||||
| 	{ | ||||
| 		G1_register[lcv] = 1; | ||||
| 		G2_register[lcv] = 1; | ||||
| 	} | ||||
|     /* Generate G1 & G2 Register */ | ||||
|     for(lcv = 0; lcv < 1023; lcv++) | ||||
|         { | ||||
|             G1[lcv] = G1_register[0]; | ||||
|             G2[lcv] = G2_register[0]; | ||||
|  | ||||
| 	/* Generate G1 & G2 Register */ | ||||
| 	for(lcv = 0; lcv < 1023; lcv++) | ||||
| 	{ | ||||
| 		G1[lcv] = G1_register[0]; | ||||
| 		G2[lcv] = G2_register[0]; | ||||
|             feedback1 = G1_register[7]^G1_register[0]; | ||||
|             feedback2 = (G2_register[8] + G2_register[7] + G2_register[4] + G2_register[2] + G2_register[1] + G2_register[0]) & 0x1; | ||||
|  | ||||
| 		feedback1 = G1_register[7]^G1_register[0]; | ||||
| 		feedback2 = (G2_register[8] + G2_register[7] + G2_register[4] + G2_register[2] + G2_register[1] + G2_register[0]) & 0x1; | ||||
|             for(lcv2 = 0; lcv2 < 9; lcv2++) | ||||
|                 { | ||||
|                     G1_register[lcv2] = G1_register[lcv2 + 1]; | ||||
|                     G2_register[lcv2] = G2_register[lcv2 + 1]; | ||||
|                 } | ||||
|  | ||||
| 		for(lcv2 = 0; lcv2 < 9; lcv2++) | ||||
| 		{ | ||||
| 			G1_register[lcv2] = G1_register[lcv2 + 1]; | ||||
| 			G2_register[lcv2] = G2_register[lcv2 + 1]; | ||||
| 		} | ||||
|  | ||||
| 		G1_register[9] = feedback1; | ||||
| 		G2_register[9] = feedback2; | ||||
| 	} | ||||
|  | ||||
| 	/* Set the delay */ | ||||
| 	delay = 1023 - delays[prn]; | ||||
| 	delay += _chip_shift; | ||||
| 	delay %= 1023; | ||||
| 	/* Generate PRN from G1 and G2 Registers */ | ||||
| 	for(lcv = 0; lcv < 1023; lcv++) | ||||
| 	{ | ||||
| 		_dest[lcv] = std::complex<float>(G1[(lcv +  _chip_shift)%1023]^G2[delay], 0); | ||||
| 		if(_dest[lcv].real() == 0.0) //javi | ||||
| 		{ | ||||
| 			_dest[lcv].real(-1.0); | ||||
| 		} | ||||
| 		delay++; | ||||
| 		delay %= 1023; | ||||
| 		//std::cout<<_dest[lcv].real(); //OK | ||||
| 	} | ||||
|             G1_register[9] = feedback1; | ||||
|             G2_register[9] = feedback2; | ||||
|         } | ||||
|  | ||||
|     /* Set the delay */ | ||||
|     delay = 1023 - delays[prn]; | ||||
|     delay += _chip_shift; | ||||
|     delay %= 1023; | ||||
|     /* Generate PRN from G1 and G2 Registers */ | ||||
|     for(lcv = 0; lcv < 1023; lcv++) | ||||
|         { | ||||
|             _dest[lcv] = std::complex<float>(G1[(lcv +  _chip_shift)%1023]^G2[delay], 0); | ||||
|             if(_dest[lcv].real() == 0.0) //javi | ||||
|                 { | ||||
|                     _dest[lcv].real(-1.0); | ||||
|                 } | ||||
|             delay++; | ||||
|             delay %= 1023; | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| /*! | ||||
|  * \ | ||||
| /* | ||||
|  * code_gen_complex_sampled, generate GPS L1 C/A code complex for the desired SV ID and sampled to specific sampling frequency | ||||
|  * \ | ||||
|  */ | ||||
| void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift) | ||||
| { | ||||
| 	// This function is based on the GNU software GPS for MATLAB in the Kay Borre book | ||||
|     // This function is based on the GNU software GPS for MATLAB in the Kay Borre book | ||||
|     std::complex<float> _code[1023]; | ||||
|     signed int _samplesPerCode, _codeValueIndex; | ||||
|     float _ts; | ||||
| @@ -124,9 +118,7 @@ void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int | ||||
|     _ts = 1/(float)_fs;   // Sampling period in sec | ||||
|     _tc = 1/(float)_codeFreqBasis;  // C/A chip period in sec | ||||
|     gps_l1_ca_code_gen_complex(_code,_prn, _chip_shift); //generate C/A code 1 sample per chip | ||||
|     //std::cout<<"ts="<<_ts<<std::endl; | ||||
|     //std::cout<<"tc="<<_tc<<std::endl; | ||||
|     //std::cout<<"sv="<<_prn<<std::endl; | ||||
|  | ||||
|     for (signed int i=0; i<_samplesPerCode; i++) | ||||
|         { | ||||
|             //=== Digitizing ======================================================= | ||||
| @@ -136,7 +128,6 @@ void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int | ||||
|             // number of samples per millisecond (because one C/A code period is one | ||||
|             // millisecond). | ||||
|  | ||||
|  | ||||
|             _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; | ||||
|  | ||||
|             //--- Make the digitized version of the C/A code ----------------------- | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
|  * Copyright (C) 2010-2012  (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * GNSS-SDR is a software defined Global Navigation | ||||
|  *          Satellite Systems receiver | ||||
| @@ -30,8 +30,8 @@ | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #ifndef GPS_SDR_SIGNAL_PROCESSING_H_ | ||||
| #define GPS_SDR_SIGNAL_PROCESSING_H_ | ||||
| #ifndef GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ | ||||
| #define GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ | ||||
|  | ||||
| #include <complex> | ||||
| #include <iostream> | ||||
| @@ -41,4 +41,4 @@ | ||||
| void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift); | ||||
| void gps_l1_ca_code_gen_complex_sampled(std::complex<float>* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift); | ||||
|  | ||||
| #endif /* GPS_SDR_SIGNAL_PROCESSING_H_ */ | ||||
| #endif /* GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ */ | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
|  * Copyright (C) 2010-2012  (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * GNSS-SDR is a software defined Global Navigation | ||||
|  *          Satellite Systems receiver | ||||
| @@ -31,8 +31,6 @@ | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
|  | ||||
|  | ||||
| #include "pass_through.h" | ||||
| #include <iostream> | ||||
| #include <gnuradio/gr_io_signature.h> | ||||
| @@ -42,19 +40,16 @@ | ||||
|  | ||||
| using google::LogMessage; | ||||
|  | ||||
| Pass_Through::Pass_Through(ConfigurationInterface* configuration,	std::string role, | ||||
| Pass_Through::Pass_Through(ConfigurationInterface* configuration, std::string role, | ||||
|         unsigned int in_streams, | ||||
|         unsigned int out_streams) : | ||||
|         role_(role), | ||||
|         in_streams_(in_streams), | ||||
|         out_streams_(out_streams) | ||||
| { | ||||
|  | ||||
|     std::string default_item_type = "gr_complex"; | ||||
|  | ||||
|     item_type_ = configuration->property(role + ".item_type", default_item_type); | ||||
|     vector_size_ = configuration->property(role + ".vector_size", 1); | ||||
|  | ||||
|     if(item_type_.compare("float") == 0) | ||||
|         { | ||||
|             item_size_ = sizeof(float); | ||||
| @@ -72,29 +67,38 @@ Pass_Through::Pass_Through(ConfigurationInterface* configuration,	std::string ro | ||||
|             LOG_AT_LEVEL(WARNING) << item_type_ << " unrecognized item type. Using float"; | ||||
|             item_size_ = sizeof(float); | ||||
|         } | ||||
|  | ||||
|     kludge_copy_ = gr_make_kludge_copy(item_size_); | ||||
|     DLOG(INFO) << "kludge_copy(" << kludge_copy_->unique_id() << ")"; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| Pass_Through::~Pass_Through() | ||||
| {} | ||||
|  | ||||
|  | ||||
|  | ||||
| void Pass_Through::connect(gr_top_block_sptr top_block) | ||||
| { | ||||
|     DLOG(INFO) << "nothing to connect internally"; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| void Pass_Through::disconnect(gr_top_block_sptr top_block) | ||||
| { | ||||
|     // Nothing to disconnect | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| gr_basic_block_sptr Pass_Through::get_left_block() | ||||
| { | ||||
|     return kludge_copy_; | ||||
| } | ||||
|  | ||||
|  | ||||
|  | ||||
| gr_basic_block_sptr Pass_Through::get_right_block() | ||||
| { | ||||
|     return kludge_copy_; | ||||
|   | ||||
| @@ -7,7 +7,7 @@ | ||||
|  * | ||||
|  * ------------------------------------------------------------------------- | ||||
|  * | ||||
|  * Copyright (C) 2010-2011  (see AUTHORS file for a list of contributors) | ||||
|  * Copyright (C) 2010-2012  (see AUTHORS file for a list of contributors) | ||||
|  * | ||||
|  * GNSS-SDR is a software defined Global Navigation | ||||
|  *          Satellite Systems receiver | ||||
| @@ -30,9 +30,6 @@ | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| #ifndef GNSS_SDR_PASS_THROUGH_H_ | ||||
| #define GNSS_SDR_PASS_THROUGH_H_ | ||||
|  | ||||
| @@ -45,7 +42,6 @@ class ConfigurationInterface; | ||||
|  | ||||
| class Pass_Through : public GNSSBlockInterface | ||||
| { | ||||
|  | ||||
| public: | ||||
|     Pass_Through(ConfigurationInterface* configuration, | ||||
|             std::string role, | ||||
| @@ -53,7 +49,6 @@ public: | ||||
|             unsigned int out_stream); | ||||
|  | ||||
|     virtual ~Pass_Through(); | ||||
|  | ||||
|     std::string role() | ||||
|     { | ||||
|         return role_; | ||||
| @@ -62,7 +57,6 @@ public: | ||||
|     { | ||||
|         return "Pass_Through"; | ||||
|     } | ||||
|  | ||||
|     std::string item_type() | ||||
|     { | ||||
|         return item_type_; | ||||
| @@ -75,20 +69,17 @@ public: | ||||
|     { | ||||
|         return item_size_; | ||||
|     } | ||||
|  | ||||
|     void connect(gr_top_block_sptr top_block); | ||||
|     void disconnect(gr_top_block_sptr top_block); | ||||
|     gr_basic_block_sptr get_left_block(); | ||||
|     gr_basic_block_sptr get_right_block(); | ||||
|  | ||||
| private: | ||||
|  | ||||
|     std::string item_type_; | ||||
|     size_t vector_size_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     gr_kludge_copy_sptr kludge_copy_; | ||||
|     size_t item_size_; | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez