From 2f0ef5753eadcb97e211537d247556c3e5bfbf73 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 22 Aug 2018 10:24:40 +0200 Subject: [PATCH 01/53] changed the device name for the interrupt counter in the PL removed the acknowledgement of the interrupt triggered by the interrupt counter IP (edge interrupt). --- src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc | 4 ++-- src/algorithms/libs/gnss_sdr_fpga_sample_counter.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc index 727de7521..d6d0670be 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc @@ -293,8 +293,8 @@ uint32_t gnss_sdr_fpga_sample_counter::wait_for_interrupt_and_read_counter() printf("acquisition module Interrupt number %d\n", irq_count); } - // acknowledge the interrupt - map_base[1] = 0; // writing anything to reg 1 acknowledges the interrupt + // it is a rising edge interrupt, the interrupt does not need to be acknowledged + //map_base[1] = 0; // writing anything to reg 1 acknowledges the interrupt // add number of passed samples or read the current counter value for more accuracy counter = samples_per_output; //map_base[0]; diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h index e02320afc..9ee2b67dc 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h @@ -68,7 +68,7 @@ private: bool flag_enable_send_msg; int32_t fd; // driver descriptor volatile uint32_t *map_base; // driver memory map - std::string device_name = "/dev/uio26"; // HW device name + std::string device_name = "/dev/uio2"; // HW device name public: friend gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms); From 2b15343a6a2b76cbb93052f13a85fee8be39b1af Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 29 Aug 2018 18:20:41 +0200 Subject: [PATCH 02/53] started tracking pull-in test implementation for the FPGA --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 10 + .../gps_l1_ca_pcps_acquisition_fpga.cc | 13 + .../gnuradio_blocks/pcps_acquisition_fpga.cc | 38 +- .../gnuradio_blocks/pcps_acquisition_fpga.h | 5 +- .../acquisition/libs/fpga_acquisition.cc | 31 +- .../acquisition/libs/fpga_acquisition.h | 2 + .../adapters/ad9361_fpga_signal_source.cc | 2 +- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 2 +- .../dll_pll_veml_tracking_fpga.cc | 4 +- src/tests/test_main.cc | 2 +- .../tracking/tracking_pull-in_test_fpga.cc | 566 ++++++++++++++---- 11 files changed, 548 insertions(+), 127 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 73a38d257..7157899cc 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -58,6 +58,16 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); + acq_parameters.downsampling_factor = downsampling_factor; + //fs_in = fs_in/2.0; // downampling filter + //printf("fs_in pre downsampling = %ld\n", fs_in); + + fs_in = fs_in/downsampling_factor; + //printf("fs_in post downsampling = %ld\n", fs_in); + + acq_parameters.fs_in = fs_in; //if_ = configuration_->property(role + ".if", 0); //acq_parameters.freq = if_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 383e098b3..326a66d7c 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -60,7 +60,15 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); + acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter + printf("fs_in pre downsampling = %ld\n", fs_in); + + fs_in = fs_in/downsampling_factor; + printf("fs_in post downsampling = %ld\n", fs_in); + //printf("####### DEBUG Acq: fs_in = %d\n", fs_in); acq_parameters.fs_in = fs_in; acq_parameters.samples_per_code = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD * static_cast(acq_parameters.fs_in))); @@ -71,16 +79,20 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( acq_parameters.sampled_ms = sampled_ms; unsigned int code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; + //printf("acq adapter code_length = %d\n", code_length); // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; + //printf("acq adapter vector_length = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); + //printf("acq adapter device name = %s\n", device_name.c_str()); acq_parameters.device_name = device_name; acq_parameters.samples_per_ms = nsamples_total / sampled_ms; + //printf("acq adapter samples_per_ms = %d\n", nsamples_total / sampled_ms); acq_parameters.samples_per_code = nsamples_total; // compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time @@ -237,6 +249,7 @@ void GpsL1CaPcpsAcquisitionFpga::set_local_code() void GpsL1CaPcpsAcquisitionFpga::reset() { acquisition_fpga_->set_active(true); + //printf("acq reset end dddsss\n"); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 5e97a8ed5..902257c38 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -76,6 +76,8 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( d_channel = 0U; d_gnss_synchro = 0; + d_downsampling_factor = acq_parameters.downsampling_factor; + d_select_queue_Fpga = acq_parameters.select_queue_Fpga; //printf("zzzz acq_parameters.code_length = %d\n", acq_parameters.code_length); //printf("zzzz acq_parameters.samples_per_ms = %d\n", acq_parameters.samples_per_ms); //printf("zzzz d_fft_size = %d\n", d_fft_size); @@ -176,6 +178,7 @@ void pcps_acquisition_fpga::send_positive_acquisition() << ", magnitude " << d_mag << ", input signal power " << d_input_power; + //printf("acq sending positive acquisition\n"); this->message_port_pub(pmt::mp("events"), pmt::from_long(1)); // printf("acq send positive acquisition end\n"); } @@ -196,6 +199,7 @@ void pcps_acquisition_fpga::send_negative_acquisition() << ", magnitude " << d_mag << ", input signal power " << d_input_power; + //printf("acq sending negative acquisition\n"); this->message_port_pub(pmt::mp("events"), pmt::from_long(2)); // printf("acq send negative acquisition end\n"); } @@ -269,8 +273,12 @@ void pcps_acquisition_fpga::set_active(bool active) // run loop in hw //printf("LAUNCH ACQ\n"); + //printf("acq lib d_num_doppler_bins = %d\n", d_num_doppler_bins); acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); + //acquisition_fpga->set_doppler_sweep(2); + //printf("acq lib going to launch acquisition\n"); acquisition_fpga->run_acquisition(); + //printf("acq lib going to read the acquisition results\n"); acquisition_fpga->read_acquisition_results(&indext, &magt, &initial_sample, &d_input_power, &d_doppler_index); //printf("READ ACQ RESULTS\n"); @@ -292,12 +300,35 @@ void pcps_acquisition_fpga::set_active(bool active) d_input_power = (d_input_power - d_mag) / (d_fft_size - 1); int32_t doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * d_doppler_index; //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % (2*acq_parameters.samples_per_code))); - d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_sample_counter = initial_sample; + + if (d_select_queue_Fpga == 0) + { + if (d_downsampling_factor > 1) + { + d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext % acq_parameters.samples_per_code)); + d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5*d_downsampling_factor; // delay due to the downsampling filter in the acquisition + } + else + { + d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition + } + } + else + { + d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition + } + + + //d_gnss_synchro->Acq_samplestamp_samples = 2*d_sample_counter - 81; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition - d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition + d_test_statistics = (d_mag / d_input_power); //* correction_factor; // debug @@ -339,7 +370,7 @@ void pcps_acquisition_fpga::set_active(bool active) send_negative_acquisition(); } - // printf("acq set active end\n"); + //printf("acq set active end\n"); } @@ -347,6 +378,7 @@ int pcps_acquisition_fpga::general_work(int noutput_items __attribute__((unused) gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items __attribute__((unused))) { + //printf("ACQ GENERAL WORK CALLED\n"); // the general work is not used with the acquisition that uses the FPGA return noutput_items; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index abf8f6b06..4709cfb1f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -73,7 +73,7 @@ typedef struct uint32_t select_queue_Fpga; std::string device_name; lv_16sc_t* all_fft_codes; // memory that contains all the code ffts - + float downsampling_factor; } pcpsconf_fpga_t; class pcps_acquisition_fpga; @@ -124,6 +124,9 @@ private: int32_t debug_indext; int32_t debug_doppler_index; + float d_downsampling_factor; + uint32_t d_select_queue_Fpga; + public: ~pcps_acquisition_fpga(); diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 57e2a6ba2..dad09488c 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -70,6 +70,7 @@ bool fpga_acquisition::init() { + //printf("acq lib init called\n"); // configure the acquisition with the main initialization values fpga_acquisition::configure_acquisition(); return true; @@ -78,6 +79,7 @@ bool fpga_acquisition::init() bool fpga_acquisition::set_local_code(uint32_t PRN) { + //printf("acq lib set_local_code_called\n"); // select the code with the chosen PRN fpga_acquisition::fpga_configure_acquisition_local_code( &d_all_fft_codes[d_nsamples_total * (PRN - 1)]); @@ -96,6 +98,7 @@ fpga_acquisition::fpga_acquisition(std::string device_name, uint32_t sampled_ms, uint32_t select_queue, lv_16sc_t *all_fft_codes) { + //printf("acq lib constructor called\n"); //printf("AAA- sampled_ms = %d\n ", sampled_ms); uint32_t vector_length = nsamples_total; // * sampled_ms; @@ -121,6 +124,10 @@ fpga_acquisition::fpga_acquisition(std::string device_name, LOG(WARNING) << "Cannot open deviceio" << d_device_name; std::cout << "Acq: cannot open deviceio" << d_device_name << std::endl; } + else + { + //printf("acq lib DEVICE OPENED CORRECTLY\n"); + } d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_fd, 0)); @@ -129,6 +136,10 @@ fpga_acquisition::fpga_acquisition(std::string device_name, LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory"; std::cout << "Acq: cannot map deviceio" << d_device_name << std::endl; } + else + { + //printf("acq lib MAP BASE MAPPED CORRECTLY\n"); + } // sanity check : check test register uint32_t writeval = TEST_REG_SANITY_CHECK; @@ -141,6 +152,7 @@ fpga_acquisition::fpga_acquisition(std::string device_name, else { LOG(INFO) << "Acquisition test register sanity check success!"; + //printf("acq lib REG SANITY CHECK SUCCESS\n"); //std::cout << "Acquisition test register sanity check success!" << std::endl; } fpga_acquisition::reset_acquisition(); @@ -150,18 +162,21 @@ fpga_acquisition::fpga_acquisition(std::string device_name, fpga_acquisition::~fpga_acquisition() { + //printf("acq lib destructor called\n"); close_device(); } bool fpga_acquisition::free() { + //printf("acq lib free called\n"); return true; } uint32_t fpga_acquisition::fpga_acquisition_test_register(uint32_t writeval) { + //printf("acq lib test register called\n"); uint32_t readval; // write value to test register d_map_base[15] = writeval; @@ -177,7 +192,7 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local uint32_t local_code; uint32_t k, tmp, tmp2; uint32_t fft_data; - + //printf("acq lib fpga_configure_acquisition_local_code_called\n"); // clear memory address counter //d_map_base[6] = LOCAL_CODE_CLEAR_MEM; d_map_base[9] = LOCAL_CODE_CLEAR_MEM; @@ -208,13 +223,14 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local void fpga_acquisition::run_acquisition(void) { + //printf("acq lib run_acqisition called\n"); // enable interrupts int32_t reenable = 1; write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); // launch the acquisition process - //printf("launchin acquisition ...\n"); + //printf("acq lib launchin acquisition ...\n"); d_map_base[8] = LAUNCH_ACQUISITION; // writing a 1 to reg 8 launches the acquisition process - + //printf("acq lib waiting for interrupt ...\n"); int32_t irq_count; ssize_t nb; // wait for interrupt @@ -230,6 +246,7 @@ void fpga_acquisition::run_acquisition(void) void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) { + //printf("acq lib set_doppler_sweep called\n"); float phase_step_rad_real; float phase_step_rad_int_temp; int32_t phase_step_rad_int; @@ -276,6 +293,7 @@ void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) void fpga_acquisition::set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t doppler_index) { + //printf("acq lib set_doppler_sweep_debug called\n"); float phase_step_rad_real; float phase_step_rad_int_temp; int32_t phase_step_rad_int; @@ -323,6 +341,7 @@ void fpga_acquisition::set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t dop void fpga_acquisition::configure_acquisition() { + //printf("acq lib configure acquisition called\n"); //printf("AAA d_select_queue = %d\n", d_select_queue); d_map_base[0] = d_select_queue; //printf("AAA writing d_vector_length = %d to d map base 1\n ", d_vector_length); @@ -338,6 +357,7 @@ void fpga_acquisition::configure_acquisition() void fpga_acquisition::set_phase_step(uint32_t doppler_index) { + //printf("acq lib set phase step called\n"); float phase_step_rad_real; float phase_step_rad_int_temp; int32_t phase_step_rad_int; @@ -367,6 +387,7 @@ void fpga_acquisition::set_phase_step(uint32_t doppler_index) void fpga_acquisition::read_acquisition_results(uint32_t *max_index, float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) { + //printf("acq lib read_acquisition_results_called\n"); uint64_t initial_sample_tmp = 0; uint32_t readval = 0; @@ -396,18 +417,21 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, void fpga_acquisition::block_samples() { + //printf("acq lib block samples called\n"); d_map_base[14] = 1; // block the samples } void fpga_acquisition::unblock_samples() { + //printf("acq lib unblock samples called\n"); d_map_base[14] = 0; // unblock the samples } void fpga_acquisition::close_device() { + //printf("acq lib close device called\n"); uint32_t *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { @@ -419,5 +443,6 @@ void fpga_acquisition::close_device() void fpga_acquisition::reset_acquisition(void) { + //printf("acq lib reset acquisition called\n"); d_map_base[8] = RESET_ACQUISITION; // writing a 2 to d_map_base[8] resets the multicorrelator } diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index c23e6b5d5..c3528d277 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -74,6 +74,7 @@ public: */ void set_doppler_max(uint32_t doppler_max) { + //printf("acq lib set doppler max called\n"); d_doppler_max = doppler_max; } @@ -83,6 +84,7 @@ public: */ void set_doppler_step(uint32_t doppler_step) { + //printf("acq lib set doppler step called\n"); d_doppler_step = doppler_step; } diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index e34103561..316d73e9f 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -106,7 +106,7 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface* configura } // turn switch to A/D position - std::string default_device_name = "/dev/uio13"; + std::string default_device_name = "/dev/uio1"; std::string device_name = configuration->property(role + ".devicename", default_device_name); int switch_position = configuration->property(role + ".switch_position", 0); switch_fpga = std::make_shared(device_name); diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index 1f72b6884..b00e3d3d8 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -581,7 +581,7 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking() { std::cout << "Writing .mat files ..."; } - save_matfile(); +// save_matfile(); if (d_channel == 0) { std::cout << " done." << std::endl; diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index d4b97974e..ac42058be 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -589,7 +589,7 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { std::cout << "Writing .mat files ..."; } - save_matfile(); + // save_matfile(); if (d_channel == 0) { std::cout << " done." << std::endl; @@ -1251,8 +1251,10 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un //printf("333333 current_synchro_data.Acq_delay_samples = %f\n", current_synchro_data.Acq_delay_samples); //printf("333333 d_correlation_length_samples = %d\n", d_correlation_length_samples); uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples) / d_correlation_length_samples); + //uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples*2 - current_synchro_data.Acq_delay_samples*2) / d_correlation_length_samples); //printf("333333 num_frames = %d\n", num_frames); uint64_t absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames * d_correlation_length_samples); + //uint64_t absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples*2 + current_synchro_data.Acq_samplestamp_samples*2 + num_frames * d_correlation_length_samples); //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); multicorrelator_fpga->set_initial_sample(absolute_samples_offset); d_absolute_samples_offset = absolute_samples_offset; diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index 6df8889be..194fb2b9d 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -149,7 +149,7 @@ DECLARE_string(log_dir); #include "unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc" #include "unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc" #include "unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc" -#if ENABLE_FPGA +#if FPGA_BLOCKS_TEST #include "unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc" #endif #include "unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc" diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 1c35cc64e..2ec7e751d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -45,12 +45,21 @@ #include "GPS_L1_CA.h" #include "gnss_block_factory.h" #include "tracking_interface.h" +//------------- remove when transition to FPGA is complete ----- #include "gps_l2_m_pcps_acquisition.h" #include "gps_l1_ca_pcps_acquisition.h" +//-------------------------------------------------------------- +#include "gps_l1_ca_pcps_acquisition_fpga.h" +#include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" +#include "galileo_e5a_pcps_acquisition_fpga.h" +#include "gps_l5i_pcps_acquisition_fpga.h" + +//------------- remove when transition to FPGA is complete ----- #include "gps_l1_ca_pcps_acquisition_fine_doppler.h" #include "galileo_e5a_noncoherent_iq_acquisition_caf.h" #include "galileo_e5a_pcps_acquisition.h" #include "gps_l5i_pcps_acquisition.h" +//-------------------------------------------------------------- #include "in_memory_configuration.h" #include "tracking_true_obs_reader.h" #include "tracking_dump_reader.h" @@ -59,36 +68,45 @@ #include "test_flags.h" #include "tracking_tests_flags.h" +// threads +#include // for pthread stuff +#include // for open, O_RDWR, O_SYNC +#include // for cout, endl +#include // for mmap + +#define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples +#define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes +#define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) // ######## GNURADIO ACQUISITION BLOCK MESSAGE RECEVER ######### -class Acquisition_msg_rx; +class Acquisition_msg_rx_Fpga; -typedef boost::shared_ptr Acquisition_msg_rx_sptr; +typedef boost::shared_ptr Acquisition_msg_rx_Fpga_sptr; -Acquisition_msg_rx_sptr Acquisition_msg_rx_make(); +Acquisition_msg_rx_Fpga_sptr Acquisition_msg_rx_Fpga_make(); -class Acquisition_msg_rx : public gr::block +class Acquisition_msg_rx_Fpga : public gr::block { private: - friend Acquisition_msg_rx_sptr Acquisition_msg_rx_make(); + friend Acquisition_msg_rx_Fpga_sptr Acquisition_msg_rx_Fpga_make(); void msg_handler_events(pmt::pmt_t msg); - Acquisition_msg_rx(); + Acquisition_msg_rx_Fpga(); public: int rx_message; gr::top_block_sptr top_block; - ~Acquisition_msg_rx(); //!< Default destructor + ~Acquisition_msg_rx_Fpga(); //!< Default destructor }; -Acquisition_msg_rx_sptr Acquisition_msg_rx_make() +Acquisition_msg_rx_Fpga_sptr Acquisition_msg_rx_Fpga_make() { - return Acquisition_msg_rx_sptr(new Acquisition_msg_rx()); + return Acquisition_msg_rx_Fpga_sptr(new Acquisition_msg_rx_Fpga()); } -void Acquisition_msg_rx::msg_handler_events(pmt::pmt_t msg) +void Acquisition_msg_rx_Fpga::msg_handler_events(pmt::pmt_t msg) { try { @@ -104,15 +122,15 @@ void Acquisition_msg_rx::msg_handler_events(pmt::pmt_t msg) } -Acquisition_msg_rx::Acquisition_msg_rx() : gr::block("Acquisition_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +Acquisition_msg_rx_Fpga::Acquisition_msg_rx_Fpga() : gr::block("Acquisition_msg_rx_Fpga", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) { this->message_port_register_in(pmt::mp("events")); - this->set_msg_handler(pmt::mp("events"), boost::bind(&Acquisition_msg_rx::msg_handler_events, this, _1)); + this->set_msg_handler(pmt::mp("events"), boost::bind(&Acquisition_msg_rx_Fpga::msg_handler_events, this, _1)); rx_message = 0; } -Acquisition_msg_rx::~Acquisition_msg_rx() {} +Acquisition_msg_rx_Fpga::~Acquisition_msg_rx_Fpga() {} // ######## GNURADIO TRACKING BLOCK MESSAGE RECEVER ######### class TrackingPullInTestFpga_msg_rx; @@ -306,7 +324,10 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); std::string System_and_Signal; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) + + printf("¿¿¿¿¿¿¿¿¿ implementation = %s\n", implementation.c_str()); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { gnss_synchro.System = 'G'; std::string signal = "1C"; @@ -315,7 +336,7 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.early_late_space_chips", "0.5"); config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { gnss_synchro.System = 'E'; std::string signal = "1B"; @@ -327,7 +348,7 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); config->set_property("Tracking.track_pilot", "true"); } - else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) + else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking_Fpga") == 0) { gnss_synchro.System = 'G'; std::string signal = "2S"; @@ -336,7 +357,7 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.early_late_space_chips", "0.5"); config->set_property("Tracking.track_pilot", "false"); } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking") == 0 or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) { gnss_synchro.System = 'E'; std::string signal = "5X"; @@ -350,7 +371,7 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.track_pilot", "false"); config->set_property("Tracking.order", "2"); } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking") == 0) + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { gnss_synchro.System = 'G'; std::string signal = "L5"; @@ -380,9 +401,197 @@ void TrackingPullInTestFpga::configure_receiver( std::cout << "*****************************************\n"; } +const size_t PAGE_SIZE = 0x10000; +const unsigned int TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; + +void setup_fpga_switch(void) +{ + //printf("starting switch function\n"); + int switch_device_descriptor; // driver descriptor + volatile unsigned *switch_map_base; // driver memory map + + if ((switch_device_descriptor = open("/dev/uio1", O_RDWR | O_SYNC)) == -1) + { + LOG(WARNING) << "Cannot open deviceio" << "/dev/uio1"; + } + switch_map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, switch_device_descriptor, 0)); + + if (switch_map_base == reinterpret_cast(-1)) + { + LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory"; + std::cout << "Could not map switch memory." << std::endl; + } + else + { + // std::cout << "Switch memory successfully mapped." << std::endl; + } + + // sanity check : check test register + unsigned writeval = TEST_REGISTER_TRACK_WRITEVAL; + unsigned readval; + // write value to test register + switch_map_base[3] = writeval; + // read value from test register + readval = switch_map_base[3]; + + if (writeval != readval) + { + LOG(WARNING) << "Test register sanity check failed"; + } + else + { + LOG(INFO) << "Test register sanity check success !"; + } + + switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues + //printf("switch set to DMA\n"); +} + + +static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + +unsigned int send_samples_start = 0; + +int8_t input_samples[MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE]; // re - im +int8_t input_samples_dma[MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE*NUM_QUEUES]; + +struct DMA_handler_args { + std::string file; + unsigned int nsamples_tx; +}; + +void *handler_DMA(void *arguments) +{ + // DMA process that configures the DMA to send the samples to the acquisition engine + int tx_fd; // DMA descriptor + FILE *rx_signal_file_id; // Input file descriptor + bool file_completed = false; // flag to indicate if the file is completed + unsigned int nsamples_block; // number of samples to send in the next DMA block of samples + unsigned int nread_elements; // number of elements effectively read from the input file + unsigned int nsamples = 0; // number of complex samples effectively transferred + unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA + unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes + + unsigned int testdummy; + + struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; + + unsigned int nsamples_tx = args->nsamples_tx; + //std::string *file = (std::string *)file_void_ptr; // input filename + std::string file = args->file; // input filename + + //unsigned int *nsamples_tx = (unsigned int *)nsamples_tx_void_ptr; // number of samples to transfer in total + // debug + //printf("DMA %s\n", file.c_str()); + //printf("DMA Starting DMA child process\n"); + //printf("DMA nsamples to send = %d\n", nsamples_tx); + + + + // open DMA device + tx_fd = open("/dev/loop_tx", O_WRONLY); + if ( tx_fd < 0 ) + { + printf("DMA can't open loop device\n"); + exit(1); + } + else + { +// printf("DMA loop device opened successfully\n"); + } + + // open input file + rx_signal_file_id = fopen(file.c_str(), "rb"); + if (rx_signal_file_id < 0) + { + printf("DMA can't open input file\n"); + exit(1); + } + else + { +// printf("DMA open file opened successfully\n"); + } + + while(send_samples_start == 0); // wait until acquisition starts + + //printf("DMA going to sleep to give time\n"); + usleep(50000); // wait 1 second to give time to the main thread to start the acquisition module + +// printf("DMA child process: starting sample transfer\n"); + // transfer samples + + + while (file_completed == false) + { + + if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + { + nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + } + else + { + nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent + file_completed = true; + } + + nread_elements = fread(input_samples, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + + if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) + { + printf("could not read the desired number of samples from the input file\n"); + file_completed = true; + } + + nsamples+=(nread_elements/COMPLEX_SAMPLE_SIZE); + + if (nread_elements > 0) + { + // for the 32-BIT DMA + dma_index = 0; + for (index0 = 0;index0 < (nread_elements);index0+=COMPLEX_SAMPLE_SIZE) + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = 0; + input_samples_dma[dma_index+1] = 0; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index+2] = input_samples[index0]; + input_samples_dma[dma_index+3] = input_samples[index0+1]; + + dma_index += 4; + } + + //send_tracking_gps_input_samples(tx_fd, input_samples_dma, nread_elements*2); // for the 32-bit DMA + //assert( num_bytes_to_transfer == write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES) ); + testdummy = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); + //testdummy = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); + //printf("testdummy = %d nread_elements*NUM_QUEUES = %d\n", testdummy, nread_elements*NUM_QUEUES); + } + //printf("DMA nsamples transferred = %d...\n", nsamples); + +// if (nread_elements != MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE) +// { +// file_completed = true; +// } + } + + +// printf("number of samples transferred = %d\n",nsamples); + close(tx_fd); + fclose(rx_signal_file_id); + + //printf("Ending the DMA child process\n"); + return NULL; + +} + bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { + // pointer to the DMA thread that sends the samples to the acquisition engine + pthread_t thread_DMA; + + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); @@ -398,11 +607,15 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); config->set_property("Acquisition.use_CFAR_algorithm", "false"); - std::shared_ptr acquisition; + //std::shared_ptr acquisition; + std::shared_ptr acquisition_Fpga; std::string System_and_Signal; + + //printf("¿¿¿¿¿¿¿¿¿2 implementation = %s\n", implementation.c_str()); + //create the correspondign acquisition block according to the desired tracking signal - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; @@ -412,9 +625,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) System_and_Signal = "GPS L1 CA"; config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking") == 0) + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; @@ -423,9 +637,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E1B"; config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); } - else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) + else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking_Fpga") == 0) { tmp_gnss_synchro.System = 'G'; std::string signal = "2S"; @@ -434,25 +649,26 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L2CM"; config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) - { - tmp_gnss_synchro.System = 'E'; - std::string signal = "5X"; - const char* str = signal.c_str(); // get a C style null terminated string - std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null - tmp_gnss_synchro.PRN = SV_ID; - System_and_Signal = "Galileo E5a"; - config->set_property("Acquisition_5X.coherent_integration_time_ms", "1"); - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - config->set_property("Acquisition.CAF_window_hz", "0"); // **Only for E5a** Resolves doppler ambiguity averaging the specified BW in the winner code delay. If set to 0 CAF filter is desactivated. Recommended value 3000 Hz - config->set_property("Acquisition.Zero_padding", "0"); //**Only for E5a** Avoids power loss and doppler ambiguity in bit transitions by correlating one code with twice the input data length, ensuring that at least one full code is present without transitions. If set to 1 it is ON, if set to 0 it is OFF. - config->set_property("Acquisition.bit_transition_flag", "false"); - acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); } +// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) +// { +// tmp_gnss_synchro.System = 'E'; +// std::string signal = "5X"; +// const char* str = signal.c_str(); // get a C style null terminated string +// std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null +// tmp_gnss_synchro.PRN = SV_ID; +// System_and_Signal = "Galileo E5a"; +// config->set_property("Acquisition_5X.coherent_integration_time_ms", "1"); +// config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); +// config->set_property("Acquisition.CAF_window_hz", "0"); // **Only for E5a** Resolves doppler ambiguity averaging the specified BW in the winner code delay. If set to 0 CAF filter is desactivated. Recommended value 3000 Hz +// config->set_property("Acquisition.Zero_padding", "0"); //**Only for E5a** Avoids power loss and doppler ambiguity in bit transitions by correlating one code with twice the input data length, ensuring that at least one full code is present without transitions. If set to 1 it is ON, if set to 0 it is OFF. +// config->set_property("Acquisition.bit_transition_flag", "false"); +// //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); +// +// } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking") == 0) + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; @@ -461,9 +677,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E5a"; config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking") == 0) + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { tmp_gnss_synchro.System = 'G'; std::string signal = "L5"; @@ -472,7 +689,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L5I"; config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); } else { @@ -480,32 +698,54 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) throw(std::exception()); } - acquisition->set_gnss_synchro(&tmp_gnss_synchro); - acquisition->set_channel(0); - acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition->init(); - acquisition->set_local_code(); - acquisition->set_state(1); // Ensure that acquisition starts at the first sample - acquisition->connect(top_block); + //acquisition->set_gnss_synchro(&tmp_gnss_synchro); + //acquisition->set_channel(0); + //acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + //acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + //acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + //acquisition->init(); + //acquisition->set_local_code(); + //acquisition->set_state(1); // Ensure that acquisition starts at the first sample + //acquisition->connect(top_block); - gr::blocks::file_source::sptr file_source; + //acquisition_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_Fpga->set_channel(0); + acquisition_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + acquisition_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + //acquisition_Fpga->init(); + //acquisition_Fpga->set_local_code(); + // PROBABLY WE DONN'T NEED THIS acquisition_Fpga->set_state(1); // Ensure that acquisition starts at the first sample + acquisition_Fpga->connect(top_block); + + //gr::blocks::file_source::sptr file_source; std::string file = FLAGS_signal_file; - const char* file_name = file.c_str(); - file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample - gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + + struct DMA_handler_args args; + + args.file = file; + args.nsamples_tx = 50000000; // number of samples to transfer + + + + + + + const char* file_name = file.c_str(); + + //file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); //gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); - top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + //top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); //top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); - boost::shared_ptr msg_rx; + boost::shared_ptr msg_rx; try { - msg_rx = Acquisition_msg_rx_make(); + msg_rx = Acquisition_msg_rx_Fpga_make(); } catch (const std::exception& e) { @@ -514,7 +754,9 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } msg_rx->top_block = top_block; - top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + //top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + + top_block->msg_connect(acquisition_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); // 5. Run the flowgraph // Get visible GPS satellites (positive acquisitions with Doppler measurements) @@ -543,16 +785,52 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) MAX_PRN_IDX = 33; } + //printf("NOW CALLING SWITCH\n"); + setup_fpga_switch(); + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) { - tmp_gnss_synchro.PRN = PRN; - acquisition->set_gnss_synchro(&tmp_gnss_synchro); - acquisition->init(); - acquisition->set_local_code(); - acquisition->reset(); - acquisition->set_state(1); + //printf("PRN %d\n", PRN); + tmp_gnss_synchro.PRN = PRN; +// acquisition->set_gnss_synchro(&tmp_gnss_synchro); +// acquisition->init(); +// acquisition->set_local_code(); +// acquisition->reset(); +// acquisition->set_state(1); + +// printf("SSSSSSSSSSSSSSSSSSSSTEPA\n"); + acquisition_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_Fpga->init(); + acquisition_Fpga->set_local_code(); +// printf("SSSSSSSSSSSSSSSSSSSSTEPB\n"); + + // create DMA child process + //if (pthread_create(&thread_DMA, NULL, handler_DMA, &file, nsamples_tx) < 0) + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } +// else +// { +// printf("DMA child process created successfully\n"); +// } + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + msg_rx->rx_message = 0; - top_block->run(); + top_block->start(); + +// printf("main thread: starting acquisition\n"); + acquisition_Fpga->reset(); //NOT YET +// printf("zzzzzzzzzzzzzzzzzzzzz\n"); + // PROBABLY WE DON'T NEED THIS acquisition_Fpga->set_state(1); + //msg_rx->rx_message = 0; +// printf("aaaaaaaaaaaaaaaaaaaaaaaa\n"); + //top_block->run(); +// printf("bbbbbbbbbbbbbbbbbbbbbbbb\n"); if (start_msg == true) { std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; @@ -560,12 +838,29 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::cout << "["; start_msg = false; } + + + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); +// printf("DMA child process terminated successfully\n"); + + + //printf("enter number whatever\n"); + //unsigned int kk; + //scanf("%d\n", &kk); + //printf("ok number obtained \n"); + + send_samples_start = 0; + while (msg_rx->rx_message == 0) { + //printf("message is zero\n"); usleep(100000); } if (msg_rx->rx_message == 1) { + //printf("message is something\n"); std::cout << " " << PRN << " "; doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); @@ -573,10 +868,11 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else { + //printf("message is something not contemplated\n"); std::cout << " . "; } top_block->stop(); - file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample std::cout.flush(); } std::cout << "]" << std::endl; @@ -598,6 +894,14 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) TEST_F(TrackingPullInTestFpga, ValidationOfResults) { + + // pointer to the DMA thread that sends the samples to the acquisition engine + pthread_t thread_DMA; + + struct DMA_handler_args args; + + + //************************************************* //***** STEP 1: Prepare the parameters sweep ****** //************************************************* @@ -624,10 +928,12 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) std::vector generator_CN0_values; if (FLAGS_enable_external_signal_file) { + printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX READ FROM FILE\n"); generator_CN0_values.push_back(999); // an external input signal capture is selected, no CN0 information available } else { + printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GENERATE INPUT SIGNAL\n"); if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop) { generator_CN0_values.push_back(FLAGS_CN0_dBHz_start); @@ -644,6 +950,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) // use generator or use an external capture file if (FLAGS_enable_external_signal_file) { + printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX READ FROM FILE 2\n"); //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters ASSERT_EQ(acquire_signal(FLAGS_test_satellite_PRN), true); bool found_satellite = doppler_measurements_map.find(FLAGS_test_satellite_PRN) != doppler_measurements_map.end(); @@ -652,6 +959,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } else { + printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GENERATE INPUT SIGNAL 2\n"); for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) { // Configure the signal generator @@ -682,6 +990,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) tracking_true_obs_reader true_obs_data; if (!FLAGS_enable_external_signal_file) { + printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GENERATE INPUT SIGNAL 3\n"); test_satellite_PRN = FLAGS_test_satellite_PRN; std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); true_obs_file.append(std::to_string(test_satellite_PRN)); @@ -701,6 +1010,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } else { + printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX READ FROM FILE 3\n"); true_acq_doppler_hz = doppler_measurements_map.find(FLAGS_test_satellite_PRN)->second; true_acq_delay_samples = code_delay_measurements_map.find(FLAGS_test_satellite_PRN)->second; acq_samplestamp_samples = 0; @@ -747,30 +1057,50 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) ASSERT_NO_THROW({ if (!FLAGS_enable_external_signal_file) { + printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GENERATE INPUT SIGNAL 4\n"); file = "./" + filename_raw_data + std::to_string(current_cn0_idx); } else { + printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX READ FROM FILE 4\n"); file = FLAGS_signal_file; } const char* file_name = file.c_str(); - gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + //gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); - gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); - top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - top_block->connect(gr_interleaved_char_to_complex, 0, head_samples, 0); - top_block->connect(head_samples, 0, tracking->get_left_block(), 0); + //gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); + //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + //top_block->connect(gr_interleaved_char_to_complex, 0, head_samples, 0); + //top_block->connect(head_samples, 0, tracking->get_left_block(), 0); top_block->connect(tracking->get_right_block(), 0, sink, 0); top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks of tracking test."; //******************************************************************** //***** STEP 5: Perform the signal tracking and read the results ***** //******************************************************************** + + args.file = file; + args.nsamples_tx = 500000000; // number of samples to transfer + + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + else + { + printf("DMA child process created successfully\n"); + } + std::cout << "--- START TRACKING WITH PULL-IN ERROR: " << acq_doppler_error_hz_values.at(current_acq_doppler_error_idx) << " [Hz] and " << acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) << " [Chips] ---" << std::endl; + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + tracking->start_tracking(); std::chrono::time_point start, end; EXPECT_NO_THROW({ @@ -782,9 +1112,14 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) std::chrono::duration elapsed_seconds = end - start; std::cout << "Signal tracking completed in " << elapsed_seconds.count() << " seconds" << std::endl; - pull_in_results_v.push_back(msg_rx->rx_message != 3); //save last asynchronous tracking message in order to detect a loss of lock + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + printf("DMA child process terminated successfully\n"); + + send_samples_start = 0; + //******************************** //***** STEP 7: Plot results ***** //******************************** @@ -973,46 +1308,45 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) std::vector pull_in_result_mesh; pull_in_result_mesh = pull_in_results_v_v.at(current_cn0_idx); //plot grid - Gnuplot g4("points palette pointsize 2 pointtype 7"); + if (FLAGS_show_plots) { - g4.showonscreen(); // window output - } - else - { - g4.disablescreen(); - } - g4.cmd("set palette defined ( 0 \"black\", 1 \"green\" )"); - g4.cmd("set key off"); - g4.cmd("set view map"); - std::string title; - if (!FLAGS_enable_external_signal_file) - { - title = std::string("Tracking Pull-in result grid at CN0:" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + " [dB-Hz], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz]."); - } - else - { - title = std::string("Tracking Pull-in result grid, PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + Gnuplot g4("points palette pointsize 2 pointtype 7"); + g4.showonscreen(); // window output + g4.cmd("set palette defined ( 0 \"black\", 1 \"green\" )"); + g4.cmd("set key off"); + g4.cmd("set view map"); + std::string title; + if (!FLAGS_enable_external_signal_file) + { + title = std::string("Tracking Pull-in result grid at CN0:" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + " [dB-Hz], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz]."); + } + else + { + title = std::string("Tracking Pull-in result grid, PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + + g4.set_title(title); + g4.set_grid(); + g4.set_xlabel("Acquisition Doppler error [Hz]"); + g4.set_ylabel("Acquisition Code Delay error [Chips]"); + g4.cmd("set cbrange[0:1]"); + g4.plot_xyz(doppler_error_mesh, + code_delay_error_mesh, + pull_in_result_mesh); + g4.set_legend(); + if (!FLAGS_enable_external_signal_file) + { + g4.savetops("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx))))); + g4.savetopdf("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))), 12); + } + else + { + g4.savetops("trk_pull_in_grid_external_file"); + g4.savetopdf("trk_pull_in_grid_external_file", 12); + } + } - g4.set_title(title); - g4.set_grid(); - g4.set_xlabel("Acquisition Doppler error [Hz]"); - g4.set_ylabel("Acquisition Code Delay error [Chips]"); - g4.cmd("set cbrange[0:1]"); - g4.plot_xyz(doppler_error_mesh, - code_delay_error_mesh, - pull_in_result_mesh); - g4.set_legend(); - if (!FLAGS_enable_external_signal_file) - { - g4.savetops("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx))))); - g4.savetopdf("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))), 12); - } - else - { - g4.savetops("trk_pull_in_grid_external_file"); - g4.savetopdf("trk_pull_in_grid_external_file", 12); - } } } From 57c358d1b124decdee69086170bd8cb6d06efe16 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 29 Aug 2018 18:23:34 +0200 Subject: [PATCH 03/53] removed unnecessary printed messages --- .../acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 326a66d7c..5b79bbe53 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -64,10 +64,10 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter - printf("fs_in pre downsampling = %ld\n", fs_in); + //printf("fs_in pre downsampling = %ld\n", fs_in); fs_in = fs_in/downsampling_factor; - printf("fs_in post downsampling = %ld\n", fs_in); + //printf("fs_in post downsampling = %ld\n", fs_in); //printf("####### DEBUG Acq: fs_in = %d\n", fs_in); acq_parameters.fs_in = fs_in; From 5b9b63cc77c61a5cbfb8d375825164800ce6bc96 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 12 Sep 2018 16:02:23 +0200 Subject: [PATCH 04/53] implemented tracking pull-in tests for the FPGA solved a bug in which the SW was using the doppler shift index reported by the HW acquisition accelerator plus one, instead of using the doppler shift index as such. --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 18 + ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 15 + .../galileo_e5a_pcps_acquisition_fpga.cc | 18 + .../galileo_e5a_pcps_acquisition_fpga.h | 15 + .../gps_l1_ca_pcps_acquisition_fpga.cc | 22 +- .../gps_l1_ca_pcps_acquisition_fpga.h | 15 + .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 20 + .../adapters/gps_l5i_pcps_acquisition_fpga.h | 15 + .../gnuradio_blocks/pcps_acquisition_fpga.cc | 39 +- .../gnuradio_blocks/pcps_acquisition_fpga.h | 26 +- .../acquisition/libs/fpga_acquisition.cc | 153 ++- .../acquisition/libs/fpga_acquisition.h | 16 +- .../galileo_e1_dll_pll_veml_tracking_fpga.cc | 2 +- .../galileo_e5a_dll_pll_tracking_fpga.cc | 2 +- .../gps_l1_ca_dll_pll_tracking_fpga.cc | 2 +- .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 2 +- .../dll_pll_veml_tracking_fpga.cc | 32 +- .../tracking/libs/fpga_multicorrelator.cc | 2 +- .../tracking/tracking_pull-in_test_fpga.cc | 904 ++++++++++++------ 19 files changed, 940 insertions(+), 378 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 7157899cc..c010cc19b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -472,6 +472,24 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::set_state(int state) // return threshold; //} +// this function is only used for the unit tests +void GalileoE1PcpsAmbiguousAcquisitionFpga::set_single_doppler_flag(unsigned int single_doppler_flag) +{ + acquisition_fpga_->set_single_doppler_flag(single_doppler_flag); +} +// this function is only used for the unit tests +void GalileoE1PcpsAmbiguousAcquisitionFpga::read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) +{ + acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, + initial_sample, power_sum, doppler_index); +} + +// this function is only used for the unit tests +void GalileoE1PcpsAmbiguousAcquisitionFpga::reset_acquisition(void) +{ + acquisition_fpga_->reset_acquisition(); +} void GalileoE1PcpsAmbiguousAcquisitionFpga::connect(gr::top_block_sptr top_block) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 6c975e30e..f142c74f6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -136,6 +136,21 @@ public: */ void set_state(int state) override; + /*! + * \brief This function is only used in the unit tests + */ + void set_single_doppler_flag(unsigned int single_doppler_flag); + /*! + * \brief This function is only used in the unit tests + */ + void read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + + /*! + * \brief This function is only used in the unit tests + */ + void reset_acquisition(void); + private: ConfigurationInterface* configuration_; //pcps_acquisition_sptr acquisition_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 2901081ac..4c75d34d9 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -356,6 +356,24 @@ void GalileoE5aPcpsAcquisitionFpga::set_state(int state) acquisition_fpga_->set_state(state); } +// this function is only used for the unit tests +void GalileoE5aPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_doppler_flag) +{ + acquisition_fpga_->set_single_doppler_flag(single_doppler_flag); +} +// this function is only used for the unit tests +void GalileoE5aPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) +{ + acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, + initial_sample, power_sum, doppler_index); +} + +// this function is only used for the unit tests +void GalileoE5aPcpsAcquisitionFpga::reset_acquisition(void) +{ + acquisition_fpga_->reset_acquisition(); +} void GalileoE5aPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index 1bdca10cc..2d1df0ca6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -124,6 +124,21 @@ public: */ void set_state(int state) override; + /*! + * \brief This function is only used in the unit tests + */ + void set_single_doppler_flag(unsigned int single_doppler_flag); + /*! + * \brief This function is only used in the unit tests + */ + void read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + + /*! + * \brief This function is only used in the unit tests + */ + void reset_acquisition(void); + private: //float calculate_threshold(float pfa); diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 5b79bbe53..84ecac49a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -71,7 +71,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( //printf("####### DEBUG Acq: fs_in = %d\n", fs_in); acq_parameters.fs_in = fs_in; - acq_parameters.samples_per_code = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD * static_cast(acq_parameters.fs_in))); + //acq_parameters.samples_per_code = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD * static_cast(acq_parameters.fs_in))); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; @@ -258,6 +258,26 @@ void GpsL1CaPcpsAcquisitionFpga::set_state(int state) acquisition_fpga_->set_state(state); } + +// this function is only used for the unit tests +void GpsL1CaPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_doppler_flag) +{ + acquisition_fpga_->set_single_doppler_flag(single_doppler_flag); +} +// this function is only used for the unit tests +void GpsL1CaPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) +{ + acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, + initial_sample, power_sum, doppler_index); +} + +// this function is only used for the unit tests +void GpsL1CaPcpsAcquisitionFpga::reset_acquisition(void) +{ + acquisition_fpga_->reset_acquisition(); +} + void GpsL1CaPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { // nothing to connect diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index 7e74f70e9..4b0d3da9b 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -134,6 +134,21 @@ public: */ void set_state(int state) override; + /*! + * \brief This function is only used in the unit tests + */ + void set_single_doppler_flag(unsigned int single_doppler_flag); + /*! + * \brief This function is only used in the unit tests + */ + void read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + + /*! + * \brief This function is only used in the unit tests + */ + void reset_acquisition(void); + private: ConfigurationInterface* configuration_; pcps_acquisition_fpga_sptr acquisition_fpga_; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 57e986d66..9e9691745 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -323,6 +323,26 @@ void GpsL5iPcpsAcquisitionFpga::set_state(int state) //} +// this function is only used for the unit tests +void GpsL5iPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_doppler_flag) +{ + acquisition_fpga_->set_single_doppler_flag(single_doppler_flag); +} +// this function is only used for the unit tests +void GpsL5iPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) +{ + acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, + initial_sample, power_sum, doppler_index); +} + +// this function is only used for the unit tests +void GpsL5iPcpsAcquisitionFpga::reset_acquisition(void) +{ + acquisition_fpga_->reset_acquisition(); +} + + void GpsL5iPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { // if (item_type_.compare("gr_complex") == 0) diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index f7115aaa2..f52cc6799 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -134,6 +134,21 @@ public: */ void set_state(int state) override; + /*! + * \brief This function is only used in the unit tests + */ + void set_single_doppler_flag(unsigned int single_doppler_flag); + /*! + * \brief This function is only used in the unit tests + */ + void read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + + /*! + * \brief This function is only used in the unit tests + */ + void reset_acquisition(void); + private: ConfigurationInterface* configuration_; //pcps_acquisition_sptr acquisition_; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 902257c38..edb459669 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -130,8 +130,10 @@ void pcps_acquisition_fpga::init() d_gnss_synchro->Acq_samplestamp_samples = 0; d_mag = 0.0; d_input_power = 0.0; - d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))); - + d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))) + 1; + //printf("acq gnuradioblock doppler_max = %lu\n", (unsigned long) static_cast(acq_parameters.doppler_max)); + //printf("acq gnuradioblock doppler_step = %lu\n", (unsigned long) d_doppler_step); + //printf("acq gnuradioblock d_num_doppler_bins = %lu\n", (unsigned long) d_num_doppler_bins); acquisition_fpga->init(); // printf("acq init end\n"); } @@ -290,15 +292,15 @@ void pcps_acquisition_fpga::set_active(bool active) // debug - debug_d_max_absolute = magt; - debug_d_input_power_absolute = d_input_power; - debug_indext = indext; - debug_doppler_index = d_doppler_index; + //debug_d_max_absolute = magt; + //debug_d_input_power_absolute = d_input_power; + //debug_indext = indext; + //debug_doppler_index = d_doppler_index; // temp_d_input_power = d_input_power; d_input_power = (d_input_power - d_mag) / (d_fft_size - 1); - int32_t doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * d_doppler_index; + int32_t doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % (2*acq_parameters.samples_per_code))); @@ -382,3 +384,26 @@ int pcps_acquisition_fpga::general_work(int noutput_items __attribute__((unused) // the general work is not used with the acquisition that uses the FPGA return noutput_items; } + + +// this function is only used for the unit tests +void pcps_acquisition_fpga::set_single_doppler_flag(unsigned int single_doppler_flag) +{ + acquisition_fpga->set_single_doppler_flag(single_doppler_flag); +} + +// this function is only used for the unit tests +void pcps_acquisition_fpga::read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) +{ + acquisition_fpga->read_acquisition_results(max_index, max_magnitude, + initial_sample, power_sum, doppler_index); +} + +// this function is only used for the unit tests +void pcps_acquisition_fpga::reset_acquisition(void) +{ + acquisition_fpga->reset_acquisition(); +} + + diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index 4709cfb1f..45cce7339 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -119,14 +119,16 @@ private: std::shared_ptr acquisition_fpga; // debug - float debug_d_max_absolute; - float debug_d_input_power_absolute; - int32_t debug_indext; - int32_t debug_doppler_index; + //float debug_d_max_absolute; + //float debug_d_input_power_absolute; + //int32_t debug_indext; + //int32_t debug_doppler_index; float d_downsampling_factor; uint32_t d_select_queue_Fpga; + + public: ~pcps_acquisition_fpga(); @@ -228,6 +230,22 @@ public: int general_work(int noutput_items, gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items); + + /*! + * \brief This function is only used for the unit tests + */ + void set_single_doppler_flag(unsigned int single_doppler_flag); + + /*! + * \brief This funciton is only used for the unit tests + */ + void read_acquisition_results(uint32_t *max_index, + float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + + /*! + * \brief This funciton is only used for the unit tests + */ + void reset_acquisition(void); }; #endif /* GNSS_SDR_PCPS_ACQUISITION_FPGA_H_*/ diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index dad09488c..ca228cc3d 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -156,7 +156,12 @@ fpga_acquisition::fpga_acquisition(std::string device_name, //std::cout << "Acquisition test register sanity check success!" << std::endl; } fpga_acquisition::reset_acquisition(); + + // flag used for testing purposes + d_single_doppler_flag = 0; + DLOG(INFO) << "Acquisition FPGA class created"; + } @@ -246,51 +251,102 @@ void fpga_acquisition::run_acquisition(void) void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) { - //printf("acq lib set_doppler_sweep called\n"); - float phase_step_rad_real; - float phase_step_rad_int_temp; - int32_t phase_step_rad_int; - //int32_t doppler = static_cast(-d_doppler_max) + d_doppler_step * doppler_index; - int32_t doppler = static_cast(-d_doppler_max); - //float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); - float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing - // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) - // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) - // while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x) - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - // avoid saturation of the fixed point representation in the fpga - // (only the positive value can saturate due to the 2's complement representation) + if (d_single_doppler_flag == 0) + { + //printf("acq lib set_doppler_sweep called\n"); + float phase_step_rad_real; + float phase_step_rad_int_temp; + int32_t phase_step_rad_int; + //int32_t doppler = static_cast(-d_doppler_max) + d_doppler_step * doppler_index; + int32_t doppler = static_cast(-d_doppler_max); + //float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); + float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); + // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing + // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) + // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) + // while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x) + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); + // avoid saturation of the fixed point representation in the fpga + // (only the positive value can saturate due to the 2's complement representation) - //printf("AAA phase_step_rad_real for initial doppler = %f\n", phase_step_rad_real); - if (phase_step_rad_real >= 1.0) - { - phase_step_rad_real = MAX_PHASE_STEP_RAD; - } - //printf("AAA phase_step_rad_real for initial doppler after checking = %f\n", phase_step_rad_real); - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAA writing phase_step_rad_int for initial doppler = %d to d map base 3\n", phase_step_rad_int); - d_map_base[3] = phase_step_rad_int; + //printf("AAA phase_step_rad_real for initial doppler = %f\n", phase_step_rad_real); + if (phase_step_rad_real >= 1.0) + { + phase_step_rad_real = MAX_PHASE_STEP_RAD; + } + //printf("AAA phase_step_rad_real for initial doppler after checking = %f\n", phase_step_rad_real); + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + //printf("AAA writing phase_step_rad_int for initial doppler = %d to d map base 3\n", phase_step_rad_int); + d_map_base[3] = phase_step_rad_int; + + // repeat the calculation with the doppler step + doppler = static_cast(d_doppler_step); + phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); + //printf("AAA phase_step_rad_real for doppler step = %f\n", phase_step_rad_real); + if (phase_step_rad_real >= 1.0) + { + phase_step_rad_real = MAX_PHASE_STEP_RAD; + } + //printf("AAA phase_step_rad_real for doppler step after checking = %f\n", phase_step_rad_real); + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + //printf("AAA writing phase_step_rad_int for doppler step = %d to d map base 4\n", phase_step_rad_int); + d_map_base[4] = phase_step_rad_int; + //printf("AAA writing num sweeps to d map base 5 = %d\n", num_sweeps); + d_map_base[5] = num_sweeps; + } + else + { + //printf("acq lib set_doppler_sweep called\n"); + float phase_step_rad_real; + float phase_step_rad_int_temp; + int32_t phase_step_rad_int; + //int32_t doppler = static_cast(-d_doppler_max) + d_doppler_step * doppler_index; + int32_t doppler = static_cast(d_doppler_max); + //float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); + float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); + // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing + // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) + // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) + // while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x) + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); + // avoid saturation of the fixed point representation in the fpga + // (only the positive value can saturate due to the 2's complement representation) + + //printf("AAA phase_step_rad_real for initial doppler = %f\n", phase_step_rad_real); + if (phase_step_rad_real >= 1.0) + { + phase_step_rad_real = MAX_PHASE_STEP_RAD; + } + //printf("AAA phase_step_rad_real for initial doppler after checking = %f\n", phase_step_rad_real); + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + //printf("AAA writing phase_step_rad_int for initial doppler = %d to d map base 3\n", phase_step_rad_int); + d_map_base[3] = phase_step_rad_int; + + // repeat the calculation with the doppler step + doppler = 0; + phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); + //printf("AAA phase_step_rad_real for doppler step = %f\n", phase_step_rad_real); + if (phase_step_rad_real >= 1.0) + { + phase_step_rad_real = MAX_PHASE_STEP_RAD; + } + //printf("AAA phase_step_rad_real for doppler step after checking = %f\n", phase_step_rad_real); + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + //printf("AAA writing phase_step_rad_int for doppler step = %d to d map base 4\n", phase_step_rad_int); + d_map_base[4] = phase_step_rad_int; + //printf("AAA writing num sweeps to d map base 5 = %d\n", num_sweeps); + d_map_base[5] = 1; // 1 sweep + + } - // repeat the calculation with the doppler step - doppler = static_cast(d_doppler_step); - phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - //printf("AAA phase_step_rad_real for doppler step = %f\n", phase_step_rad_real); - if (phase_step_rad_real >= 1.0) - { - phase_step_rad_real = MAX_PHASE_STEP_RAD; - } - //printf("AAA phase_step_rad_real for doppler step after checking = %f\n", phase_step_rad_real); - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAA writing phase_step_rad_int for doppler step = %d to d map base 4\n", phase_step_rad_int); - d_map_base[4] = phase_step_rad_int; - //printf("AAA writing num sweeps to d map base 5 = %d\n", num_sweeps); - d_map_base[5] = num_sweeps; } - +/* void fpga_acquisition::set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t doppler_index) { //printf("acq lib set_doppler_sweep_debug called\n"); @@ -337,7 +393,7 @@ void fpga_acquisition::set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t dop //printf("AAAh writing num sweeps to d map base 5 = %d\n", num_sweeps); d_map_base[5] = num_sweeps; } - +*/ void fpga_acquisition::configure_acquisition() { @@ -402,10 +458,10 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, *initial_sample = initial_sample_tmp; readval = d_map_base[6]; *max_magnitude = static_cast(readval); - //printf("read max_magnitude dmap 2 = %d\n", readval); + //printf("acq lib read max_magnitude dmap 2 = %d = %f\n", readval, *max_magnitude); readval = d_map_base[4]; *power_sum = static_cast(readval); - //printf("read power sum dmap 4 = %d\n", readval); + //printf("acq lib read power sum dmap 4 = %d = %f\n", readval, *power_sum); readval = d_map_base[5]; // read doppler index *doppler_index = readval; //printf("read doppler_index dmap 5 = %d\n", readval); @@ -446,3 +502,10 @@ void fpga_acquisition::reset_acquisition(void) //printf("acq lib reset acquisition called\n"); d_map_base[8] = RESET_ACQUISITION; // writing a 2 to d_map_base[8] resets the multicorrelator } + +// this function is only used for the unit tests +void fpga_acquisition::set_single_doppler_flag(unsigned int single_doppler_flag) +{ + d_single_doppler_flag = single_doppler_flag; +} + diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index c3528d277..a5b0d29db 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -60,7 +60,7 @@ public: bool set_local_code(uint32_t PRN); bool free(); void set_doppler_sweep(uint32_t num_sweeps); - void set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t doppler_index); + //void set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t doppler_index); void run_acquisition(void); void set_phase_step(uint32_t doppler_index); void read_acquisition_results(uint32_t *max_index, float *max_magnitude, @@ -88,6 +88,16 @@ public: d_doppler_step = doppler_step; } + /*! + * \brief this function is only used in the unit test + */ + void set_single_doppler_flag(unsigned int single_doppler_flag); + + /*! + * \brief this function is only used in the unit test + */ + void reset_acquisition(void); + private: int64_t d_fs_in; // data related to the hardware module and the driver @@ -105,8 +115,10 @@ private: uint32_t fpga_acquisition_test_register(uint32_t writeval); void fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]); void configure_acquisition(); - void reset_acquisition(void); void close_device(); + + // test parameters + unsigned int d_single_doppler_flag; // this flag is only used for testing purposes }; #endif /* GNSS_SDR_FPGA_ACQUISITION_H_ */ diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index cd4b2f84b..6a5955b2d 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -123,7 +123,7 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 1); + unsigned int device_base = configuration->property(role + ".device_base", 15); trk_param_fpga.device_base = device_base; //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 1); trk_param_fpga.multicorr_type = 1; // 0 -> 3 correlators, 1 -> 5 correlators diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index 8be397a02..469885378 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -123,7 +123,7 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 1); + unsigned int device_base = configuration->property(role + ".device_base", 27); trk_param_fpga.device_base = device_base; //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 1); trk_param_fpga.multicorr_type = 1; // 0 -> 3 correlators, 1 -> up to 5+1 correlators diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index 06d59e91f..2e7125d5d 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -127,7 +127,7 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 1); + unsigned int device_base = configuration->property(role + ".device_base", 3); trk_param_fpga.device_base = device_base; //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 0); trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc index 0df38771c..74e9f0566 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -123,7 +123,7 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 1); + unsigned int device_base = configuration->property(role + ".device_base", 27); trk_param_fpga.device_base = device_base; //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 0); trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index ac42058be..1d88e33ef 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -1218,6 +1218,7 @@ void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) int dll_pll_veml_tracking_fpga::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) { + // Block input data and block output stream pointers Gnss_Synchro **out = reinterpret_cast(&output_items[0]); @@ -1247,15 +1248,29 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un multicorrelator_fpga->lock_channel(); uint64_t counter_value = multicorrelator_fpga->read_sample_counter(); //printf("333333 counter_value = %llu\n", counter_value); - //printf("333333 current_synchro_data.Acq_samplestamp_samples = %d\n", current_synchro_data.Acq_samplestamp_samples); + //printf("333333 current_synchro_data.Acq_samplestamp_samples = %llu\n", current_synchro_data.Acq_samplestamp_samples); //printf("333333 current_synchro_data.Acq_delay_samples = %f\n", current_synchro_data.Acq_delay_samples); //printf("333333 d_correlation_length_samples = %d\n", d_correlation_length_samples); - uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples) / d_correlation_length_samples); - //uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples*2 - current_synchro_data.Acq_delay_samples*2) / d_correlation_length_samples); - //printf("333333 num_frames = %d\n", num_frames); - uint64_t absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames * d_correlation_length_samples); - //uint64_t absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples*2 + current_synchro_data.Acq_samplestamp_samples*2 + num_frames * d_correlation_length_samples); - //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); + + uint64_t absolute_samples_offset; + + if (counter_value > (current_synchro_data.Acq_samplestamp_samples + current_synchro_data.Acq_delay_samples)) + { + // normal operation + uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples) / d_correlation_length_samples); + //uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples*2 - current_synchro_data.Acq_delay_samples*2) / d_correlation_length_samples); + //printf("333333 num_frames = %d\n", num_frames); + absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames * d_correlation_length_samples); + //uint64_t absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples*2 + current_synchro_data.Acq_samplestamp_samples*2 + num_frames * d_correlation_length_samples); + //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); + } + else + { + // during the unit tests the counter value may be reset after the acquisition process. We have to take this into account + absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples); + //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); + } + multicorrelator_fpga->set_initial_sample(absolute_samples_offset); d_absolute_samples_offset = absolute_samples_offset; d_sample_counter = absolute_samples_offset; @@ -1268,6 +1283,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un case 2: { + //printf("trk state 2 counter value = %" PRIu64 "\n", multicorrelator_fpga->read_sample_counter()); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); @@ -1481,6 +1497,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un case 3: { + //printf("trk state 3 counter value = %" PRIu64 "\n", multicorrelator_fpga->read_sample_counter()); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); @@ -1541,6 +1558,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un case 4: // narrow tracking { + //printf("trk state 4 counter value = %" PRIu64 "\n", multicorrelator_fpga->read_sample_counter()); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 80123157d..3aa381048 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -320,7 +320,7 @@ bool fpga_multicorrelator_8sc::free() void fpga_multicorrelator_8sc::set_channel(uint32_t channel) { - //printf("www trk set channel\n"); + //printf("www trk set channel channel=%lu\n", (unsigned long) channel); char device_io_name[MAX_LENGTH_DEVICEIO_NAME]; // driver io name d_channel = channel; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 2ec7e751d..3680f91d2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -1,8 +1,9 @@ /*! - * \file tracking_test.cc - * \brief This class implements a tracking Pull-In test for GPS_L1_CA_DLL_PLL_Tracking - * implementation based on some input parameters. - * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \file tracking_pull-in_test_fpga.cc + * \brief This class implements a tracking Pull-In test for FPGA HW accelerator + * implementations based on some input parameters. + * \author Marc Majoral, 2018. majoralmarc(at)cttc.es + * Javier Arribas, 2018. jarribas(at)cttc.es * * * ------------------------------------------------------------------------- @@ -43,23 +44,15 @@ #include #include #include "GPS_L1_CA.h" +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "GPS_L5.h" #include "gnss_block_factory.h" #include "tracking_interface.h" -//------------- remove when transition to FPGA is complete ----- -#include "gps_l2_m_pcps_acquisition.h" -#include "gps_l1_ca_pcps_acquisition.h" -//-------------------------------------------------------------- #include "gps_l1_ca_pcps_acquisition_fpga.h" #include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" #include "galileo_e5a_pcps_acquisition_fpga.h" #include "gps_l5i_pcps_acquisition_fpga.h" - -//------------- remove when transition to FPGA is complete ----- -#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" -#include "galileo_e5a_noncoherent_iq_acquisition_caf.h" -#include "galileo_e5a_pcps_acquisition.h" -#include "gps_l5i_pcps_acquisition.h" -//-------------------------------------------------------------- #include "in_memory_configuration.h" #include "tracking_true_obs_reader.h" #include "tracking_dump_reader.h" @@ -77,6 +70,18 @@ #define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) +#define NSAMPLES_TRACKING 90000000 // number of samples during which we test the tracking module +#define NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module +#define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop + +// HW related options +bool doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW +bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if doppler_control_in_sw = 1), 0=> do not show it +bool skip_samples_already_used = 1; // if doppler_control_in_sw = 1 and skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops + // (exactly in the same way as the SW) + // if doppler_control_in_sw = 1 and skip_samples_already_used = 0 => the sampe samples are used for each PRN loop + // if doppler_control_in_sw = 0 => skip_samples_already_used is not applicable + // ######## GNURADIO ACQUISITION BLOCK MESSAGE RECEVER ######### class Acquisition_msg_rx_Fpga; @@ -85,7 +90,6 @@ typedef boost::shared_ptr Acquisition_msg_rx_Fpga_sptr; Acquisition_msg_rx_Fpga_sptr Acquisition_msg_rx_Fpga_make(); - class Acquisition_msg_rx_Fpga : public gr::block { private: @@ -99,13 +103,11 @@ public: ~Acquisition_msg_rx_Fpga(); //!< Default destructor }; - Acquisition_msg_rx_Fpga_sptr Acquisition_msg_rx_Fpga_make() { return Acquisition_msg_rx_Fpga_sptr(new Acquisition_msg_rx_Fpga()); } - void Acquisition_msg_rx_Fpga::msg_handler_events(pmt::pmt_t msg) { try @@ -121,7 +123,6 @@ void Acquisition_msg_rx_Fpga::msg_handler_events(pmt::pmt_t msg) } } - Acquisition_msg_rx_Fpga::Acquisition_msg_rx_Fpga() : gr::block("Acquisition_msg_rx_Fpga", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) { this->message_port_register_in(pmt::mp("events")); @@ -129,7 +130,6 @@ Acquisition_msg_rx_Fpga::Acquisition_msg_rx_Fpga() : gr::block("Acquisition_msg_ rx_message = 0; } - Acquisition_msg_rx_Fpga::~Acquisition_msg_rx_Fpga() {} // ######## GNURADIO TRACKING BLOCK MESSAGE RECEVER ######### class TrackingPullInTestFpga_msg_rx; @@ -150,20 +150,17 @@ public: ~TrackingPullInTestFpga_msg_rx(); //!< Default destructor }; - TrackingPullInTestFpga_msg_rx_sptr TrackingPullInTestFpga_msg_rx_make() { return TrackingPullInTestFpga_msg_rx_sptr(new TrackingPullInTestFpga_msg_rx()); } - void TrackingPullInTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { int64_t message = pmt::to_long(msg); rx_message = message; //3 -> loss of lock - //std::cout << "Received trk message: " << rx_message << std::endl; } catch (boost::bad_any_cast& e) { @@ -172,7 +169,6 @@ void TrackingPullInTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg) } } - TrackingPullInTestFpga_msg_rx::TrackingPullInTestFpga_msg_rx() : gr::block("TrackingPullInTestFpga_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) { this->message_port_register_in(pmt::mp("events")); @@ -185,7 +181,6 @@ TrackingPullInTestFpga_msg_rx::~TrackingPullInTestFpga_msg_rx() { } - // ########################################################### class TrackingPullInTestFpga : public ::testing::Test @@ -256,7 +251,6 @@ public: size_t item_size; }; - int TrackingPullInTestFpga::configure_generator(double CN0_dBHz, int file_idx) { // Configure signal generator @@ -278,7 +272,6 @@ int TrackingPullInTestFpga::configure_generator(double CN0_dBHz, int file_idx) return 0; } - int TrackingPullInTestFpga::generate_signal() { int child_status; @@ -301,7 +294,6 @@ int TrackingPullInTestFpga::generate_signal() return 0; } - void TrackingPullInTestFpga::configure_receiver( double PLL_wide_bw_hz, double DLL_wide_bw_hz, @@ -325,8 +317,6 @@ void TrackingPullInTestFpga::configure_receiver( std::string System_and_Signal; - printf("¿¿¿¿¿¿¿¿¿ implementation = %s\n", implementation.c_str()); - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { gnss_synchro.System = 'G'; @@ -348,15 +338,7 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); config->set_property("Tracking.track_pilot", "true"); } - else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking_Fpga") == 0) - { - gnss_synchro.System = 'G'; - std::string signal = "2S"; - System_and_Signal = "GPS L2CM"; - signal.copy(gnss_synchro.Signal, 2, 0); - config->set_property("Tracking.early_late_space_chips", "0.5"); - config->set_property("Tracking.track_pilot", "false"); - } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) { gnss_synchro.System = 'E'; @@ -406,7 +388,6 @@ const unsigned int TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; void setup_fpga_switch(void) { - //printf("starting switch function\n"); int switch_device_descriptor; // driver descriptor volatile unsigned *switch_map_base; // driver memory map @@ -422,10 +403,6 @@ void setup_fpga_switch(void) LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory"; std::cout << "Could not map switch memory." << std::endl; } - else - { - // std::cout << "Switch memory successfully mapped." << std::endl; - } // sanity check : check test register unsigned writeval = TEST_REGISTER_TRACK_WRITEVAL; @@ -445,13 +422,12 @@ void setup_fpga_switch(void) } switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues - //printf("switch set to DMA\n"); } static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -unsigned int send_samples_start = 0; +volatile unsigned int send_samples_start = 0; int8_t input_samples[MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE]; // re - im int8_t input_samples_dma[MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE*NUM_QUEUES]; @@ -459,6 +435,8 @@ int8_t input_samples_dma[MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE*NUM struct DMA_handler_args { std::string file; unsigned int nsamples_tx; + unsigned int skip_used_samples; + unsigned int freq_band; // 0 for GPS L1/ Galileo E1, 1 for GPS L5/Galileo E5 }; void *handler_DMA(void *arguments) @@ -473,21 +451,13 @@ void *handler_DMA(void *arguments) unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes - unsigned int testdummy; + unsigned int nsamples_transmitted; struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; unsigned int nsamples_tx = args->nsamples_tx; - //std::string *file = (std::string *)file_void_ptr; // input filename - std::string file = args->file; // input filename - - //unsigned int *nsamples_tx = (unsigned int *)nsamples_tx_void_ptr; // number of samples to transfer in total - // debug - //printf("DMA %s\n", file.c_str()); - //printf("DMA Starting DMA child process\n"); - //printf("DMA nsamples to send = %d\n", nsamples_tx); - - + std::string file = args->file; // input filename + unsigned int skip_used_samples = args->skip_used_samples; // open DMA device tx_fd = open("/dev/loop_tx", O_WRONLY); @@ -497,9 +467,6 @@ void *handler_DMA(void *arguments) exit(1); } else - { -// printf("DMA loop device opened successfully\n"); - } // open input file rx_signal_file_id = fopen(file.c_str(), "rb"); @@ -508,19 +475,15 @@ void *handler_DMA(void *arguments) printf("DMA can't open input file\n"); exit(1); } - else - { -// printf("DMA open file opened successfully\n"); - } while(send_samples_start == 0); // wait until acquisition starts - //printf("DMA going to sleep to give time\n"); - usleep(50000); // wait 1 second to give time to the main thread to start the acquisition module + // skip initial samples + int skip_samples = (int) FLAGS_skip_samples; -// printf("DMA child process: starting sample transfer\n"); - // transfer samples + fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); + usleep(50000); // wait some time to give time to the main thread to start the acquisition module while (file_completed == false) { @@ -551,48 +514,48 @@ void *handler_DMA(void *arguments) dma_index = 0; for (index0 = 0;index0 < (nread_elements);index0+=COMPLEX_SAMPLE_SIZE) { - // channel 1 (queue 1) -> E5/L5 - input_samples_dma[dma_index] = 0; - input_samples_dma[dma_index+1] = 0; - // channel 0 (queue 0) -> E1/L1 - input_samples_dma[dma_index+2] = input_samples[index0]; - input_samples_dma[dma_index+3] = input_samples[index0+1]; - + if (args->freq_band == 0) + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = 0; + input_samples_dma[dma_index+1] = 0; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index+2] = input_samples[index0]; + input_samples_dma[dma_index+3] = input_samples[index0+1]; + } + else + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = input_samples[index0]; + input_samples_dma[dma_index+1] = input_samples[index0+1]; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index+2] = 0; + input_samples_dma[dma_index+3] = 0; + } dma_index += 4; } - //send_tracking_gps_input_samples(tx_fd, input_samples_dma, nread_elements*2); // for the 32-bit DMA - //assert( num_bytes_to_transfer == write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES) ); - testdummy = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); - //testdummy = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); - //printf("testdummy = %d nread_elements*NUM_QUEUES = %d\n", testdummy, nread_elements*NUM_QUEUES); - } - //printf("DMA nsamples transferred = %d...\n", nsamples); + nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); -// if (nread_elements != MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE) -// { -// file_completed = true; -// } + if (nsamples_transmitted != nread_elements*NUM_QUEUES) + { + std::cout << "Error : DMA could not send all the requested samples" << std::endl; + } + } } - -// printf("number of samples transferred = %d\n",nsamples); close(tx_fd); fclose(rx_signal_file_id); - //printf("Ending the DMA child process\n"); return NULL; - } bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { - // pointer to the DMA thread that sends the samples to the acquisition engine pthread_t thread_DMA; - - // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); @@ -607,14 +570,14 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); config->set_property("Acquisition.use_CFAR_algorithm", "false"); - //std::shared_ptr acquisition; - std::shared_ptr acquisition_Fpga; + std::shared_ptr acquisition_GpsL1Ca_Fpga; + std::shared_ptr acquisition_GpsE1_Fpga; + std::shared_ptr acquisition_GpsE5a_Fpga; + std::shared_ptr acquisition_GpsL5_Fpga; std::string System_and_Signal; - //printf("¿¿¿¿¿¿¿¿¿2 implementation = %s\n", implementation.c_str()); - //create the correspondign acquisition block according to the desired tracking signal if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { tmp_gnss_synchro.System = 'G'; @@ -623,11 +586,15 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L1 CA"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + + acquisition_GpsL1Ca_Fpga->set_channel(0); + acquisition_GpsL1Ca_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition_GpsL1Ca_Fpga->connect(top_block); + } + + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { tmp_gnss_synchro.System = 'E'; @@ -636,38 +603,15 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E1B"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - } - else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking_Fpga") == 0) - { - tmp_gnss_synchro.System = 'G'; - std::string signal = "2S"; - const char* str = signal.c_str(); // get a C style null terminated string - std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null - tmp_gnss_synchro.PRN = SV_ID; - System_and_Signal = "GPS L2CM"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - } -// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) -// { -// tmp_gnss_synchro.System = 'E'; -// std::string signal = "5X"; -// const char* str = signal.c_str(); // get a C style null terminated string -// std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null -// tmp_gnss_synchro.PRN = SV_ID; -// System_and_Signal = "Galileo E5a"; -// config->set_property("Acquisition_5X.coherent_integration_time_ms", "1"); -// config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); -// config->set_property("Acquisition.CAF_window_hz", "0"); // **Only for E5a** Resolves doppler ambiguity averaging the specified BW in the winner code delay. If set to 0 CAF filter is desactivated. Recommended value 3000 Hz -// config->set_property("Acquisition.Zero_padding", "0"); //**Only for E5a** Avoids power loss and doppler ambiguity in bit transitions by correlating one code with twice the input data length, ensuring that at least one full code is present without transitions. If set to 1 it is ON, if set to 0 it is OFF. -// config->set_property("Acquisition.bit_transition_flag", "false"); -// //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); -// -// } + //std::shared_ptr acquisition_Fpga; + acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition_GpsE1_Fpga->set_channel(0); + acquisition_GpsE1_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition_GpsE1_Fpga->connect(top_block); + } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { tmp_gnss_synchro.System = 'E'; @@ -676,9 +620,14 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E5a"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + //std::shared_ptr acquisition_Fpga; + acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + + acquisition_GpsE5a_Fpga->set_channel(0); + acquisition_GpsE5a_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition_GpsE5a_Fpga->connect(top_block); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { @@ -688,60 +637,27 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L5I"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + //std::shared_ptr acquisition_Fpga; + acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + + acquisition_GpsL5_Fpga->set_channel(0); + acquisition_GpsL5_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition_GpsL5_Fpga->connect(top_block); } else { - std::cout << "The test can not run with the selected tracking implementation\n "; + std::cout << "The test can not run with the selected tracking implementation \n "; throw(std::exception()); } - //acquisition->set_gnss_synchro(&tmp_gnss_synchro); - //acquisition->set_channel(0); - //acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - //acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - //acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - //acquisition->init(); - //acquisition->set_local_code(); - //acquisition->set_state(1); // Ensure that acquisition starts at the first sample - //acquisition->connect(top_block); - - //acquisition_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_Fpga->set_channel(0); - acquisition_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - acquisition_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - //acquisition_Fpga->init(); - //acquisition_Fpga->set_local_code(); - // PROBABLY WE DONN'T NEED THIS acquisition_Fpga->set_state(1); // Ensure that acquisition starts at the first sample - acquisition_Fpga->connect(top_block); - - //gr::blocks::file_source::sptr file_source; std::string file = FLAGS_signal_file; struct DMA_handler_args args; - args.file = file; - args.nsamples_tx = 50000000; // number of samples to transfer - - - - - - const char* file_name = file.c_str(); - //file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample - //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); - //gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); - - //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - //top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); - //top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); - boost::shared_ptr msg_rx; try { @@ -754,9 +670,23 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } msg_rx->top_block = top_block; - //top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - top_block->msg_connect(acquisition_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + top_block->msg_connect(acquisition_GpsL1Ca_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + top_block->msg_connect(acquisition_GpsE1_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + top_block->msg_connect(acquisition_GpsE5a_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + top_block->msg_connect(acquisition_GpsL5_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } // 5. Run the flowgraph // Get visible GPS satellites (positive acquisitions with Doppler measurements) @@ -785,96 +715,409 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) MAX_PRN_IDX = 33; } - //printf("NOW CALLING SWITCH\n"); setup_fpga_switch(); + if (doppler_control_in_sw == 0) + { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - //printf("PRN %d\n", PRN); - tmp_gnss_synchro.PRN = PRN; -// acquisition->set_gnss_synchro(&tmp_gnss_synchro); -// acquisition->init(); -// acquisition->set_local_code(); -// acquisition->reset(); -// acquisition->set_state(1); - -// printf("SSSSSSSSSSSSSSSSSSSSTEPA\n"); - acquisition_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_Fpga->init(); - acquisition_Fpga->set_local_code(); -// printf("SSSSSSSSSSSSSSSSSSSSTEPB\n"); - - // create DMA child process - //if (pthread_create(&thread_DMA, NULL, handler_DMA, &file, nsamples_tx) < 0) - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } -// else -// { -// printf("DMA child process created successfully\n"); -// } - - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - - msg_rx->rx_message = 0; - top_block->start(); - -// printf("main thread: starting acquisition\n"); - acquisition_Fpga->reset(); //NOT YET -// printf("zzzzzzzzzzzzzzzzzzzzz\n"); - // PROBABLY WE DON'T NEED THIS acquisition_Fpga->set_state(1); - //msg_rx->rx_message = 0; -// printf("aaaaaaaaaaaaaaaaaaaaaaaa\n"); - //top_block->run(); -// printf("bbbbbbbbbbbbbbbbbbbbbbbb\n"); - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } + args.file = file; + args.nsamples_tx = NSAMPLES_ACQ_DOPPLER_SWEEP; // number of samples to transfer + args.skip_used_samples = 0; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_single_doppler_flag(0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_single_doppler_flag(0); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_single_doppler_flag(0); + args.freq_band = 1; + } - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); -// printf("DMA child process terminated successfully\n"); + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + tmp_gnss_synchro.PRN = PRN; - //printf("enter number whatever\n"); - //unsigned int kk; - //scanf("%d\n", &kk); - //printf("ok number obtained \n"); + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_GpsL1Ca_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - send_samples_start = 0; + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_GpsE1_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - while (msg_rx->rx_message == 0) - { - //printf("message is zero\n"); - usleep(100000); - } - if (msg_rx->rx_message == 1) - { - //printf("message is something\n"); - std::cout << " " << PRN << " "; - doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); - code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); - acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); - } - else - { - //printf("message is something not contemplated\n"); - std::cout << " . "; - } - top_block->stop(); - //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample - std::cout.flush(); - } + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_GpsE5a_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_GpsL5_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + } + + // create DMA child process + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); + } + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); + code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); + acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); + } + else + { + std::cout << " . "; + } + top_block->stop(); + std::cout.flush(); + } + } + else + { + + unsigned int code_length; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + } + + float nbits = ceilf(log2f((float)code_length)); + unsigned int fft_size = pow(2, nbits); + unsigned int nsamples_total = fft_size; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_single_doppler_flag(1); + } + + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + + int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; + + float result_table[MAX_PRN_IDX][num_doppler_steps][2]; + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + + uint32_t max_index = 0; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float power_sum = 0; + uint32_t doppler_index = 0; + + uint32_t max_index_iteration; + float max_magnitude_iteration; + uint64_t initial_sample_iteration; + float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; + + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + tmp_gnss_synchro.PRN = PRN; + + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL1Ca_Fpga->set_doppler_step(0); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE1_Fpga->set_doppler_step(0); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE5a_Fpga->set_doppler_step(0); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL5_Fpga->set_doppler_step(0); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } + + args.file = file; + args.nsamples_tx = fft_size; //50000; // max size of the FFT + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } + + // create DMA child process + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); + } + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + + result_table[PRN][doppler_num][0] = max_magnitude_iteration; + result_table[PRN][doppler_num][1] = power_sum_iteration; + doppler_num = doppler_num + 1; + + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + initial_sample = initial_sample_iteration; + power_sum = power_sum_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + top_block->stop(); + } + + power_sum = (power_sum - max_magnitude) / (fft_size - 1); + float test_statistics = (max_magnitude / power_sum); + float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); + if (test_statistics > threshold) + { + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); + code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); + acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + } + else + { + std::cout << " . "; + } + + std::cout.flush(); + + } + + uint32_t max_index = 0; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float power_sum = 0; + uint32_t doppler_index = 0; + + if (show_results_table == 1) + { + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; + int doppler_num = 0; + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + max_magnitude = result_table[PRN][doppler_num][0]; + power_sum = result_table[PRN][doppler_num][1]; + doppler_num = doppler_num + 1; + + std::cout << "Doppler shift " << doppler_shift << std::endl; + std::cout << "Max magnitude = " << max_magnitude << "Power sum = " << power_sum << std::endl; + + power_sum = (power_sum - max_magnitude) / (fft_size - 1); + float test_statistics = (max_magnitude / power_sum); + std::cout << "test_statistics = " << test_statistics << std::endl; + + } + } + } + + } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -883,6 +1126,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::cout << "DETECTED SATELLITE " << System_and_Signal << " PRN: " << x.first << " with Doppler: " << x.second << " [Hz], code phase: " << code_delay_measurements_map.at(x.first) << " [samples] at signal SampleStamp " << acq_samplestamp_map.at(x.first) << "\n"; } + // report the elapsed time end = std::chrono::system_clock::now(); elapsed_seconds = end - start; @@ -898,10 +1142,10 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) // pointer to the DMA thread that sends the samples to the acquisition engine pthread_t thread_DMA; + + struct DMA_handler_args args; - - //************************************************* //***** STEP 1: Prepare the parameters sweep ****** //************************************************* @@ -921,19 +1165,16 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) acq_delay_error_chips_values.push_back(tmp_vector); } - //*********************************************************** //***** STEP 2: Generate the input signal (if required) ***** //*********************************************************** std::vector generator_CN0_values; if (FLAGS_enable_external_signal_file) { - printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX READ FROM FILE\n"); generator_CN0_values.push_back(999); // an external input signal capture is selected, no CN0 information available } else { - printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GENERATE INPUT SIGNAL\n"); if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop) { generator_CN0_values.push_back(FLAGS_CN0_dBHz_start); @@ -950,7 +1191,6 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) // use generator or use an external capture file if (FLAGS_enable_external_signal_file) { - printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX READ FROM FILE 2\n"); //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters ASSERT_EQ(acquire_signal(FLAGS_test_satellite_PRN), true); bool found_satellite = doppler_measurements_map.find(FLAGS_test_satellite_PRN) != doppler_measurements_map.end(); @@ -959,7 +1199,6 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } else { - printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GENERATE INPUT SIGNAL 2\n"); for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) { // Configure the signal generator @@ -972,7 +1211,6 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } } - configure_receiver(FLAGS_PLL_bw_hz_start, FLAGS_DLL_bw_hz_start, FLAGS_PLL_narrow_bw_hz, @@ -990,7 +1228,6 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) tracking_true_obs_reader true_obs_data; if (!FLAGS_enable_external_signal_file) { - printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GENERATE INPUT SIGNAL 3\n"); test_satellite_PRN = FLAGS_test_satellite_PRN; std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); true_obs_file.append(std::to_string(test_satellite_PRN)); @@ -1010,17 +1247,41 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } else { - printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX READ FROM FILE 3\n"); true_acq_doppler_hz = doppler_measurements_map.find(FLAGS_test_satellite_PRN)->second; true_acq_delay_samples = code_delay_measurements_map.find(FLAGS_test_satellite_PRN)->second; - acq_samplestamp_samples = 0; + acq_samplestamp_samples = acq_samplestamp_map.find(FLAGS_test_satellite_PRN)->second; std::cout << "Estimated Initial Doppler " << true_acq_doppler_hz << " [Hz], estimated Initial code delay " << true_acq_delay_samples << " [Samples]" - << " Acquisition SampleStamp is " << acq_samplestamp_map.find(FLAGS_test_satellite_PRN)->second << std::endl; + << " Acquisition SampleStamp is " << acq_samplestamp_samples << std::endl; + } - //CN0 LOOP + std::vector> pull_in_results_v_v; + unsigned int code_length; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + } + + float nbits = ceilf(log2f((float)code_length)); + unsigned int fft_size = pow(2, nbits); + + + for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) { std::vector pull_in_results_v; @@ -1039,7 +1300,33 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); boost::shared_ptr msg_rx = TrackingPullInTestFpga_msg_rx_make(); + printf("loop part b2\n"); + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + std::shared_ptr acquisition_Fpga; + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + std::shared_ptr acquisition_Fpga; + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + std::shared_ptr acquisition_Fpga; + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + std::shared_ptr acquisition_Fpga; + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } ASSERT_NO_THROW({ tracking->set_channel(gnss_synchro.Channel_ID); @@ -1053,29 +1340,10 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) tracking->connect(top_block); }) << "Failure connecting tracking to the top_block."; - std::string file; ASSERT_NO_THROW({ - if (!FLAGS_enable_external_signal_file) - { - printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX GENERATE INPUT SIGNAL 4\n"); - file = "./" + filename_raw_data + std::to_string(current_cn0_idx); - } - else - { - printf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX READ FROM FILE 4\n"); - file = FLAGS_signal_file; - } - const char* file_name = file.c_str(); - //gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro)); - //gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); - //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - //top_block->connect(gr_interleaved_char_to_complex, 0, head_samples, 0); - //top_block->connect(head_samples, 0, tracking->get_left_block(), 0); top_block->connect(tracking->get_right_block(), 0, sink, 0); top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks of tracking test."; @@ -1083,42 +1351,63 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) //***** STEP 5: Perform the signal tracking and read the results ***** //******************************************************************** + std::string file = FLAGS_signal_file; + args.file = file; - args.nsamples_tx = 500000000; // number of samples to transfer + args.nsamples_tx = NSAMPLES_TRACKING; // number of samples to transfer + + + if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) + { + args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } - else - { - printf("DMA child process created successfully\n"); - } std::cout << "--- START TRACKING WITH PULL-IN ERROR: " << acq_doppler_error_hz_values.at(current_acq_doppler_error_idx) << " [Hz] and " << acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) << " [Chips] ---" << std::endl; + tracking->start_tracking(); + pthread_mutex_lock(&mutex); send_samples_start = 1; pthread_mutex_unlock(&mutex); - tracking->start_tracking(); - std::chrono::time_point start, end; - EXPECT_NO_THROW({ - start = std::chrono::system_clock::now(); - top_block->run(); // Start threads and wait - end = std::chrono::system_clock::now(); - }) << "Failure running the top_block."; - - std::chrono::duration elapsed_seconds = end - start; - std::cout << "Signal tracking completed in " << elapsed_seconds.count() << " seconds" << std::endl; - - pull_in_results_v.push_back(msg_rx->rx_message != 3); //save last asynchronous tracking message in order to detect a loss of lock + top_block->start(); // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); - printf("DMA child process terminated successfully\n"); + top_block->stop(); + + // send more samples to unblock the tracking process in case it was waiting for samples + args.file = file; + if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) + { + // skip the samples that have already been used + args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size + args.nsamples_tx; + } + else + { + args.skip_used_samples = 0; + } + args.nsamples_tx = NSAMPLES_FINAL; + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + pthread_join(thread_DMA, NULL); + pthread_mutex_lock(&mutex); send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + pull_in_results_v.push_back(msg_rx->rx_message != 3); //save last asynchronous tracking message in order to detect a loss of lock //******************************** //***** STEP 7: Plot results ***** @@ -1287,11 +1576,12 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } //end acquisition Delay errors loop } //end acquisition Doppler errors loop - pull_in_results_v_v.push_back(pull_in_results_v); + pull_in_results_v_v.push_back(pull_in_results_v); } //end CN0 LOOP //build the mesh grid + std::vector doppler_error_mesh; std::vector code_delay_error_mesh; for (unsigned int current_acq_doppler_error_idx = 0; current_acq_doppler_error_idx < acq_doppler_error_hz_values.size(); current_acq_doppler_error_idx++) From 1b0568e0e99145e600ba81d50c6f2c1f1220c78f Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Thu, 13 Sep 2018 16:36:21 +0200 Subject: [PATCH 05/53] implemented hybrid observables tests using the FPGA. The hybrid observables test funtions are not tested yet. --- src/tests/test_main.cc | 3 + .../hybrid_observables_test_fpga.cc | 2399 +++++++++++++++++ .../tracking/tracking_pull-in_test_fpga.cc | 8 +- 3 files changed, 2406 insertions(+), 4 deletions(-) create mode 100644 src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index 194fb2b9d..baab8c2c3 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -154,6 +154,9 @@ DECLARE_string(log_dir); #endif #include "unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc" #include "unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc" +#if FPGA_BLOCKS_TEST +#include "unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc" +#endif #endif #include "unit-tests/system-parameters/glonass_gnav_ephemeris_test.cc" diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc new file mode 100644 index 000000000..e79f48288 --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -0,0 +1,2399 @@ +/*! + * \file hybrid_observables_test.cc + * \brief This class implements a tracking test for Galileo_E5a_DLL_PLL_Tracking + * implementation based on some input parameters. + * \author Javier Arribas, 2015. jarribas(at)cttc.es + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "GPS_L1_CA.h" +#include "gnss_satellite.h" +#include "gnss_block_factory.h" +#include "gnss_block_interface.h" +#include "tracking_interface.h" +#include "telemetry_decoder_interface.h" +#include "in_memory_configuration.h" +#include "gnss_synchro.h" +#include "gps_l1_ca_telemetry_decoder.h" +#include "tracking_true_obs_reader.h" +#include "true_observables_reader.h" +#include "tracking_dump_reader.h" +#include "observables_dump_reader.h" +#include "tlm_dump_reader.h" +#include "gps_l1_ca_dll_pll_tracking.h" +#include "gps_l1_ca_dll_pll_tracking_fpga.h" +#include "hybrid_observables.h" +#include "signal_generator_flags.h" +#include "gnss_sdr_sample_counter.h" +#include "test_flags.h" +#include "tracking_tests_flags.h" +#include "observable_tests_flags.h" +#include "gnuplot_i.h" + +// threads +#include // for pthread stuff +#include // for open, O_RDWR, O_SYNC +#include // for cout, endl +#include // for mmap + +#define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples +#define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes +#define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) +#define TEST_OBS_NSAMPLES_TRACKING 90000000 // number of samples during which we test the tracking module +#define TEST_OBS_NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module +#define TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop + +// HW related options +bool test_observables_doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW +bool test_observables_show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if test_observables_doppler_control_in_sw = 1), 0=> do not show it +bool test_observables_skip_samples_already_used = 1; // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops + // (exactly in the same way as the SW) + // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 0 => the sampe samples are used for each PRN loop + // if test_observables_doppler_control_in_sw = 0 => test_observables_skip_samples_already_used is not applicable + +// ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES ######### +class HybridObservablesTest_msg_rx_Fpga; + +typedef boost::shared_ptr HybridObservablesTest_msg_rx_Fpga_sptr; + +HybridObservablesTest_msg_rx_Fpga_sptr HybridObservablesTest_msg_rx_Fpga_make(); + +class HybridObservablesTest_msg_rx_Fpga : public gr::block +{ +private: + friend HybridObservablesTest_msg_rx_Fpga_sptr HybridObservablesTest_msg_rx_Fpga_make(); + void msg_handler_events(pmt::pmt_t msg); + HybridObservablesTest_msg_rx_Fpga(); + +public: + int rx_message; + ~HybridObservablesTest_msg_rx_Fpga(); //!< Default destructor +}; + +HybridObservablesTest_msg_rx_Fpga_sptr HybridObservablesTest_msg_rx_Fpga_make() +{ + return HybridObservablesTest_msg_rx_Fpga_sptr(new HybridObservablesTest_msg_rx_Fpga()); +} + +void HybridObservablesTest_msg_rx_Fpga::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(msg); + rx_message = message; + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; + rx_message = 0; + } +} + +HybridObservablesTest_msg_rx_Fpga::HybridObservablesTest_msg_rx_Fpga() : gr::block("HybridObservablesTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&HybridObservablesTest_msg_rx_Fpga::msg_handler_events, this, _1)); + rx_message = 0; +} + +HybridObservablesTest_msg_rx_Fpga::~HybridObservablesTest_msg_rx_Fpga() +{ +} + + +// ########################################################### + + +// ######## GNURADIO BLOCK MESSAGE RECEVER FOR TLM MESSAGES ######### +class HybridObservablesTest_tlm_msg_rx_Fpga; + +typedef boost::shared_ptr HybridObservablesTest_tlm_msg_rx_Fpga_sptr; + +HybridObservablesTest_tlm_msg_rx_Fpga_sptr HybridObservablesTest_tlm_msg_rx_Fpga_make(); + +class HybridObservablesTest_tlm_msg_rx_Fpga : public gr::block +{ +private: + friend HybridObservablesTest_tlm_msg_rx_Fpga_sptr HybridObservablesTest_tlm_msg_rx_Fpga_make(); + void msg_handler_events(pmt::pmt_t msg); + HybridObservablesTest_tlm_msg_rx_Fpga(); + +public: + int rx_message; + ~HybridObservablesTest_tlm_msg_rx_Fpga(); //!< Default destructor +}; + +HybridObservablesTest_tlm_msg_rx_Fpga_sptr HybridObservablesTest_tlm_msg_rx_Fpga_make() +{ + return HybridObservablesTest_tlm_msg_rx_Fpga_sptr(new HybridObservablesTest_tlm_msg_rx_Fpga()); +} + +void HybridObservablesTest_tlm_msg_rx_Fpga::msg_handler_events(pmt::pmt_t msg) +{ + try + { + int64_t message = pmt::to_long(msg); + rx_message = message; + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; + rx_message = 0; + } +} + +HybridObservablesTest_tlm_msg_rx_Fpga::HybridObservablesTest_tlm_msg_rx_Fpga() : gr::block("HybridObservablesTest_tlm_msg_rx_Fpga", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&HybridObservablesTest_tlm_msg_rx_Fpga::msg_handler_events, this, _1)); + rx_message = 0; +} + +HybridObservablesTest_tlm_msg_rx_Fpga::~HybridObservablesTest_tlm_msg_rx_Fpga() +{ +} + + +// ########################################################### + + +class HybridObservablesTestFpga : public ::testing::Test +{ +public: + std::string generator_binary; + std::string p1; + std::string p2; + std::string p3; + std::string p4; + std::string p5; + std::string implementation = FLAGS_trk_test_implementation; + + const int baseband_sampling_freq = FLAGS_fs_gen_sps; + + std::string filename_rinex_obs = FLAGS_filename_rinex_obs; + std::string filename_raw_data = FLAGS_filename_raw_data; + + int configure_generator(); + int generate_signal(); + bool save_mat_xy(std::vector& x, std::vector& y, std::string filename); + void check_results_carrier_phase( + arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + std::string data_title); + void check_results_carrier_phase_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title); + void check_results_carrier_doppler(arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + std::string data_title); + void check_results_carrier_doppler_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title); + void check_results_code_pseudorange( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title); + + HybridObservablesTestFpga() + { + factory = std::make_shared(); + config = std::make_shared(); + item_size = sizeof(gr_complex); + } + + ~HybridObservablesTestFpga() + { + } + + bool ReadRinexObs(std::vector* obs_vec, Gnss_Synchro gnss); + + bool acquire_signal(); + void configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols); + + gr::top_block_sptr top_block; + std::shared_ptr factory; + std::shared_ptr config; + Gnss_Synchro gnss_synchro_master; + std::vector gnss_synchro_vec; + size_t item_size; +}; + +int HybridObservablesTestFpga::configure_generator() +{ + // Configure signal generator + generator_binary = FLAGS_generator_binary; + + p1 = std::string("-rinex_nav_file=") + FLAGS_rinex_nav_file; + if (FLAGS_dynamic_position.empty()) + { + p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10); + } + else + { + p2 = std::string("-obs_pos_file=") + std::string(FLAGS_dynamic_position); + } + p3 = std::string("-rinex_obs_file=") + FLAGS_filename_rinex_obs; // RINEX 2.10 observation file output + p4 = std::string("-sig_out_file=") + FLAGS_filename_raw_data; // Baseband signal output file. Will be stored in int8_t IQ multiplexed samples + p5 = std::string("-sampling_freq=") + std::to_string(baseband_sampling_freq); //Baseband sampling frequency [MSps] + return 0; +} + + +int HybridObservablesTestFpga::generate_signal() +{ + int child_status; + + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL}; + + int pid; + if ((pid = fork()) == -1) + perror("fork err"); + else if (pid == 0) + { + execv(&generator_binary[0], parmList); + std::cout << "Return not expected. Must be an execv err." << std::endl; + std::terminate(); + } + + waitpid(pid, &child_status, 0); + + std::cout << "Signal and Observables RINEX and RAW files created." << std::endl; + return 0; +} + + +const size_t TEST_OBS_PAGE_SIZE = 0x10000; +const unsigned int TEST_OBS_TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; + +void setup_fpga_switch_obs_test(void) +{ + int switch_device_descriptor; // driver descriptor + volatile unsigned *switch_map_base; // driver memory map + + if ((switch_device_descriptor = open("/dev/uio1", O_RDWR | O_SYNC)) == -1) + { + LOG(WARNING) << "Cannot open deviceio" << "/dev/uio1"; + } + switch_map_base = reinterpret_cast(mmap(nullptr, TEST_OBS_PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, switch_device_descriptor, 0)); + + if (switch_map_base == reinterpret_cast(-1)) + { + LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory"; + std::cout << "Could not map switch memory." << std::endl; + } + + // sanity check : check test register + unsigned writeval = TEST_OBS_TEST_REGISTER_TRACK_WRITEVAL; + unsigned readval; + // write value to test register + switch_map_base[3] = writeval; + // read value from test register + readval = switch_map_base[3]; + + if (writeval != readval) + { + LOG(WARNING) << "Test register sanity check failed"; + } + else + { + LOG(INFO) << "Test register sanity check success !"; + } + + switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues +} + + +static pthread_mutex_t mutex_obs_test = PTHREAD_MUTEX_INITIALIZER; + +volatile unsigned int send_samples_start_obs_test = 0; + +int8_t input_samples_obs_test[TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL*TEST_OBS_COMPLEX_SAMPLE_SIZE]; // re - im +int8_t input_samples_dma_obs_test[TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL*TEST_OBS_COMPLEX_SAMPLE_SIZE*TEST_OBS_NUM_QUEUES]; + +struct DMA_handler_args_obs_test { + std::string file; + unsigned int nsamples_tx; + unsigned int skip_used_samples; + unsigned int freq_band; // 0 for GPS L1/ Galileo E1, 1 for GPS L5/Galileo E5 +}; + +void *handler_DMA_obs_test(void *arguments) +{ + // DMA process that configures the DMA to send the samples to the acquisition engine + int tx_fd; // DMA descriptor + FILE *rx_signal_file_id; // Input file descriptor + bool file_completed = false; // flag to indicate if the file is completed + unsigned int nsamples_block; // number of samples to send in the next DMA block of samples + unsigned int nread_elements; // number of elements effectively read from the input file + unsigned int nsamples = 0; // number of complex samples effectively transferred + unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA + unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes + + unsigned int nsamples_transmitted; + + struct DMA_handler_args_obs_test *args = (struct DMA_handler_args_obs_test *) arguments; + + unsigned int nsamples_tx = args->nsamples_tx; + std::string file = args->file; // input filename + unsigned int skip_used_samples = args->skip_used_samples; + + // open DMA device + tx_fd = open("/dev/loop_tx", O_WRONLY); + if ( tx_fd < 0 ) + { + printf("DMA can't open loop device\n"); + exit(1); + } + else + + // open input file + rx_signal_file_id = fopen(file.c_str(), "rb"); + if (rx_signal_file_id < 0) + { + printf("DMA can't open input file\n"); + exit(1); + } + + while(send_samples_start_obs_test == 0); // wait until acquisition starts + + // skip initial samples + int skip_samples = (int) FLAGS_skip_samples; + + fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); + + usleep(50000); // wait some time to give time to the main thread to start the acquisition module + + while (file_completed == false) + { + + if (nsamples_tx - nsamples > TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + { + nsamples_block = TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + } + else + { + nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent + file_completed = true; + } + + nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block*TEST_OBS_COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + + if (nread_elements != nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE) + { + printf("could not read the desired number of samples from the input file\n"); + file_completed = true; + } + + nsamples+=(nread_elements/TEST_OBS_COMPLEX_SAMPLE_SIZE); + + if (nread_elements > 0) + { + // for the 32-BIT DMA + dma_index = 0; + for (index0 = 0;index0 < (nread_elements);index0+=TEST_OBS_COMPLEX_SAMPLE_SIZE) + { + if (args->freq_band == 0) + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma_obs_test[dma_index] = 0; + input_samples_dma_obs_test[dma_index+1] = 0; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma_obs_test[dma_index+2] = input_samples_obs_test[index0]; + input_samples_dma_obs_test[dma_index+3] = input_samples_obs_test[index0+1]; + } + else + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma_obs_test[dma_index] = input_samples_obs_test[index0]; + input_samples_dma_obs_test[dma_index+1] = input_samples_obs_test[index0+1]; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma_obs_test[dma_index+2] = 0; + input_samples_dma_obs_test[dma_index+3] = 0; + } + dma_index += 4; + } + + nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements*TEST_OBS_NUM_QUEUES); + + if (nsamples_transmitted != nread_elements*TEST_OBS_NUM_QUEUES) + { + std::cout << "Error : DMA could not send all the requested samples" << std::endl; + } + } + } + + close(tx_fd); + fclose(rx_signal_file_id); + + return NULL; +} + + +bool HybridObservablesTestFpga::acquire_signal() +{ + pthread_t thread_DMA; + + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) + gr::top_block_sptr top_block; + top_block = gr::make_top_block("Acquisition test"); + int SV_ID = 1; //initial sv id + // Satellite signal definition + Gnss_Synchro tmp_gnss_synchro; + tmp_gnss_synchro.Channel_ID = 0; + config = std::make_shared(); + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + config->set_property("Acquisition.blocking_on_standby", "true"); + config->set_property("Acquisition.blocking", "true"); + config->set_property("Acquisition.dump", "false"); + config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); + config->set_property("Acquisition.use_CFAR_algorithm", "false"); + + //std::shared_ptr acquisition; + + std::shared_ptr acquisition_GpsL1Ca_Fpga; + std::shared_ptr acquisition_GpsE1_Fpga; + std::shared_ptr acquisition_GpsE5a_Fpga; + std::shared_ptr acquisition_GpsL5_Fpga; + + std::string System_and_Signal; + //create the correspondign acquisition block according to the desired tracking signal + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'G'; + std::string signal = "1C"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L1 CA"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + ////acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + + acquisition_GpsL1Ca_Fpga->set_channel(0); + acquisition_GpsL1Ca_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition_GpsL1Ca_Fpga->connect(top_block); + + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'E'; + std::string signal = "1B"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E1B"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + + acquisition_GpsE1_Fpga->set_channel(0); + acquisition_GpsE1_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition_GpsE1_Fpga->connect(top_block); + + } +// else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) +// { +// tmp_gnss_synchro.System = 'G'; +// std::string signal = "2S"; +// signal.copy(tmp_gnss_synchro.Signal, 2, 0); +// tmp_gnss_synchro.PRN = SV_ID; +// System_and_Signal = "GPS L2CM"; +// config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); +// acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); +// } +// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) +// { +// tmp_gnss_synchro.System = 'E'; +// std::string signal = "5X"; +// signal.copy(tmp_gnss_synchro.Signal, 2, 0); +// tmp_gnss_synchro.PRN = SV_ID; +// System_and_Signal = "Galileo E5a"; +// config->set_property("Acquisition_5X.coherent_integration_time_ms", "1"); +// config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); +// config->set_property("Acquisition.CAF_window_hz", "0"); // **Only for E5a** Resolves doppler ambiguity averaging the specified BW in the winner code delay. If set to 0 CAF filter is desactivated. Recommended value 3000 Hz +// config->set_property("Acquisition.Zero_padding", "0"); //**Only for E5a** Avoids power loss and doppler ambiguity in bit transitions by correlating one code with twice the input data length, ensuring that at least one full code is present without transitions. If set to 1 it is ON, if set to 0 it is OFF. +// config->set_property("Acquisition.bit_transition_flag", "false"); +// acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); +// } + + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'E'; + std::string signal = "5X"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "Galileo E5a"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + + acquisition_GpsE5a_Fpga->set_channel(0); + acquisition_GpsE5a_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition_GpsE5a_Fpga->connect(top_block); + + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + tmp_gnss_synchro.System = 'G'; + std::string signal = "L5"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + tmp_gnss_synchro.PRN = SV_ID; + System_and_Signal = "GPS L5I"; + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); + acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + + acquisition_GpsL5_Fpga->set_channel(0); + acquisition_GpsL5_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition_GpsL5_Fpga->connect(top_block); + + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + //acquisition->set_gnss_synchro(&tmp_gnss_synchro); + //acquisition->set_channel(0); + //acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + //acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + //acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + //acquisition->init(); + //acquisition->set_local_code(); + //acquisition->set_state(1); // Ensure that acquisition starts at the first sample + //acquisition->connect(top_block); + + //gr::blocks::file_source::sptr file_source; + std::string file = FLAGS_signal_file; + const char* file_name = file.c_str(); + //file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + //gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); + + //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + //top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); + //top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); + + struct DMA_handler_args_obs_test args; + + boost::shared_ptr msg_rx; + try + { + msg_rx = Acquisition_msg_rx_make(); + } + catch (const std::exception& e) + { + std::cout << "Failure connecting the message port system: " << e.what() << std::endl; + exit(0); + } + + msg_rx->top_block = top_block; + //top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + top_block->msg_connect(acquisition_GpsL1Ca_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + top_block->msg_connect(acquisition_GpsE1_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + top_block->msg_connect(acquisition_GpsE5a_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + top_block->msg_connect(acquisition_GpsL5_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + } + + + // 5. Run the flowgraph + // Get visible GPS satellites (positive acquisitions with Doppler measurements) + // record startup time + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds; + start = std::chrono::system_clock::now(); + + bool start_msg = true; + + unsigned int MAX_PRN_IDX = 0; + + switch (tmp_gnss_synchro.System) + { + case 'G': + MAX_PRN_IDX = 33; + break; + case 'E': + MAX_PRN_IDX = 37; + break; + default: + MAX_PRN_IDX = 33; + } + + setup_fpga_switch_obs_test(); + + if (test_observables_doppler_control_in_sw == 0) + { + + args.file = file; + args.nsamples_tx = TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP; // number of samples to transfer + args.skip_used_samples = 0; + + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_single_doppler_flag(0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_single_doppler_flag(0); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_single_doppler_flag(0); + args.freq_band = 1; + } + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + tmp_gnss_synchro.PRN = PRN; + //acquisition->set_gnss_synchro(&tmp_gnss_synchro); + //acquisition->init(); + //acquisition->set_local_code(); + //acquisition->reset(); + //acquisition->set_state(1); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_GpsL1Ca_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_GpsE1_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_GpsE5a_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); + acquisition_GpsL5_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + } + + // create DMA child process + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex_obs_test); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); + } + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); + + //msg_rx->rx_message = 0; + //top_block->run(); + //if (start_msg == true) + // { + // std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + // std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + // std::cout << "["; + // start_msg = false; + // } + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + else + { + std::cout << " . "; + } + top_block->stop(); + //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + std::cout.flush(); + } + } + else + { + unsigned int code_length; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + } + + float nbits = ceilf(log2f((float)code_length)); + unsigned int fft_size = pow(2, nbits); + unsigned int nsamples_total = fft_size; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_single_doppler_flag(1); + } + + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + + int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; + + float result_table[MAX_PRN_IDX][num_doppler_steps][2]; + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + + uint32_t max_index = 0; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float power_sum = 0; + uint32_t doppler_index = 0; + + uint32_t max_index_iteration; + float max_magnitude_iteration; + uint64_t initial_sample_iteration; + float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; + + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + tmp_gnss_synchro.PRN = PRN; + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL1Ca_Fpga->set_doppler_step(0); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE1_Fpga->set_doppler_step(0); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE5a_Fpga->set_doppler_step(0); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL5_Fpga->set_doppler_step(0); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } + + args.file = file; + args.nsamples_tx = fft_size; //50000; // max size of the FFT + if (test_observables_skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } + + // create DMA child process + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex_obs_test); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); + } + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); + + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + + result_table[PRN][doppler_num][0] = max_magnitude_iteration; + result_table[PRN][doppler_num][1] = power_sum_iteration; + doppler_num = doppler_num + 1; + + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + initial_sample = initial_sample_iteration; + power_sum = power_sum_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + top_block->stop(); + } + + power_sum = (power_sum - max_magnitude) / (fft_size - 1); + float test_statistics = (max_magnitude / power_sum); + float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); + if (test_statistics > threshold) + { + std::cout << " " << PRN << " "; + //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); + //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); + //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + else + { + std::cout << " . "; + } + + std::cout.flush(); + + } + + uint32_t max_index = 0; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float power_sum = 0; + uint32_t doppler_index = 0; + + if (test_observables_show_results_table == 1) + { + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; + int doppler_num = 0; + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + max_magnitude = result_table[PRN][doppler_num][0]; + power_sum = result_table[PRN][doppler_num][1]; + doppler_num = doppler_num + 1; + + std::cout << "Doppler shift " << doppler_shift << std::endl; + std::cout << "Max magnitude = " << max_magnitude << "Power sum = " << power_sum << std::endl; + + power_sum = (power_sum - max_magnitude) / (fft_size - 1); + float test_statistics = (max_magnitude / power_sum); + std::cout << "test_statistics = " << test_statistics << std::endl; + + } + } + } + } + std::cout << "]" << std::endl; + std::cout << "-------------------------------------------\n"; + + for (auto& x : gnss_synchro_vec) + { + std::cout << "DETECTED SATELLITE " << System_and_Signal + << " PRN: " << x.PRN + << " with Doppler: " << x.Acq_doppler_hz + << " [Hz], code phase: " << x.Acq_delay_samples + << " [samples] at signal SampleStamp " << x.Acq_samplestamp_samples << "\n"; + } + + // report the elapsed time + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + std::cout << "Total signal acquisition run time " + << elapsed_seconds.count() + << " [seconds]" << std::endl; + if (gnss_synchro_vec.size() > 0) + { + return true; + } + else + { + return false; + } +} + + +void HybridObservablesTestFpga::configure_receiver( + double PLL_wide_bw_hz, + double DLL_wide_bw_hz, + double PLL_narrow_bw_hz, + double DLL_narrow_bw_hz, + int extend_correlation_symbols) +{ + config = std::make_shared(); + config->set_property("Tracking.dump", "true"); + config->set_property("Tracking.dump_filename", "./tracking_ch_"); + config->set_property("Tracking.implementation", implementation); + config->set_property("Tracking.item_type", "gr_complex"); + config->set_property("Tracking.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); + config->set_property("Tracking.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); + config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); + config->set_property("Observables.implementation", "Hybrid_Observables"); + config->set_property("Observables.dump", "true"); + config->set_property("TelemetryDecoder.dump", "true"); + + gnss_synchro_master.Channel_ID = 0; + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); + + std::string System_and_Signal; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + gnss_synchro_master.System = 'G'; + std::string signal = "1C"; + System_and_Signal = "GPS L1 CA"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); + + config->set_property("TelemetryDecoder.implementation", "GPS_L1_CA_Telemetry_Decoder"); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + gnss_synchro_master.System = 'E'; + std::string signal = "1B"; + System_and_Signal = "Galileo E1B"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_chips", "0.6"); + config->set_property("Tracking.early_late_space_narrow_chips", "0.15"); + config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); + config->set_property("Tracking.track_pilot", "true"); + + config->set_property("TelemetryDecoder.implementation", "Galileo_E1B_Telemetry_Decoder"); + } +// else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) +// { +// gnss_synchro_master.System = 'G'; +// std::string signal = "2S"; +// System_and_Signal = "GPS L2CM"; +// const char* str = signal.c_str(); // get a C style null terminated string +// std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null +// +// config->set_property("Tracking.early_late_space_chips", "0.5"); +// config->set_property("Tracking.track_pilot", "false"); +// +// config->set_property("TelemetryDecoder.implementation", "GPS_L2C_Telemetry_Decoder"); +// } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) + { + gnss_synchro_master.System = 'E'; + std::string signal = "5X"; + System_and_Signal = "Galileo E5a"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + //if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) + // { + // config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); + // } + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "false"); + config->set_property("Tracking.order", "2"); + + config->set_property("TelemetryDecoder.implementation", "Galileo_E5a_Telemetry_Decoder"); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + gnss_synchro_master.System = 'G'; + std::string signal = "L5"; + System_and_Signal = "GPS L5I"; + const char* str = signal.c_str(); // get a C style null terminated string + std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null + + config->set_property("Tracking.early_late_space_chips", "0.5"); + config->set_property("Tracking.track_pilot", "false"); + config->set_property("Tracking.order", "2"); + + config->set_property("TelemetryDecoder.implementation", "GPS_L5_Telemetry_Decoder"); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + std::cout << "*****************************************\n"; + std::cout << "*** Tracking configuration parameters ***\n"; + std::cout << "*****************************************\n"; + std::cout << "Signal: " << System_and_Signal << "\n"; + std::cout << "implementation: " << config->property("Tracking.implementation", std::string("undefined")) << " \n"; + std::cout << "pll_bw_hz: " << config->property("Tracking.pll_bw_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_hz: " << config->property("Tracking.dll_bw_hz", 0.0) << " Hz\n"; + std::cout << "pll_bw_narrow_hz: " << config->property("Tracking.pll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "dll_bw_narrow_hz: " << config->property("Tracking.dll_bw_narrow_hz", 0.0) << " Hz\n"; + std::cout << "extend_correlation_symbols: " << config->property("Tracking.extend_correlation_symbols", 0) << " Symbols\n"; + std::cout << "*****************************************\n"; + std::cout << "*****************************************\n"; +} + +void HybridObservablesTestFpga::check_results_carrier_phase( + arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = measured_ch0(0, 0); + int size1 = measured_ch0.col(0).n_rows; + double t1 = measured_ch0(size1 - 1, 0); + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + arma::vec true_ch0_phase_interp; + arma::interp1(true_tow_s, true_ch0.col(3), t, true_ch0_phase_interp); + + arma::vec meas_ch0_phase_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(3), t, meas_ch0_phase_interp); + + //2. RMSE + arma::vec err_ch0_cycles; + + //compute error without the accumulated carrier phase offsets (which depends on the receiver starting time) + err_ch0_cycles = meas_ch0_phase_interp - true_ch0_phase_interp - meas_ch0_phase_interp(0) + true_ch0_phase_interp(0); + + arma::vec err2_ch0 = arma::square(err_ch0_cycles); + double rmse_ch0 = sqrt(arma::mean(err2_ch0)); + + //3. Mean err and variance + double error_mean_ch0 = arma::mean(err_ch0_cycles); + double error_var_ch0 = arma::var(err_ch0_cycles); + + // 4. Peaks + double max_error_ch0 = arma::max(err_ch0_cycles); + double min_error_ch0 = arma::min(err_ch0_cycles); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << " Accumulated Carrier phase RMSE = " + << rmse_ch0 << ", mean = " << error_mean_ch0 + << ", stdev = " << sqrt(error_var_ch0) + << " (max,min) = " << max_error_ch0 + << "," << min_error_ch0 + << " [cycles]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Accumulated Carrier phase error [cycles]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Carrier Phase error [cycles]"); + //conversion between arma::vec and std:vector + std::vector error_vec(err_ch0_cycles.colptr(0), err_ch0_cycles.colptr(0) + err_ch0_cycles.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, error_vec, + "Carrier Phase error"); + g3.set_legend(); + g3.savetops(data_title + "Carrier_phase_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(rmse_ch0, 0.25); + ASSERT_LT(error_mean_ch0, 0.2); + ASSERT_GT(error_mean_ch0, -0.2); + ASSERT_LT(error_var_ch0, 0.5); + ASSERT_LT(max_error_ch0, 0.5); + ASSERT_GT(min_error_ch0, -0.5); +} + + +void HybridObservablesTestFpga::check_results_carrier_phase_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + int size1 = measured_ch0.col(0).n_rows; + int size2 = measured_ch1.col(0).n_rows; + double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + + arma::vec true_ch0_carrier_phase_interp; + arma::vec true_ch1_carrier_phase_interp; + arma::interp1(true_tow_ch0_s, true_ch0.col(3), t, true_ch0_carrier_phase_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(3), t, true_ch1_carrier_phase_interp); + + arma::vec meas_ch0_carrier_phase_interp; + arma::vec meas_ch1_carrier_phase_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(3), t, meas_ch0_carrier_phase_interp); + arma::interp1(measured_ch1.col(0), measured_ch1.col(3), t, meas_ch1_carrier_phase_interp); + + // generate double difference accumulated carrier phases + //compute error without the accumulated carrier phase offsets (which depends on the receiver starting time) + arma::vec delta_true_carrier_phase_cycles = (true_ch0_carrier_phase_interp - true_ch0_carrier_phase_interp(0)) - (true_ch1_carrier_phase_interp - true_ch1_carrier_phase_interp(0)); + arma::vec delta_measured_carrier_phase_cycles = (meas_ch0_carrier_phase_interp - meas_ch0_carrier_phase_interp(0)) - (meas_ch1_carrier_phase_interp - meas_ch1_carrier_phase_interp(0)); + + //2. RMSE + arma::vec err; + + err = delta_measured_carrier_phase_cycles - delta_true_carrier_phase_cycles; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + //3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Double diff Carrier Phase RMSE = " + << rmse << ", mean = " << error_mean + << ", stdev = " << sqrt(error_var) + << " (max,min) = " << max_error + << "," << min_error + << " [Cycles]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Carrier Phase error [Cycles]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Carrier Phase error [Cycles]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Carrier Phase error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_carrier_phase_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(rmse, 0.25); + ASSERT_LT(error_mean, 0.2); + ASSERT_GT(error_mean, -0.2); + ASSERT_LT(error_var, 0.5); + ASSERT_LT(max_error, 0.5); + ASSERT_GT(min_error, -0.5); +} + + +void HybridObservablesTestFpga::check_results_carrier_doppler_double_diff( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + int size1 = measured_ch0.col(0).n_rows; + int size2 = measured_ch1.col(0).n_rows; + double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + + arma::vec true_ch0_carrier_doppler_interp; + arma::vec true_ch1_carrier_doppler_interp; + arma::interp1(true_tow_ch0_s, true_ch0.col(2), t, true_ch0_carrier_doppler_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(2), t, true_ch1_carrier_doppler_interp); + + arma::vec meas_ch0_carrier_doppler_interp; + arma::vec meas_ch1_carrier_doppler_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(2), t, meas_ch0_carrier_doppler_interp); + arma::interp1(measured_ch1.col(0), measured_ch1.col(2), t, meas_ch1_carrier_doppler_interp); + + // generate double difference carrier Doppler + arma::vec delta_true_carrier_doppler_cycles = true_ch0_carrier_doppler_interp - true_ch1_carrier_doppler_interp; + arma::vec delta_measured_carrier_doppler_cycles = meas_ch0_carrier_doppler_interp - meas_ch1_carrier_doppler_interp; + + //2. RMSE + arma::vec err; + + err = delta_measured_carrier_doppler_cycles - delta_true_carrier_doppler_cycles; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + //3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Double diff Carrier Doppler RMSE = " + << rmse << ", mean = " << error_mean + << ", stdev = " << sqrt(error_var) + << " (max,min) = " << max_error + << "," << min_error + << " [Hz]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Carrier Doppler error [Hz]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Carrier Doppler error [Hz]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Carrier Doppler error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_carrier_doppler_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(error_mean, 5); + ASSERT_GT(error_mean, -5); + //assuming PLL BW=35 + ASSERT_LT(error_var, 200); + ASSERT_LT(max_error, 70); + ASSERT_GT(min_error, -70); + ASSERT_LT(rmse, 30); +} + + +void HybridObservablesTestFpga::check_results_carrier_doppler( + arma::mat& true_ch0, + arma::vec& true_tow_s, + arma::mat& measured_ch0, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = measured_ch0(0, 0); + int size1 = measured_ch0.col(0).n_rows; + double t1 = measured_ch0(size1 - 1, 0); + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + arma::vec true_ch0_doppler_interp; + arma::interp1(true_tow_s, true_ch0.col(2), t, true_ch0_doppler_interp); + + arma::vec meas_ch0_doppler_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(2), t, meas_ch0_doppler_interp); + + //2. RMSE + arma::vec err_ch0_hz; + + //compute error + err_ch0_hz = meas_ch0_doppler_interp - true_ch0_doppler_interp; + + arma::vec err2_ch0 = arma::square(err_ch0_hz); + double rmse_ch0 = sqrt(arma::mean(err2_ch0)); + + //3. Mean err and variance + double error_mean_ch0 = arma::mean(err_ch0_hz); + double error_var_ch0 = arma::var(err_ch0_hz); + + // 4. Peaks + double max_error_ch0 = arma::max(err_ch0_hz); + double min_error_ch0 = arma::min(err_ch0_hz); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Carrier Doppler RMSE = " + << rmse_ch0 << ", mean = " << error_mean_ch0 + << ", stdev = " << sqrt(error_var_ch0) + << " (max,min) = " << max_error_ch0 + << "," << min_error_ch0 + << " [Hz]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Carrier Doppler error [Hz]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Carrier Doppler error [Hz]"); + //conversion between arma::vec and std:vector + std::vector error_vec(err_ch0_hz.colptr(0), err_ch0_hz.colptr(0) + err_ch0_hz.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, error_vec, + "Carrier Doppler error"); + g3.set_legend(); + g3.savetops(data_title + "Carrier_doppler_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(error_mean_ch0, 5); + ASSERT_GT(error_mean_ch0, -5); + //assuming PLL BW=35 + ASSERT_LT(error_var_ch0, 200); + ASSERT_LT(max_error_ch0, 70); + ASSERT_GT(min_error_ch0, -70); + ASSERT_LT(rmse_ch0, 30); +} + +bool HybridObservablesTestFpga::save_mat_xy(std::vector& x, std::vector& y, std::string filename) +{ + try + { + // WRITE MAT FILE + mat_t* matfp; + matvar_t* matvar; + filename.append(".mat"); + std::cout << "save_mat_xy write " << filename << std::endl; + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT5); + if (reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, x.size()}; + matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &x[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("y", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &y[0], 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + else + { + std::cout << "save_mat_xy: error creating file" << std::endl; + } + Mat_Close(matfp); + return true; + } + catch (const std::exception& ex) + { + std::cout << "save_mat_xy: " << ex.what() << std::endl; + return false; + } +} + +void HybridObservablesTestFpga::check_results_code_pseudorange( + arma::mat& true_ch0, + arma::mat& true_ch1, + arma::vec& true_tow_ch0_s, + arma::vec& true_tow_ch1_s, + arma::mat& measured_ch0, + arma::mat& measured_ch1, + std::string data_title) +{ + //1. True value interpolation to match the measurement times + + double t0 = std::max(measured_ch0(0, 0), measured_ch1(0, 0)); + int size1 = measured_ch0.col(0).n_rows; + int size2 = measured_ch1.col(0).n_rows; + double t1 = std::min(measured_ch0(size1 - 1, 0), measured_ch1(size2 - 1, 0)); + + arma::vec t = arma::linspace(t0, t1, floor((t1 - t0) * 1e3)); + //conversion between arma::vec and std:vector + arma::vec t_from_start = arma::linspace(0, t1 - t0, floor((t1 - t0) * 1e3)); + std::vector time_vector(t_from_start.colptr(0), t_from_start.colptr(0) + t_from_start.n_rows); + + + arma::vec true_ch0_dist_interp; + arma::vec true_ch1_dist_interp; + arma::interp1(true_tow_ch0_s, true_ch0.col(1), t, true_ch0_dist_interp); + arma::interp1(true_tow_ch1_s, true_ch1.col(1), t, true_ch1_dist_interp); + + arma::vec meas_ch0_dist_interp; + arma::vec meas_ch1_dist_interp; + arma::interp1(measured_ch0.col(0), measured_ch0.col(4), t, meas_ch0_dist_interp); + arma::interp1(measured_ch1.col(0), measured_ch1.col(4), t, meas_ch1_dist_interp); + + // generate delta pseudoranges + arma::vec delta_true_dist_m = true_ch0_dist_interp - true_ch1_dist_interp; + arma::vec delta_measured_dist_m = meas_ch0_dist_interp - meas_ch1_dist_interp; + + //2. RMSE + arma::vec err; + + err = delta_measured_dist_m - delta_true_dist_m; + arma::vec err2 = arma::square(err); + double rmse = sqrt(arma::mean(err2)); + + //3. Mean err and variance + double error_mean = arma::mean(err); + double error_var = arma::var(err); + + // 4. Peaks + double max_error = arma::max(err); + double min_error = arma::min(err); + + //5. report + std::streamsize ss = std::cout.precision(); + std::cout << std::setprecision(10) << data_title << "Double diff Pseudorange RMSE = " + << rmse << ", mean = " << error_mean + << ", stdev = " << sqrt(error_var) + << " (max,min) = " << max_error + << "," << min_error + << " [meters]" << std::endl; + std::cout.precision(ss); + + //plots + if (FLAGS_show_plots) + { + Gnuplot g3("linespoints"); + g3.set_title(data_title + "Double diff Pseudorange error [m]"); + g3.set_grid(); + g3.set_xlabel("Time [s]"); + g3.set_ylabel("Double diff Pseudorange error [m]"); + //conversion between arma::vec and std:vector + std::vector range_error_m(err.colptr(0), err.colptr(0) + err.n_rows); + g3.cmd("set key box opaque"); + g3.plot_xy(time_vector, range_error_m, + "Double diff Pseudorrange error"); + g3.set_legend(); + g3.savetops(data_title + "double_diff_pseudorrange_error"); + + g3.showonscreen(); // window output + } + + //check results against the test tolerance + ASSERT_LT(rmse, 3.0); + ASSERT_LT(error_mean, 1.0); + ASSERT_GT(error_mean, -1.0); + ASSERT_LT(error_var, 10.0); + ASSERT_LT(max_error, 10.0); + ASSERT_GT(min_error, -10.0); +} + +bool HybridObservablesTestFpga::ReadRinexObs(std::vector* obs_vec, Gnss_Synchro gnss) +{ + // Open and read reference RINEX observables file + try + { + gpstk::Rinex3ObsStream r_ref(FLAGS_filename_rinex_obs); + r_ref.exceptions(std::ios::failbit); + gpstk::Rinex3ObsData r_ref_data; + gpstk::Rinex3ObsHeader r_ref_header; + + gpstk::RinexDatum dataobj; + + r_ref >> r_ref_header; + + std::vector first_row; + gpstk::SatID prn; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + first_row.push_back(true); + obs_vec->push_back(arma::zeros(1, 4)); + } + while (r_ref >> r_ref_data) + { + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + int myprn = gnss_synchro_vec.at(n).PRN; + + switch (gnss.System) + { + case 'G': + prn = gpstk::SatID(myprn, gpstk::SatID::systemGPS); + break; + case 'E': + prn = gpstk::SatID(myprn, gpstk::SatID::systemGalileo); + break; + default: + prn = gpstk::SatID(myprn, gpstk::SatID::systemGPS); + } + + gpstk::CommonTime time = r_ref_data.time; + double sow(static_cast(time).sow); + + gpstk::Rinex3ObsData::DataMap::iterator pointer = r_ref_data.obs.find(prn); + if (pointer == r_ref_data.obs.end()) + { + // PRN not present; do nothing + } + else + { + if (first_row.at(n) == false) + { + //insert next column + obs_vec->at(n).insert_rows(obs_vec->at(n).n_rows, 1); + } + else + { + first_row.at(n) = false; + } + if (strcmp("1C\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; //C1C P1 (psudorange L1) + dataobj = r_ref_data.getObs(prn, "D1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; //D1C Carrier Doppler + dataobj = r_ref_data.getObs(prn, "L1C", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; //L1C Carrier Phase + } + else if (strcmp("1B\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L1B", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("2S\0", gnss.Signal) == 0) //L2M + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L2S", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("L5\0", gnss.Signal) == 0) + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L5I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else if (strcmp("5X\0", gnss.Signal) == 0) //Simulator gives RINEX with E5a+E5b + { + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 0) = sow; + dataobj = r_ref_data.getObs(prn, "C8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 1) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "D8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 2) = dataobj.data; + dataobj = r_ref_data.getObs(prn, "L8I", r_ref_header); + obs_vec->at(n)(obs_vec->at(n).n_rows - 1, 3) = dataobj.data; + } + else + { + std::cout << "ReadRinexObs unknown signal requested: " << gnss.Signal << std::endl; + return false; + } + } + } + } // end while + } // End of 'try' block + catch (const gpstk::FFStreamError& e) + { + std::cout << e; + return false; + } + catch (const gpstk::Exception& e) + { + std::cout << e; + return false; + } + catch (const std::exception& e) + { + std::cout << "Exception: " << e.what(); + std::cout << "unknown error. I don't feel so well..." << std::endl; + return false; + } + std::cout << "ReadRinexObs info:" << std::endl; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + std::cout << "SAT PRN " << gnss_synchro_vec.at(n).PRN << " RINEX epoch readed: " << obs_vec->at(n).n_rows << std::endl; + } + return true; +} +TEST_F(HybridObservablesTestFpga, ValidationOfResults) +{ + + // pointer to the DMA thread that sends the samples to the acquisition engine + pthread_t thread_DMA; + + struct DMA_handler_args_obs_test args; + + // Configure the signal generator + configure_generator(); + + // Generate signal raw signal samples and observations RINEX file + if (FLAGS_disable_generator == false) + { + generate_signal(); + } + + std::chrono::time_point start, end; + std::chrono::duration elapsed_seconds(0); + + // use generator or use an external capture file + if (FLAGS_enable_external_signal_file) + { + //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters + ASSERT_EQ(acquire_signal(), true); + } + else + { + Gnss_Synchro tmp_gnss_synchro; + tmp_gnss_synchro.System = 'G'; + std::string signal = "1C"; + signal.copy(tmp_gnss_synchro.Signal, 2, 0); + + std::istringstream ss(FLAGS_test_satellite_PRN_list); + std::string token; + + while (std::getline(ss, token, ',')) + { + tmp_gnss_synchro.PRN = boost::lexical_cast(token); + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + } + + + configure_receiver(FLAGS_PLL_bw_hz_start, + FLAGS_DLL_bw_hz_start, + FLAGS_PLL_narrow_bw_hz, + FLAGS_DLL_narrow_bw_hz, + FLAGS_extend_correlation_symbols); + + + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + //setup the signal synchronization, simulating an acquisition + if (!FLAGS_enable_external_signal_file) + { + //based on true observables metadata (for custom sdr generator) + //open true observables log file written by the simulator or based on provided RINEX obs + std::vector> true_reader_vec; + //read true data from the generator logs + true_reader_vec.push_back(std::make_shared()); + std::cout << "Loading true observable data for PRN " << gnss_synchro_vec.at(n).PRN << std::endl; + std::string true_obs_file = std::string("./gps_l1_ca_obs_prn"); + true_obs_file.append(std::to_string(gnss_synchro_vec.at(n).PRN)); + true_obs_file.append(".dat"); + ASSERT_NO_THROW({ + if (true_reader_vec.back()->open_obs_file(true_obs_file) == false) + { + throw std::exception(); + }; + }) << "Failure opening true observables file"; + + // load acquisition data based on the first epoch of the true observations + ASSERT_NO_THROW({ + if (true_reader_vec.back()->read_binary_obs() == false) + { + throw std::exception(); + }; + }) << "Failure reading true observables file"; + + //restart the epoch counter + true_reader_vec.back()->restart(); + + std::cout << "Initial Doppler [Hz]=" << true_reader_vec.back()->doppler_l1_hz << " Initial code delay [Chips]=" + << true_reader_vec.back()->prn_delay_chips << std::endl; + gnss_synchro_vec.at(n).Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_reader_vec.back()->prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD; + gnss_synchro_vec.at(n).Acq_doppler_hz = true_reader_vec.back()->doppler_l1_hz; + gnss_synchro_vec.at(n).Acq_samplestamp_samples = 0; + } + else + { + //based on the signal acquisition process + std::cout << "Estimated Initial Doppler " << gnss_synchro_vec.at(n).Acq_doppler_hz + << " [Hz], estimated Initial code delay " << gnss_synchro_vec.at(n).Acq_delay_samples << " [Samples]" + << " Acquisition SampleStamp is " << gnss_synchro_vec.at(n).Acq_samplestamp_samples << std::endl; + gnss_synchro_vec.at(n).Acq_samplestamp_samples = 0; + } + } + + unsigned int code_length; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + } + + float nbits = ceilf(log2f((float)code_length)); + unsigned int fft_size = pow(2, nbits); + + + std::vector> tracking_ch_vec; + std::vector> tlm_ch_vec; + + std::vector null_sink_vec; + for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) + { + //set channels ids + gnss_synchro_vec.at(n).Channel_ID = n; + + //create the tracking channels and create the telemetry decoders + + std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); + tracking_ch_vec.push_back(std::dynamic_pointer_cast(trk_)); + std::shared_ptr tlm_ = factory->GetBlock(config, "TelemetryDecoder", config->property("TelemetryDecoder.implementation", std::string("undefined")), 1, 1); + tlm_ch_vec.push_back(std::dynamic_pointer_cast(tlm_)); + + //create null sinks for observables output + null_sink_vec.push_back(gr::blocks::null_sink::make(sizeof(Gnss_Synchro))); + + ASSERT_NO_THROW({ + tlm_ch_vec.back()->set_channel(gnss_synchro_vec.at(n).Channel_ID); + + switch (gnss_synchro_master.System) + { + case 'G': + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("GPS"), gnss_synchro_vec.at(n).PRN)); + break; + case 'E': + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("Galileo"), gnss_synchro_vec.at(n).PRN)); + break; + default: + tlm_ch_vec.back()->set_satellite(Gnss_Satellite(std::string("GPS"), gnss_synchro_vec.at(n).PRN)); + } + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + tracking_ch_vec.back()->set_channel(gnss_synchro_vec.at(n).Channel_ID); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + tracking_ch_vec.back()->set_gnss_synchro(&gnss_synchro_vec.at(n)); + }) << "Failure setting gnss_synchro."; + } + + top_block = gr::make_top_block("Telemetry_Decoder test"); + boost::shared_ptr dummy_msg_rx_trk = HybridObservablesTest_msg_rx_Fpga_make(); + boost::shared_ptr dummy_tlm_msg_rx = HybridObservablesTest_tlm_msg_rx_Fpga_make(); + //Observables + std::shared_ptr observables(new HybridObservables(config.get(), "Observables", tracking_ch_vec.size() + 1, tracking_ch_vec.size())); + + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + ASSERT_NO_THROW({ + tracking_ch_vec.at(n)->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + } + + std::string file; + const char* file_name; + + ASSERT_NO_THROW({ + //std::string file; + if (!FLAGS_enable_external_signal_file) + { + file = "./" + filename_raw_data; + } + else + { + file = FLAGS_signal_file; + } + //const char* file_name = file.c_str(); + file_name = file.c_str(); + //gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + int observable_interval_ms = 20; + gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); + //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + //top_block->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); + + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + //top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); + top_block->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); + top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); + } + //connect sample counter and timmer to the last channel in observables block (extra channel) + top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); + + //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + }) << "Failure connecting the blocks."; + + // create acquisition class such that a global Reset is produced for all the HW and the sample counters are reset to 0 + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + std::shared_ptr acquisition_Fpga; + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + std::shared_ptr acquisition_Fpga; + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + std::shared_ptr acquisition_Fpga; + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + std::shared_ptr acquisition_Fpga; + acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } + + args.file = file; + args.nsamples_tx = TEST_OBS_NSAMPLES_TRACKING; // number of samples to transfer + + + //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) + //{ + // args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; + //} + //else + //{ + args.skip_used_samples = 0; + //} + + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + tracking_ch_vec.at(n)->start_tracking(); + } + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex_obs_test); + + top_block->start(); + + + + + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + //top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + }) << "Failure running the top_block."; + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + top_block->stop(); + + // send more samples to unblock the tracking process in case it was waiting for samples + args.file = file; + //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) + //{ + // skip the samples that have already been used + args.skip_used_samples = args.nsamples_tx; + //} + //else + //{ + // args.skip_used_samples = 0; + //} + args.nsamples_tx = TEST_OBS_NSAMPLES_FINAL; + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + pthread_join(thread_DMA, NULL); + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); + + + + //check results + // Matrices for storing columnwise true GPS time, Range, Doppler and Carrier phase + std::vector true_obs_vec; + + if (!FLAGS_enable_external_signal_file) + { + //load the true values + true_observables_reader true_observables; + ASSERT_NO_THROW({ + if (true_observables.open_obs_file(std::string("./obs_out.bin")) == false) + { + throw std::exception(); + } + }) << "Failure opening true observables file"; + + unsigned int nepoch = static_cast(true_observables.num_epochs()); + + std::cout << "True observation epochs = " << nepoch << std::endl; + + true_observables.restart(); + int64_t epoch_counter = 0; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + true_obs_vec.push_back(arma::zeros(nepoch, 4)); + } + + ASSERT_NO_THROW({ + while (true_observables.read_binary_obs()) + { + for (unsigned int n = 0; n < true_obs_vec.size(); n++) + { + if (round(true_observables.prn[n]) != gnss_synchro_vec.at(n).PRN) + { + std::cout << "True observables SV PRN does not match measured ones: " + << round(true_observables.prn[n]) << " vs. " << gnss_synchro_vec.at(n).PRN << std::endl; + throw std::exception(); + } + true_obs_vec.at(n)(epoch_counter, 0) = true_observables.gps_time_sec[n]; + true_obs_vec.at(n)(epoch_counter, 1) = true_observables.dist_m[n]; + true_obs_vec.at(n)(epoch_counter, 2) = true_observables.doppler_l1_hz[n]; + true_obs_vec.at(n)(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[n]; + } + epoch_counter++; + } + }); + } + else + { + ASSERT_EQ(ReadRinexObs(&true_obs_vec, gnss_synchro_master), true) + << "Failure reading RINEX file"; + } + //read measured values + observables_dump_reader estimated_observables(tracking_ch_vec.size()); + ASSERT_NO_THROW({ + if (estimated_observables.open_obs_file(std::string("./observables.dat")) == false) + { + throw std::exception(); + } + }) << "Failure opening dump observables file"; + + unsigned int nepoch = static_cast(estimated_observables.num_epochs()); + std::cout << "Measured observations epochs = " << nepoch << std::endl; + + // Matrices for storing columnwise measured RX_time, TOW, Doppler, Carrier phase and Pseudorange + std::vector measured_obs_vec; + std::vector epoch_counters_vec; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + measured_obs_vec.push_back(arma::zeros(nepoch, 5)); + epoch_counters_vec.push_back(0); + } + + estimated_observables.restart(); + while (estimated_observables.read_binary_obs()) + { + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (static_cast(estimated_observables.valid[n])) + { + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 3) = estimated_observables.Acc_carrier_phase_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 4) = estimated_observables.Pseudorange_m[n]; + epoch_counters_vec.at(n)++; + } + } + } + + + //Cut measurement tail zeros + arma::uvec index; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + index = arma::find(measured_obs_vec.at(n).col(0) > 0.0, 1, "last"); + if ((index.size() > 0) and index(0) < (nepoch - 1)) + { + measured_obs_vec.at(n).shed_rows(index(0) + 1, nepoch - 1); + } + } + + //Cut measurement initial transitory of the measurements + + double initial_transitory_s = FLAGS_skip_obs_transitory_s; + + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + index = arma::find(measured_obs_vec.at(n).col(0) >= (measured_obs_vec.at(n)(0, 0) + initial_transitory_s), 1, "first"); + if ((index.size() > 0) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } + + index = arma::find(measured_obs_vec.at(n).col(0) >= true_obs_vec.at(n)(0, 0), 1, "first"); + if ((index.size() > 0) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } + } + + + //Correct the clock error using true values (it is not possible for a receiver to correct + //the receiver clock offset error at the observables level because it is required the + //decoding of the ephemeris data and solve the PVT equations) + + //Find the reference satellite (the nearest) and compute the receiver time offset at observable level + double min_pr = std::numeric_limits::max(); + unsigned int min_pr_ch_id = 0; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + { + if (measured_obs_vec.at(n)(0, 4) < min_pr) + { + min_pr = measured_obs_vec.at(n)(0, 4); + min_pr_ch_id = n; + } + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } + + arma::vec receiver_time_offset_ref_channel_s; + receiver_time_offset_ref_channel_s = true_obs_vec.at(min_pr_ch_id).col(1) / GPS_C_m_s - GPS_STARTOFFSET_ms / 1000.0; + std::cout << "Ref channel initial Receiver time offset " << receiver_time_offset_ref_channel_s(0) * 1e3 << " [ms]" << std::endl; + + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + //debug save to .mat + std::vector tmp_vector_x(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y(true_obs_vec.at(n).col(1).colptr(0), + true_obs_vec.at(n).col(1).colptr(0) + true_obs_vec.at(n).col(1).n_rows); + save_mat_xy(tmp_vector_x, tmp_vector_y, std::string("true_pr_ch_" + std::to_string(n))); + + std::vector tmp_vector_x2(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y2(measured_obs_vec.at(n).col(4).colptr(0), + measured_obs_vec.at(n).col(4).colptr(0) + measured_obs_vec.at(n).col(4).n_rows); + save_mat_xy(tmp_vector_x2, tmp_vector_y2, std::string("measured_pr_ch_" + std::to_string(n))); + + std::vector tmp_vector_x3(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y3(true_obs_vec.at(n).col(2).colptr(0), + true_obs_vec.at(n).col(2).colptr(0) + true_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x3, tmp_vector_y3, std::string("true_doppler_ch_" + std::to_string(n))); + + std::vector tmp_vector_x4(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y4(measured_obs_vec.at(n).col(2).colptr(0), + measured_obs_vec.at(n).col(2).colptr(0) + measured_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x4, tmp_vector_y4, std::string("measured_doppler_ch_" + std::to_string(n))); + + + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + arma::vec true_TOW_ref_ch_s = true_obs_vec.at(min_pr_ch_id).col(0) - receiver_time_offset_ref_channel_s(0); + arma::vec true_TOW_ch_s = true_obs_vec.at(n).col(0) - receiver_time_offset_ref_channel_s(0); + //Compare measured observables + if (min_pr_ch_id != n) + { + check_results_code_pseudorange(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_phase_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + + check_results_carrier_doppler_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + else + { + std::cout << "[CH " << std::to_string(n) << "] PRN " << std::to_string(gnss_synchro_vec.at(n).PRN) << " is the reference satellite" << std::endl; + } + if (FLAGS_compute_single_diffs) + { + check_results_carrier_phase(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_doppler(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } + std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; +} diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 3680f91d2..b0f31b39a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -345,10 +345,10 @@ void TrackingPullInTestFpga::configure_receiver( std::string signal = "5X"; System_and_Signal = "Galileo E5a"; signal.copy(gnss_synchro.Signal, 2, 0); - if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) - { - config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); - } + //if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) + // { + // config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); + // } config->set_property("Tracking.early_late_space_chips", "0.5"); config->set_property("Tracking.track_pilot", "false"); config->set_property("Tracking.order", "2"); From f333c05305677dda8cac0ad6a66b6bccc5c67b2c Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Tue, 18 Sep 2018 11:36:12 +0200 Subject: [PATCH 06/53] saving temporary changes before merging with usptream next branch added functions that allow the tests to read the scaling factor used by the FFT and the IFFT during acquisition --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 6 + ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 5 + .../galileo_e5a_pcps_acquisition_fpga.cc | 6 + .../galileo_e5a_pcps_acquisition_fpga.h | 5 + .../gps_l1_ca_pcps_acquisition_fpga.cc | 7 + .../gps_l1_ca_pcps_acquisition_fpga.h | 5 + .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 5 + .../adapters/gps_l5i_pcps_acquisition_fpga.h | 5 + .../gnuradio_blocks/pcps_acquisition_fpga.cc | 5 +- .../gnuradio_blocks/pcps_acquisition_fpga.h | 5 + .../acquisition/libs/fpga_acquisition.cc | 9 + .../acquisition/libs/fpga_acquisition.h | 5 + .../hybrid_observables_test_fpga.cc | 504 +++++++++--------- .../tracking/tracking_pull-in_test_fpga.cc | 16 +- 14 files changed, 333 insertions(+), 255 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index c010cc19b..b3956368b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -491,6 +491,12 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::reset_acquisition(void) acquisition_fpga_->reset_acquisition(); } +// this function is only used for the unit tests +void GalileoE1PcpsAmbiguousAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +{ + acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +} + void GalileoE1PcpsAmbiguousAcquisitionFpga::connect(gr::top_block_sptr top_block) { // printf("top acq connect\n"); diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index f142c74f6..7dea9e459 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -151,6 +151,11 @@ public: */ void reset_acquisition(void); + /*! + * \brief This function is only used in the unit tests + */ + void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + private: ConfigurationInterface* configuration_; //pcps_acquisition_sptr acquisition_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 4c75d34d9..d5557286d 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -375,6 +375,12 @@ void GalileoE5aPcpsAcquisitionFpga::reset_acquisition(void) acquisition_fpga_->reset_acquisition(); } +// this function is only used for the unit tests +void GalileoE5aPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +{ + acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +} + void GalileoE5aPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { // if (item_type_.compare("gr_complex") == 0) diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index 2d1df0ca6..b2791a7d9 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -139,6 +139,11 @@ public: */ void reset_acquisition(void); + /*! + * \brief This function is only used in the unit tests + */ + void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + private: //float calculate_threshold(float pfa); diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 84ecac49a..71350ea42 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -278,6 +278,13 @@ void GpsL1CaPcpsAcquisitionFpga::reset_acquisition(void) acquisition_fpga_->reset_acquisition(); } +// this function is only used for the unit tests +void GpsL1CaPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +{ + acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +} + + void GpsL1CaPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { // nothing to connect diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index 4b0d3da9b..9231f3a70 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -149,6 +149,11 @@ public: */ void reset_acquisition(void); + /*! + * \brief This function is only used in the unit tests + */ + void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + private: ConfigurationInterface* configuration_; pcps_acquisition_fpga_sptr acquisition_fpga_; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 9e9691745..cb76cd4c8 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -342,6 +342,11 @@ void GpsL5iPcpsAcquisitionFpga::reset_acquisition(void) acquisition_fpga_->reset_acquisition(); } +// this function is only used for the unit tests +void GpsL5iPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +{ + acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +} void GpsL5iPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index f52cc6799..1f9638e9d 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -149,6 +149,11 @@ public: */ void reset_acquisition(void); + /*! + * \brief This function is only used in the unit tests + */ + void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + private: ConfigurationInterface* configuration_; //pcps_acquisition_sptr acquisition_; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index edb459669..88ef69f48 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -406,4 +406,7 @@ void pcps_acquisition_fpga::reset_acquisition(void) acquisition_fpga->reset_acquisition(); } - +void pcps_acquisition_fpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +{ + acquisition_fpga->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +} diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index 45cce7339..dec5962f7 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -246,6 +246,11 @@ public: * \brief This funciton is only used for the unit tests */ void reset_acquisition(void); + + /*! + * \brief This funciton is only used for the unit tests + */ + void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); }; #endif /* GNSS_SDR_PCPS_ACQUISITION_FPGA_H_*/ diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index ca228cc3d..3c97f1b29 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -509,3 +509,12 @@ void fpga_acquisition::set_single_doppler_flag(unsigned int single_doppler_flag) d_single_doppler_flag = single_doppler_flag; } +// this function is only used for the unit tests +void fpga_acquisition::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +{ + uint32_t readval = 0; + readval = d_map_base[7]; + *total_scale_factor = readval; + readval = d_map_base[8]; + *fw_scale_factor = readval; +} diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index a5b0d29db..9e84ab334 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -98,6 +98,11 @@ public: */ void reset_acquisition(void); + /*! + * \brief this function is only used in the unit test + */ + void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + private: int64_t d_fs_in; // data related to the hardware module and the driver diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index e79f48288..cf823c8cb 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -843,269 +843,269 @@ bool HybridObservablesTestFpga::acquire_signal() } } else - { - unsigned int code_length; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); - - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); - } - - float nbits = ceilf(log2f((float)code_length)); - unsigned int fft_size = pow(2, nbits); - unsigned int nsamples_total = fft_size; - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_single_doppler_flag(1); - } - - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); - int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); - - int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - - float result_table[MAX_PRN_IDX][num_doppler_steps][2]; - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + unsigned int code_length; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - - uint32_t max_index = 0; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - float max_magnitude_iteration; - uint64_t initial_sample_iteration; - float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - tmp_gnss_synchro.PRN = PRN; - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } - - args.file = file; - args.nsamples_tx = fft_size; //50000; // max size of the FFT - if (test_observables_skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } - - // create DMA child process - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); - } - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - } - - result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = power_sum_iteration; - doppler_num = doppler_num + 1; - - if (max_magnitude_iteration > max_magnitude) - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - initial_sample = initial_sample_iteration; - power_sum = power_sum_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - top_block->stop(); - } - - power_sum = (power_sum - max_magnitude) / (fft_size - 1); - float test_statistics = (max_magnitude / power_sum); - float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - if (test_statistics > threshold) - { - std::cout << " " << PRN << " "; - //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) - gnss_synchro_vec.push_back(tmp_gnss_synchro); - } - else - { - std::cout << " . "; - } - - std::cout.flush(); + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); } - - uint32_t max_index = 0; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float power_sum = 0; - uint32_t doppler_index = 0; - - if (test_observables_show_results_table == 1) + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + } + + float nbits = ceilf(log2f((float)code_length)); + unsigned int fft_size = pow(2, nbits); + unsigned int nsamples_total = fft_size; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_single_doppler_flag(1); + } + + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + + int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; + + float result_table[MAX_PRN_IDX][num_doppler_steps][2]; + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) { - std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + + uint32_t max_index = 0; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float power_sum = 0; + uint32_t doppler_index = 0; + + uint32_t max_index_iteration; + float max_magnitude_iteration; + uint64_t initial_sample_iteration; + float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; + + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { - max_magnitude = result_table[PRN][doppler_num][0]; - power_sum = result_table[PRN][doppler_num][1]; + tmp_gnss_synchro.PRN = PRN; + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL1Ca_Fpga->set_doppler_step(0); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE1_Fpga->set_doppler_step(0); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE5a_Fpga->set_doppler_step(0); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL5_Fpga->set_doppler_step(0); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } + + args.file = file; + args.nsamples_tx = fft_size; //50000; // max size of the FFT + if (test_observables_skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } + + // create DMA child process + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex_obs_test); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); + } + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); + + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + } + + result_table[PRN][doppler_num][0] = max_magnitude_iteration; + result_table[PRN][doppler_num][1] = power_sum_iteration; doppler_num = doppler_num + 1; - std::cout << "Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << "Power sum = " << power_sum << std::endl; + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + initial_sample = initial_sample_iteration; + power_sum = power_sum_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + top_block->stop(); + } - power_sum = (power_sum - max_magnitude) / (fft_size - 1); - float test_statistics = (max_magnitude / power_sum); - std::cout << "test_statistics = " << test_statistics << std::endl; + power_sum = (power_sum - max_magnitude) / (fft_size - 1); + float test_statistics = (max_magnitude / power_sum); + float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); + if (test_statistics > threshold) + { + std::cout << " " << PRN << " "; + //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); + //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); + //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + else + { + std::cout << " . "; + } + std::cout.flush(); + + } + + uint32_t max_index = 0; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float power_sum = 0; + uint32_t doppler_index = 0; + + if (test_observables_show_results_table == 1) + { + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; + int doppler_num = 0; + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + max_magnitude = result_table[PRN][doppler_num][0]; + power_sum = result_table[PRN][doppler_num][1]; + doppler_num = doppler_num + 1; + + std::cout << "Doppler shift " << doppler_shift << std::endl; + std::cout << "Max magnitude = " << max_magnitude << "Power sum = " << power_sum << std::endl; + + power_sum = (power_sum - max_magnitude) / (fft_size - 1); + float test_statistics = (max_magnitude / power_sum); + std::cout << "test_statistics = " << test_statistics << std::endl; + + } } } - } - } + } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -1899,7 +1899,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } } - + printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Signal Acquired\n"); configure_receiver(FLAGS_PLL_bw_hz_start, FLAGS_DLL_bw_hz_start, FLAGS_PLL_narrow_bw_hz, diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index b0f31b39a..af1704dfc 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -901,7 +901,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - float result_table[MAX_PRN_IDX][num_doppler_steps][2]; + float result_table[MAX_PRN_IDX][num_doppler_steps][4]; for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) { @@ -913,6 +913,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) uint32_t doppler_index = 0; uint32_t max_index_iteration; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; float max_magnitude_iteration; uint64_t initial_sample_iteration; float power_sum_iteration; @@ -1039,22 +1041,28 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } result_table[PRN][doppler_num][0] = max_magnitude_iteration; result_table[PRN][doppler_num][1] = power_sum_iteration; + result_table[PRN][doppler_num][2] = total_fft_scaling_factor; + result_table[PRN][doppler_num][3] = fw_fft_scaling_factor; doppler_num = doppler_num + 1; if (max_magnitude_iteration > max_magnitude) @@ -1089,6 +1097,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } uint32_t max_index = 0; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; float max_magnitude = 0.0; uint64_t initial_sample = 0; float power_sum = 0; @@ -1104,11 +1114,13 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { max_magnitude = result_table[PRN][doppler_num][0]; power_sum = result_table[PRN][doppler_num][1]; + total_fft_scaling_factor = result_table[PRN][doppler_num][2]; + fw_fft_scaling_factor = result_table[PRN][doppler_num][3]; doppler_num = doppler_num + 1; std::cout << "Doppler shift " << doppler_shift << std::endl; std::cout << "Max magnitude = " << max_magnitude << "Power sum = " << power_sum << std::endl; - + std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << " FW FFT scaling factor = " << fw_fft_scaling_factor << std::endl; power_sum = (power_sum - max_magnitude) / (fft_size - 1); float test_statistics = (max_magnitude / power_sum); std::cout << "test_statistics = " << test_statistics << std::endl; From 2826dd21d3249691197da3a51d700ca76a62dbbe Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Thu, 4 Oct 2018 17:49:09 +0200 Subject: [PATCH 07/53] use of the :2 decimator in the GPS L1/Galileo E1 frequency band added methods to the L1 and E1 FPGA acquisition classes for the unit tests to be able to control the doppler sweep from the SW instead of the HW. In this way we can produce more detailed results. --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 3 +- .../gps_l1_ca_pcps_acquisition_fpga.cc | 2 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 30 +++++++++- .../gnuradio_blocks/pcps_acquisition_fpga.h | 2 +- .../acquisition/libs/fpga_acquisition.cc | 2 +- .../acquisition/libs/fpga_acquisition.h | 2 + .../dll_pll_veml_tracking_fpga.cc | 4 +- .../hybrid_observables_test_fpga.cc | 55 +++++++++++++++++-- .../tracking/tracking_pull-in_test_fpga.cc | 13 +++-- 9 files changed, 95 insertions(+), 18 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index b3956368b..63de5cf9b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -59,8 +59,9 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); + float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 2.0); acq_parameters.downsampling_factor = downsampling_factor; + //fs_in = fs_in/2.0; // downampling filter //printf("fs_in pre downsampling = %ld\n", fs_in); diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 71350ea42..38093a84f 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -61,7 +61,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); + float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 2.0); acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter //printf("fs_in pre downsampling = %ld\n", fs_in); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 88ef69f48..33e2d104f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -75,8 +75,10 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( d_test_statistics = 0.0; d_channel = 0U; d_gnss_synchro = 0; + d_single_doppler_flag = false; d_downsampling_factor = acq_parameters.downsampling_factor; + printf("downsampling_factor = %f\n", d_downsampling_factor); d_select_queue_Fpga = acq_parameters.select_queue_Fpga; //printf("zzzz acq_parameters.code_length = %d\n", acq_parameters.code_length); //printf("zzzz acq_parameters.samples_per_ms = %d\n", acq_parameters.samples_per_ms); @@ -300,10 +302,21 @@ void pcps_acquisition_fpga::set_active(bool active) // temp_d_input_power = d_input_power; d_input_power = (d_input_power - d_mag) / (d_fft_size - 1); - int32_t doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); + int32_t doppler; + if (d_single_doppler_flag == false) + { + doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); + //doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index); // this is the wrong one + } + else + { + doppler = static_cast(acq_parameters.doppler_max); + } //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % (2*acq_parameters.samples_per_code))); + //printf("acq gnuradioblock doppler = %d\n", doppler); + d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_sample_counter = initial_sample; @@ -311,13 +324,21 @@ void pcps_acquisition_fpga::set_active(bool active) { if (d_downsampling_factor > 1) { + //printf("yes here\n"); d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext % acq_parameters.samples_per_code)); - d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5*d_downsampling_factor; // delay due to the downsampling filter in the acquisition + d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % acq_parameters.samples_per_code)); + //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext)); + //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter*2 - 81; + //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; } else { d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5*d_downsampling_factor; } } else @@ -364,6 +385,10 @@ void pcps_acquisition_fpga::set_active(bool active) // printf("##### debug_doppler_index = %d\n",debug_doppler_index); send_positive_acquisition(); d_state = 0; // Positive acquisition + + //printf("acq d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); + //printf("acq d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); + } else { @@ -390,6 +415,7 @@ int pcps_acquisition_fpga::general_work(int noutput_items __attribute__((unused) void pcps_acquisition_fpga::set_single_doppler_flag(unsigned int single_doppler_flag) { acquisition_fpga->set_single_doppler_flag(single_doppler_flag); + d_single_doppler_flag = true; } // this function is only used for the unit tests diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index dec5962f7..e9800f97f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -126,7 +126,7 @@ private: float d_downsampling_factor; uint32_t d_select_queue_Fpga; - + bool d_single_doppler_flag; public: diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 3c97f1b29..8ae772eb8 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -327,7 +327,7 @@ void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) d_map_base[3] = phase_step_rad_int; // repeat the calculation with the doppler step - doppler = 0; + doppler = static_cast(d_doppler_step); phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); //printf("AAA phase_step_rad_real for doppler step = %f\n", phase_step_rad_real); diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index 9e84ab334..192ff8cc4 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -76,6 +76,7 @@ public: { //printf("acq lib set doppler max called\n"); d_doppler_max = doppler_max; + //printf("set acq lib d_doppler_max = %d\n", (int) d_doppler_max); } /*! @@ -86,6 +87,7 @@ public: { //printf("acq lib set doppler step called\n"); d_doppler_step = doppler_step; + //printf("set acq lib d_doppler_step = %d\n", (int) d_doppler_step); } /*! diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 1d88e33ef..34378589a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -1258,10 +1258,10 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un { // normal operation uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples) / d_correlation_length_samples); - //uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples*2 - current_synchro_data.Acq_delay_samples*2) / d_correlation_length_samples); + //uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples*2 - current_synchro_data.Acq_delay_samples*2 + 40) / d_correlation_length_samples); //printf("333333 num_frames = %d\n", num_frames); absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames * d_correlation_length_samples); - //uint64_t absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples*2 + current_synchro_data.Acq_samplestamp_samples*2 + num_frames * d_correlation_length_samples); + //absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples*2 + current_synchro_data.Acq_samplestamp_samples*2 -40 + num_frames * d_correlation_length_samples); //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); } else diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index cf823c8cb..a243bcd8a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -518,8 +518,10 @@ bool HybridObservablesTestFpga::acquire_signal() std::string System_and_Signal; //create the correspondign acquisition block according to the desired tracking signal + printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { + printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); @@ -614,6 +616,7 @@ bool HybridObservablesTestFpga::acquire_signal() throw(std::exception()); } + printf("BBBBBBBBBBBBBBBBBBBBBBBBBB\n"); //acquisition->set_gnss_synchro(&tmp_gnss_synchro); //acquisition->set_channel(0); //acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); @@ -654,6 +657,7 @@ bool HybridObservablesTestFpga::acquire_signal() if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { + printf("BBBBBBBBBBBBBBBBBBBBBBBBBB2222222222\n"); top_block->msg_connect(acquisition_GpsL1Ca_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -694,7 +698,7 @@ bool HybridObservablesTestFpga::acquire_signal() } setup_fpga_switch_obs_test(); - + printf("CCCCCCCCCCCCCCCCCCCCCCCCCCCC\n"); if (test_observables_doppler_control_in_sw == 0) { @@ -844,9 +848,11 @@ bool HybridObservablesTestFpga::acquire_signal() } else { + printf("DDDDDDDDDDDDDDDDDDDDDDDDD\n"); unsigned int code_length; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { + printf("DDDDDDDDDDDDDDDDDDDDDDDDD22222222222\n"); code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -863,12 +869,17 @@ bool HybridObservablesTestFpga::acquire_signal() code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); } + printf("DDDDDDD3 code_length = %d\n", code_length); float nbits = ceilf(log2f((float)code_length)); unsigned int fft_size = pow(2, nbits); unsigned int nsamples_total = fft_size; + printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { + printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -907,9 +918,18 @@ bool HybridObservablesTestFpga::acquire_signal() uint32_t doppler_index_iteration; int doppler_shift_selected; int doppler_num = 0; + //printf("FFFFFFFFFFFFFFFFFFFFFFFFF PRN= %d\n", PRN); + //printf("acq_doppler_max = %d acq_doppler_step = %d", acq_doppler_max, acq_doppler_step); + // debug + //acq_doppler_step = 250; + //int dummyflag; + //printf("PRN = %d type a number \n", PRN); + //std::cin >> dummyflag; for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { + + //printf("main loop doppler_shift = %d\n", doppler_shift); tmp_gnss_synchro.PRN = PRN; pthread_mutex_lock(&mutex_obs_test); @@ -979,6 +999,10 @@ bool HybridObservablesTestFpga::acquire_signal() { printf("ERROR cannot create DMA Process\n"); } +// else +// { +// printf("$$$$$$$$$$$$44 CREATED DMA PROCESS\n"); +// } msg_rx->rx_message = 0; top_block->start(); @@ -1063,9 +1087,16 @@ bool HybridObservablesTestFpga::acquire_signal() if (test_statistics > threshold) { std::cout << " " << PRN << " "; + //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + + tmp_gnss_synchro.Acq_doppler_hz = doppler_shift_selected; + tmp_gnss_synchro.Acq_delay_samples = max_index; + tmp_gnss_synchro.Acq_samplestamp_samples = initial_sample; // delay due to the downsampling filter in the acquisition + + gnss_synchro_vec.push_back(tmp_gnss_synchro); } else @@ -1951,7 +1982,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) std::cout << "Estimated Initial Doppler " << gnss_synchro_vec.at(n).Acq_doppler_hz << " [Hz], estimated Initial code delay " << gnss_synchro_vec.at(n).Acq_delay_samples << " [Samples]" << " Acquisition SampleStamp is " << gnss_synchro_vec.at(n).Acq_samplestamp_samples << std::endl; - gnss_synchro_vec.at(n).Acq_samplestamp_samples = 0; + //gnss_synchro_vec.at(n).Acq_samplestamp_samples = 0; // caution ! samplestamp_samples may not zero if doppler runs inside the FPGA } } @@ -1959,6 +1990,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + printf("000000000000 code_length = %d\n", code_length); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { @@ -1976,7 +2008,8 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) float nbits = ceilf(log2f((float)code_length)); unsigned int fft_size = pow(2, nbits); - + printf("000000000000 nbits = %f\n", nbits); + printf("000000000000 fft_size = %d\n", fft_size); std::vector> tracking_ch_vec; std::vector> tlm_ch_vec; @@ -2066,7 +2099,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); } //connect sample counter and timmer to the last channel in observables block (extra channel) - top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); + //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks."; @@ -2074,6 +2107,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // create acquisition class such that a global Reset is produced for all the HW and the sample counters are reset to 0 if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { + printf("111111111111\n"); std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); } @@ -2111,6 +2145,8 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) args.skip_used_samples = 0; //} + printf("2222222222222 CREATE PROCES\n"); + printf("%s\n", file.c_str()); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); @@ -2121,13 +2157,13 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { tracking_ch_vec.at(n)->start_tracking(); } - + printf("222222222222222222 bis\n"); pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex_obs_test); top_block->start(); - + printf("33333333333333333333 top block started\n"); @@ -2141,8 +2177,12 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); + printf("444444444444 CHILD PROCESS FINISHED\n"); + top_block->stop(); + printf("55555555555 TOP BLOCK STOPPED\n"); + // send more samples to unblock the tracking process in case it was waiting for samples args.file = file; //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) @@ -2155,11 +2195,14 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // args.skip_used_samples = 0; //} args.nsamples_tx = TEST_OBS_NSAMPLES_FINAL; + printf("666666666 CREATE PROCESS TO SEND EXTRA SAMPLES\n"); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } pthread_join(thread_DMA, NULL); + printf("777777777 PROCESS FINISHED \n"); + pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 0; pthread_mutex_unlock(&mutex_obs_test); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index af1704dfc..2cb789ed3 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -1102,6 +1102,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) float max_magnitude = 0.0; uint64_t initial_sample = 0; float power_sum = 0; + float peak_to_power = 0; + float test_statistics; uint32_t doppler_index = 0; if (show_results_table == 1) @@ -1118,14 +1120,17 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) fw_fft_scaling_factor = result_table[PRN][doppler_num][3]; doppler_num = doppler_num + 1; - std::cout << "Doppler shift " << doppler_shift << std::endl; + std::cout << "==================== Doppler shift " << doppler_shift << std::endl; std::cout << "Max magnitude = " << max_magnitude << "Power sum = " << power_sum << std::endl; std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << " FW FFT scaling factor = " << fw_fft_scaling_factor << std::endl; + peak_to_power = max_magnitude/power_sum; power_sum = (power_sum - max_magnitude) / (fft_size - 1); - float test_statistics = (max_magnitude / power_sum); - std::cout << "test_statistics = " << test_statistics << std::endl; - + test_statistics = (max_magnitude / power_sum); + std::cout << "peak to power = " << peak_to_power << " test_statistics = " << test_statistics << std::endl; } + int dummy_val; + std::cout << "Enter a value to continue"; + std::cin >> dummy_val; } } From 6c56107664f7491b4e96e148c3a5e9c8a469d353 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 8 Oct 2018 18:09:25 +0200 Subject: [PATCH 08/53] removed some unnecessary debug messages updated the Hybrid Observables test for the FPGA to instantiate the FPGA sample counter instead of the SW sample counter. --- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 2 +- .../hybrid_observables_test_fpga.cc | 69 ++++++++++++------- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 33e2d104f..782d98e47 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -78,7 +78,7 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( d_single_doppler_flag = false; d_downsampling_factor = acq_parameters.downsampling_factor; - printf("downsampling_factor = %f\n", d_downsampling_factor); + //printf("downsampling_factor = %f\n", d_downsampling_factor); d_select_queue_Fpga = acq_parameters.select_queue_Fpga; //printf("zzzz acq_parameters.code_length = %d\n", acq_parameters.code_length); //printf("zzzz acq_parameters.samples_per_ms = %d\n", acq_parameters.samples_per_ms); diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index a243bcd8a..9c9a61327 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -63,7 +63,8 @@ #include "gps_l1_ca_dll_pll_tracking_fpga.h" #include "hybrid_observables.h" #include "signal_generator_flags.h" -#include "gnss_sdr_sample_counter.h" +//#include "gnss_sdr_sample_counter.h" +#include "gnss_sdr_fpga_sample_counter.h" #include "test_flags.h" #include "tracking_tests_flags.h" #include "observable_tests_flags.h" @@ -518,10 +519,10 @@ bool HybridObservablesTestFpga::acquire_signal() std::string System_and_Signal; //create the correspondign acquisition block according to the desired tracking signal - printf("AAAAAAAAAAAAAAAAAAAAA\n"); + //printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); + //printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); @@ -616,7 +617,7 @@ bool HybridObservablesTestFpga::acquire_signal() throw(std::exception()); } - printf("BBBBBBBBBBBBBBBBBBBBBBBBBB\n"); + //printf("BBBBBBBBBBBBBBBBBBBBBBBBBB\n"); //acquisition->set_gnss_synchro(&tmp_gnss_synchro); //acquisition->set_channel(0); //acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); @@ -657,7 +658,7 @@ bool HybridObservablesTestFpga::acquire_signal() if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - printf("BBBBBBBBBBBBBBBBBBBBBBBBBB2222222222\n"); + //printf("BBBBBBBBBBBBBBBBBBBBBBBBBB2222222222\n"); top_block->msg_connect(acquisition_GpsL1Ca_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -698,7 +699,7 @@ bool HybridObservablesTestFpga::acquire_signal() } setup_fpga_switch_obs_test(); - printf("CCCCCCCCCCCCCCCCCCCCCCCCCCCC\n"); + //printf("CCCCCCCCCCCCCCCCCCCCCCCCCCCC\n"); if (test_observables_doppler_control_in_sw == 0) { @@ -848,11 +849,11 @@ bool HybridObservablesTestFpga::acquire_signal() } else { - printf("DDDDDDDDDDDDDDDDDDDDDDDDD\n"); + //printf("DDDDDDDDDDDDDDDDDDDDDDDDD\n"); unsigned int code_length; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - printf("DDDDDDDDDDDDDDDDDDDDDDDDD22222222222\n"); + //printf("DDDDDDDDDDDDDDDDDDDDDDDDD22222222222\n"); code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -869,17 +870,17 @@ bool HybridObservablesTestFpga::acquire_signal() code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); } - printf("DDDDDDD3 code_length = %d\n", code_length); + //printf("DDDDDDD3 code_length = %d\n", code_length); float nbits = ceilf(log2f((float)code_length)); unsigned int fft_size = pow(2, nbits); unsigned int nsamples_total = fft_size; - printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); + //printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); + //printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -1903,6 +1904,10 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { generate_signal(); } + else + { + //printf("PATH IS OK 0 \n"); + } std::chrono::time_point start, end; std::chrono::duration elapsed_seconds(0); @@ -1910,6 +1915,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // use generator or use an external capture file if (FLAGS_enable_external_signal_file) { + //printf("PATH IS OK 1 \n"); //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters ASSERT_EQ(acquire_signal(), true); } @@ -1930,19 +1936,20 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } } - printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Signal Acquired\n"); + //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Signal Acquired\n"); configure_receiver(FLAGS_PLL_bw_hz_start, FLAGS_DLL_bw_hz_start, FLAGS_PLL_narrow_bw_hz, FLAGS_DLL_narrow_bw_hz, FLAGS_extend_correlation_symbols); - + //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Receiver Configured\n"); for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) { //setup the signal synchronization, simulating an acquisition if (!FLAGS_enable_external_signal_file) { + //printf("HERE\n"); //based on true observables metadata (for custom sdr generator) //open true observables log file written by the simulator or based on provided RINEX obs std::vector> true_reader_vec; @@ -1978,6 +1985,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } else { + //printf("OR THERE\n"); //based on the signal acquisition process std::cout << "Estimated Initial Doppler " << gnss_synchro_vec.at(n).Acq_doppler_hz << " [Hz], estimated Initial code delay " << gnss_synchro_vec.at(n).Acq_delay_samples << " [Samples]" @@ -1986,11 +1994,13 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } } + //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ First part is done\n"); + unsigned int code_length; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - printf("000000000000 code_length = %d\n", code_length); + //printf("000000000000 code_length = %d\n", code_length); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { @@ -2008,8 +2018,8 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) float nbits = ceilf(log2f((float)code_length)); unsigned int fft_size = pow(2, nbits); - printf("000000000000 nbits = %f\n", nbits); - printf("000000000000 fft_size = %d\n", fft_size); + //printf("000000000000 nbits = %f\n", nbits); + //printf("000000000000 fft_size = %d\n", fft_size); std::vector> tracking_ch_vec; std::vector> tlm_ch_vec; @@ -2086,10 +2096,17 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) //gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); int observable_interval_ms = 20; - gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); + //gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); //top_block->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); + double fs = static_cast(config->property("GNSS-SDR.internal_fs_sps", 0)); + + gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter; + ch_out_fpga_sample_counter = gnss_sdr_make_fpga_sample_counter(fs, observable_interval_ms); + + + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) { //top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); @@ -2100,6 +2117,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } //connect sample counter and timmer to the last channel in observables block (extra channel) //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); + top_block->connect(ch_out_fpga_sample_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //extra port for the sample counter pulse //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks."; @@ -2107,7 +2125,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // create acquisition class such that a global Reset is produced for all the HW and the sample counters are reset to 0 if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - printf("111111111111\n"); + //printf("111111111111\n"); std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); } @@ -2145,7 +2163,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) args.skip_used_samples = 0; //} - printf("2222222222222 CREATE PROCES\n"); + //printf("2222222222222 CREATE PROCES\n"); printf("%s\n", file.c_str()); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { @@ -2157,13 +2175,13 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { tracking_ch_vec.at(n)->start_tracking(); } - printf("222222222222222222 bis\n"); + //printf("222222222222222222 bis\n"); pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex_obs_test); top_block->start(); - printf("33333333333333333333 top block started\n"); + //printf("33333333333333333333 top block started\n"); @@ -2177,11 +2195,11 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); - printf("444444444444 CHILD PROCESS FINISHED\n"); + //printf("444444444444 CHILD PROCESS FINISHED\n"); top_block->stop(); - printf("55555555555 TOP BLOCK STOPPED\n"); + //printf("55555555555 TOP BLOCK STOPPED\n"); // send more samples to unblock the tracking process in case it was waiting for samples args.file = file; @@ -2195,13 +2213,13 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // args.skip_used_samples = 0; //} args.nsamples_tx = TEST_OBS_NSAMPLES_FINAL; - printf("666666666 CREATE PROCESS TO SEND EXTRA SAMPLES\n"); + //printf("666666666 CREATE PROCESS TO SEND EXTRA SAMPLES\n"); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } pthread_join(thread_DMA, NULL); - printf("777777777 PROCESS FINISHED \n"); + //printf("777777777 PROCESS FINISHED \n"); pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 0; @@ -2386,7 +2404,6 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) measured_obs_vec.at(n).col(2).colptr(0) + measured_obs_vec.at(n).col(2).n_rows); save_mat_xy(tmp_vector_x4, tmp_vector_y4, std::string("measured_doppler_ch_" + std::to_string(n))); - if (epoch_counters_vec.at(n) > 10) //discard non-valid channels { arma::vec true_TOW_ref_ch_s = true_obs_vec.at(min_pr_ch_id).col(0) - receiver_time_offset_ref_channel_s(0); From 8e6370e1331211b3f8153ca25258ea0ab04f6923 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 17 Oct 2018 15:45:08 +0200 Subject: [PATCH 09/53] changed the downsampling factor of the L1 and E1 acquisition from /2 to /4 --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 2 +- .../gps_l1_ca_pcps_acquisition_fpga.cc | 2 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 5 +- .../dll_pll_veml_tracking_fpga.cc | 27 +++ .../tracking/tracking_pull-in_test_fpga.cc | 167 +++++++++++++++++- 5 files changed, 195 insertions(+), 8 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 63de5cf9b..72d330513 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -59,7 +59,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 2.0); + float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 4.0); acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 38093a84f..0b640bf00 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -61,7 +61,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 2.0); + float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 4.0); acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter //printf("fs_in pre downsampling = %ld\n", fs_in); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 6283f3d1c..353893e6e 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -326,7 +326,9 @@ void pcps_acquisition_fpga::set_active(bool active) { //printf("yes here\n"); d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext % acq_parameters.samples_per_code)); - d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition + d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81/d_downsampling_factor; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % acq_parameters.samples_per_code)); //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext)); //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter*2 - 81; @@ -335,6 +337,7 @@ void pcps_acquisition_fpga::set_active(bool active) } else { + //printf("xxxxxxxxxxxxxxxx no here\n"); d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 34378589a..90a3745d4 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -430,6 +430,10 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; + //printf("start tracking Acq_delay_samples = %d\n", (unsigned int) d_acq_code_phase_samples); + //printf("start tracking Acq_samplestamp_samples = %d\n", (unsigned int) d_acq_sample_stamp); + //printf("start tracking Acq_doppler_hz = %f\n", d_acq_carrier_doppler_hz); + //printf("PRN = %d\n", (unsigned int) d_acquisition_gnss_synchro->PRN); double acq_trk_diff_seconds = 0; // when using the FPGA we don't use the global sample counter // Doppler effect Fd = (C / (C + Vr)) * F double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; @@ -659,6 +663,8 @@ bool dll_pll_veml_tracking_fpga::acquire_secondary() bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integration_time_s) { //printf("kkkkkkkkkkkkk d_cn0_estimation_counter = %d\n", d_cn0_estimation_counter); + //printf("trk_parameters.cn0_samples = %d\n", trk_parameters.cn0_samples); + // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### if (d_cn0_estimation_counter < trk_parameters.cn0_samples) { @@ -676,6 +682,12 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra // Carrier lock indicator d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); // Loss of lock detection + //printf("d_carrier_lock_test = %f\n", d_carrier_lock_test); + //printf("d_carrier_lock_threshold = %f\n", d_carrier_lock_threshold); + //printf("d_CN0_SNV_dB_Hz = %f\n", d_CN0_SNV_dB_Hz); + //printf("trk_parameters.cn0_min = %f\n", trk_parameters.cn0_min); + //printf("d_carrier_lock_fail_counter = %d\n", d_carrier_lock_fail_counter); + //printf("trk_parameters.max_lock_fail = %d\n", trk_parameters.max_lock_fail); if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < trk_parameters.cn0_min) { d_carrier_lock_fail_counter++; @@ -1257,6 +1269,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un if (counter_value > (current_synchro_data.Acq_samplestamp_samples + current_synchro_data.Acq_delay_samples)) { // normal operation + //printf("normal operation\n"); uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples) / d_correlation_length_samples); //uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples*2 - current_synchro_data.Acq_delay_samples*2 + 40) / d_correlation_length_samples); //printf("333333 num_frames = %d\n", num_frames); @@ -1266,6 +1279,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } else { + printf("test operation\n"); // during the unit tests the counter value may be reset after the acquisition process. We have to take this into account absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples); //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); @@ -1299,10 +1313,22 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un { d_VE_accu = *d_Very_Early; d_VL_accu = *d_Very_Late; + //printf("very early real = %f\n", d_VE_accu.real()); + //printf("very early imag = %f\n", d_VE_accu.imag()); + //printf("very late real = %f\n", d_VL_accu.real()); + //printf("very late imag = %f\n", d_VL_accu.imag()); } d_E_accu = *d_Early; d_P_accu = *d_Prompt; d_L_accu = *d_Late; + //printf("early real = %f\n", d_E_accu.real()); + //printf("early imag = %f\n", d_E_accu.imag()); + //printf("prompt real = %f\n", d_P_accu.real()); + //printf("prompt imag = %f\n", d_P_accu.imag()); + //printf("late real = %f\n", d_L_accu.real()); + //printf("late imag = %f\n", d_L_accu.imag()); + + //printf("d_code_period = %f\n", d_code_period); if (!cn0_and_tracking_lock_status(d_code_period)) { @@ -1635,6 +1661,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } if (current_synchro_data.Flag_valid_symbol_output) { + //printf("tracking sending synchro data\n"); current_synchro_data.fs = static_cast(trk_parameters.fs_in); current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); *out[0] = current_synchro_data; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 2cb789ed3..a5de5fca0 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -70,16 +70,16 @@ #define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define NSAMPLES_TRACKING 90000000 // number of samples during which we test the tracking module +#define NSAMPLES_TRACKING 200000000 // number of samples during which we test the tracking module #define NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop // HW related options bool doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if doppler_control_in_sw = 1), 0=> do not show it -bool skip_samples_already_used = 1; // if doppler_control_in_sw = 1 and skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops +bool skip_samples_already_used = 0; // if doppler_control_in_sw = 1 and skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops // (exactly in the same way as the SW) - // if doppler_control_in_sw = 1 and skip_samples_already_used = 0 => the sampe samples are used for each PRN loop + // if doppler_control_in_sw = 1 and skip_samples_already_used = 0 => the sampe samples are used for each doppler sweep // if doppler_control_in_sw = 0 => skip_samples_already_used is not applicable @@ -441,6 +441,7 @@ struct DMA_handler_args { void *handler_DMA(void *arguments) { + //printf("in handler DMA NO tracking\n"); // DMA process that configures the DMA to send the samples to the acquisition engine int tx_fd; // DMA descriptor FILE *rx_signal_file_id; // Input file descriptor @@ -483,6 +484,13 @@ void *handler_DMA(void *arguments) fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); + //printf("\n dma skip_samples = %d\n", skip_samples); + //printf("\n dma skip used samples = %d\n", skip_used_samples); + //printf("dma skip_samples = %d\n", skip_samples); + //printf("dma skip used samples = %d\n", skip_used_samples); + //printf("dma file_completed = %d\n", file_completed); + //printf("dma nsamples = %d\n", nsamples); + //printf("dma nsamples_tx = %d\n", nsamples_tx); usleep(50000); // wait some time to give time to the main thread to start the acquisition module while (file_completed == false) @@ -551,6 +559,134 @@ void *handler_DMA(void *arguments) } + + +void *handler_DMA_tracking(void *arguments) +{ + //printf("in handler DMA NO tracking\n"); + // DMA process that configures the DMA to send the samples to the acquisition engine + int tx_fd; // DMA descriptor + FILE *rx_signal_file_id; // Input file descriptor + bool file_completed = false; // flag to indicate if the file is completed + unsigned int nsamples_block; // number of samples to send in the next DMA block of samples + unsigned int nread_elements; // number of elements effectively read from the input file + unsigned int nsamples = 0; // number of complex samples effectively transferred + unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA + unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes + + unsigned int nsamples_transmitted; + + struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; + + unsigned int nsamples_tx = args->nsamples_tx; + std::string file = args->file; // input filename + unsigned int skip_used_samples = args->skip_used_samples; + + // open DMA device + tx_fd = open("/dev/loop_tx", O_WRONLY); + if ( tx_fd < 0 ) + { + printf("DMA can't open loop device\n"); + exit(1); + } + else + + // open input file + rx_signal_file_id = fopen(file.c_str(), "rb"); + if (rx_signal_file_id < 0) + { + printf("DMA can't open input file\n"); + exit(1); + } + + while(send_samples_start == 0); // wait until acquisition starts + + // skip initial samples + int skip_samples = (int) FLAGS_skip_samples; + + + fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); + printf("\n dma skip_samples = %d\n", skip_samples); + printf("\n dma skip used samples = %d\n", skip_used_samples); + //printf("dma file_completed = %d\n", file_completed); + //printf("dma nsamples = %d\n", nsamples); + //printf("dma nsamples_tx = %d\n", nsamples_tx); + usleep(50000); // wait some time to give time to the main thread to start the acquisition module + + while (file_completed == false) + { + + if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + { + nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + } + else + { + nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent + file_completed = true; + } + + nread_elements = fread(input_samples, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + + if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) + { + printf("could not read the desired number of samples from the input file\n"); + file_completed = true; + } + + nsamples+=(nread_elements/COMPLEX_SAMPLE_SIZE); + + if (nread_elements > 0) + { + // for the 32-BIT DMA + dma_index = 0; + for (index0 = 0;index0 < (nread_elements);index0+=COMPLEX_SAMPLE_SIZE) + { + if (args->freq_band == 0) + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = 0; + input_samples_dma[dma_index+1] = 0; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index+2] = input_samples[index0]; + input_samples_dma[dma_index+3] = input_samples[index0+1]; + } + else + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = input_samples[index0]; + input_samples_dma[dma_index+1] = input_samples[index0+1]; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index+2] = 0; + input_samples_dma[dma_index+3] = 0; + } + dma_index += 4; + } + + nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); + + if (nsamples_transmitted != nread_elements*NUM_QUEUES) + { + std::cout << "Error : DMA could not send all the requested samples" << std::endl; + } + } + } + + close(tx_fd); + fclose(rx_signal_file_id); + + return NULL; +} + + + + + + + + + + bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { pthread_t thread_DMA; @@ -715,6 +851,9 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) MAX_PRN_IDX = 33; } + // debug + //MAX_PRN_IDX = 10; + setup_fpga_switch(); if (doppler_control_in_sw == 0) @@ -789,6 +928,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } // create DMA child process + //printf("|||||||| args freq_band = %d\n", args.freq_band); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); @@ -989,6 +1129,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } // create DMA child process + //printf("||||||||1 args freq_band = %d\n", args.freq_band); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); @@ -1306,38 +1447,51 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) { for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++) { + // DEBUG TEST THE RESULTS OF THE SW + //acq_samplestamp_samples = 108856983; + //true_acq_doppler_hz = 3250; + //true_acq_delay_samples = 836; + gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; //simulate a Doppler error in acquisition gnss_synchro.Acq_doppler_hz = true_acq_doppler_hz + acq_doppler_error_hz_values.at(current_acq_doppler_error_idx); //simulate Code Delay error in acquisition gnss_synchro.Acq_delay_samples = true_acq_delay_samples + (acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) / GPS_L1_CA_CODE_RATE_HZ) * static_cast(baseband_sampling_freq); + + + + //create flowgraph top_block = gr::make_top_block("Tracking test"); std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); boost::shared_ptr msg_rx = TrackingPullInTestFpga_msg_rx_make(); - printf("loop part b2\n"); + //printf("loop part b2\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; } else { @@ -1382,8 +1536,10 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) { args.skip_used_samples = 0; } + //args.skip_used_samples = 0; - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + //printf("||||||||1 args freq_band = %d\n", args.freq_band); + if (pthread_create(&thread_DMA, NULL, handler_DMA_tracking, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } @@ -1415,6 +1571,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) args.skip_used_samples = 0; } args.nsamples_tx = NSAMPLES_FINAL; + //printf("||||||||1 args freq_band = %d\n", args.freq_band); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); From b5409f0860ad53dbed9b79dab94b539455520189 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 31 Oct 2018 18:48:08 +0100 Subject: [PATCH 10/53] updated the SW to run the new Acquisition HW accelerator, which compensates the scaling factors of the FFT and the IFFT, and computes the test statistics out of the peak value and the second peak value resulting from the correlation performed by the acquisition process. Updated the GPS L1 and Galileo E1 acquisition adapters. --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 17 +- .../gps_l1_ca_pcps_acquisition_fpga.cc | 21 ++- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 6 + .../gnuradio_blocks/pcps_acquisition_fpga.cc | 153 +++++++++++------- .../gnuradio_blocks/pcps_acquisition_fpga.h | 6 + .../acquisition/libs/fpga_acquisition.cc | 133 +++++++++++---- .../acquisition/libs/fpga_acquisition.h | 24 ++- 7 files changed, 262 insertions(+), 98 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 72d330513..8f00f3d97 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -113,7 +113,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( //printf("acq adapter code_length = %d\n", code_length); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length)); + float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; //printf("acq adapter nsamples_total (= vector_length) = %d\n", vector_length); @@ -124,6 +124,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( acq_parameters.device_name = device_name; acq_parameters.samples_per_ms = nsamples_total/sampled_ms; acq_parameters.samples_per_code = nsamples_total; + acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / Galileo_E1_CODE_CHIP_RATE_HZ)); // compute all the GALILEO E1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -178,9 +179,15 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( // } // fclose(fid); + for (int s = code_length; s < 2*code_length; s++) + { + code[s] = code[s - code_length]; + //code[s] = 0; + } + // // fill in zero padding - for (int s = code_length; s < nsamples_total; s++) + for (int s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(static_cast(0,0)); //code[s] = 0; @@ -226,8 +233,8 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( // static_cast(floor(256*fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max))); // d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(16*fft_codes_padded[i].real() * (pow(2, 11) - 1) / max)), // static_cast(floor(16*fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); // tmp_re = static_cast(floor(fft_codes_padded[i].real() * (pow(2, 7) - 1) / max)); // tmp_im = static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max)); @@ -292,6 +299,8 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( delete fft_if; delete[] fft_codes_padded; + acq_parameters.total_block_exp = 11; + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 0b640bf00..c862dcf6a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -81,7 +81,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( acq_parameters.code_length = code_length; //printf("acq adapter code_length = %d\n", code_length); // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length)); + float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; //printf("acq adapter vector_length = %d\n", vector_length); @@ -94,7 +94,8 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( acq_parameters.samples_per_ms = nsamples_total / sampled_ms; //printf("acq adapter samples_per_ms = %d\n", nsamples_total / sampled_ms); acq_parameters.samples_per_code = nsamples_total; - + acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L1_CA_CODE_RATE_HZ)); + //printf("excludelimit = %d\n", (int) acq_parameters.excludelimit); // compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) gr::fft::fft_complex* fft_if = new gr::fft::fft_complex(vector_length, true); // Direct FFT @@ -106,12 +107,20 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in, 0); // generate PRN code + + for (int s = code_length; s < 2*code_length; s++) + { + code[s] = code[s - code_length]; + //code[s] = 0; + } + // fill in zero padding - for (int s = code_length; s < nsamples_total; s++) + for (int s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(static_cast(0, 0)); //code[s] = 0; } + int offset = 0; memcpy(fft_if->get_inbuf() + offset, code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code @@ -150,8 +159,8 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( // static_cast(16*floor(fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), // static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); } @@ -176,6 +185,8 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( delete fft_if; delete[] fft_codes_padded; + acq_parameters.total_block_exp = 0; + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index cb76cd4c8..f585e75d9 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -59,6 +59,12 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); + acq_parameters.downsampling_factor = downsampling_factor; + + fs_in = fs_in/downsampling_factor; + acq_parameters.fs_in = fs_in; //if_ = configuration_->property(role + ".if", 0); //acq_parameters.freq = if_; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 353893e6e..ffcf9ddbf 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -43,6 +43,7 @@ #include #include "pcps_acquisition_fpga.h" +#include // for the usleep function only (debug) #define AQ_DOWNSAMPLING_DELAY 40 // delay due to the downsampling filter in the acquisition @@ -89,14 +90,18 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( // (acq_parameters.device_name, acq_parameters.code_length, acq_parameters.doppler_max, acq_parameters.samples_per_ms, // acq_parameters.fs_in, acq_parameters.freq, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes); + + d_total_block_exp = acq_parameters.total_block_exp; + // this one is the one it should be but it doesn't work acquisition_fpga = std::make_shared(acq_parameters.device_name, acq_parameters.code_length, acq_parameters.doppler_max, d_fft_size, - acq_parameters.fs_in, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes); + acq_parameters.fs_in, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes, acq_parameters.excludelimit); // acquisition_fpga = std::make_shared // (acq_parameters.device_name, acq_parameters.samples_per_code, acq_parameters.doppler_max, acq_parameters.samples_per_code, // acq_parameters.fs_in, acq_parameters.freq, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes); + // debug //debug_d_max_absolute = 0.0; //debug_d_input_power_absolute = 0.0; @@ -211,13 +216,16 @@ void pcps_acquisition_fpga::send_negative_acquisition() void pcps_acquisition_fpga::set_active(bool active) { + // printf("acq set active start\n"); d_active = active; // initialize acquisition algorithm uint32_t indext = 0U; - float magt = 0.0; - float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); + float firstpeak = 0.0; + float secondpeak = 0.0; + uint32_t total_block_exp; + //float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_input_power = 0.0; d_mag = 0.0; @@ -236,73 +244,60 @@ void pcps_acquisition_fpga::set_active(bool active) float temp_d_input_power; - // loop through acquisition - /* - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) - { - // doppler search steps - int32_t doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * doppler_index; - - //acquisition_fpga->set_phase_step(doppler_index); - acquisition_fpga->set_doppler_sweep_debug(1, doppler_index); - acquisition_fpga->run_acquisition(); // runs acquisition and waits until it is finished - acquisition_fpga->read_acquisition_results(&indext, &magt, - &initial_sample, &d_input_power, &d_doppler_index); - d_sample_counter = initial_sample; - - if (d_mag < magt) - { - d_mag = magt; - - temp_d_input_power = d_input_power; - - input_power_all = d_input_power / (d_fft_size - 1); - input_power_computed = (d_input_power - d_mag) / (d_fft_size - 1); - d_input_power = (d_input_power - d_mag) / (d_fft_size - 1); - - d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); - d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); - d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - - d_test_statistics = (d_mag / d_input_power); //* correction_factor; - } - - // In the case of the FPGA the option of dumping the results of the acquisition to a file is not available - // because the IFFT vector is not available - } -*/ - // debug //acquisition_fpga->block_samples(); + + // while(1) + //{ + + + // run loop in hw //printf("LAUNCH ACQ\n"); //printf("acq lib d_num_doppler_bins = %d\n", d_num_doppler_bins); + //printf("writing config for channel %d -----------------------------------------\n", (int) d_channel); + acquisition_fpga->configure_acquisition(); acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); + + acquisition_fpga->write_local_code(); + //acquisition_fpga->set_doppler_sweep(2); //printf("acq lib going to launch acquisition\n"); + acquisition_fpga->set_block_exp(d_total_block_exp); + + //printf("running acq for channel %d\n", (int) d_channel); + acquisition_fpga->run_acquisition(); //printf("acq lib going to read the acquisition results\n"); - acquisition_fpga->read_acquisition_results(&indext, &magt, - &initial_sample, &d_input_power, &d_doppler_index); + //read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index); + + //printf("reading results for channel %d\n", (int) d_channel); + acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); + + //printf("gnuradio block : d_total_block_exp = %d total_block_exp = %d\n", (int) d_total_block_exp, (int) total_block_exp); + + if (total_block_exp > d_total_block_exp) + { + printf("changing blk exp..... d_total_block_exp = %d total_block_exp = %d chan = %d\n", d_total_block_exp, total_block_exp, d_channel); + d_total_block_exp = total_block_exp; + + } + + //printf("end channel %d -----------------------------------------------------\n", (int) d_channel); //printf("READ ACQ RESULTS\n"); // debug //acquisition_fpga->unblock_samples(); - d_mag = magt; + //usleep(5000000); + //} // end while test - // debug - //debug_d_max_absolute = magt; - //debug_d_input_power_absolute = d_input_power; - //debug_indext = indext; - //debug_doppler_index = d_doppler_index; - - // temp_d_input_power = d_input_power; - - d_input_power = (d_input_power - d_mag) / (d_fft_size - 1); int32_t doppler; + + // NEW SATELLITE DETECTION ALGORITHM STARTS HERE ---------------------------------------------------- + if (d_single_doppler_flag == false) { doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); @@ -312,10 +307,46 @@ void pcps_acquisition_fpga::set_active(bool active) { doppler = static_cast(acq_parameters.doppler_max); } - //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % (2*acq_parameters.samples_per_code))); + if (secondpeak > 0) + { + d_test_statistics = firstpeak/secondpeak; + } + else + { + d_test_statistics = 0.0; + } - //printf("acq gnuradioblock doppler = %d\n", doppler); +// // OLD SATELLITE DETECTION ALGORITHM STARTS HERE ---------------------------------------------------- +// +// d_mag = magt; +// +// +// // debug +// //debug_d_max_absolute = magt; +// //debug_d_input_power_absolute = d_input_power; +// //debug_indext = indext; +// //debug_doppler_index = d_doppler_index; +// +// // temp_d_input_power = d_input_power; +// +// d_input_power = (d_input_power - d_mag) / (d_fft_size - 1); +// //int32_t doppler; +// if (d_single_doppler_flag == false) +// { +// doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); +// //doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index); // this is the wrong one +// } +// else +// { +// doppler = static_cast(acq_parameters.doppler_max); +// } +// //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % (2*acq_parameters.samples_per_code))); +// +// +// //printf("acq gnuradioblock doppler = %d\n", doppler); +// +// // END OF OLD SATELLITE ALGORITHM -------------------------------------------------------------------- d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_sample_counter = initial_sample; @@ -355,7 +386,13 @@ void pcps_acquisition_fpga::set_active(bool active) //d_gnss_synchro->Acq_samplestamp_samples = 2*d_sample_counter - 81; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition - d_test_statistics = (d_mag / d_input_power); //* correction_factor; +// // OLD SATELLITE DETECTION ALGORITHM STARTS HERE AGAIN ----------------------------------------------- +// +// d_test_statistics = (d_mag / d_input_power); //* correction_factor; +// +// // END OF OLD SATELLITE ALGORITHM AGAIN -------------------------------------------------------------------- + + // debug // if (d_gnss_synchro->Acq_delay_samples > acq_parameters.code_length) @@ -400,6 +437,7 @@ void pcps_acquisition_fpga::set_active(bool active) send_negative_acquisition(); } + //printf("acq set active end\n"); } @@ -425,8 +463,8 @@ void pcps_acquisition_fpga::set_single_doppler_flag(unsigned int single_doppler_ void pcps_acquisition_fpga::read_acquisition_results(uint32_t *max_index, float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) { - acquisition_fpga->read_acquisition_results(max_index, max_magnitude, - initial_sample, power_sum, doppler_index); +// acquisition_fpga->read_acquisition_results(max_index, max_magnitude, +// initial_sample, power_sum, doppler_index); } // this function is only used for the unit tests @@ -439,3 +477,6 @@ void pcps_acquisition_fpga::read_fpga_total_scale_factor(uint32_t *total_scale_f { acquisition_fpga->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); } + + + diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index e9800f97f..9dcf0261d 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -74,6 +74,8 @@ typedef struct std::string device_name; lv_16sc_t* all_fft_codes; // memory that contains all the code ffts float downsampling_factor; + uint32_t total_block_exp; + uint32_t excludelimit; } pcpsconf_fpga_t; class pcps_acquisition_fpga; @@ -102,6 +104,8 @@ private: void send_positive_acquisition(); + float first_vs_second_peak_statistic(uint32_t& indext, int32_t& doppler, uint32_t num_doppler_bins, int32_t doppler_max, int32_t doppler_step); + pcpsconf_fpga_t acq_parameters; bool d_active; float d_threshold; @@ -128,6 +132,8 @@ private: uint32_t d_select_queue_Fpga; bool d_single_doppler_flag; + uint32_t d_total_block_exp; + public: ~pcps_acquisition_fpga(); diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 8ae772eb8..09b28e88a 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -41,6 +41,9 @@ #include // libraries used by the GIPO #include // libraries used by the GIPO +#include // for the usleep function only (debug) + + #define PAGE_SIZE 0x10000 // default page size for the multicorrelator memory map #define MAX_PHASE_STEP_RAD 0.999999999534339 // 1 - pow(2,-31); @@ -72,7 +75,7 @@ bool fpga_acquisition::init() { //printf("acq lib init called\n"); // configure the acquisition with the main initialization values - fpga_acquisition::configure_acquisition(); + //fpga_acquisition::configure_acquisition(); return true; } @@ -81,8 +84,11 @@ bool fpga_acquisition::set_local_code(uint32_t PRN) { //printf("acq lib set_local_code_called\n"); // select the code with the chosen PRN - fpga_acquisition::fpga_configure_acquisition_local_code( - &d_all_fft_codes[d_nsamples_total * (PRN - 1)]); + d_PRN = PRN; +// printf("#### ACQ: WRITING LOCAL CODE for PRN %d\n", (int) PRN); +// +// fpga_acquisition::fpga_configure_acquisition_local_code( +// &d_all_fft_codes[d_nsamples_total * (PRN - 1)]); //fpga_acquisition::fpga_configure_acquisition_local_code( // &d_all_fft_codes[0]); @@ -91,12 +97,22 @@ bool fpga_acquisition::set_local_code(uint32_t PRN) } +void fpga_acquisition::write_local_code() +{ + //printf("#### ACQ: WRITING LOCAL CODE for PRN %d\n", (int) d_PRN); + + fpga_acquisition::fpga_configure_acquisition_local_code( + &d_all_fft_codes[d_nsamples_total * (d_PRN - 1)]); + +} + fpga_acquisition::fpga_acquisition(std::string device_name, uint32_t nsamples, uint32_t doppler_max, uint32_t nsamples_total, int64_t fs_in, uint32_t sampled_ms, uint32_t select_queue, - lv_16sc_t *all_fft_codes) + lv_16sc_t *all_fft_codes, + uint32_t excludelimit) { //printf("acq lib constructor called\n"); //printf("AAA- sampled_ms = %d\n ", sampled_ms); @@ -109,6 +125,7 @@ fpga_acquisition::fpga_acquisition(std::string device_name, //d_freq = freq; d_fs_in = fs_in; d_vector_length = vector_length; + d_excludelimit = excludelimit; d_nsamples = nsamples; // number of samples not including padding d_select_queue = select_queue; d_nsamples_total = nsamples_total; @@ -160,6 +177,7 @@ fpga_acquisition::fpga_acquisition(std::string device_name, // flag used for testing purposes d_single_doppler_flag = 0; + d_PRN = 0; DLOG(INFO) << "Acquisition FPGA class created"; } @@ -228,26 +246,46 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local void fpga_acquisition::run_acquisition(void) { + //printf("acq lib run_acqisition called\n"); // enable interrupts - int32_t reenable = 1; - write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); + //int32_t reenable = 1; + //reenable = 1; + //write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); + // launch the acquisition process //printf("acq lib launchin acquisition ...\n"); d_map_base[8] = LAUNCH_ACQUISITION; // writing a 1 to reg 8 launches the acquisition process //printf("acq lib waiting for interrupt ...\n"); int32_t irq_count; ssize_t nb; + + uint32_t result_valid = 0; + + usleep(50); + while(result_valid == 0) + { + read_result_valid(&result_valid); // polling + } // wait for interrupt - nb = read(d_fd, &irq_count, sizeof(irq_count)); + //nb = read(d_fd, &irq_count, sizeof(irq_count)); + //usleep(500000); // debug //printf("interrupt received\n"); - if (nb != sizeof(irq_count)) - { - printf("acquisition module Read failed to retrieve 4 bytes!\n"); - printf("acquisition module Interrupt number %d\n", irq_count); - } + //if (nb != sizeof(irq_count)) + // { + // printf("acquisition module Read failed to retrieve 4 bytes!\n"); + // printf("acquisition module Interrupt number %d\n", irq_count); + // } + + + } +void fpga_acquisition::set_block_exp(uint32_t total_block_exp) +{ + //printf("******* acq writing total exponent = %d\n", (int) total_block_exp); + d_map_base[11] = total_block_exp; +} void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) { @@ -292,7 +330,7 @@ void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) //printf("AAA phase_step_rad_real for doppler step after checking = %f\n", phase_step_rad_real); phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAA writing phase_step_rad_int for doppler step = %d to d map base 4\n", phase_step_rad_int); + //printf("AAA writing phase_step_incr for doppler step = %d to d map base 4\n", phase_step_rad_int); d_map_base[4] = phase_step_rad_int; //printf("AAA writing num sweeps to d map base 5 = %d\n", num_sweeps); d_map_base[5] = num_sweeps; @@ -406,6 +444,9 @@ void fpga_acquisition::configure_acquisition() d_map_base[2] = d_nsamples; //printf("AAA writing LOG2 d_vector_length = %d to d map base 7\n ", (int)log2((float)d_vector_length)); d_map_base[7] = static_cast(log2(static_cast(d_vector_length))); // log2 FFTlength + //printf("AAA writing excludelimit = %d to d map base 12\n", (int) d_excludelimit); + d_map_base[12] = d_excludelimit; + //printf("acquisition debug vector length = %d\n", d_vector_length); //printf("acquisition debug vector length = %d\n", (int)log2((float)d_vector_length)); } @@ -435,39 +476,65 @@ void fpga_acquisition::set_phase_step(uint32_t doppler_index) //printf("AAA+ phase_step_rad_real after checking = %f\n", phase_step_rad_real); phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("writing phase_step_rad_int = %d to d_map_base 3\n", phase_step_rad_int); + //printf("writing phase_step_rad_int = %d to d_map_base 3 THE SECOND FUNCTION\n", phase_step_rad_int); d_map_base[3] = phase_step_rad_int; } void fpga_acquisition::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) + float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp) { + + + //printf("acq lib read_acquisition_results_called\n"); uint64_t initial_sample_tmp = 0; uint32_t readval = 0; uint64_t readval_long = 0; uint64_t readval_long_shifted = 0; + + + readval = d_map_base[1]; initial_sample_tmp = readval; + readval_long = d_map_base[2]; readval_long_shifted = readval_long << 32; // 2^32 + initial_sample_tmp = initial_sample_tmp + readval_long_shifted; // 2^32 - //printf("----------------------------------------------------------------> acq initial sample TOTAL = %llu\n", initial_sample_tmp); *initial_sample = initial_sample_tmp; - readval = d_map_base[6]; - *max_magnitude = static_cast(readval); - //printf("acq lib read max_magnitude dmap 2 = %d = %f\n", readval, *max_magnitude); - readval = d_map_base[4]; - *power_sum = static_cast(readval); - //printf("acq lib read power sum dmap 4 = %d = %f\n", readval, *power_sum); - readval = d_map_base[5]; // read doppler index - *doppler_index = readval; - //printf("read doppler_index dmap 5 = %d\n", readval); + //printf("-------> acq initial sample TOTAL = %llu\n", *initial_sample); + readval = d_map_base[3]; + *firstpeak = static_cast(readval); + //printf("-------> read first peak = %f\n", *firstpeak); + + readval = d_map_base[4]; + *secondpeak = static_cast(readval); + //printf("-------> read second peak = %f\n", *secondpeak); + + readval = d_map_base[5]; *max_index = readval; - //printf("read max index dmap 3 = %d\n", readval); + //printf("-------> read max index = %d\n", (int) *max_index); + + //printf("acq lib read max_magnitude dmap 2 = %d = %f\n", readval, *max_magnitude); + //readval = d_map_base[4]; + *power_sum = 0; + //printf("acq lib read power sum dmap 4 = %d = %f\n", readval, *power_sum); + + + + readval = d_map_base[8]; + *total_blk_exp = readval; + //printf("---------> read total block exponent = %d\n", (int) *total_blk_exp); + + readval = d_map_base[7]; // read doppler index -- this read releases the interrupt line + *doppler_index = readval; + //printf("---------> read doppler_index = %d\n", (int) *doppler_index ); + + readval = d_map_base[15]; // read dummy + } @@ -513,8 +580,16 @@ void fpga_acquisition::set_single_doppler_flag(unsigned int single_doppler_flag) void fpga_acquisition::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) { uint32_t readval = 0; - readval = d_map_base[7]; - *total_scale_factor = readval; readval = d_map_base[8]; - *fw_scale_factor = readval; + *total_scale_factor = readval; + + //readval = d_map_base[8]; + *fw_scale_factor = 0; +} + +void fpga_acquisition::read_result_valid(uint32_t *result_valid) +{ + uint32_t readval = 0; + readval = d_map_base[0]; + *result_valid = readval; } diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index 192ff8cc4..d007c6583 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -53,7 +53,8 @@ public: int64_t fs_in, uint32_t sampled_ms, uint32_t select_queue, - lv_16sc_t *all_fft_codes); + lv_16sc_t *all_fft_codes, + uint32_t excludelimit); ~fpga_acquisition(); bool init(); @@ -63,8 +64,11 @@ public: //void set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t doppler_index); void run_acquisition(void); void set_phase_step(uint32_t doppler_index); - void read_acquisition_results(uint32_t *max_index, float *max_magnitude, - uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + //void read_acquisition_results(uint32_t *max_index, float *max_magnitude, + // uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + void read_acquisition_results(uint32_t *max_index, float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp); + + void block_samples(); void unblock_samples(); @@ -105,6 +109,14 @@ public: */ void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + void set_block_exp(uint32_t total_block_exp); + + void write_local_code(void); + + void configure_acquisition(void); + + + private: int64_t d_fs_in; // data related to the hardware module and the driver @@ -112,18 +124,22 @@ private: volatile uint32_t *d_map_base; // driver memory map lv_16sc_t *d_all_fft_codes; // memory that contains all the code ffts uint32_t d_vector_length; // number of samples incluing padding and number of ms + uint32_t d_excludelimit; uint32_t d_nsamples_total; // number of samples including padding uint32_t d_nsamples; // number of samples not including padding uint32_t d_select_queue; // queue selection std::string d_device_name; // HW device name uint32_t d_doppler_max; // max doppler uint32_t d_doppler_step; // doppler step + uint32_t d_PRN; // PRN // FPGA private functions uint32_t fpga_acquisition_test_register(uint32_t writeval); void fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]); - void configure_acquisition(); + //void configure_acquisition(); void close_device(); + void read_result_valid(uint32_t *result_valid); + // test parameters unsigned int d_single_doppler_flag; // this flag is only used for testing purposes }; From 392f92839fdba0710b77bb2696773bb57c3d25ff Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 5 Nov 2018 17:01:29 +0100 Subject: [PATCH 11/53] updated L5 and E5a adapters for debugging corrected minor issues --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 4 +-- .../galileo_e5a_pcps_acquisition_fpga.cc | 29 +++++++++++++---- .../gps_l1_ca_pcps_acquisition_fpga.cc | 8 +++-- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 31 +++++++++++++------ .../tracking/libs/fpga_multicorrelator.cc | 2 ++ 5 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 8f00f3d97..c4e5eb843 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -49,7 +49,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( //printf("top acq constructor start\n"); pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - std::string default_item_type = "gr_complex"; + std::string default_item_type = "cshort"; std::string default_dump_filename = "./data/acquisition.dat"; DLOG(INFO) << "role " << role; @@ -59,7 +59,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 4.0); + float downsampling_factor = configuration_->property(role + ".downsampling_factor", 4.0); acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index d5557286d..66ceca8a6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -50,7 +50,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf //printf("creating the E5A acquisition"); pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - std::string default_item_type = "gr_complex"; + std::string default_item_type = "cshort"; std::string default_dump_filename = "../data/acquisition.dat"; DLOG(INFO) << "Role " << role; @@ -59,6 +59,12 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + + float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); + acq_parameters.downsampling_factor = downsampling_factor; + + fs_in = fs_in/downsampling_factor; + acq_parameters.fs_in = fs_in; //acq_parameters.freq = 0; @@ -68,7 +74,9 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - unsigned int sampled_ms = 1; + + unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); + acq_parameters.sampled_ms = sampled_ms; //max_dwells_ = configuration_->property(role + ".max_dwells", 1); //acq_parameters.max_dwells = max_dwells_; //dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); @@ -91,10 +99,11 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf unsigned int code_length = static_cast(std::round(static_cast(fs_in) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length)); + float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); + printf("select queue = %d\n", select_queue_Fpga); //printf("select_queue_Fpga = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; @@ -137,8 +146,14 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf galileo_e5_a_code_gen_complex_sampled(code, signal_, PRN, fs_in, 0); + for (int s = code_length; s < 2*code_length; s++) + { + code[s] = code[s - code_length]; + //code[s] = 0; + } + // fill in zero padding - for (int s = code_length; s < nsamples_total; s++) + for (int s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(static_cast(0,0)); //code[s] = 0; @@ -162,8 +177,8 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf } for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); } } @@ -202,6 +217,8 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf //acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); //DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + acq_parameters.total_block_exp = 9; + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index c862dcf6a..033f17015 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -54,14 +54,15 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( { pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - std::string default_item_type = "gr_complex"; + std::string default_item_type = "cshort"; DLOG(INFO) << "role " << role; long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 4.0); + float downsampling_factor = configuration_->property(role + ".downsampling_factor", 4.0); + printf("downsampling_factor = %f\n", downsampling_factor); acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter //printf("fs_in pre downsampling = %ld\n", fs_in); @@ -86,6 +87,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( unsigned int vector_length = nsamples_total; //printf("acq adapter vector_length = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); + printf("select queue = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); @@ -185,7 +187,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( delete fft_if; delete[] fft_codes_padded; - acq_parameters.total_block_exp = 0; + acq_parameters.total_block_exp = 9; acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index f585e75d9..4d124978a 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -50,7 +50,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( //printf("L5 ACQ CLASS CREATED\n"); pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - std::string default_item_type = "gr_complex"; + std::string default_item_type = "cshort"; std::string default_dump_filename = "./data/acquisition.dat"; LOG(INFO) << "role " << role; @@ -60,7 +60,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); + float downsampling_factor = configuration_->property(role + ".downsampling_factor", 1.0); acq_parameters.downsampling_factor = downsampling_factor; fs_in = fs_in/downsampling_factor; @@ -93,22 +93,26 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( unsigned int code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length)); + float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); + printf("select queue = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); acq_parameters.device_name = device_name; - acq_parameters.samples_per_ms = nsamples_total; + acq_parameters.samples_per_ms = nsamples_total/sampled_ms; acq_parameters.samples_per_code = nsamples_total; + + acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L5i_CODE_RATE_HZ)); + //printf("L5 ACQ CLASS MID 01\n"); // compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) - gr::fft::fft_complex* fft_if = new gr::fft::fft_complex(vector_length, true); // Direct FFT + gr::fft::fft_complex* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT //printf("L5 ACQ CLASS MID 02\n"); - std::complex* code = new gr_complex[vector_length]; + std::complex* code = new gr_complex[nsamples_total]; //printf("L5 ACQ CLASS MID 03\n"); gr_complex* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); //printf("L5 ACQ CLASS MID 04\n"); @@ -123,7 +127,14 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( gps_l5i_code_gen_complex_sampled(code, PRN, fs_in); //printf("L5 ACQ CLASS processing PRN = %d (cont) \n", PRN); // fill in zero padding - for (int s = code_length; s < nsamples_total; s++) + + for (int s = code_length; s < 2*code_length; s++) + { + code[s] = code[s - code_length]; + //code[s] = 0; + } + + for (int s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(static_cast(0,0)); //code[s] = 0; @@ -152,8 +163,8 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( // static_cast(16*floor(fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), // static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); } @@ -196,6 +207,8 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( // acquisition_fpga_ = pcps_make_acquisition(acq_parameters); // DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + acq_parameters.total_block_exp = 9; + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 3aa381048..8c069314c 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -334,6 +334,8 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) //printf("ppps opening device %s\n", device_io_name); + printf("trk device_io_name = %s\n", device_io_name); + if ((d_device_descriptor = open(device_io_name, O_RDWR | O_SYNC)) == -1) { LOG(WARNING) << "Cannot open deviceio" << device_io_name; From 0d9b08df70af9e8a5bfa014c05f87ba347fdd62f Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 5 Nov 2018 19:50:40 +0100 Subject: [PATCH 12/53] updated the tracking pull-in test for the FPGA. To be tested. --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 8 ++- ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 3 +- .../galileo_e5a_pcps_acquisition_fpga.cc | 7 ++- .../galileo_e5a_pcps_acquisition_fpga.h | 3 +- .../gps_l1_ca_pcps_acquisition_fpga.cc | 7 ++- .../gps_l1_ca_pcps_acquisition_fpga.h | 2 +- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 9 ++- .../adapters/gps_l5i_pcps_acquisition_fpga.h | 3 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 6 +- .../gnuradio_blocks/pcps_acquisition_fpga.h | 3 +- .../hybrid_observables_test_fpga.cc | 12 ++-- .../tracking/tracking_pull-in_test_fpga.cc | 56 ++++++++++--------- 12 files changed, 71 insertions(+), 48 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index d0fc0bd5d..adf165d09 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -496,12 +496,14 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::set_single_doppler_flag(unsigned int } // this function is only used for the unit tests void GalileoE1PcpsAmbiguousAcquisitionFpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) + { - acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, - initial_sample, power_sum, doppler_index); + acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, second_magnitude, + initial_sample, doppler_index, total_fft_scaling_factor); } + // this function is only used for the unit tests void GalileoE1PcpsAmbiguousAcquisitionFpga::reset_acquisition(void) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index ba8a6662d..6c70c8d11 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -144,7 +144,8 @@ public: * \brief This function is only used in the unit tests */ void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); + /*! * \brief This function is only used in the unit tests diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index d30a30500..d73f463e8 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -380,10 +380,11 @@ void GalileoE5aPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_ } // this function is only used for the unit tests void GalileoE5aPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) + { - acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, - initial_sample, power_sum, doppler_index); + acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, second_magnitude, + initial_sample, doppler_index, total_fft_scaling_factor); } // this function is only used for the unit tests diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index dbf593380..f681979c9 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -132,7 +132,8 @@ public: * \brief This function is only used in the unit tests */ void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); + /*! * \brief This function is only used in the unit tests diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index d7461b287..d34584d55 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -283,10 +283,11 @@ void GpsL1CaPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_dop } // this function is only used for the unit tests void GpsL1CaPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) + { - acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, - initial_sample, power_sum, doppler_index); + acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, second_magnitude, + initial_sample, doppler_index, total_fft_scaling_factor); } // this function is only used for the unit tests diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index 60fdab730..9bf3178cf 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -142,7 +142,7 @@ public: * \brief This function is only used in the unit tests */ void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); /*! * \brief This function is only used in the unit tests diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 8a166f44e..f75116ed5 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -351,12 +351,15 @@ void GpsL5iPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_dopp } // this function is only used for the unit tests void GpsL5iPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) + { - acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, - initial_sample, power_sum, doppler_index); + acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, second_magnitude, + initial_sample, doppler_index, total_fft_scaling_factor); } + + // this function is only used for the unit tests void GpsL5iPcpsAcquisitionFpga::reset_acquisition(void) { diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index 5b25b0771..a6ed38eb4 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -142,7 +142,8 @@ public: * \brief This function is only used in the unit tests */ void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); + /*! * \brief This function is only used in the unit tests diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index ffcf9ddbf..c89a40247 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -461,8 +461,12 @@ void pcps_acquisition_fpga::set_single_doppler_flag(unsigned int single_doppler_ // this function is only used for the unit tests void pcps_acquisition_fpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index) + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) { + float input_power; // not used + acquisition_fpga->read_acquisition_results(max_index, max_magnitude, second_magnitude, initial_sample, &input_power, doppler_index, total_fft_scaling_factor); + + // acquisition_fpga->read_acquisition_results(max_index, max_magnitude, // initial_sample, power_sum, doppler_index); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index 9dcf0261d..acf505bde 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -246,7 +246,8 @@ public: * \brief This funciton is only used for the unit tests */ void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); + float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); + /*! * \brief This funciton is only used for the unit tests diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 9c9a61327..e365dc61c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -1051,19 +1051,23 @@ bool HybridObservablesTestFpga::acquire_signal() if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + // UPDATE! + //acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + // UPDATE! + //acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + // UPDATE! + //acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); + // UPDATE! + //acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); } result_table[PRN][doppler_num][0] = max_magnitude_iteration; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index a5de5fca0..2b1f4020f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -1041,27 +1041,30 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - float result_table[MAX_PRN_IDX][num_doppler_steps][4]; + float result_table[MAX_PRN_IDX][num_doppler_steps][3]; for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) { uint32_t max_index = 0; float max_magnitude = 0.0; + float second_magnitude = 0.0; uint64_t initial_sample = 0; - float power_sum = 0; + //float power_sum = 0; uint32_t doppler_index = 0; uint32_t max_index_iteration; uint32_t total_fft_scaling_factor; uint32_t fw_fft_scaling_factor; float max_magnitude_iteration; + float second_magnitude_iteration; uint64_t initial_sample_iteration; - float power_sum_iteration; + //float power_sum_iteration; uint32_t doppler_index_iteration; int doppler_shift_selected; int doppler_num = 0; + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { tmp_gnss_synchro.PRN = PRN; @@ -1181,45 +1184,45 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = power_sum_iteration; + result_table[PRN][doppler_num][1] = second_magnitude_iteration; result_table[PRN][doppler_num][2] = total_fft_scaling_factor; - result_table[PRN][doppler_num][3] = fw_fft_scaling_factor; doppler_num = doppler_num + 1; if (max_magnitude_iteration > max_magnitude) { max_index = max_index_iteration; max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; initial_sample = initial_sample_iteration; - power_sum = power_sum_iteration; doppler_index = doppler_index_iteration; doppler_shift_selected = doppler_shift; } top_block->stop(); } - power_sum = (power_sum - max_magnitude) / (fft_size - 1); - float test_statistics = (max_magnitude / power_sum); + //power_sum = (power_sum - max_magnitude) / (fft_size - 1); + //float test_statistics = (max_magnitude / power_sum); + float test_statistics = max_magnitude/second_magnitude; float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); if (test_statistics > threshold) { @@ -1239,10 +1242,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) uint32_t max_index = 0; uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; + //uint32_t fw_fft_scaling_factor; float max_magnitude = 0.0; uint64_t initial_sample = 0; - float power_sum = 0; + float second_magnitude = 0; float peak_to_power = 0; float test_statistics; uint32_t doppler_index = 0; @@ -1256,18 +1259,19 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { max_magnitude = result_table[PRN][doppler_num][0]; - power_sum = result_table[PRN][doppler_num][1]; + second_magnitude = result_table[PRN][doppler_num][1]; total_fft_scaling_factor = result_table[PRN][doppler_num][2]; - fw_fft_scaling_factor = result_table[PRN][doppler_num][3]; + //fw_fft_scaling_factor = result_table[PRN][doppler_num][3]; doppler_num = doppler_num + 1; std::cout << "==================== Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << "Power sum = " << power_sum << std::endl; - std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << " FW FFT scaling factor = " << fw_fft_scaling_factor << std::endl; - peak_to_power = max_magnitude/power_sum; - power_sum = (power_sum - max_magnitude) / (fft_size - 1); - test_statistics = (max_magnitude / power_sum); - std::cout << "peak to power = " << peak_to_power << " test_statistics = " << test_statistics << std::endl; + std::cout << "Max magnitude = " << max_magnitude << std::endl; + std::cout << "Second magnitude = " << second_magnitude << std::endl; + std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; + //peak_to_power = max_magnitude/power_sum; + //power_sum = (power_sum - max_magnitude) / (fft_size - 1); + test_statistics = (max_magnitude / second_magnitude); + std::cout << " test_statistics = " << test_statistics << std::endl; } int dummy_val; std::cout << "Enter a value to continue"; From 1c80eaa50c2eb6700ae770dec876338249d35014 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 7 Nov 2018 20:21:05 +0100 Subject: [PATCH 13/53] corrected a bug in the fpga tracking pull-in test where a parameter was rewritten with an incorrect value modified the fpga tracking pull-in test to take into account the downsampling factor in the L1/E1 queue --- .../gps_l1_ca_pcps_acquisition_fpga.cc | 7 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 25 ++- .../acquisition/libs/fpga_acquisition.cc | 4 + .../tracking/tracking_pull-in_test_fpga.cc | 153 ++++++++++++++---- 4 files changed, 152 insertions(+), 37 deletions(-) diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index d34584d55..2e23fd0f8 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -69,10 +69,10 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( printf("downsampling_factor = %f\n", downsampling_factor); acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter - //printf("fs_in pre downsampling = %ld\n", fs_in); + printf("fs_in pre downsampling = %ld\n", fs_in); fs_in = fs_in/downsampling_factor; - //printf("fs_in post downsampling = %ld\n", fs_in); + printf("fs_in post downsampling = %ld\n", fs_in); //printf("####### DEBUG Acq: fs_in = %d\n", fs_in); acq_parameters.fs_in = fs_in; @@ -89,7 +89,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; - //printf("acq adapter vector_length = %d\n", vector_length); + printf("acq adapter vector_length = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); printf("select queue = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; @@ -265,6 +265,7 @@ void GpsL1CaPcpsAcquisitionFpga::set_local_code() void GpsL1CaPcpsAcquisitionFpga::reset() { + //printf("######### acq RESET called\n"); acquisition_fpga_->set_active(true); //printf("acq reset end dddsss\n"); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index c89a40247..3cef0d117 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -137,8 +137,16 @@ void pcps_acquisition_fpga::init() d_gnss_synchro->Acq_samplestamp_samples = 0; d_mag = 0.0; d_input_power = 0.0; - d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))) + 1; - //printf("acq gnuradioblock doppler_max = %lu\n", (unsigned long) static_cast(acq_parameters.doppler_max)); + + if (d_single_doppler_flag == 1) + { + d_num_doppler_bins = 1; + } + else + { + d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))) + 1; + } + //printf("acq gnuradioblock doppler_max = %lu\n", (unsigned long) static_cast(acq_parameters.doppler_max)); //printf("acq gnuradioblock doppler_step = %lu\n", (unsigned long) d_doppler_step); //printf("acq gnuradioblock d_num_doppler_bins = %lu\n", (unsigned long) d_num_doppler_bins); acquisition_fpga->init(); @@ -251,7 +259,7 @@ void pcps_acquisition_fpga::set_active(bool active) // while(1) //{ - + //printf("######### acq ENTERING SET ACTIVE\n"); // run loop in hw //printf("LAUNCH ACQ\n"); @@ -260,6 +268,7 @@ void pcps_acquisition_fpga::set_active(bool active) acquisition_fpga->configure_acquisition(); acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); + //printf("d_num_doppler_bins = %d\n", (int) d_num_doppler_bins); acquisition_fpga->write_local_code(); //acquisition_fpga->set_doppler_sweep(2); @@ -275,6 +284,8 @@ void pcps_acquisition_fpga::set_active(bool active) //printf("reading results for channel %d\n", (int) d_channel); acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); + //printf("returned d_doppler_index = %d\n", d_doppler_index); + //printf("gnuradio block : d_total_block_exp = %d total_block_exp = %d\n", (int) d_total_block_exp, (int) total_block_exp); if (total_block_exp > d_total_block_exp) @@ -358,13 +369,14 @@ void pcps_acquisition_fpga::set_active(bool active) //printf("yes here\n"); d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext % acq_parameters.samples_per_code)); //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition - d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5; // delay due to the downsampling filter in the acquisition + d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81/d_downsampling_factor; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % acq_parameters.samples_per_code)); //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext)); //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter*2 - 81; //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; + } else { @@ -428,7 +440,8 @@ void pcps_acquisition_fpga::set_active(bool active) //printf("acq d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); //printf("acq d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); - + //printf("acq d_gnss_synchro->Acq_doppler_hz = %f\n", d_gnss_synchro->Acq_doppler_hz); + //printf("acq d_gnss_synchro->PRN = %d\n", (int) d_gnss_synchro->PRN); } else { @@ -437,7 +450,7 @@ void pcps_acquisition_fpga::set_active(bool active) send_negative_acquisition(); } - + //printf("######### acq LEAVING SET ACTIVE\n"); //printf("acq set active end\n"); } diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 09b28e88a..fa2676e4f 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -255,6 +255,7 @@ void fpga_acquisition::run_acquisition(void) // launch the acquisition process //printf("acq lib launchin acquisition ...\n"); + //printf("acq lib launch acquisition\n"); d_map_base[8] = LAUNCH_ACQUISITION; // writing a 1 to reg 8 launches the acquisition process //printf("acq lib waiting for interrupt ...\n"); int32_t irq_count; @@ -263,6 +264,7 @@ void fpga_acquisition::run_acquisition(void) uint32_t result_valid = 0; usleep(50); + //printf("acq lib waiting for result valid\n"); while(result_valid == 0) { read_result_valid(&result_valid); // polling @@ -342,6 +344,7 @@ void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) float phase_step_rad_int_temp; int32_t phase_step_rad_int; //int32_t doppler = static_cast(-d_doppler_max) + d_doppler_step * doppler_index; + //printf("executing with doppler = %d\n", (int) d_doppler_max); int32_t doppler = static_cast(d_doppler_max); //float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); @@ -364,6 +367,7 @@ void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) //printf("AAA writing phase_step_rad_int for initial doppler = %d to d map base 3\n", phase_step_rad_int); d_map_base[3] = phase_step_rad_int; + //printf("executing with doppler step = %d\n", (int) d_doppler_step); // repeat the calculation with the doppler step doppler = static_cast(d_doppler_step); phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 2b1f4020f..cd8198527 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -73,7 +73,7 @@ #define NSAMPLES_TRACKING 200000000 // number of samples during which we test the tracking module #define NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop - +#define DOWNAMPLING_FILTER_INIT_SAMPLES 2000 // some samples to initialize the state of the downsampling filter // HW related options bool doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if doppler_control_in_sw = 1), 0=> do not show it @@ -196,7 +196,6 @@ public: std::string implementation = FLAGS_trk_test_implementation; const int baseband_sampling_freq = FLAGS_fs_gen_sps; - std::string filename_rinex_obs = FLAGS_filename_rinex_obs; std::string filename_raw_data = FLAGS_signal_file; @@ -305,12 +304,13 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.dump", "true"); config->set_property("Tracking.dump_filename", "./tracking_ch_"); config->set_property("Tracking.implementation", implementation); - config->set_property("Tracking.item_type", "gr_complex"); + //config->set_property("Tracking.item_type", "gr_complex"); + config->set_property("Tracking.item_type", "cshort"); config->set_property("Tracking.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); config->set_property("Tracking.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); - config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); - config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); - config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); + //config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + //config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + //config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); gnss_synchro.PRN = FLAGS_test_satellite_PRN; gnss_synchro.Channel_ID = 0; config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); @@ -324,7 +324,12 @@ void TrackingPullInTestFpga::configure_receiver( System_and_Signal = "GPS L1 CA"; signal.copy(gnss_synchro.Signal, 2, 0); config->set_property("Tracking.early_late_space_chips", "0.5"); - config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); + //config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); + // added by me + config->set_property("Tracking.if", "0"); + config->set_property("Tracking.order", "3"); + + } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { @@ -483,7 +488,7 @@ void *handler_DMA(void *arguments) int skip_samples = (int) FLAGS_skip_samples; fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); - + //printf("sending %d samples starting at position %d\n", nsamples_tx,skip_samples + skip_used_samples); //printf("\n dma skip_samples = %d\n", skip_samples); //printf("\n dma skip used samples = %d\n", skip_used_samples); //printf("dma skip_samples = %d\n", skip_samples); @@ -606,8 +611,11 @@ void *handler_DMA_tracking(void *arguments) fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); - printf("\n dma skip_samples = %d\n", skip_samples); - printf("\n dma skip used samples = %d\n", skip_used_samples); + //printf("sending %d samples starting at position %d\n", nsamples_tx,skip_samples + skip_used_samples); + //printf("\nTRK skip 0 samples\n"); + //printf("\n dma skip_samples = %d\n", skip_samples); + //printf("\n dma skip used samples = %d\n", skip_used_samples); + //printf("dma file_completed = %d\n", file_completed); //printf("dma nsamples = %d\n", nsamples); //printf("dma nsamples_tx = %d\n", nsamples_tx); @@ -615,7 +623,7 @@ void *handler_DMA_tracking(void *arguments) while (file_completed == false) { - + //printf("dma remaining samples = %d\n", (int) (nsamples_tx - nsamples)); if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) { nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; @@ -672,6 +680,7 @@ void *handler_DMA_tracking(void *arguments) } } + printf("tracking dma process finished\n"); close(tx_fd); fclose(rx_signal_file_id); @@ -691,6 +700,17 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { pthread_t thread_DMA; + int baseband_sampling_freq_acquisition; + // step 0 determine the sampling frequency + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 + } + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); @@ -943,19 +963,19 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL1Ca_Fpga->reset(); + acquisition_GpsL1Ca_Fpga->reset(); // set active } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - acquisition_GpsE1_Fpga->reset(); + acquisition_GpsE1_Fpga->reset(); // set active } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsE5a_Fpga->reset(); + acquisition_GpsE5a_Fpga->reset(); // set active } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL5_Fpga->reset(); + acquisition_GpsL5_Fpga->reset(); // set active } if (start_msg == true) @@ -997,25 +1017,30 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { unsigned int code_length; + unsigned int nsamples_to_transfer; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); - + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } - float nbits = ceilf(log2f((float)code_length)); + + float nbits = ceilf(log2f((float)code_length*2)); unsigned int fft_size = pow(2, nbits); unsigned int nsamples_total = fft_size; @@ -1067,6 +1092,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { + //printf("doppler_shift = %d\n", doppler_shift); tmp_gnss_synchro.PRN = PRN; pthread_mutex_lock(&mutex); @@ -1121,7 +1147,34 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } args.file = file; - args.nsamples_tx = fft_size; //50000; // max size of the FFT + + + + // send the previous samples to set the downsampling filter in a good condition +// send_samples_start = 0; +// if (skip_samples_already_used == 1) +// { +// args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before +// } +// else +// { +// args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before +// } +// args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES; //50000; // max size of the FFT +// if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) +// { +// printf("ERROR cannot create DMA Process\n"); +// } +// pthread_mutex_lock(&mutex); +// send_samples_start = 1; +// pthread_mutex_unlock(&mutex); +// pthread_join(thread_DMA, NULL); +// send_samples_start = 0; +// printf("finished sending samples init filter status\n"); + + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + if (skip_samples_already_used == 1) { args.skip_used_samples = (PRN -1)*fft_size; @@ -1131,6 +1184,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.skip_used_samples = 0; } + // create DMA child process //printf("||||||||1 args freq_band = %d\n", args.freq_band); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) @@ -1147,23 +1201,27 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL1Ca_Fpga->reset(); + acquisition_GpsL1Ca_Fpga->reset(); // set active } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - acquisition_GpsE1_Fpga->reset(); + acquisition_GpsE1_Fpga->reset(); // set active } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsE5a_Fpga->reset(); + acquisition_GpsE5a_Fpga->reset(); // set active } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL5_Fpga->reset(); + acquisition_GpsL5_Fpga->reset(); // set active } +// pthread_mutex_lock(&mutex); // it doesn't work if it is done here +// send_samples_start = 1; +// pthread_mutex_unlock(&mutex); + if (start_msg == true) - { + { std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; std::cout << "["; @@ -1208,6 +1266,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) result_table[PRN][doppler_num][2] = total_fft_scaling_factor; doppler_num = doppler_num + 1; + //printf("max_magnitude_iteration = %f\n", max_magnitude_iteration); + //printf("second_magnitude_iteration = %f\n", second_magnitude_iteration); if (max_magnitude_iteration > max_magnitude) { max_index = max_index_iteration; @@ -1304,10 +1364,22 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) // pointer to the DMA thread that sends the samples to the acquisition engine pthread_t thread_DMA; - + //printf("AAAA000\n"); struct DMA_handler_args args; +// // step 0 determine the sampling frequency +// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) +// { +// baseband_sampling_freq = baseband_sampling_freq/4; // downsampling filter in L1/E1 +// } +// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) +// { +// baseband_sampling_freq = baseband_sampling_freq/4; // downsampling filter in L1/E1 +// } + + + //************************************************* //***** STEP 1: Prepare the parameters sweep ****** //************************************************* @@ -1327,6 +1399,8 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) acq_delay_error_chips_values.push_back(tmp_vector); } + //printf("BBB\n"); + //*********************************************************** //***** STEP 2: Generate the input signal (if required) ***** //*********************************************************** @@ -1350,6 +1424,10 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } } + //printf("CCC\n"); + + // DEBUG + // use generator or use an external capture file if (FLAGS_enable_external_signal_file) { @@ -1373,12 +1451,15 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } } + configure_receiver(FLAGS_PLL_bw_hz_start, FLAGS_DLL_bw_hz_start, FLAGS_PLL_narrow_bw_hz, FLAGS_DLL_narrow_bw_hz, FLAGS_extend_correlation_symbols); + //printf("DDD\n"); + //****************************************************************************************** //***** Obtain the initial signal sinchronization parameters (emulating an acquisition) **** //****************************************************************************************** @@ -1455,6 +1536,21 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) //acq_samplestamp_samples = 108856983; //true_acq_doppler_hz = 3250; //true_acq_delay_samples = 836; + //acq_samplestamp_samples = 0; + //true_acq_doppler_hz = -3000; + //true_acq_delay_samples = 748; + +// acq_samplestamp_samples = 636461056; +// true_acq_doppler_hz = -3125; +// true_acq_delay_samples = 1077; + +// acq_samplestamp_samples = 104898560; +// true_acq_doppler_hz = -2500; +// true_acq_delay_samples = 5353; + +// acq_samplestamp_samples = 523050976; +// true_acq_doppler_hz = 3500; +// true_acq_delay_samples = 932; gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; //simulate a Doppler error in acquisition @@ -1563,6 +1659,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) top_block->stop(); + printf("going to send more samples\n"); // send more samples to unblock the tracking process in case it was waiting for samples args.file = file; if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) From 047807ba0ca115d754632f75fa6121002d9639b4 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Thu, 8 Nov 2018 19:19:39 +0100 Subject: [PATCH 14/53] solved a bug that caused the tracking pull-in test in the FPGA not to work when using the downsampling filter in the acquisition. --- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 44 +++- .../tracking/tracking_pull-in_test_fpga.cc | 221 +++++++++++++----- 2 files changed, 206 insertions(+), 59 deletions(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 3cef0d117..45e093a0f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -369,7 +369,7 @@ void pcps_acquisition_fpga::set_active(bool active) //printf("yes here\n"); d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext % acq_parameters.samples_per_code)); //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition - d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition + d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81/d_downsampling_factor; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % acq_parameters.samples_per_code)); //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext)); @@ -438,10 +438,10 @@ void pcps_acquisition_fpga::set_active(bool active) send_positive_acquisition(); d_state = 0; // Positive acquisition - //printf("acq d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); - //printf("acq d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); - //printf("acq d_gnss_synchro->Acq_doppler_hz = %f\n", d_gnss_synchro->Acq_doppler_hz); - //printf("acq d_gnss_synchro->PRN = %d\n", (int) d_gnss_synchro->PRN); + // printf("acq d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); + // printf("acq d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); + // printf("acq d_gnss_synchro->Acq_doppler_hz = %f\n", d_gnss_synchro->Acq_doppler_hz); + // printf("acq d_gnss_synchro->PRN = %d\n", (int) d_gnss_synchro->PRN); } else { @@ -480,6 +480,40 @@ void pcps_acquisition_fpga::read_acquisition_results(uint32_t *max_index, acquisition_fpga->read_acquisition_results(max_index, max_magnitude, second_magnitude, initial_sample, &input_power, doppler_index, total_fft_scaling_factor); + if (d_select_queue_Fpga == 0) + { + if (d_downsampling_factor > 1) + { + //printf("yes here\n"); + *max_index = static_cast(d_downsampling_factor*(*max_index)); + //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition + *initial_sample = d_downsampling_factor*(*initial_sample) - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81/d_downsampling_factor; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % acq_parameters.samples_per_code)); + //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext)); + //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter*2 - 81; + //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; + + } + else + { + //printf("xxxxxxxxxxxxxxxx no here\n"); + //max_index = static_cast(indext % acq_parameters.samples_per_code); + //initial_sample = d_sample_counter; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition + //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5*d_downsampling_factor; + } + } +// else +// { +// d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); +// d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition +// } + + + + // acquisition_fpga->read_acquisition_results(max_index, max_magnitude, // initial_sample, power_sum, doppler_index); } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index cd8198527..99f5f50b6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -73,7 +73,9 @@ #define NSAMPLES_TRACKING 200000000 // number of samples during which we test the tracking module #define NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop -#define DOWNAMPLING_FILTER_INIT_SAMPLES 2000 // some samples to initialize the state of the downsampling filter +#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define DOWNSAMPLING_FILTER_DELAY 11 + // HW related options bool doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if doppler_control_in_sw = 1), 0=> do not show it @@ -1030,12 +1032,12 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } @@ -1069,6 +1071,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) float result_table[MAX_PRN_IDX][num_doppler_steps][3]; for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 13; PRN < 15; PRN++) { uint32_t max_index = 0; @@ -1149,42 +1152,62 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.file = file; - - // send the previous samples to set the downsampling filter in a good condition -// send_samples_start = 0; -// if (skip_samples_already_used == 1) -// { -// args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before -// } -// else -// { -// args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before -// } -// args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES; //50000; // max size of the FFT -// if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) -// { -// printf("ERROR cannot create DMA Process\n"); -// } -// pthread_mutex_lock(&mutex); -// send_samples_start = 1; -// pthread_mutex_unlock(&mutex); -// pthread_join(thread_DMA, NULL); -// send_samples_start = 0; -// printf("finished sending samples init filter status\n"); - - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (skip_samples_already_used == 1) + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"))) { - args.skip_used_samples = (PRN -1)*fft_size; + //---------------------------------------------------------------------------------- + // send the previous samples to set the downsampling filter in a good condition + send_samples_start = 0; + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + else + { + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY; //50000; // max size of the FFT + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start = 0; + //printf("finished sending samples init filter status\n"); + //----------------------------------------------------------------------------------- + + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY; + } + else + { + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; + } } else { - args.skip_used_samples = 0; + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } } + + // create DMA child process //printf("||||||||1 args freq_band = %d\n", args.freq_band); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) @@ -1268,14 +1291,29 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) //printf("max_magnitude_iteration = %f\n", max_magnitude_iteration); //printf("second_magnitude_iteration = %f\n", second_magnitude_iteration); - if (max_magnitude_iteration > max_magnitude) + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"))) + { + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + initial_sample = initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + } + else { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + initial_sample = initial_sample_iteration - (DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY); + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } } top_block->stop(); } @@ -1286,9 +1324,11 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); if (test_statistics > threshold) { + //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); std::cout << " " << PRN << " "; doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); + code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) } else @@ -1361,6 +1401,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) TEST_F(TrackingPullInTestFpga, ValidationOfResults) { + // pointer to the DMA thread that sends the samples to the acquisition engine pthread_t thread_DMA; @@ -1368,6 +1409,17 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) struct DMA_handler_args args; + int interpolation_factor; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + interpolation_factor = 4; // downsampling filter in L1/E1 + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + interpolation_factor = 4; // downsampling filter in L1/E1 + } + + // // step 0 determine the sampling frequency // if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) // { @@ -1451,7 +1503,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } } - + //printf("#################################### CONFIGURE \n"); configure_receiver(FLAGS_PLL_bw_hz_start, FLAGS_DLL_bw_hz_start, FLAGS_PLL_narrow_bw_hz, @@ -1468,6 +1520,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) double true_acq_delay_samples = 0.0; uint64_t acq_samplestamp_samples = 0; + //printf("#################################### NEXT\n"); tracking_true_obs_reader true_obs_data; if (!FLAGS_enable_external_signal_file) { @@ -1524,7 +1577,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) unsigned int fft_size = pow(2, nbits); - + printf("####################################\n"); for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) { std::vector pull_in_results_v; @@ -1548,10 +1601,18 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) // true_acq_doppler_hz = -2500; // true_acq_delay_samples = 5353; -// acq_samplestamp_samples = 523050976; -// true_acq_doppler_hz = 3500; -// true_acq_delay_samples = 932; + //acq_samplestamp_samples = 79470544; + //true_acq_doppler_hz = -4000; + //true_acq_delay_samples = 1292; + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"))) + { + acq_samplestamp_samples = 0; + + true_acq_delay_samples = true_acq_delay_samples - interpolation_factor*DOWNSAMPLING_FILTER_DELAY; + printf("acq_samplestamp_samples = %d\n", (int)acq_samplestamp_samples); + printf("true_acq_delay_samples = %d\n", (int)true_acq_delay_samples); + } gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; //simulate a Doppler error in acquisition gnss_synchro.Acq_doppler_hz = true_acq_doppler_hz + acq_doppler_error_hz_values.at(current_acq_doppler_error_idx); @@ -1618,24 +1679,76 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) }) << "Failure connecting the blocks of tracking test."; + std::string file = FLAGS_signal_file; + + args.file = file; + +// if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"))) +// { +// //---------------------------------------------------------------------------------- +// // send the previous samples to set the downsampling filter in a good condition +// send_samples_start = 0; +// if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) +// { +// args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; +// } +// else +// { +// args.skip_used_samples = 0; +// } +// args.nsamples_tx = DOWNSAMPLING_FILTER_DELAY; //50000; // max size of the FFT +// if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) +// { +// printf("ERROR cannot create DMA Process\n"); +// } +// pthread_mutex_lock(&mutex); +// send_samples_start = 1; +// pthread_mutex_unlock(&mutex); +// pthread_join(thread_DMA, NULL); +// send_samples_start = 0; +// //printf("finished sending samples init filter status\n"); +// //----------------------------------------------------------------------------------- +// if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) +// { +// args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size + DOWNSAMPLING_FILTER_DELAY; +// } +// else +// { +// args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; +// } +// +// } +// else +// { + if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) + { + args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } + // } + + //******************************************************************** //***** STEP 5: Perform the signal tracking and read the results ***** //******************************************************************** - std::string file = FLAGS_signal_file; + //std::string file = FLAGS_signal_file; - args.file = file; + //args.file = file; args.nsamples_tx = NSAMPLES_TRACKING; // number of samples to transfer - if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) - { - args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } +// if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) +// { +// args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; +// } +// else +// { +// args.skip_used_samples = 0; +// } //args.skip_used_samples = 0; //printf("||||||||1 args freq_band = %d\n", args.freq_band); From f150fe02c73ea162dd38d87615a9bd1904d0520e Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Fri, 9 Nov 2018 20:50:32 +0100 Subject: [PATCH 15/53] solved a bug which caused the tracking pull-in test not to work correctly with Galileo E1 when using the downsampling filter in the acquisition. --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 7 + .../gnuradio_blocks/pcps_acquisition_fpga.cc | 17 +- .../acquisition/libs/fpga_acquisition.cc | 10 +- .../tracking/tracking_pull-in_test_fpga.cc | 365 ++++++++++-------- 4 files changed, 225 insertions(+), 174 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index adf165d09..d7eac4b7f 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -69,8 +69,12 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( //fs_in = fs_in/2.0; // downampling filter //printf("fs_in pre downsampling = %ld\n", fs_in); + printf("fs_in pre downsampling = %ld\n", fs_in); fs_in = fs_in/downsampling_factor; + + printf("fs_in post downsampling = %ld\n", fs_in); + //printf("fs_in post downsampling = %ld\n", fs_in); @@ -121,8 +125,11 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; + printf("acq adapter vector_length = %d\n", vector_length); //printf("acq adapter nsamples_total (= vector_length) = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); + printf("select queue = %d\n", select_queue_Fpga); + acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 45e093a0f..0af1b79f8 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -438,10 +438,10 @@ void pcps_acquisition_fpga::set_active(bool active) send_positive_acquisition(); d_state = 0; // Positive acquisition - // printf("acq d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); - // printf("acq d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); - // printf("acq d_gnss_synchro->Acq_doppler_hz = %f\n", d_gnss_synchro->Acq_doppler_hz); - // printf("acq d_gnss_synchro->PRN = %d\n", (int) d_gnss_synchro->PRN); + //printf("acq d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); + //printf("acq d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); + //printf("acq d_gnss_synchro->Acq_doppler_hz = %f\n", d_gnss_synchro->Acq_doppler_hz); + //printf("acq d_gnss_synchro->PRN = %d\n", (int) d_gnss_synchro->PRN); } else { @@ -477,7 +477,9 @@ void pcps_acquisition_fpga::read_acquisition_results(uint32_t *max_index, float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) { float input_power; // not used - acquisition_fpga->read_acquisition_results(max_index, max_magnitude, second_magnitude, initial_sample, &input_power, doppler_index, total_fft_scaling_factor); + uint32_t max_index_tmp; + uint64_t initial_sample_tmp; + acquisition_fpga->read_acquisition_results(&max_index_tmp, max_magnitude, second_magnitude, &initial_sample_tmp, &input_power, doppler_index, total_fft_scaling_factor); if (d_select_queue_Fpga == 0) @@ -485,9 +487,9 @@ void pcps_acquisition_fpga::read_acquisition_results(uint32_t *max_index, if (d_downsampling_factor > 1) { //printf("yes here\n"); - *max_index = static_cast(d_downsampling_factor*(*max_index)); + *max_index = static_cast(d_downsampling_factor*(max_index_tmp)); //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition - *initial_sample = d_downsampling_factor*(*initial_sample) - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition + *initial_sample = (initial_sample_tmp)*d_downsampling_factor - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81/d_downsampling_factor; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % acq_parameters.samples_per_code)); //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext)); @@ -505,6 +507,7 @@ void pcps_acquisition_fpga::read_acquisition_results(uint32_t *max_index, //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5*d_downsampling_factor; } } +// printf("gnuradioblock acq samplestamp = %d\n", (int) *initial_sample); // else // { // d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index fa2676e4f..27f53efee 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -135,6 +135,7 @@ fpga_acquisition::fpga_acquisition(std::string device_name, d_map_base = nullptr; // driver memory map d_all_fft_codes = all_fft_codes; + //printf("acq internal device name = %s\n", d_device_name.c_str()); // open communication with HW accelerator if ((d_fd = open(d_device_name.c_str(), O_RDWR | O_SYNC)) == -1) { @@ -239,7 +240,7 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local //printf("debug local code %d real = %d imag = %d local_code = %d fft_data = %d\n", k, tmp, tmp2, local_code, fft_data); //printf("debug local code %d real = 0x%08X imag = 0x%08X local_code = 0x%08X fft_data = 0x%08X\n", k, tmp, tmp2, local_code, fft_data); } - //printf("d_vector_length = %d\n", d_vector_length); + //printf("acq d_vector_length = %d\n", d_vector_length); //while(1); } @@ -269,6 +270,7 @@ void fpga_acquisition::run_acquisition(void) { read_result_valid(&result_valid); // polling } + //printf("result valid\n"); // wait for interrupt //nb = read(d_fd, &irq_count, sizeof(irq_count)); //usleep(500000); // debug @@ -382,7 +384,7 @@ void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings //printf("AAA writing phase_step_rad_int for doppler step = %d to d map base 4\n", phase_step_rad_int); d_map_base[4] = phase_step_rad_int; - //printf("AAA writing num sweeps to d map base 5 = %d\n", num_sweeps); + //printf("AAA writing num sweeps to d map base 5 = 1\n"); d_map_base[5] = 1; // 1 sweep } @@ -442,9 +444,9 @@ void fpga_acquisition::configure_acquisition() //printf("acq lib configure acquisition called\n"); //printf("AAA d_select_queue = %d\n", d_select_queue); d_map_base[0] = d_select_queue; - //printf("AAA writing d_vector_length = %d to d map base 1\n ", d_vector_length); + //printf("acq internal writing d_vector_length = %d to d map base 1\n ", d_vector_length); d_map_base[1] = d_vector_length; - //printf("AAA writing d_nsamples = %d to d map base 2\n ", d_nsamples); + //printf("acq interal writing d_nsamples = %d to d map base 2\n ", d_nsamples); d_map_base[2] = d_nsamples; //printf("AAA writing LOG2 d_vector_length = %d to d map base 7\n ", (int)log2((float)d_vector_length)); d_map_base[7] = static_cast(log2(static_cast(d_vector_length))); // log2 FFTlength diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 99f5f50b6..a56b06189 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -73,7 +73,7 @@ #define NSAMPLES_TRACKING 200000000 // number of samples during which we test the tracking module #define NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop -#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter #define DOWNSAMPLING_FILTER_DELAY 11 // HW related options @@ -448,7 +448,7 @@ struct DMA_handler_args { void *handler_DMA(void *arguments) { - //printf("in handler DMA NO tracking\n"); + // DMA process that configures the DMA to send the samples to the acquisition engine int tx_fd; // DMA descriptor FILE *rx_signal_file_id; // Input file descriptor @@ -464,6 +464,7 @@ void *handler_DMA(void *arguments) struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; unsigned int nsamples_tx = args->nsamples_tx; + //printf("in handler DMA to send %d\n", nsamples_tx); std::string file = args->file; // input filename unsigned int skip_used_samples = args->skip_used_samples; @@ -483,9 +484,9 @@ void *handler_DMA(void *arguments) printf("DMA can't open input file\n"); exit(1); } - + //printf("in handler DMA waiting for send samples start\n"); while(send_samples_start == 0); // wait until acquisition starts - + //printf("in handler DMA going to send samples\n"); // skip initial samples int skip_samples = (int) FLAGS_skip_samples; @@ -498,11 +499,15 @@ void *handler_DMA(void *arguments) //printf("dma file_completed = %d\n", file_completed); //printf("dma nsamples = %d\n", nsamples); //printf("dma nsamples_tx = %d\n", nsamples_tx); + usleep(50000); // wait some time to give time to the main thread to start the acquisition module + unsigned int kk; + //printf("enter kk"); + //scanf("%d", &kk); while (file_completed == false) { - + //printf("samples sent = %d\n", nsamples); if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) { nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; @@ -549,9 +554,9 @@ void *handler_DMA(void *arguments) } dma_index += 4; } - + //printf("writing samples to send\n"); nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); - + //printf("exited writing samples to send\n"); if (nsamples_transmitted != nread_elements*NUM_QUEUES) { std::cout << "Error : DMA could not send all the requested samples" << std::endl; @@ -559,9 +564,10 @@ void *handler_DMA(void *arguments) } } + close(tx_fd); fclose(rx_signal_file_id); - + //printf("DMA finished\n"); return NULL; } @@ -707,10 +713,12 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 + printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 + printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) @@ -769,6 +777,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) acquisition_GpsE1_Fpga->set_channel(0); acquisition_GpsE1_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); acquisition_GpsE1_Fpga->connect(top_block); + printf(" bbbbbbbb baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -836,6 +845,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { top_block->msg_connect(acquisition_GpsE1_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + printf(" cccccc baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -878,145 +888,145 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) setup_fpga_switch(); - if (doppler_control_in_sw == 0) - { - - args.file = file; - args.nsamples_tx = NSAMPLES_ACQ_DOPPLER_SWEEP; // number of samples to transfer - args.skip_used_samples = 0; - - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(0); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_single_doppler_flag(0); - args.freq_band = 1; - } - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - - tmp_gnss_synchro.PRN = PRN; - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_GpsL1Ca_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_GpsE1_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_GpsE5a_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_GpsL5_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - } - - // create DMA child process - //printf("|||||||| args freq_band = %d\n", args.freq_band); - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); // set active - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); // set active - } - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); - - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - - if (msg_rx->rx_message == 1) - { - std::cout << " " << PRN << " "; - doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); - code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); - acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); - } - else - { - std::cout << " . "; - } - top_block->stop(); - std::cout.flush(); - } - } - else - { +// if (doppler_control_in_sw == 0) +// { +// +// args.file = file; +// args.nsamples_tx = NSAMPLES_ACQ_DOPPLER_SWEEP; // number of samples to transfer +// args.skip_used_samples = 0; +// +// +// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(0); +// args.freq_band = 0; +// } +// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) +// { +// acquisition_GpsE1_Fpga->set_single_doppler_flag(0); +// args.freq_band = 0; +// } +// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsE5a_Fpga->set_single_doppler_flag(0); +// args.freq_band = 1; +// } +// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL5_Fpga->set_single_doppler_flag(0); +// args.freq_band = 1; +// } +// +// for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) +// { +// +// tmp_gnss_synchro.PRN = PRN; +// +// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL1Ca_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); +// acquisition_GpsL1Ca_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); +// +// acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); +// acquisition_GpsL1Ca_Fpga->init(); +// acquisition_GpsL1Ca_Fpga->set_local_code(); +// } +// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) +// { +// acquisition_GpsE1_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); +// acquisition_GpsE1_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); +// +// acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); +// acquisition_GpsE1_Fpga->init(); +// acquisition_GpsE1_Fpga->set_local_code(); +// } +// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsE5a_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); +// acquisition_GpsE5a_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); +// +// acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); +// acquisition_GpsE5a_Fpga->init(); +// acquisition_GpsE5a_Fpga->set_local_code(); +// } +// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL5_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); +// acquisition_GpsL5_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); +// +// acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); +// acquisition_GpsL5_Fpga->init(); +// acquisition_GpsL5_Fpga->set_local_code(); +// } +// +// // create DMA child process +// //printf("|||||||| args freq_band = %d\n", args.freq_band); +// if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) +// { +// printf("ERROR cannot create DMA Process\n"); +// } +// +// msg_rx->rx_message = 0; +// top_block->start(); +// +// pthread_mutex_lock(&mutex); +// send_samples_start = 1; +// pthread_mutex_unlock(&mutex); +// +// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL1Ca_Fpga->reset(); // set active +// } +// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) +// { +// acquisition_GpsE1_Fpga->reset(); // set active +// } +// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsE5a_Fpga->reset(); // set active +// } +// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL5_Fpga->reset(); // set active +// } +// +// if (start_msg == true) +// { +// std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; +// std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; +// std::cout << "["; +// start_msg = false; +// } +// +// // wait for the child DMA process to finish +// pthread_join(thread_DMA, NULL); +// +// pthread_mutex_lock(&mutex); +// send_samples_start = 0; +// pthread_mutex_unlock(&mutex); +// +// while (msg_rx->rx_message == 0) +// { +// usleep(100000); +// } +// +// if (msg_rx->rx_message == 1) +// { +// std::cout << " " << PRN << " "; +// doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); +// code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); +// acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); +// } +// else +// { +// std::cout << " . "; +// } +// top_block->stop(); +// std::cout.flush(); +// } +// } +// else +// { unsigned int code_length; unsigned int nsamples_to_transfer; @@ -1028,7 +1038,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -1053,6 +1064,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { acquisition_GpsE1_Fpga->set_single_doppler_flag(1); + printf("eeeeeee just set doppler flag\n"); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -1066,12 +1078,18 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + printf("acq_doppler_max = %d\n", acq_doppler_max); + printf("acq_doppler_step = %d\n", acq_doppler_step); + int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 13; PRN < 15; PRN++) + uint32_t index_debug[MAX_PRN_IDX]; + uint32_t samplestamp_debug[MAX_PRN_IDX]; + + //for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + for (unsigned int PRN = 0; PRN < 17; PRN++) { uint32_t max_index = 0; @@ -1093,6 +1111,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) int doppler_num = 0; + + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { //printf("doppler_shift = %d\n", doppler_shift); @@ -1124,7 +1144,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) acquisition_GpsE1_Fpga->init(); acquisition_GpsE1_Fpga->set_local_code(); args.freq_band = 0; - //printf("ending configuring acquisition\n"); + //printf("ffffffffffff ending configuring acquisition\n"); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -1152,8 +1172,9 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.file = file; - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"))) + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) { + //printf("gggggggg \n"); //---------------------------------------------------------------------------------- // send the previous samples to set the downsampling filter in a good condition send_samples_start = 0; @@ -1166,6 +1187,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before } args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY; //50000; // max size of the FFT + //printf("sending pre init %d\n", args.nsamples_tx); + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); @@ -1210,6 +1233,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) // create DMA child process //printf("||||||||1 args freq_band = %d\n", args.freq_band); + //printf("sending samples main DMA %d\n", args.nsamples_tx); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); @@ -1228,6 +1252,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { + //printf("hhhhhhhhhhhh\n"); acquisition_GpsE1_Fpga->reset(); // set active } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) @@ -1270,6 +1295,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { + //printf("iiiiiiiiiiiiii\n"); acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); } @@ -1291,26 +1317,31 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) //printf("max_magnitude_iteration = %f\n", max_magnitude_iteration); //printf("second_magnitude_iteration = %f\n", second_magnitude_iteration); - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"))) + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) { + //printf("jjjjjjjjjjjjjjj\n"); if (max_magnitude_iteration > max_magnitude) { - max_index = max_index_iteration; + int interpolation_factor = 4; + index_debug[PRN - 1] = max_index_iteration; + max_index = max_index_iteration - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); max_magnitude = max_magnitude_iteration; second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; + samplestamp_debug[PRN - 1] = initial_sample_iteration; + initial_sample = 0; //initial_sample_iteration; doppler_index = doppler_index_iteration; doppler_shift_selected = doppler_shift; } } else { + if (max_magnitude_iteration > max_magnitude) { max_index = max_index_iteration; max_magnitude = max_magnitude_iteration; second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration - (DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY); + initial_sample = initial_sample_iteration; doppler_index = doppler_index_iteration; doppler_shift_selected = doppler_shift; } @@ -1379,7 +1410,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } } - } +// } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -1389,6 +1420,12 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } + for (unsigned k=0;k Date: Mon, 12 Nov 2018 17:44:42 +0100 Subject: [PATCH 16/53] now the FPGA Galileo E1 tracking pull-in tests work successfully --- .../tracking/tracking_pull-in_test_fpga.cc | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index a56b06189..67a112340 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -74,8 +74,8 @@ #define NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop #define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter -#define DOWNSAMPLING_FILTER_DELAY 11 - +#define DOWNSAMPLING_FILTER_DELAY 48 +#define DOWNSAMPLING_FILTER_OFFSET_SAMPLES 0 // HW related options bool doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if doppler_control_in_sw = 1), 0=> do not show it @@ -341,9 +341,14 @@ void TrackingPullInTestFpga::configure_receiver( signal.copy(gnss_synchro.Signal, 2, 0); config->set_property("Tracking.early_late_space_chips", "0.15"); config->set_property("Tracking.very_early_late_space_chips", "0.6"); - config->set_property("Tracking.early_late_space_narrow_chips", "0.15"); - config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); + //config->set_property("Tracking.early_late_space_narrow_chips", "0.15"); + //config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); config->set_property("Tracking.track_pilot", "true"); + + // added by me + config->set_property("Tracking.if", "0"); + config->set_property("Tracking.devicename", "/dev/uio"); + config->set_property("Tracking.device_base", "15"); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) @@ -736,6 +741,16 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); config->set_property("Acquisition.use_CFAR_algorithm", "false"); + config->set_property("Acquisition.item_type", "cshort"); + config->set_property("Acquisition.if", "0"); + config->set_property("Acquisition.sampled_ms", "4"); + config->set_property("Acquisition.select_queue_Fpga", "0"); + config->set_property("Acquisition.devicename", "/dev/uio0"); + + if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + config->set_property("Acquisition.acquire_pilot", "false"); + } std::shared_ptr acquisition_GpsL1Ca_Fpga; std::shared_ptr acquisition_GpsE1_Fpga; std::shared_ptr acquisition_GpsE5a_Fpga; @@ -1088,8 +1103,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) uint32_t index_debug[MAX_PRN_IDX]; uint32_t samplestamp_debug[MAX_PRN_IDX]; - //for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - for (unsigned int PRN = 0; PRN < 17; PRN++) + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 0; PRN < 17; PRN++) { uint32_t max_index = 0; @@ -1186,7 +1201,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before } - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY; //50000; // max size of the FFT + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT //printf("sending pre init %d\n", args.nsamples_tx); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) @@ -1206,11 +1221,11 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (skip_samples_already_used == 1) { - args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY; + args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; } else { - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; } } else @@ -1324,7 +1339,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { int interpolation_factor = 4; index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); + max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); max_magnitude = max_magnitude_iteration; second_magnitude = second_magnitude_iteration; samplestamp_debug[PRN - 1] = initial_sample_iteration; From cf56de15de1b424a49846ca5ddec7aae9c9c4f2c Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 12 Nov 2018 18:54:04 +0100 Subject: [PATCH 17/53] did some code cleaning on the tracking pull-in tests --- .../tracking/tracking_pull-in_test_fpga.cc | 373 +----------------- 1 file changed, 12 insertions(+), 361 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 67a112340..9a0dd636f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -77,12 +77,10 @@ #define DOWNSAMPLING_FILTER_DELAY 48 #define DOWNSAMPLING_FILTER_OFFSET_SAMPLES 0 // HW related options -bool doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW -bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if doppler_control_in_sw = 1), 0=> do not show it -bool skip_samples_already_used = 0; // if doppler_control_in_sw = 1 and skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops +bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results, 0=> do not show it +bool skip_samples_already_used = 0; // if skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops // (exactly in the same way as the SW) - // if doppler_control_in_sw = 1 and skip_samples_already_used = 0 => the sampe samples are used for each doppler sweep - // if doppler_control_in_sw = 0 => skip_samples_already_used is not applicable + // ######## GNURADIO ACQUISITION BLOCK MESSAGE RECEVER ######### @@ -579,134 +577,6 @@ void *handler_DMA(void *arguments) -void *handler_DMA_tracking(void *arguments) -{ - //printf("in handler DMA NO tracking\n"); - // DMA process that configures the DMA to send the samples to the acquisition engine - int tx_fd; // DMA descriptor - FILE *rx_signal_file_id; // Input file descriptor - bool file_completed = false; // flag to indicate if the file is completed - unsigned int nsamples_block; // number of samples to send in the next DMA block of samples - unsigned int nread_elements; // number of elements effectively read from the input file - unsigned int nsamples = 0; // number of complex samples effectively transferred - unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA - unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes - - unsigned int nsamples_transmitted; - - struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; - - unsigned int nsamples_tx = args->nsamples_tx; - std::string file = args->file; // input filename - unsigned int skip_used_samples = args->skip_used_samples; - - // open DMA device - tx_fd = open("/dev/loop_tx", O_WRONLY); - if ( tx_fd < 0 ) - { - printf("DMA can't open loop device\n"); - exit(1); - } - else - - // open input file - rx_signal_file_id = fopen(file.c_str(), "rb"); - if (rx_signal_file_id < 0) - { - printf("DMA can't open input file\n"); - exit(1); - } - - while(send_samples_start == 0); // wait until acquisition starts - - // skip initial samples - int skip_samples = (int) FLAGS_skip_samples; - - - fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); - //printf("sending %d samples starting at position %d\n", nsamples_tx,skip_samples + skip_used_samples); - //printf("\nTRK skip 0 samples\n"); - //printf("\n dma skip_samples = %d\n", skip_samples); - //printf("\n dma skip used samples = %d\n", skip_used_samples); - - //printf("dma file_completed = %d\n", file_completed); - //printf("dma nsamples = %d\n", nsamples); - //printf("dma nsamples_tx = %d\n", nsamples_tx); - usleep(50000); // wait some time to give time to the main thread to start the acquisition module - - while (file_completed == false) - { - //printf("dma remaining samples = %d\n", (int) (nsamples_tx - nsamples)); - if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) - { - nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; - } - else - { - nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent - file_completed = true; - } - - nread_elements = fread(input_samples, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); - - if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) - { - printf("could not read the desired number of samples from the input file\n"); - file_completed = true; - } - - nsamples+=(nread_elements/COMPLEX_SAMPLE_SIZE); - - if (nread_elements > 0) - { - // for the 32-BIT DMA - dma_index = 0; - for (index0 = 0;index0 < (nread_elements);index0+=COMPLEX_SAMPLE_SIZE) - { - if (args->freq_band == 0) - { - // channel 1 (queue 1) -> E5/L5 - input_samples_dma[dma_index] = 0; - input_samples_dma[dma_index+1] = 0; - // channel 0 (queue 0) -> E1/L1 - input_samples_dma[dma_index+2] = input_samples[index0]; - input_samples_dma[dma_index+3] = input_samples[index0+1]; - } - else - { - // channel 1 (queue 1) -> E5/L5 - input_samples_dma[dma_index] = input_samples[index0]; - input_samples_dma[dma_index+1] = input_samples[index0+1]; - // channel 0 (queue 0) -> E1/L1 - input_samples_dma[dma_index+2] = 0; - input_samples_dma[dma_index+3] = 0; - } - dma_index += 4; - } - - nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); - - if (nsamples_transmitted != nread_elements*NUM_QUEUES) - { - std::cout << "Error : DMA could not send all the requested samples" << std::endl; - } - } - } - - printf("tracking dma process finished\n"); - close(tx_fd); - fclose(rx_signal_file_id); - - return NULL; -} - - - - - - - - bool TrackingPullInTestFpga::acquire_signal(int SV_ID) @@ -903,146 +773,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) setup_fpga_switch(); -// if (doppler_control_in_sw == 0) -// { -// -// args.file = file; -// args.nsamples_tx = NSAMPLES_ACQ_DOPPLER_SWEEP; // number of samples to transfer -// args.skip_used_samples = 0; -// -// -// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(0); -// args.freq_band = 0; -// } -// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) -// { -// acquisition_GpsE1_Fpga->set_single_doppler_flag(0); -// args.freq_band = 0; -// } -// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsE5a_Fpga->set_single_doppler_flag(0); -// args.freq_band = 1; -// } -// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL5_Fpga->set_single_doppler_flag(0); -// args.freq_band = 1; -// } -// -// for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) -// { -// -// tmp_gnss_synchro.PRN = PRN; -// -// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL1Ca_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); -// acquisition_GpsL1Ca_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); -// -// acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); -// acquisition_GpsL1Ca_Fpga->init(); -// acquisition_GpsL1Ca_Fpga->set_local_code(); -// } -// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) -// { -// acquisition_GpsE1_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); -// acquisition_GpsE1_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); -// -// acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); -// acquisition_GpsE1_Fpga->init(); -// acquisition_GpsE1_Fpga->set_local_code(); -// } -// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsE5a_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); -// acquisition_GpsE5a_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); -// -// acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); -// acquisition_GpsE5a_Fpga->init(); -// acquisition_GpsE5a_Fpga->set_local_code(); -// } -// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL5_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); -// acquisition_GpsL5_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); -// -// acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); -// acquisition_GpsL5_Fpga->init(); -// acquisition_GpsL5_Fpga->set_local_code(); -// } -// -// // create DMA child process -// //printf("|||||||| args freq_band = %d\n", args.freq_band); -// if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) -// { -// printf("ERROR cannot create DMA Process\n"); -// } -// -// msg_rx->rx_message = 0; -// top_block->start(); -// -// pthread_mutex_lock(&mutex); -// send_samples_start = 1; -// pthread_mutex_unlock(&mutex); -// -// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL1Ca_Fpga->reset(); // set active -// } -// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) -// { -// acquisition_GpsE1_Fpga->reset(); // set active -// } -// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsE5a_Fpga->reset(); // set active -// } -// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL5_Fpga->reset(); // set active -// } -// -// if (start_msg == true) -// { -// std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; -// std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; -// std::cout << "["; -// start_msg = false; -// } -// -// // wait for the child DMA process to finish -// pthread_join(thread_DMA, NULL); -// -// pthread_mutex_lock(&mutex); -// send_samples_start = 0; -// pthread_mutex_unlock(&mutex); -// -// while (msg_rx->rx_message == 0) -// { -// usleep(100000); -// } -// -// if (msg_rx->rx_message == 1) -// { -// std::cout << " " << PRN << " "; -// doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); -// code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); -// acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); -// } -// else -// { -// std::cout << " . "; -// } -// top_block->stop(); -// std::cout.flush(); -// } -// } -// else -// { - unsigned int code_length; unsigned int nsamples_to_transfer; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) @@ -1472,15 +1202,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } -// // step 0 determine the sampling frequency -// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) -// { -// baseband_sampling_freq = baseband_sampling_freq/4; // downsampling filter in L1/E1 -// } -// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) -// { -// baseband_sampling_freq = baseband_sampling_freq/4; // downsampling filter in L1/E1 -// } + @@ -1637,35 +1359,14 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) { for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++) { - // DEBUG TEST THE RESULTS OF THE SW - //acq_samplestamp_samples = 108856983; - //true_acq_doppler_hz = 3250; - //true_acq_delay_samples = 836; - //acq_samplestamp_samples = 0; - //true_acq_doppler_hz = -3000; - //true_acq_delay_samples = 748; -// acq_samplestamp_samples = 636461056; -// true_acq_doppler_hz = -3125; -// true_acq_delay_samples = 1077; -// acq_samplestamp_samples = 104898560; -// true_acq_doppler_hz = -2500; -// true_acq_delay_samples = 5353; - //acq_samplestamp_samples = 79470544; - //true_acq_doppler_hz = -4000; - //true_acq_delay_samples = 1292; -// if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"))) -// { -// acq_samplestamp_samples = 0; -// -// true_acq_delay_samples = true_acq_delay_samples - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - printf("acq_samplestamp_samples = %d\n", (int)acq_samplestamp_samples); - printf("true_acq_delay_samples = %d\n", (int)true_acq_delay_samples); -// } - gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; + printf("acq_samplestamp_samples = %d\n", (int)acq_samplestamp_samples); + printf("true_acq_delay_samples = %d\n", (int)true_acq_delay_samples); + + gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; //simulate a Doppler error in acquisition gnss_synchro.Acq_doppler_hz = true_acq_doppler_hz + acq_doppler_error_hz_values.at(current_acq_doppler_error_idx); //simulate Code Delay error in acquisition @@ -1735,44 +1436,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) args.file = file; -// if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"))) -// { -// //---------------------------------------------------------------------------------- -// // send the previous samples to set the downsampling filter in a good condition -// send_samples_start = 0; -// if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) -// { -// args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; -// } -// else -// { -// args.skip_used_samples = 0; -// } -// args.nsamples_tx = DOWNSAMPLING_FILTER_DELAY; //50000; // max size of the FFT -// if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) -// { -// printf("ERROR cannot create DMA Process\n"); -// } -// pthread_mutex_lock(&mutex); -// send_samples_start = 1; -// pthread_mutex_unlock(&mutex); -// pthread_join(thread_DMA, NULL); -// send_samples_start = 0; -// //printf("finished sending samples init filter status\n"); -// //----------------------------------------------------------------------------------- -// if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) -// { -// args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size + DOWNSAMPLING_FILTER_DELAY; -// } -// else -// { -// args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; -// } -// -// } -// else -// { - if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) + if (skip_samples_already_used == 1) { args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; } @@ -1780,31 +1444,18 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) { args.skip_used_samples = 0; } - // } //******************************************************************** //***** STEP 5: Perform the signal tracking and read the results ***** //******************************************************************** - //std::string file = FLAGS_signal_file; - //args.file = file; args.nsamples_tx = NSAMPLES_TRACKING; // number of samples to transfer -// if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) -// { -// args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; -// } -// else -// { -// args.skip_used_samples = 0; -// } - //args.skip_used_samples = 0; - - //printf("||||||||1 args freq_band = %d\n", args.freq_band); - if (pthread_create(&thread_DMA, NULL, handler_DMA_tracking, (void *)&args) < 0) + //if (pthread_create(&thread_DMA, NULL, handler_DMA_tracking, (void *)&args) < 0) + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } @@ -1827,7 +1478,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) printf("going to send more samples\n"); // send more samples to unblock the tracking process in case it was waiting for samples args.file = file; - if (skip_samples_already_used == 1 && doppler_control_in_sw == 1) + if (skip_samples_already_used == 1) { // skip the samples that have already been used args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size + args.nsamples_tx; From 37c7576e125342babf6c015e9e9ed21a1bd5f424 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Tue, 13 Nov 2018 17:22:08 +0100 Subject: [PATCH 18/53] removed some unused test functions. updated FPGA observables test --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 8 +- ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 2 +- .../galileo_e5a_pcps_acquisition_fpga.cc | 8 +- .../galileo_e5a_pcps_acquisition_fpga.h | 2 +- .../gps_l1_ca_pcps_acquisition_fpga.cc | 8 +- .../gps_l1_ca_pcps_acquisition_fpga.h | 2 +- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 8 +- .../adapters/gps_l5i_pcps_acquisition_fpga.h | 2 +- .../hybrid_observables_test_fpga.cc | 688 +++++++++--------- 9 files changed, 360 insertions(+), 368 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index d7eac4b7f..9e27530d4 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -518,10 +518,10 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::reset_acquisition(void) } // this function is only used for the unit tests -void GalileoE1PcpsAmbiguousAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) -{ - acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); -} +//void GalileoE1PcpsAmbiguousAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +//{ +// acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +//} void GalileoE1PcpsAmbiguousAcquisitionFpga::connect(gr::top_block_sptr top_block) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 6c70c8d11..d2bf05f3f 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -155,7 +155,7 @@ public: /*! * \brief This function is only used in the unit tests */ - void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + //void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); /*! * \brief Stop running acquisition diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index d73f463e8..896237aaa 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -394,10 +394,10 @@ void GalileoE5aPcpsAcquisitionFpga::reset_acquisition(void) } // this function is only used for the unit tests -void GalileoE5aPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) -{ - acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); -} +//void GalileoE5aPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +//{ +// acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +//} void GalileoE5aPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index f681979c9..1681e3f22 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -143,7 +143,7 @@ public: /*! * \brief This function is only used in the unit tests */ - void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + //void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); /*! * \brief Stop running acquisition diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 2e23fd0f8..b058c1806 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -298,10 +298,10 @@ void GpsL1CaPcpsAcquisitionFpga::reset_acquisition(void) } // this function is only used for the unit tests -void GpsL1CaPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) -{ - acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); -} +//void GpsL1CaPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +//{ +// acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +//} void GpsL1CaPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index 9bf3178cf..6edbd0420 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -152,7 +152,7 @@ public: /*! * \brief This function is only used in the unit tests */ - void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + //void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); /*! * \brief Stop running acquisition diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index f75116ed5..1e0a44759 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -367,10 +367,10 @@ void GpsL5iPcpsAcquisitionFpga::reset_acquisition(void) } // this function is only used for the unit tests -void GpsL5iPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) -{ - acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); -} +//void GpsL5iPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +//{ +// acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); +//} void GpsL5iPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index a6ed38eb4..eadd47c0e 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -153,7 +153,7 @@ public: /*! * \brief This function is only used in the unit tests */ - void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + //void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); /*! * \brief Stop running acquisition diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index e365dc61c..0bd96c202 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -79,12 +79,15 @@ #define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define TEST_OBS_NSAMPLES_TRACKING 90000000 // number of samples during which we test the tracking module +#define TEST_OBS_NSAMPLES_TRACKING 500000000 // number of samples during which we test the tracking module #define TEST_OBS_NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop +#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define DOWNSAMPLING_FILTER_DELAY 48 +#define DOWNSAMPLING_FILTER_OFFSET_SAMPLES 0 // HW related options -bool test_observables_doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW +//bool test_observables_doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW bool test_observables_show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if test_observables_doppler_control_in_sw = 1), 0=> do not show it bool test_observables_skip_samples_already_used = 1; // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops // (exactly in the same way as the SW) @@ -381,6 +384,7 @@ struct DMA_handler_args_obs_test { void *handler_DMA_obs_test(void *arguments) { + // DMA process that configures the DMA to send the samples to the acquisition engine int tx_fd; // DMA descriptor FILE *rx_signal_file_id; // Input file descriptor @@ -393,9 +397,10 @@ void *handler_DMA_obs_test(void *arguments) unsigned int nsamples_transmitted; - struct DMA_handler_args_obs_test *args = (struct DMA_handler_args_obs_test *) arguments; + struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; unsigned int nsamples_tx = args->nsamples_tx; + //printf("in handler DMA to send %d\n", nsamples_tx); std::string file = args->file; // input filename unsigned int skip_used_samples = args->skip_used_samples; @@ -415,22 +420,33 @@ void *handler_DMA_obs_test(void *arguments) printf("DMA can't open input file\n"); exit(1); } - + //printf("in handler DMA waiting for send samples start\n"); while(send_samples_start_obs_test == 0); // wait until acquisition starts - + //printf("in handler DMA going to send samples\n"); // skip initial samples int skip_samples = (int) FLAGS_skip_samples; fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); + //printf("sending %d samples starting at position %d\n", nsamples_tx,skip_samples + skip_used_samples); + //printf("\n dma skip_samples = %d\n", skip_samples); + //printf("\n dma skip used samples = %d\n", skip_used_samples); + //printf("dma skip_samples = %d\n", skip_samples); + //printf("dma skip used samples = %d\n", skip_used_samples); + //printf("dma file_completed = %d\n", file_completed); + //printf("dma nsamples = %d\n", nsamples); + //printf("dma nsamples_tx = %d\n", nsamples_tx); usleep(50000); // wait some time to give time to the main thread to start the acquisition module + unsigned int kk; + //printf("enter kk"); + //scanf("%d", &kk); while (file_completed == false) { - - if (nsamples_tx - nsamples > TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + //printf("samples sent = %d\n", nsamples); + if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) { - nsamples_block = TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; } else { @@ -438,67 +454,84 @@ void *handler_DMA_obs_test(void *arguments) file_completed = true; } - nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block*TEST_OBS_COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + nread_elements = fread(input_samples, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); - if (nread_elements != nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE) + if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) { printf("could not read the desired number of samples from the input file\n"); file_completed = true; } - nsamples+=(nread_elements/TEST_OBS_COMPLEX_SAMPLE_SIZE); + nsamples+=(nread_elements/COMPLEX_SAMPLE_SIZE); if (nread_elements > 0) { // for the 32-BIT DMA dma_index = 0; - for (index0 = 0;index0 < (nread_elements);index0+=TEST_OBS_COMPLEX_SAMPLE_SIZE) + for (index0 = 0;index0 < (nread_elements);index0+=COMPLEX_SAMPLE_SIZE) { if (args->freq_band == 0) { // channel 1 (queue 1) -> E5/L5 - input_samples_dma_obs_test[dma_index] = 0; - input_samples_dma_obs_test[dma_index+1] = 0; + input_samples_dma[dma_index] = 0; + input_samples_dma[dma_index+1] = 0; // channel 0 (queue 0) -> E1/L1 - input_samples_dma_obs_test[dma_index+2] = input_samples_obs_test[index0]; - input_samples_dma_obs_test[dma_index+3] = input_samples_obs_test[index0+1]; + input_samples_dma[dma_index+2] = input_samples[index0]; + input_samples_dma[dma_index+3] = input_samples[index0+1]; } else { // channel 1 (queue 1) -> E5/L5 - input_samples_dma_obs_test[dma_index] = input_samples_obs_test[index0]; - input_samples_dma_obs_test[dma_index+1] = input_samples_obs_test[index0+1]; + input_samples_dma[dma_index] = input_samples[index0]; + input_samples_dma[dma_index+1] = input_samples[index0+1]; // channel 0 (queue 0) -> E1/L1 - input_samples_dma_obs_test[dma_index+2] = 0; - input_samples_dma_obs_test[dma_index+3] = 0; + input_samples_dma[dma_index+2] = 0; + input_samples_dma[dma_index+3] = 0; } dma_index += 4; } - - nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements*TEST_OBS_NUM_QUEUES); - - if (nsamples_transmitted != nread_elements*TEST_OBS_NUM_QUEUES) + //printf("writing samples to send\n"); + nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); + //printf("exited writing samples to send\n"); + if (nsamples_transmitted != nread_elements*NUM_QUEUES) { std::cout << "Error : DMA could not send all the requested samples" << std::endl; } } } + close(tx_fd); fclose(rx_signal_file_id); - + //printf("DMA finished\n"); return NULL; + } bool HybridObservablesTestFpga::acquire_signal() { + pthread_t thread_DMA; + int baseband_sampling_freq_acquisition; + // step 0 determine the sampling frequency + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 + printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 + printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + } + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); int SV_ID = 1; //initial sv id + // Satellite signal definition Gnss_Synchro tmp_gnss_synchro; tmp_gnss_synchro.Channel_ID = 0; @@ -510,6 +543,17 @@ bool HybridObservablesTestFpga::acquire_signal() config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); config->set_property("Acquisition.use_CFAR_algorithm", "false"); + config->set_property("Acquisition.item_type", "cshort"); + config->set_property("Acquisition.if", "0"); + config->set_property("Acquisition.sampled_ms", "4"); + config->set_property("Acquisition.select_queue_Fpga", "0"); + config->set_property("Acquisition.devicename", "/dev/uio0"); + + if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + config->set_property("Acquisition.acquire_pilot", "false"); + } + //std::shared_ptr acquisition; std::shared_ptr acquisition_GpsL1Ca_Fpga; @@ -522,7 +566,7 @@ bool HybridObservablesTestFpga::acquire_signal() //printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - //printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); + printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); @@ -577,6 +621,8 @@ bool HybridObservablesTestFpga::acquire_signal() // config->set_property("Acquisition.Zero_padding", "0"); //**Only for E5a** Avoids power loss and doppler ambiguity in bit transitions by correlating one code with twice the input data length, ensuring that at least one full code is present without transitions. If set to 1 it is ON, if set to 0 it is OFF. // config->set_property("Acquisition.bit_transition_flag", "false"); // acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); +// +// // } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) @@ -617,16 +663,8 @@ bool HybridObservablesTestFpga::acquire_signal() throw(std::exception()); } - //printf("BBBBBBBBBBBBBBBBBBBBBBBBBB\n"); - //acquisition->set_gnss_synchro(&tmp_gnss_synchro); - //acquisition->set_channel(0); - //acquisition->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - //acquisition->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - //acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - //acquisition->init(); - //acquisition->set_local_code(); - //acquisition->set_state(1); // Ensure that acquisition starts at the first sample - //acquisition->connect(top_block); + printf("BBBBBBBBBBBBBBBBBBBBBBBBBB\n"); + //gr::blocks::file_source::sptr file_source; std::string file = FLAGS_signal_file; @@ -699,179 +737,36 @@ bool HybridObservablesTestFpga::acquire_signal() } setup_fpga_switch_obs_test(); - //printf("CCCCCCCCCCCCCCCCCCCCCCCCCCCC\n"); - if (test_observables_doppler_control_in_sw == 0) - { - args.file = file; - args.nsamples_tx = TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP; // number of samples to transfer - args.skip_used_samples = 0; + unsigned int code_length; + unsigned int nsamples_to_transfer; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(0); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_single_doppler_flag(0); - args.freq_band = 1; - } - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - tmp_gnss_synchro.PRN = PRN; - //acquisition->set_gnss_synchro(&tmp_gnss_synchro); - //acquisition->init(); - //acquisition->set_local_code(); - //acquisition->reset(); - //acquisition->set_state(1); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_GpsL1Ca_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_GpsE1_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_GpsE5a_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_doppler_max(config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz)); - acquisition_GpsL5_Fpga->set_doppler_step(config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz)); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - } - - // create DMA child process - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); - } - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - //msg_rx->rx_message = 0; - //top_block->run(); - //if (start_msg == true) - // { - // std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - // std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - // std::cout << "["; - // start_msg = false; - // } - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - if (msg_rx->rx_message == 1) - { - std::cout << " " << PRN << " "; - gnss_synchro_vec.push_back(tmp_gnss_synchro); - } - else - { - std::cout << " . "; - } - top_block->stop(); - //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample - std::cout.flush(); - } - } - else - { - //printf("DDDDDDDDDDDDDDDDDDDDDDDDD\n"); - unsigned int code_length; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - //printf("DDDDDDDDDDDDDDDDDDDDDDDDD22222222222\n"); - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); - - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); - } //printf("DDDDDDD3 code_length = %d\n", code_length); - float nbits = ceilf(log2f((float)code_length)); + float nbits = ceilf(log2f((float)code_length*2)); unsigned int fft_size = pow(2, nbits); unsigned int nsamples_total = fft_size; //printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); @@ -901,31 +796,32 @@ bool HybridObservablesTestFpga::acquire_signal() int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - float result_table[MAX_PRN_IDX][num_doppler_steps][2]; + float result_table[MAX_PRN_IDX][num_doppler_steps][3]; + + uint32_t index_debug[MAX_PRN_IDX]; + uint32_t samplestamp_debug[MAX_PRN_IDX]; for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 1; PRN < 2; PRN++) { + //printf("PRN %d\n", PRN); + uint32_t max_index = 0; + float max_magnitude = 0.0; + float second_magnitude = 0.0; + uint64_t initial_sample = 0; + //float power_sum = 0; + uint32_t doppler_index = 0; - uint32_t max_index = 0; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - float max_magnitude_iteration; - uint64_t initial_sample_iteration; - float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - //printf("FFFFFFFFFFFFFFFFFFFFFFFFF PRN= %d\n", PRN); - //printf("acq_doppler_max = %d acq_doppler_step = %d", acq_doppler_max, acq_doppler_step); - // debug - //acq_doppler_step = 250; - //int dummyflag; - //printf("PRN = %d type a number \n", PRN); - //std::cin >> dummyflag; + uint32_t max_index_iteration; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; + float max_magnitude_iteration; + float second_magnitude_iteration; + uint64_t initial_sample_iteration; + //float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { @@ -937,73 +833,119 @@ bool HybridObservablesTestFpga::acquire_signal() send_samples_start_obs_test = 0; pthread_mutex_unlock(&mutex_obs_test); - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL1Ca_Fpga->set_doppler_step(0); - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE1_Fpga->set_doppler_step(0); - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ffffffffffff ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE5a_Fpga->set_doppler_step(0); - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL5_Fpga->set_doppler_step(0); - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } args.file = file; - args.nsamples_tx = fft_size; //50000; // max size of the FFT - if (test_observables_skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("gggggggg \n"); + //---------------------------------------------------------------------------------- + // send the previous samples to set the downsampling filter in a good condition + send_samples_start_obs_test = 0; + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + else + { + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT + //printf("sending pre init %d\n", args.nsamples_tx); + + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start_obs_test = 0; + + //printf("finished sending samples init filter status and back to main thread\n"); + //----------------------------------------------------------------------------------- + + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + } + else + { + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + } + } + else + { + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } + } + + // create DMA child process if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } -// else -// { -// printf("$$$$$$$$$$$$44 CREATED DMA PROCESS\n"); -// } msg_rx->rx_message = 0; top_block->start(); @@ -1049,45 +991,71 @@ bool HybridObservablesTestFpga::acquire_signal() usleep(100000); } - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - // UPDATE! - //acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - // UPDATE! - //acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - // UPDATE! - //acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - // UPDATE! - //acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration,&initial_sample_iteration, &power_sum_iteration, &doppler_index_iteration); - } + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("iiiiiiiiiiiiii\n"); + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = power_sum_iteration; + result_table[PRN][doppler_num][1] = second_magnitude_iteration; + result_table[PRN][doppler_num][2] = total_fft_scaling_factor; doppler_num = doppler_num + 1; - if (max_magnitude_iteration > max_magnitude) + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("jjjjjjjjjjjjjjj\n"); + if (max_magnitude_iteration > max_magnitude) + { + int interpolation_factor = 4; + index_debug[PRN - 1] = max_index_iteration; + max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + samplestamp_debug[PRN - 1] = initial_sample_iteration; + initial_sample = 0; //initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + } + else { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - initial_sample = initial_sample_iteration; - power_sum = power_sum_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; + + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + initial_sample = initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } } top_block->stop(); } - power_sum = (power_sum - max_magnitude) / (fft_size - 1); - float test_statistics = (max_magnitude / power_sum); + +// power_sum = (power_sum - max_magnitude) / (fft_size - 1); +// float test_statistics = (max_magnitude / power_sum); +// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); +// if (test_statistics > threshold) + float test_statistics = max_magnitude/second_magnitude; float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); if (test_statistics > threshold) { @@ -1113,11 +1081,15 @@ bool HybridObservablesTestFpga::acquire_signal() } - uint32_t max_index = 0; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float power_sum = 0; - uint32_t doppler_index = 0; + uint32_t max_index = 0; + uint32_t total_fft_scaling_factor; + //uint32_t fw_fft_scaling_factor; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float second_magnitude = 0; + float peak_to_power = 0; + float test_statistics; + uint32_t doppler_index = 0; if (test_observables_show_results_table == 1) { @@ -1128,20 +1100,25 @@ bool HybridObservablesTestFpga::acquire_signal() for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { max_magnitude = result_table[PRN][doppler_num][0]; - power_sum = result_table[PRN][doppler_num][1]; + //power_sum = result_table[PRN][doppler_num][1]; + second_magnitude = result_table[PRN][doppler_num][1]; + total_fft_scaling_factor = result_table[PRN][doppler_num][2]; doppler_num = doppler_num + 1; - std::cout << "Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << "Power sum = " << power_sum << std::endl; - - power_sum = (power_sum - max_magnitude) / (fft_size - 1); - float test_statistics = (max_magnitude / power_sum); - std::cout << "test_statistics = " << test_statistics << std::endl; + std::cout << "==================== Doppler shift " << doppler_shift << std::endl; + std::cout << "Max magnitude = " << max_magnitude << std::endl; + std::cout << "Second magnitude = " << second_magnitude << std::endl; + std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; + test_statistics = (max_magnitude / second_magnitude); + std::cout << " test_statistics = " << test_statistics << std::endl; } + int dummy_val; + std::cout << "Enter a value to continue"; + std::cin >> dummy_val; } } - } +// } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -1168,6 +1145,9 @@ bool HybridObservablesTestFpga::acquire_signal() { return false; } + + + return true; } @@ -1939,6 +1919,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) gnss_synchro_vec.push_back(tmp_gnss_synchro); } } + printf("KKKKKKKKK FIRST PART FINISHED\n"); //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Signal Acquired\n"); configure_receiver(FLAGS_PLL_bw_hz_start, @@ -1998,29 +1979,39 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } } - //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ First part is done\n"); + printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ First part is done\n"); - unsigned int code_length; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("000000000000 code_length = %d\n", code_length); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + unsigned int code_length; + //unsigned int nsamples_to_transfer; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); - } - float nbits = ceilf(log2f((float)code_length)); + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + printf("sssssss code_length = %d \n", code_length); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + printf("sssssss code_length = %d \n", code_length); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + printf("sssssss code_length = %d \n", code_length); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + printf("sssssss code_length = %d \n", code_length); + } + + + float nbits = ceilf(log2f((float)code_length*2)); unsigned int fft_size = pow(2, nbits); //printf("000000000000 nbits = %f\n", nbits); //printf("000000000000 fft_size = %d\n", fft_size); @@ -2167,7 +2158,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) args.skip_used_samples = 0; //} - //printf("2222222222222 CREATE PROCES\n"); + printf("2222222222222 CREATE PROCES\n"); printf("%s\n", file.c_str()); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { @@ -2185,7 +2176,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) pthread_mutex_unlock(&mutex_obs_test); top_block->start(); - //printf("33333333333333333333 top block started\n"); + printf("33333333333333333333 top block started\n"); @@ -2199,11 +2190,11 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); - //printf("444444444444 CHILD PROCESS FINISHED\n"); + printf("444444444444 CHILD PROCESS FINISHED\n"); top_block->stop(); - //printf("55555555555 TOP BLOCK STOPPED\n"); + printf("55555555555 TOP BLOCK STOPPED\n"); // send more samples to unblock the tracking process in case it was waiting for samples args.file = file; @@ -2223,7 +2214,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) printf("ERROR cannot create DMA Process\n"); } pthread_join(thread_DMA, NULL); - //printf("777777777 PROCESS FINISHED \n"); + printf("777777777 PROCESS FINISHED \n"); pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 0; @@ -2459,5 +2450,6 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; } } + std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; } From 7023e879db66eda344c7cf38b465efe20fdade57 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Tue, 13 Nov 2018 19:51:12 +0100 Subject: [PATCH 19/53] adapted the software to a bit size for the local copy of the FFT of the GNSS code to 10 bits per sample. worked on the observables tests. --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 6 ++--- .../galileo_e5a_pcps_acquisition_fpga.cc | 4 +-- .../gps_l1_ca_pcps_acquisition_fpga.cc | 14 +++++----- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 6 ++--- .../acquisition/libs/fpga_acquisition.cc | 12 ++++----- .../dll_pll_veml_tracking_fpga.cc | 4 +-- .../hybrid_observables_test_fpga.cc | 26 +++++++++---------- .../tracking/tracking_pull-in_test_fpga.cc | 8 +++--- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 9e27530d4..b7f03026c 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -246,8 +246,8 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( // static_cast(floor(256*fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max))); // d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(16*fft_codes_padded[i].real() * (pow(2, 11) - 1) / max)), // static_cast(floor(16*fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); // tmp_re = static_cast(floor(fft_codes_padded[i].real() * (pow(2, 7) - 1) / max)); // tmp_im = static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max)); @@ -313,7 +313,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( delete fft_if; delete[] fft_codes_padded; - acq_parameters.total_block_exp = 11; + acq_parameters.total_block_exp = 12; acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 896237aaa..522f1f855 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -178,8 +178,8 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf } for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index b058c1806..d0f388d1e 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -69,10 +69,10 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( printf("downsampling_factor = %f\n", downsampling_factor); acq_parameters.downsampling_factor = downsampling_factor; //fs_in = fs_in/2.0; // downampling filter - printf("fs_in pre downsampling = %ld\n", fs_in); + //printf("fs_in pre downsampling = %ld\n", fs_in); fs_in = fs_in/downsampling_factor; - printf("fs_in post downsampling = %ld\n", fs_in); + //printf("fs_in post downsampling = %ld\n", fs_in); //printf("####### DEBUG Acq: fs_in = %d\n", fs_in); acq_parameters.fs_in = fs_in; @@ -89,9 +89,9 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; - printf("acq adapter vector_length = %d\n", vector_length); + //printf("acq adapter vector_length = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); - printf("select queue = %d\n", select_queue_Fpga); + //printf("select queue = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); @@ -165,8 +165,8 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( // static_cast(16*floor(fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), // static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } @@ -191,7 +191,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( delete fft_if; delete[] fft_codes_padded; - acq_parameters.total_block_exp = 9; + acq_parameters.total_block_exp = 10; acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 1e0a44759..b9fb23fe6 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -167,8 +167,8 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( // static_cast(16*floor(fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), // static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } @@ -211,7 +211,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( // acquisition_fpga_ = pcps_make_acquisition(acq_parameters); // DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; - acq_parameters.total_block_exp = 9; + acq_parameters.total_block_exp = 10; acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 27f53efee..6e87265f6 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -65,10 +65,10 @@ //#define SELECT_24_BITS 0x00FFFFFF //#define SHL_12_BITS 4096 // 16-bits -#define SELECT_LSBits 0x0FFFF -#define SELECT_MSBbits 0xFFFF0000 -#define SELECT_32_BITS 0xFFFFFFFF -#define SHL_16_BITS 65536 +#define SELECT_LSBits 0x000003FF +#define SELECT_MSBbits 0x000FFC00 +#define SELECT_ALL_CODE_BITS 0x000FFFFF +#define SHL_CODE_BITS 1024 bool fpga_acquisition::init() @@ -231,9 +231,9 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local //local_code = (tmp & SELECT_LSB) | ((tmp2 * SHL_8_BITS) & SELECT_MSB); // put together the real part and the imaginary part //fft_data = MEM_LOCAL_CODE_WR_ENABLE | (local_code & SELECT_16_BITS); //local_code = (tmp & SELECT_LSBits) | ((tmp2 * SHL_12_BITS) & SELECT_MSBbits); // put together the real part and the imaginary part - local_code = (tmp & SELECT_LSBits) | ((tmp2 * SHL_16_BITS) & SELECT_MSBbits); // put together the real part and the imaginary part + local_code = (tmp & SELECT_LSBits) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBbits); // put together the real part and the imaginary part //fft_data = MEM_LOCAL_CODE_WR_ENABLE | (local_code & SELECT_24_BITS); - fft_data = local_code & SELECT_32_BITS; + fft_data = local_code & SELECT_ALL_CODE_BITS; d_map_base[6] = fft_data; diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index afd0d1b2d..d8c5996d2 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -1322,7 +1322,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } else { - printf("test operation\n"); + //printf("test operation\n"); // during the unit tests the counter value may be reset after the acquisition process. We have to take this into account absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples); //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); @@ -1704,7 +1704,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } if (current_synchro_data.Flag_valid_symbol_output) { - //printf("tracking sending synchro data\n"); + //printf("tracking sending synchro data "); current_synchro_data.fs = static_cast(trk_parameters.fs_in); current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); *out[0] = current_synchro_data; diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 0bd96c202..4d59f2be4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -79,7 +79,7 @@ #define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define TEST_OBS_NSAMPLES_TRACKING 500000000 // number of samples during which we test the tracking module +#define TEST_OBS_NSAMPLES_TRACKING 1000000000 // number of samples during which we test the tracking module #define TEST_OBS_NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop #define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter @@ -519,12 +519,12 @@ bool HybridObservablesTestFpga::acquire_signal() if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) @@ -566,7 +566,7 @@ bool HybridObservablesTestFpga::acquire_signal() //printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); + //printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); @@ -663,7 +663,7 @@ bool HybridObservablesTestFpga::acquire_signal() throw(std::exception()); } - printf("BBBBBBBBBBBBBBBBBBBBBBBBBB\n"); + //printf("BBBBBBBBBBBBBBBBBBBBBBBBBB\n"); //gr::blocks::file_source::sptr file_source; @@ -744,13 +744,13 @@ bool HybridObservablesTestFpga::acquire_signal() { code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); + //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); + //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -1979,7 +1979,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } } - printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ First part is done\n"); + //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ First part is done\n"); unsigned int code_length; //unsigned int nsamples_to_transfer; @@ -2158,7 +2158,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) args.skip_used_samples = 0; //} - printf("2222222222222 CREATE PROCES\n"); + //printf("2222222222222 CREATE PROCES\n"); printf("%s\n", file.c_str()); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { @@ -2176,7 +2176,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) pthread_mutex_unlock(&mutex_obs_test); top_block->start(); - printf("33333333333333333333 top block started\n"); + //printf("33333333333333333333 top block started\n"); @@ -2190,11 +2190,11 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); - printf("444444444444 CHILD PROCESS FINISHED\n"); + //printf("444444444444 CHILD PROCESS FINISHED\n"); top_block->stop(); - printf("55555555555 TOP BLOCK STOPPED\n"); + //printf("55555555555 TOP BLOCK STOPPED\n"); // send more samples to unblock the tracking process in case it was waiting for samples args.file = file; @@ -2214,7 +2214,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) printf("ERROR cannot create DMA Process\n"); } pthread_join(thread_DMA, NULL); - printf("777777777 PROCESS FINISHED \n"); + //printf("777777777 PROCESS FINISHED \n"); pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 0; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 9a0dd636f..61e54ed2c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -662,7 +662,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) acquisition_GpsE1_Fpga->set_channel(0); acquisition_GpsE1_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); acquisition_GpsE1_Fpga->connect(top_block); - printf(" bbbbbbbb baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + //printf(" bbbbbbbb baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -730,7 +730,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { top_block->msg_connect(acquisition_GpsE1_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - printf(" cccccc baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + //printf(" cccccc baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -784,7 +784,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); + //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -809,7 +809,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - printf("eeeeeee just set doppler flag\n"); + //printf("eeeeeee just set doppler flag\n"); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { From 10676fd3cfe5bc70e2a2c7d7ca03ec1f1b7951c2 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Thu, 15 Nov 2018 20:48:30 +0100 Subject: [PATCH 20/53] corrected minor bug in DMA parameter --- .../hybrid_observables_test_fpga.cc | 14 +- .../tracking/tracking_pull-in_test_fpga.cc | 829 ++++++++++++------ 2 files changed, 552 insertions(+), 291 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 4d59f2be4..5a932d513 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -79,7 +79,7 @@ #define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define TEST_OBS_NSAMPLES_TRACKING 1000000000 // number of samples during which we test the tracking module +#define TEST_OBS_NSAMPLES_TRACKING 850000000 // number of samples during which we test the tracking module #define TEST_OBS_NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop #define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter @@ -802,7 +802,7 @@ bool HybridObservablesTestFpga::acquire_signal() uint32_t samplestamp_debug[MAX_PRN_IDX]; for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 1; PRN < 2; PRN++) + //for (unsigned int PRN = 6; PRN < 8; PRN++) { //printf("PRN %d\n", PRN); uint32_t max_index = 0; @@ -2123,21 +2123,25 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) //printf("111111111111\n"); std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { std::shared_ptr acquisition_Fpga; acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; } else { @@ -2295,12 +2299,18 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } estimated_observables.restart(); + //printf("Observables : ............................\n"); while (estimated_observables.read_binary_obs()) { for (unsigned int n = 0; n < measured_obs_vec.size(); n++) { if (static_cast(estimated_observables.valid[n])) { + //printf("estimated_observables.RX_time[%d] = %d\n", n, estimated_observables.RX_time[n]); + //printf("estimated_observables.TOW_at_current_symbol_s[%d] = %d\n", n, estimated_observables.TOW_at_current_symbol_s[n]); + //printf("estimated_observables.Carrier_Doppler_hz[%d] = %d\n", n, estimated_observables.Carrier_Doppler_hz[n]); + //printf("estimated_observables.Acc_carrier_phase_hz[%d] = %d\n", n, estimated_observables.Acc_carrier_phase_hz[n]); + //printf("estimated_observables.Pseudorange_m[%d] = %d\n", n, estimated_observables.Pseudorange_m[n]); measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 61e54ed2c..b9f0a3a65 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -70,7 +70,7 @@ #define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define NSAMPLES_TRACKING 200000000 // number of samples during which we test the tracking module +#define NSAMPLES_TRACKING 850000000 // number of samples during which we test the tracking module #define NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop #define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter @@ -80,6 +80,7 @@ bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results, 0=> do not show it bool skip_samples_already_used = 0; // if skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops // (exactly in the same way as the SW) +bool doppler_loop_control_in_sw = 1; @@ -797,304 +798,590 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } + float nbits = ceilf(log2f((float)code_length*2)); + unsigned int fft_size = pow(2, nbits); + unsigned int nsamples_total = fft_size; - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); - unsigned int nsamples_total = fft_size; + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + printf("acq_doppler_max = %d\n", acq_doppler_max); + printf("acq_doppler_step = %d\n", acq_doppler_step); + + + + + if (doppler_loop_control_in_sw == 1) { - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - //printf("eeeeeee just set doppler flag\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_single_doppler_flag(1); - } - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); - int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); - printf("acq_doppler_max = %d\n", acq_doppler_max); - printf("acq_doppler_step = %d\n", acq_doppler_step); - - int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - - float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - - uint32_t index_debug[MAX_PRN_IDX]; - uint32_t samplestamp_debug[MAX_PRN_IDX]; - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 0; PRN < 17; PRN++) + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { + acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_single_doppler_flag(1); + //printf("eeeeeee just set doppler flag\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_single_doppler_flag(1); + } - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; + int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; + float result_table[MAX_PRN_IDX][num_doppler_steps][3]; + //uint32_t index_debug[MAX_PRN_IDX]; + //uint32_t samplestamp_debug[MAX_PRN_IDX]; - - - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 0; PRN < 17; PRN++) { - //printf("doppler_shift = %d\n", doppler_shift); - tmp_gnss_synchro.PRN = PRN; - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); + uint32_t max_index = 0; + float max_magnitude = 0.0; + float second_magnitude = 0.0; + uint64_t initial_sample = 0; + //float power_sum = 0; + uint32_t doppler_index = 0; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } - - args.file = file; + uint32_t max_index_iteration; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; + float max_magnitude_iteration; + float second_magnitude_iteration; + uint64_t initial_sample_iteration; + //float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition + + + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + //printf("doppler_shift = %d\n", doppler_shift); + tmp_gnss_synchro.PRN = PRN; + + pthread_mutex_lock(&mutex); send_samples_start = 0; - if (skip_samples_already_used == 1) + pthread_mutex_unlock(&mutex); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL1Ca_Fpga->set_doppler_step(0); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE1_Fpga->set_doppler_step(0); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ffffffffffff ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE5a_Fpga->set_doppler_step(0); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL5_Fpga->set_doppler_step(0); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } + + args.file = file; + + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("gggggggg \n"); + //---------------------------------------------------------------------------------- + // send the previous samples to set the downsampling filter in a good condition + send_samples_start = 0; + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + else + { + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT + //printf("sending pre init %d\n", args.nsamples_tx); + + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start = 0; + //printf("finished sending samples init filter status\n"); + //----------------------------------------------------------------------------------- + + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + } + else + { + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + } } else { - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } + } + + + + + // create DMA child process + //printf("||||||||1 args freq_band = %d\n", args.freq_band); + //printf("sending samples main DMA %d\n", args.nsamples_tx); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } + + msg_rx->rx_message = 0; + top_block->start(); + pthread_mutex_lock(&mutex); send_samples_start = 1; pthread_mutex_unlock(&mutex); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); // set active + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("hhhhhhhhhhhh\n"); + acquisition_GpsE1_Fpga->reset(); // set active + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); // set active + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); // set active + } + + // pthread_mutex_lock(&mutex); // it doesn't work if it is done here + // send_samples_start = 1; + // pthread_mutex_unlock(&mutex); + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); send_samples_start = 0; - //printf("finished sending samples init filter status\n"); - //----------------------------------------------------------------------------------- + pthread_mutex_unlock(&mutex); - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + while (msg_rx->rx_message == 0) + { + usleep(100000); + } - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - else - { - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("iiiiiiiiiiiiii\n"); + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } - } + result_table[PRN][doppler_num][0] = max_magnitude_iteration; + result_table[PRN][doppler_num][1] = second_magnitude_iteration; + result_table[PRN][doppler_num][2] = total_fft_scaling_factor; + doppler_num = doppler_num + 1; + + //printf("max_magnitude_iteration = %f\n", max_magnitude_iteration); + //printf("second_magnitude_iteration = %f\n", second_magnitude_iteration); + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("jjjjjjjjjjjjjjj\n"); + if (max_magnitude_iteration > max_magnitude) + { + int interpolation_factor = 4; + //index_debug[PRN - 1] = max_index_iteration; + max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + //samplestamp_debug[PRN - 1] = initial_sample_iteration; + initial_sample = 0; //initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + } + else + { + + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + initial_sample = initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + } + top_block->stop(); + } + + //power_sum = (power_sum - max_magnitude) / (fft_size - 1); + //float test_statistics = (max_magnitude / power_sum); + float test_statistics = max_magnitude/second_magnitude; + float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); + if (test_statistics > threshold) + { + //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); + code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); + code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); + acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + } + else + { + std::cout << " . "; + } + + std::cout.flush(); + + } + + uint32_t max_index = 0; + uint32_t total_fft_scaling_factor; + //uint32_t fw_fft_scaling_factor; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float second_magnitude = 0; + float peak_to_power = 0; + float test_statistics; + uint32_t doppler_index = 0; + + if (show_results_table == 1) + { + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; + int doppler_num = 0; + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + max_magnitude = result_table[PRN][doppler_num][0]; + second_magnitude = result_table[PRN][doppler_num][1]; + total_fft_scaling_factor = result_table[PRN][doppler_num][2]; + //fw_fft_scaling_factor = result_table[PRN][doppler_num][3]; + doppler_num = doppler_num + 1; + + std::cout << "==================== Doppler shift " << doppler_shift << std::endl; + std::cout << "Max magnitude = " << max_magnitude << std::endl; + std::cout << "Second magnitude = " << second_magnitude << std::endl; + std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; + //peak_to_power = max_magnitude/power_sum; + //power_sum = (power_sum - max_magnitude) / (fft_size - 1); + test_statistics = (max_magnitude / second_magnitude); + std::cout << " test_statistics = " << test_statistics << std::endl; + } + int dummy_val; + std::cout << "Enter a value to continue"; + std::cin >> dummy_val; + } + } + } + else // DOPPLER CONTROL IN HW + { + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 0; PRN < 17; PRN++) + { + + uint32_t max_index = 0; + float max_magnitude = 0.0; + float second_magnitude = 0.0; + uint64_t initial_sample = 0; + //float power_sum = 0; + uint32_t doppler_index = 0; + + uint32_t max_index_iteration; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; + float max_magnitude_iteration; + float second_magnitude_iteration; + uint64_t initial_sample_iteration; + //float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsL1Ca_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsE1_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ffffffffffff ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsE5a_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsL5_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } + + args.file = file; + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("gggggggg \n"); + //---------------------------------------------------------------------------------- + // send the previous samples to set the downsampling filter in a good condition + send_samples_start = 0; + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT + + //printf("sending pre init %d\n", args.nsamples_tx); - // create DMA child process - //printf("||||||||1 args freq_band = %d\n", args.freq_band); - //printf("sending samples main DMA %d\n", args.nsamples_tx); if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } - - msg_rx->rx_message = 0; - top_block->start(); - pthread_mutex_lock(&mutex); send_samples_start = 1; pthread_mutex_unlock(&mutex); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("hhhhhhhhhhhh\n"); - acquisition_GpsE1_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); // set active - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); // set active - } - -// pthread_mutex_lock(&mutex); // it doesn't work if it is done here -// send_samples_start = 1; -// pthread_mutex_unlock(&mutex); - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex); send_samples_start = 0; - pthread_mutex_unlock(&mutex); + //printf("finished sending samples init filter status\n"); + //----------------------------------------------------------------------------------- - while (msg_rx->rx_message == 0) - { - usleep(100000); - } + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("iiiiiiiiiiiiii\n"); - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = second_magnitude_iteration; - result_table[PRN][doppler_num][2] = total_fft_scaling_factor; - doppler_num = doppler_num + 1; + } + else + { + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - //printf("max_magnitude_iteration = %f\n", max_magnitude_iteration); - //printf("second_magnitude_iteration = %f\n", second_magnitude_iteration); - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("jjjjjjjjjjjjjjj\n"); - if (max_magnitude_iteration > max_magnitude) - { - int interpolation_factor = 4; - index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - samplestamp_debug[PRN - 1] = initial_sample_iteration; - initial_sample = 0; //initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - else - { - - if (max_magnitude_iteration > max_magnitude) - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - top_block->stop(); + args.skip_used_samples = 0; } - //power_sum = (power_sum - max_magnitude) / (fft_size - 1); + + + + // create DMA child process + //printf("||||||||1 args freq_band = %d\n", args.freq_band); + //printf("sending samples main DMA %d\n", args.nsamples_tx); + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); // set active + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("hhhhhhhhhhhh\n"); + acquisition_GpsE1_Fpga->reset(); // set active + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); // set active + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); // set active + } + + // pthread_mutex_lock(&mutex); // it doesn't work if it is done here + // send_samples_start = 1; + // pthread_mutex_unlock(&mutex); + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("iiiiiiiiiiiiii\n"); + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + int interpolation_factor = 4; + //index_debug[PRN - 1] = max_index_iteration; + max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + //samplestamp_debug[PRN - 1] = initial_sample_iteration; + initial_sample = 0; //initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); + } + else + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + initial_sample = initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); + } + top_block->stop(); + + //power_sum = (power_sum - max_magnitude) / (fft_size - 1); //float test_statistics = (max_magnitude / power_sum); float test_statistics = max_magnitude/second_magnitude; float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); @@ -1116,44 +1403,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } - uint32_t max_index = 0; - uint32_t total_fft_scaling_factor; - //uint32_t fw_fft_scaling_factor; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float second_magnitude = 0; - float peak_to_power = 0; - float test_statistics; - uint32_t doppler_index = 0; - if (show_results_table == 1) - { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - max_magnitude = result_table[PRN][doppler_num][0]; - second_magnitude = result_table[PRN][doppler_num][1]; - total_fft_scaling_factor = result_table[PRN][doppler_num][2]; - //fw_fft_scaling_factor = result_table[PRN][doppler_num][3]; - doppler_num = doppler_num + 1; - - std::cout << "==================== Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << std::endl; - std::cout << "Second magnitude = " << second_magnitude << std::endl; - std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; - //peak_to_power = max_magnitude/power_sum; - //power_sum = (power_sum - max_magnitude) / (fft_size - 1); - test_statistics = (max_magnitude / second_magnitude); - std::cout << " test_statistics = " << test_statistics << std::endl; - } - int dummy_val; - std::cout << "Enter a value to continue"; - std::cin >> dummy_val; - } - } + } // } std::cout << "]" << std::endl; @@ -1165,11 +1416,11 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } - for (unsigned k=0;k Date: Fri, 16 Nov 2018 18:28:02 +0100 Subject: [PATCH 21/53] re-enabled the possibility to run the FPGA tracking pull-in tests and observables tests running the doppler wipeoff in the HW. The FPGA now uses the same block of received samples to test all the doppler shifts. --- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 10 +- .../hybrid_observables_test_fpga.cc | 878 ++++++++++++------ .../tracking/tracking_pull-in_test_fpga.cc | 146 +-- 3 files changed, 669 insertions(+), 365 deletions(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 0af1b79f8..304bf402a 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -430,11 +430,11 @@ void pcps_acquisition_fpga::set_active(bool active) if (d_test_statistics > d_threshold) { d_active = false; - // printf("##### d_test_statistics = %f\n", d_test_statistics); - // printf("##### debug_d_max_absolute =%f\n",debug_d_max_absolute); - // printf("##### debug_d_input_power_absolute =%f\n",debug_d_input_power_absolute); - // printf("##### initial_sample = %llu\n",initial_sample); - // printf("##### debug_doppler_index = %d\n",debug_doppler_index); +// printf("##### d_test_statistics = %f\n", d_test_statistics); +// printf("##### firstpeak =%f\n",firstpeak); +// printf("##### secondpeak =%f\n",secondpeak); +// printf("##### d_gnss_synchro->Acq_delay_samples = %d\n",(int) d_gnss_synchro->Acq_delay_samples); +// printf("##### d_gnss_synchro->Acq_samplestamp_samples = %d\n",(int) d_gnss_synchro->Acq_samplestamp_samples); send_positive_acquisition(); d_state = 0; // Positive acquisition diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 5a932d513..9c6d520e9 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -93,6 +93,7 @@ bool test_observables_skip_samples_already_used = 1; // if test_observables_dopp // (exactly in the same way as the SW) // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 0 => the sampe samples are used for each PRN loop // if test_observables_doppler_control_in_sw = 0 => test_observables_skip_samples_already_used is not applicable +bool doppler_loop_control_in_sw_obs_test = 0; // ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES ######### class HybridObservablesTest_msg_rx_Fpga; @@ -771,353 +772,626 @@ bool HybridObservablesTestFpga::acquire_signal() unsigned int nsamples_total = fft_size; //printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); - - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - //printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_single_doppler_flag(1); - } - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); - int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; + if (doppler_loop_control_in_sw_obs_test == 1) + { - float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - - uint32_t index_debug[MAX_PRN_IDX]; - uint32_t samplestamp_debug[MAX_PRN_IDX]; - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 6; PRN < 8; PRN++) + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - //printf("PRN %d\n", PRN); - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; + //printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); + acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_single_doppler_flag(1); + } - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; + + float result_table[MAX_PRN_IDX][num_doppler_steps][3]; + + uint32_t index_debug[MAX_PRN_IDX]; + uint32_t samplestamp_debug[MAX_PRN_IDX]; + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 6; PRN < 8; PRN++) { + //printf("PRN %d\n", PRN); + uint32_t max_index = 0; + float max_magnitude = 0.0; + float second_magnitude = 0.0; + uint64_t initial_sample = 0; + //float power_sum = 0; + uint32_t doppler_index = 0; - //printf("main loop doppler_shift = %d\n", doppler_shift); - tmp_gnss_synchro.PRN = PRN; + uint32_t max_index_iteration; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; + float max_magnitude_iteration; + float second_magnitude_iteration; + uint64_t initial_sample_iteration; + //float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); + //printf("main loop doppler_shift = %d\n", doppler_shift); + tmp_gnss_synchro.PRN = PRN; - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } - - args.file = file; - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - send_samples_start_obs_test = 0; - if (skip_samples_already_used == 1) + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL1Ca_Fpga->set_doppler_step(0); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE1_Fpga->set_doppler_step(0); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ffffffffffff ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE5a_Fpga->set_doppler_step(0); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL5_Fpga->set_doppler_step(0); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } + + args.file = file; + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("gggggggg \n"); + //---------------------------------------------------------------------------------- + // send the previous samples to set the downsampling filter in a good condition + send_samples_start_obs_test = 0; + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + else + { + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT + //printf("sending pre init %d\n", args.nsamples_tx); + + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start_obs_test = 0; + + //printf("finished sending samples init filter status and back to main thread\n"); + //----------------------------------------------------------------------------------- + + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + } + else + { + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + } } else { - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + if (skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } + } + + + + // create DMA child process if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } - pthread_mutex_lock(&mutex); + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&mutex_obs_test); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); + } + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); - //printf("finished sending samples init filter status and back to main thread\n"); - //----------------------------------------------------------------------------------- + while (msg_rx->rx_message == 0) + { + usleep(100000); + } - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("iiiiiiiiiiiiii\n"); + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - else - { - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + result_table[PRN][doppler_num][0] = max_magnitude_iteration; + result_table[PRN][doppler_num][1] = second_magnitude_iteration; + result_table[PRN][doppler_num][2] = total_fft_scaling_factor; + doppler_num = doppler_num + 1; - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } - } + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("jjjjjjjjjjjjjjj\n"); + if (max_magnitude_iteration > max_magnitude) + { + int interpolation_factor = 4; + index_debug[PRN - 1] = max_index_iteration; + max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + samplestamp_debug[PRN - 1] = initial_sample_iteration; + initial_sample = 0; //initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + } + else + { + + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + initial_sample = initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + } + top_block->stop(); + } + // power_sum = (power_sum - max_magnitude) / (fft_size - 1); + // float test_statistics = (max_magnitude / power_sum); + // float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); + // if (test_statistics > threshold) + float test_statistics = max_magnitude/second_magnitude; + float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); + if (test_statistics > threshold) + { + std::cout << " " << PRN << " "; - // create DMA child process - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); + //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); + //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + + tmp_gnss_synchro.Acq_doppler_hz = doppler_shift_selected; + tmp_gnss_synchro.Acq_delay_samples = max_index; + tmp_gnss_synchro.Acq_samplestamp_samples = initial_sample; // delay due to the downsampling filter in the acquisition + + + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + else + { + std::cout << " . "; + } + + std::cout.flush(); + + } + + uint32_t max_index = 0; + uint32_t total_fft_scaling_factor; + //uint32_t fw_fft_scaling_factor; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float second_magnitude = 0; + float peak_to_power = 0; + float test_statistics; + uint32_t doppler_index = 0; + + if (test_observables_show_results_table == 1) + { + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; + int doppler_num = 0; + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + max_magnitude = result_table[PRN][doppler_num][0]; + //power_sum = result_table[PRN][doppler_num][1]; + second_magnitude = result_table[PRN][doppler_num][1]; + total_fft_scaling_factor = result_table[PRN][doppler_num][2]; + doppler_num = doppler_num + 1; + + std::cout << "==================== Doppler shift " << doppler_shift << std::endl; + std::cout << "Max magnitude = " << max_magnitude << std::endl; + std::cout << "Second magnitude = " << second_magnitude << std::endl; + std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; + test_statistics = (max_magnitude / second_magnitude); + std::cout << " test_statistics = " << test_statistics << std::endl; + + } + int dummy_val; + std::cout << "Enter a value to continue"; + std::cin >> dummy_val; + } + } + } + else // DOPPLER CONTROL IN HW + { + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 0; PRN < 17; PRN++) + { + + uint32_t max_index = 0; + float max_magnitude = 0.0; + float second_magnitude = 0.0; + uint64_t initial_sample = 0; + //float power_sum = 0; + uint32_t doppler_index = 0; + + uint32_t max_index_iteration; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; + float max_magnitude_iteration; + float second_magnitude_iteration; + uint64_t initial_sample_iteration; + //float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; + + tmp_gnss_synchro.PRN = PRN; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsL1Ca_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsE1_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ffffffffffff ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsE5a_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsL5_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } + + args.file = file; + + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("gggggggg \n"); + //---------------------------------------------------------------------------------- + // send the previous samples to set the downsampling filter in a good condition + send_samples_start = 0; + + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT + + //printf("sending pre init %d\n", args.nsamples_tx); + + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); - } - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); pthread_join(thread_DMA, NULL); + send_samples_start = 0; + //printf("finished sending samples init filter status\n"); + //----------------------------------------------------------------------------------- - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - while (msg_rx->rx_message == 0) - { - usleep(100000); - } + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("iiiiiiiiiiiiii\n"); - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } + } + else + { + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = second_magnitude_iteration; - result_table[PRN][doppler_num][2] = total_fft_scaling_factor; - doppler_num = doppler_num + 1; - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("jjjjjjjjjjjjjjj\n"); - if (max_magnitude_iteration > max_magnitude) - { - int interpolation_factor = 4; - index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - samplestamp_debug[PRN - 1] = initial_sample_iteration; - initial_sample = 0; //initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - else - { - - if (max_magnitude_iteration > max_magnitude) - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - top_block->stop(); + args.skip_used_samples = 0; } -// power_sum = (power_sum - max_magnitude) / (fft_size - 1); -// float test_statistics = (max_magnitude / power_sum); -// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); -// if (test_statistics > threshold) - float test_statistics = max_magnitude/second_magnitude; - float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - if (test_statistics > threshold) + + + // create DMA child process + //printf("||||||||1 args freq_band = %d\n", args.freq_band); + //printf("sending samples main DMA %d\n", args.nsamples_tx); + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); // set active + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("hhhhhhhhhhhh\n"); + acquisition_GpsE1_Fpga->reset(); // set active + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); // set active + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); // set active + } + + // pthread_mutex_lock(&mutex); // it doesn't work if it is done here + // send_samples_start = 1; + // pthread_mutex_unlock(&mutex); + + if (start_msg == true) { - std::cout << " " << PRN << " "; + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } - //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); - tmp_gnss_synchro.Acq_doppler_hz = doppler_shift_selected; - tmp_gnss_synchro.Acq_delay_samples = max_index; - tmp_gnss_synchro.Acq_samplestamp_samples = initial_sample; // delay due to the downsampling filter in the acquisition + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + + tmp_gnss_synchro.Acq_doppler_hz = tmp_gnss_synchro.Acq_doppler_hz; + tmp_gnss_synchro.Acq_delay_samples = tmp_gnss_synchro.Acq_delay_samples; + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + tmp_gnss_synchro.Acq_samplestamp_samples = tmp_gnss_synchro.Acq_samplestamp_samples; // delay due to the downsampling filter in the acquisition gnss_synchro_vec.push_back(tmp_gnss_synchro); - } - else - { - std::cout << " . "; - } + + +// doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); +// code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); +// tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation +// acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); + } + else + { + std::cout << " . "; + } + + // while (msg_rx->rx_message == 0) + // { + // usleep(100000); + // } + + // if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + // { + // acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + // //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + // } + // else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + // { + // //printf("iiiiiiiiiiiiii\n"); + // acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + // //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + // } + // else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + // { + // acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + // //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + // } + // else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + // { + // acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + // //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + // } + // + // if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + // { + // int interpolation_factor = 4; + // //index_debug[PRN - 1] = max_index_iteration; + // max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); + // max_magnitude = max_magnitude_iteration; + // second_magnitude = second_magnitude_iteration; + // //samplestamp_debug[PRN - 1] = initial_sample_iteration; + // initial_sample = 0; //initial_sample_iteration; + // doppler_index = doppler_index_iteration; + // doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); + // } + // else + // { + // max_index = max_index_iteration; + // max_magnitude = max_magnitude_iteration; + // second_magnitude = second_magnitude_iteration; + // initial_sample = initial_sample_iteration; + // doppler_index = doppler_index_iteration; + // doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); + // } + top_block->stop(); + + + // float test_statistics = max_magnitude/second_magnitude; + // float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); + // if (test_statistics > threshold) + // { + // //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); + // std::cout << " " << PRN << " "; + // doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); + // code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); + // code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); + // acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + // } + // else + // { + // std::cout << " . "; + // } std::cout.flush(); } - uint32_t max_index = 0; - uint32_t total_fft_scaling_factor; - //uint32_t fw_fft_scaling_factor; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float second_magnitude = 0; - float peak_to_power = 0; - float test_statistics; - uint32_t doppler_index = 0; - - if (test_observables_show_results_table == 1) - { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - max_magnitude = result_table[PRN][doppler_num][0]; - //power_sum = result_table[PRN][doppler_num][1]; - second_magnitude = result_table[PRN][doppler_num][1]; - total_fft_scaling_factor = result_table[PRN][doppler_num][2]; - doppler_num = doppler_num + 1; - - std::cout << "==================== Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << std::endl; - std::cout << "Second magnitude = " << second_magnitude << std::endl; - std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; - test_statistics = (max_magnitude / second_magnitude); - std::cout << " test_statistics = " << test_statistics << std::endl; - - } - int dummy_val; - std::cout << "Enter a value to continue"; - std::cin >> dummy_val; - } - } + } // } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -2174,11 +2448,14 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { tracking_ch_vec.at(n)->start_tracking(); } + + //printf("222222222222222222 bis\n"); pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex_obs_test); + top_block->start(); //printf("33333333333333333333 top block started\n"); @@ -2191,13 +2468,17 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) elapsed_seconds = end - start; }) << "Failure running the top_block."; + // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); + + //printf("444444444444 CHILD PROCESS FINISHED\n"); top_block->stop(); + //printf("55555555555 TOP BLOCK STOPPED\n"); // send more samples to unblock the tracking process in case it was waiting for samples @@ -2220,9 +2501,11 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) pthread_join(thread_DMA, NULL); //printf("777777777 PROCESS FINISHED \n"); - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); + + +// pthread_mutex_lock(&mutex_obs_test); +// send_samples_start_obs_test = 0; +// pthread_mutex_unlock(&mutex_obs_test); @@ -2277,6 +2560,8 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) ASSERT_EQ(ReadRinexObs(&true_obs_vec, gnss_synchro_master), true) << "Failure reading RINEX file"; } + + //read measured values observables_dump_reader estimated_observables(tracking_ch_vec.size()); ASSERT_NO_THROW({ @@ -2461,5 +2746,6 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } } + std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index b9f0a3a65..28f2e0263 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -80,7 +80,7 @@ bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results, 0=> do not show it bool skip_samples_already_used = 0; // if skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops // (exactly in the same way as the SW) -bool doppler_loop_control_in_sw = 1; +bool doppler_loop_control_in_sw = 0; @@ -1187,6 +1187,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) int doppler_shift_selected; int doppler_num = 0; + tmp_gnss_synchro.PRN = PRN; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters @@ -1331,73 +1333,89 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) send_samples_start = 0; pthread_mutex_unlock(&mutex); - while (msg_rx->rx_message == 0) - { - usleep(100000); - } + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); + code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); + } + else + { + std::cout << " . "; + } - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("iiiiiiiiiiiiii\n"); - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } +// while (msg_rx->rx_message == 0) +// { +// usleep(100000); +// } - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - int interpolation_factor = 4; - //index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - //samplestamp_debug[PRN - 1] = initial_sample_iteration; - initial_sample = 0; //initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); - } - else - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); - } +// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); +// //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); +// } +// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) +// { +// //printf("iiiiiiiiiiiiii\n"); +// acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); +// //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); +// } +// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); +// //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); +// } +// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); +// //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); +// } +// +// if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) +// { +// int interpolation_factor = 4; +// //index_debug[PRN - 1] = max_index_iteration; +// max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); +// max_magnitude = max_magnitude_iteration; +// second_magnitude = second_magnitude_iteration; +// //samplestamp_debug[PRN - 1] = initial_sample_iteration; +// initial_sample = 0; //initial_sample_iteration; +// doppler_index = doppler_index_iteration; +// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); +// } +// else +// { +// max_index = max_index_iteration; +// max_magnitude = max_magnitude_iteration; +// second_magnitude = second_magnitude_iteration; +// initial_sample = initial_sample_iteration; +// doppler_index = doppler_index_iteration; +// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); +// } top_block->stop(); - //power_sum = (power_sum - max_magnitude) / (fft_size - 1); - //float test_statistics = (max_magnitude / power_sum); - float test_statistics = max_magnitude/second_magnitude; - float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - if (test_statistics > threshold) - { - //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); - std::cout << " " << PRN << " "; - doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); - acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) - } - else - { - std::cout << " . "; - } + +// float test_statistics = max_magnitude/second_magnitude; +// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); +// if (test_statistics > threshold) +// { +// //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); +// std::cout << " " << PRN << " "; +// doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); +// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); +// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); +// acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) +// } +// else +// { +// std::cout << " . "; +// } std::cout.flush(); From f48a91c4132c09b3aa5b062d7c45ba4f439cb2ab Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Fri, 30 Nov 2018 11:07:01 +0100 Subject: [PATCH 22/53] Galileo E5a is now debugged and working. Acquisition is using interrupts again. Each acquisition process opens and closes the acquisition device when an acquisition is done instead of having the device opened all the time. In this way the acquisition interrupt should only be received by the process that is using the interrupt at that time. --- .../galileo_e5a_pcps_acquisition_fpga.cc | 20 ++- .../gps_l1_ca_pcps_acquisition_fpga.cc | 4 +- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 5 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 57 ++++++- .../acquisition/libs/fpga_acquisition.cc | 155 +++++++++++++++--- .../acquisition/libs/fpga_acquisition.h | 6 +- .../galileo_e1_dll_pll_veml_tracking_fpga.cc | 8 + .../gps_l1_ca_dll_pll_tracking_fpga.cc | 5 + .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 26 ++- .../dll_pll_veml_tracking_fpga.cc | 28 +++- .../tracking/libs/fpga_multicorrelator.cc | 2 + .../hybrid_observables_test_fpga.cc | 70 +++++--- .../tracking/tracking_pull-in_test_fpga.cc | 39 ++++- 13 files changed, 353 insertions(+), 72 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 522f1f855..90c1695d7 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -51,19 +51,19 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf //printf("creating the E5A acquisition"); pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - std::string default_item_type = "cshort"; + //std::string default_item_type = "cshort"; std::string default_dump_filename = "../data/acquisition.dat"; DLOG(INFO) << "Role " << role; //item_type_ = configuration_->property(role + ".item_type", default_item_type); - long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); + long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 12500000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); acq_parameters.downsampling_factor = downsampling_factor; - + printf("downsampling_factor = %f\n", downsampling_factor); fs_in = fs_in/downsampling_factor; acq_parameters.fs_in = fs_in; @@ -103,9 +103,11 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; + printf("code_length = %d\n", code_length); + printf("vector_length = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); printf("select queue = %d\n", select_queue_Fpga); - //printf("select_queue_Fpga = %d\n", select_queue_Fpga); + //printf("acq adapter select_queue_Fpga = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); @@ -126,6 +128,8 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf //printf("creating the E5A acquisition CONT"); //printf("nsamples_total = %d\n", nsamples_total); + printf("number of codes = %d\n", Galileo_E5a_NUMBER_OF_CODES); + for (unsigned int PRN = 1; PRN <= Galileo_E5a_NUMBER_OF_CODES; PRN++) { // gr_complex* code = new gr_complex[code_length_]; @@ -133,14 +137,17 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf if (acq_iq_) { + //printf("aaaaaaaaaaaaa\n"); strcpy(signal_, "5X"); } else if (acq_pilot_) { + //printf("bbbbbbbbbbbbb\n"); strcpy(signal_, "5Q"); } else { + //printf("cccccccccccc\n"); strcpy(signal_, "5I"); } @@ -180,6 +187,9 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf { d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + + //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t((2^3)*static_cast(floor(fft_codes_padded[i].real() * (pow(2, 6) - 1) / max)), + // (2^3)*static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 6) - 1) / max))); } } @@ -217,7 +227,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf //acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); //DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; - acq_parameters.total_block_exp = 9; + acq_parameters.total_block_exp = 10; acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index d0f388d1e..f9a9e42d7 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -80,7 +80,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); + unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 4); acq_parameters.sampled_ms = sampled_ms; unsigned int code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; @@ -113,7 +113,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in, 0); // generate PRN code - + for (int s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index b9fb23fe6..dd9ee99f7 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -54,7 +54,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( //printf("L5 ACQ CLASS CREATED\n"); pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - std::string default_item_type = "cshort"; + //std::string default_item_type = "cshort"; std::string default_dump_filename = "./data/acquisition.dat"; LOG(INFO) << "role " << role; @@ -101,7 +101,10 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); + printf("code_length = %d\n", (int) code_length); + printf("vector length = %d\n", (int) vector_length); printf("select queue = %d\n", select_queue_Fpga); + printf("sampled_ms = %d\n", sampled_ms); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 304bf402a..db20977b4 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -79,7 +79,7 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( d_single_doppler_flag = false; d_downsampling_factor = acq_parameters.downsampling_factor; - //printf("AAAAAAAAAA downsampling_factor = %f\n", d_downsampling_factor); + //printf("CONSTRUCTOR downsampling_factor = %d\n", (int) d_downsampling_factor); d_select_queue_Fpga = acq_parameters.select_queue_Fpga; //printf("zzzz acq_parameters.code_length = %d\n", acq_parameters.code_length); //printf("zzzz acq_parameters.samples_per_ms = %d\n", acq_parameters.samples_per_ms); @@ -238,6 +238,8 @@ void pcps_acquisition_fpga::set_active(bool active) d_input_power = 0.0; d_mag = 0.0; + int32_t doppler; + DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " @@ -265,22 +267,56 @@ void pcps_acquisition_fpga::set_active(bool active) //printf("LAUNCH ACQ\n"); //printf("acq lib d_num_doppler_bins = %d\n", d_num_doppler_bins); //printf("writing config for channel %d -----------------------------------------\n", (int) d_channel); + + + //printf("d_downsampling_factor = %f\n", d_downsampling_factor); + + //printf("acq_parameters.code_length = %d\n", (int) acq_parameters.code_length); + // debug +// if (acq_parameters.code_length == 12500) +// { +// acquisition_fpga->configure_acquisition_debug(); +// acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); +// acquisition_fpga->write_local_code(); +// acquisition_fpga->set_block_exp(d_total_block_exp); +// +// acquisition_fpga->run_acquisition(); +// acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); +// +// doppler = 0; +// d_test_statistics = 0; +// } +// else +// { + + + acquisition_fpga->configure_acquisition(); acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); + + //printf("d_num_doppler_bins = %d\n", (int) d_num_doppler_bins); acquisition_fpga->write_local_code(); + + //acquisition_fpga->set_doppler_sweep(2); //printf("acq lib going to launch acquisition\n"); acquisition_fpga->set_block_exp(d_total_block_exp); + + + //printf("running acq for channel %d\n", (int) d_channel); acquisition_fpga->run_acquisition(); //printf("acq lib going to read the acquisition results\n"); //read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index); + + + //printf("reading results for channel %d\n", (int) d_channel); acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); @@ -288,13 +324,27 @@ void pcps_acquisition_fpga::set_active(bool active) //printf("gnuradio block : d_total_block_exp = %d total_block_exp = %d\n", (int) d_total_block_exp, (int) total_block_exp); + + + if (total_block_exp > d_total_block_exp) { printf("changing blk exp..... d_total_block_exp = %d total_block_exp = %d chan = %d\n", d_total_block_exp, total_block_exp, d_channel); + //getchar(); d_total_block_exp = total_block_exp; } + +// // debug +// if (acq_parameters.code_length == 12500) +// { +// doppler = 0; +// d_test_statistics = 0; +// } +// else +// { + //printf("end channel %d -----------------------------------------------------\n", (int) d_channel); //printf("READ ACQ RESULTS\n"); @@ -305,7 +355,7 @@ void pcps_acquisition_fpga::set_active(bool active) //usleep(5000000); //} // end while test - int32_t doppler; + //int32_t doppler; // NEW SATELLITE DETECTION ALGORITHM STARTS HERE ---------------------------------------------------- @@ -328,6 +378,9 @@ void pcps_acquisition_fpga::set_active(bool active) d_test_statistics = 0.0; } + +// } // debug condition + // // OLD SATELLITE DETECTION ALGORITHM STARTS HERE ---------------------------------------------------- // // d_mag = magt; diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 6e87265f6..77ca6b4ff 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -101,6 +101,7 @@ void fpga_acquisition::write_local_code() { //printf("#### ACQ: WRITING LOCAL CODE for PRN %d\n", (int) d_PRN); + fpga_acquisition::fpga_configure_acquisition_local_code( &d_all_fft_codes[d_nsamples_total * (d_PRN - 1)]); @@ -134,7 +135,7 @@ fpga_acquisition::fpga_acquisition(std::string device_name, d_fd = 0; // driver descriptor d_map_base = nullptr; // driver memory map d_all_fft_codes = all_fft_codes; - +/* //printf("acq internal device name = %s\n", d_device_name.c_str()); // open communication with HW accelerator if ((d_fd = open(d_device_name.c_str(), O_RDWR | O_SYNC)) == -1) @@ -173,7 +174,11 @@ fpga_acquisition::fpga_acquisition(std::string device_name, //printf("acq lib REG SANITY CHECK SUCCESS\n"); //std::cout << "Acquisition test register sanity check success!" << std::endl; } + */ + fpga_acquisition::open_device(); fpga_acquisition::reset_acquisition(); + fpga_acquisition::fpga_acquisition_test_register(); + fpga_acquisition::close_device(); // flag used for testing purposes d_single_doppler_flag = 0; @@ -183,11 +188,56 @@ fpga_acquisition::fpga_acquisition(std::string device_name, } +void fpga_acquisition::open_device() +{ + //printf("acq internal device name = %s\n", d_device_name.c_str()); + // open communication with HW accelerator + if ((d_fd = open(d_device_name.c_str(), O_RDWR | O_SYNC)) == -1) + { + LOG(WARNING) << "Cannot open deviceio" << d_device_name; + std::cout << "Acq: cannot open deviceio" << d_device_name << std::endl; + } + else + { + //printf("acq lib DEVICE OPENED CORRECTLY\n"); + } + d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, + PROT_READ | PROT_WRITE, MAP_SHARED, d_fd, 0)); + + if (d_map_base == reinterpret_cast(-1)) + { + LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory"; + std::cout << "Acq: cannot map deviceio" << d_device_name << std::endl; + } + else + { + //printf("acq lib MAP BASE MAPPED CORRECTLY\n"); + } + + /* + // sanity check : check test register + uint32_t writeval = TEST_REG_SANITY_CHECK; + uint32_t readval; + readval = fpga_acquisition::fpga_acquisition_test_register(writeval); + if (writeval != readval) + { + LOG(WARNING) << "Acquisition test register sanity check failed"; + } + else + { + LOG(INFO) << "Acquisition test register sanity check success!"; + //printf("acq lib REG SANITY CHECK SUCCESS\n"); + //std::cout << "Acquisition test register sanity check success!" << std::endl; + } + + */ + +} fpga_acquisition::~fpga_acquisition() { //printf("acq lib destructor called\n"); - close_device(); + //fpga_acquisition::close_device(); } @@ -198,8 +248,34 @@ bool fpga_acquisition::free() } -uint32_t fpga_acquisition::fpga_acquisition_test_register(uint32_t writeval) +void fpga_acquisition::fpga_acquisition_test_register() { + + // sanity check : check test register + uint32_t writeval = TEST_REG_SANITY_CHECK; + uint32_t readval; + + //printf("acq lib test register called\n"); + //uint32_t readval; + // write value to test register + d_map_base[15] = writeval; + // read value from test register + readval = d_map_base[15]; + + + //readval = fpga_acquisition::fpga_acquisition_test_register(writeval); + if (writeval != readval) + { + LOG(WARNING) << "Acquisition test register sanity check failed"; + } + else + { + LOG(INFO) << "Acquisition test register sanity check success!"; + //printf("acq lib REG SANITY CHECK SUCCESS\n"); + //std::cout << "Acquisition test register sanity check success!" << std::endl; + } + +/* //printf("acq lib test register called\n"); uint32_t readval; // write value to test register @@ -208,6 +284,7 @@ uint32_t fpga_acquisition::fpga_acquisition_test_register(uint32_t writeval) readval = d_map_base[15]; // return read value return readval; + */ } @@ -219,6 +296,10 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local //printf("acq lib fpga_configure_acquisition_local_code_called\n"); // clear memory address counter //d_map_base[6] = LOCAL_CODE_CLEAR_MEM; + + //printf("writing local code for d_PRN = %d\n", (int) d_PRN); + //printf("writing local code d_nsamples_total = %d\n", (int) d_nsamples_total); + //printf("writing local code d_vector_length = %d\n", (int) d_vector_length); d_map_base[9] = LOCAL_CODE_CLEAR_MEM; // write local code for (k = 0; k < d_vector_length; k++) @@ -250,9 +331,9 @@ void fpga_acquisition::run_acquisition(void) //printf("acq lib run_acqisition called\n"); // enable interrupts - //int32_t reenable = 1; + int32_t reenable = 1; //reenable = 1; - //write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); + write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); // launch the acquisition process //printf("acq lib launchin acquisition ...\n"); @@ -262,24 +343,24 @@ void fpga_acquisition::run_acquisition(void) int32_t irq_count; ssize_t nb; - uint32_t result_valid = 0; + //uint32_t result_valid = 0; - usleep(50); + //usleep(500000); //printf("acq lib waiting for result valid\n"); - while(result_valid == 0) - { - read_result_valid(&result_valid); // polling - } + //while(result_valid == 0) + //{ + // read_result_valid(&result_valid); // polling + //} //printf("result valid\n"); // wait for interrupt - //nb = read(d_fd, &irq_count, sizeof(irq_count)); + nb = read(d_fd, &irq_count, sizeof(irq_count)); //usleep(500000); // debug //printf("interrupt received\n"); - //if (nb != sizeof(irq_count)) - // { - // printf("acquisition module Read failed to retrieve 4 bytes!\n"); - // printf("acquisition module Interrupt number %d\n", irq_count); - // } + if (nb != sizeof(irq_count)) + { + printf("acquisition module Read failed to retrieve 4 bytes!\n"); + printf("acquisition module Interrupt number %d\n", irq_count); + } @@ -293,6 +374,10 @@ void fpga_acquisition::set_block_exp(uint32_t total_block_exp) void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) { + //printf("writing doppler_max = %d\n", (int) d_doppler_max); + //printf("writing doppler_step = %d\n", (int) d_doppler_step); + //printf("num_sweeps = %d\n", num_sweeps); + if (d_single_doppler_flag == 0) { //printf("acq lib set_doppler_sweep called\n"); @@ -441,9 +526,12 @@ void fpga_acquisition::set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t dop void fpga_acquisition::configure_acquisition() { + fpga_acquisition::open_device(); + //printf("acq lib configure acquisition called\n"); //printf("AAA d_select_queue = %d\n", d_select_queue); d_map_base[0] = d_select_queue; + //d_map_base[0] = 1; //printf("acq internal writing d_vector_length = %d to d map base 1\n ", d_vector_length); d_map_base[1] = d_vector_length; //printf("acq interal writing d_nsamples = %d to d map base 2\n ", d_nsamples); @@ -458,9 +546,30 @@ void fpga_acquisition::configure_acquisition() } + +//void fpga_acquisition::configure_acquisition_debug() +//{ +// //printf("acq lib configure acquisition called\n"); +// //printf("AAA d_select_queue = %d\n", d_select_queue); +// d_map_base[0] = d_select_queue; +// //printf("acq internal writing d_vector_length = %d to d map base 1\n ", d_vector_length); +// d_map_base[1] = d_vector_length; +// //printf("acq interal writing d_nsamples = %d to d map base 2\n ", d_nsamples); +// d_map_base[2] = d_nsamples; +// //printf("AAA writing LOG2 d_vector_length = %d to d map base 7\n ", (int)log2((float)d_vector_length)); +// d_map_base[7] = static_cast(log2(static_cast(d_vector_length))); // log2 FFTlength +// //printf("AAA writing excludelimit = %d to d map base 12\n", (int) d_excludelimit); +// d_map_base[12] = d_excludelimit; +// +// //printf("acquisition debug vector length = %d\n", d_vector_length); +// //printf("acquisition debug vector length = %d\n", (int)log2((float)d_vector_length)); +//} + + + void fpga_acquisition::set_phase_step(uint32_t doppler_index) { - //printf("acq lib set phase step called\n"); + //printf("acq lib set phase step SHOULD NOT BE called\n"); float phase_step_rad_real; float phase_step_rad_int_temp; int32_t phase_step_rad_int; @@ -491,7 +600,8 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp) { - + //usleep(500000); + //printf("reading results\n"); //printf("acq lib read_acquisition_results_called\n"); uint64_t initial_sample_tmp = 0; @@ -541,6 +651,10 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, readval = d_map_base[15]; // read dummy + + + fpga_acquisition::close_device(); + } @@ -585,12 +699,15 @@ void fpga_acquisition::set_single_doppler_flag(unsigned int single_doppler_flag) // this function is only used for the unit tests void fpga_acquisition::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) { + uint32_t readval = 0; readval = d_map_base[8]; *total_scale_factor = readval; //readval = d_map_base[8]; *fw_scale_factor = 0; + + //printf("reading scale factor of %d\n", (int) readval); } void fpga_acquisition::read_result_valid(uint32_t *result_valid) diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index d007c6583..bab0cbabc 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -115,7 +115,7 @@ public: void configure_acquisition(void); - + //void configure_acquisition_debug(void); private: int64_t d_fs_in; @@ -133,11 +133,11 @@ private: uint32_t d_doppler_step; // doppler step uint32_t d_PRN; // PRN // FPGA private functions - uint32_t fpga_acquisition_test_register(uint32_t writeval); + void fpga_acquisition_test_register(void); void fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]); //void configure_acquisition(); void close_device(); - + void open_device(); void read_result_valid(uint32_t *result_valid); // test parameters diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index ad9da322c..b3e2c88e9 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -140,6 +140,8 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( float* ca_codes_f; float* data_codes_f; + + printf("trk_param_fpga.track_pilot = %d\n", trk_param_fpga.track_pilot); if (trk_param_fpga.track_pilot) { d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * Galileo_E1_NUMBER_OF_CODES * sizeof(int), volk_gnsssdr_get_alignment())); @@ -155,6 +157,8 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( //int kk; + + for (unsigned int PRN = 1; PRN <= Galileo_E1_NUMBER_OF_CODES; PRN++) { char data_signal[3] = "1B"; @@ -170,6 +174,9 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( d_ca_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); d_data_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(data_codes_f[s]); //printf("%f %d | ", data_codes_f[s], d_data_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); + //printf("data_codes_f[%d] = %f\n", s, data_codes_f[s]); + //printf("d_ca_codes[%d] = %d\n", static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s, d_data_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s]); + } //printf("\n next \n"); //scanf ("%d",&kk); @@ -183,6 +190,7 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( { d_ca_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); //printf("%f %d | ", ca_codes_f[s], d_ca_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); + } //printf("\n next \n"); //scanf ("%d",&kk); diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index 571d89c6b..f3bc1a059 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -142,6 +142,11 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); + // debug +// for (int kk=0;kkproperty(role + ".item_type", default_item_type); - int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 12500000); int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); @@ -86,6 +86,7 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.early_late_space_chips = early_late_space_chips; int vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L5i_CODE_RATE_HZ) / static_cast(GPS_L5i_CODE_LENGTH_CHIPS))); trk_param_fpga.vector_length = vector_length; + printf("trk vector length = %d\n", vector_length); int extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; @@ -121,11 +122,12 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; trk_param_fpga.max_lock_fail = max_lock_fail; - double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); + double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.75); if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; trk_param_fpga.carrier_lock_th = carrier_lock_th; // FPGA configuration parameters + std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; @@ -133,7 +135,6 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.device_base = device_base; //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 0); trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators - //################# PRE-COMPUTE ALL THE CODES ################# unsigned int code_samples_per_chip = 1; unsigned int code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); @@ -178,14 +179,31 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( gps_l5i_code_gen_float(tracking_code, PRN); for (unsigned int s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + +// if (d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] == -1) +// { +// d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = 1; +// } +// else +// { +// d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = 0; +// } + // printf("tracking_code[%d] = %f\n", s, tracking_code[s]); + // printf("d_ca_codes[%d] = %d\n", static_cast(code_length_chips) * (PRN - 1) + s, d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s]); //printf("%f %d | ", ca_codes_f[s], d_ca_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); + //printf("d_ca_codes[%d] = %d\n", static_cast(code_length_chips) * (PRN - 1) + s, d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s]); + + } } } //printf("end \n"); + + + delete[] tracking_code; if (trk_param_fpga.track_pilot) { diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 9981432d3..cffdfa95e 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -498,9 +498,13 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; + d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / trk_parameters.fs_in; + //printf("d_carrier_doppler_hz = %f\n", d_carrier_doppler_hz); + //printf("d_carrier_phase_step_rad = %f\n", d_carrier_phase_step_rad); + // DLL/PLL filter initialization d_carrier_loop_filter.initialize(); // initialize the carrier filter d_code_loop_filter.initialize(); // initialize the code filter @@ -693,8 +697,10 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra { //printf("kkkkkkkkkkkkk d_cn0_estimation_counter = %d\n", d_cn0_estimation_counter); //printf("trk_parameters.cn0_samples = %d\n", trk_parameters.cn0_samples); - +// printf("trk_parameters.cn0_samples = %d\n", trk_parameters.cn0_samples); +// printf("d_cn0_estimation_counter = %d\n", d_cn0_estimation_counter); // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### + if (d_cn0_estimation_counter < trk_parameters.cn0_samples) { // fill buffer with prompt correlator output values @@ -708,6 +714,9 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra d_cn0_estimation_counter = 0; // Code lock indicator d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, trk_parameters.cn0_samples, coh_integration_time_s); + + + // Carrier lock indicator d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); // Loss of lock detection @@ -717,6 +726,14 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra //printf("trk_parameters.cn0_min = %f\n", trk_parameters.cn0_min); //printf("d_carrier_lock_fail_counter = %d\n", d_carrier_lock_fail_counter); //printf("trk_parameters.max_lock_fail = %d\n", trk_parameters.max_lock_fail); + +// printf("d_CN0_SNV_dB_Hz = %f\n", d_CN0_SNV_dB_Hz); +// printf("d_carrier_lock_threshold = %f\n", d_carrier_lock_threshold); +// printf("trk_parameters.cn0_min = %d\n", trk_parameters.cn0_min); +// printf("trk_parameters.cn0_samples = %d\n", trk_parameters.cn0_samples); +// printf("d_carrier_lock_test = %f\n", d_carrier_lock_test); +// printf("d_carrier_lock_threshold = %f\n", d_carrier_lock_threshold); + if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < trk_parameters.cn0_min) { d_carrier_lock_fail_counter++; @@ -1299,6 +1316,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } case 1: // Standby - Consume samples at full throttle, do nothing { + //printf("d_state = 1\n"); d_pull_in = 0; multicorrelator_fpga->lock_channel(); uint64_t counter_value = multicorrelator_fpga->read_sample_counter(); @@ -1340,6 +1358,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un case 2: { + //printf("d_state = 2\n"); //printf("trk state 2 counter value = %" PRIu64 "\n", multicorrelator_fpga->read_sample_counter()); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); @@ -1393,6 +1412,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un d_Prompt_buffer_deque.push_back(*d_Prompt); if (d_Prompt_buffer_deque.size() == d_secondary_code_length) { + //printf("Secondary code lock\n"); next_state = acquire_secondary(); if (next_state) { @@ -1556,6 +1576,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } else { + //printf(" do not enable extended integration\n"); d_state = 4; } } @@ -1566,6 +1587,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un case 3: { + //printf("d_state = 3\n"); //printf("trk state 3 counter value = %" PRIu64 "\n", multicorrelator_fpga->read_sample_counter()); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); @@ -1638,6 +1660,8 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un d_rem_code_phase_chips * static_cast(d_code_samples_per_chip), d_code_phase_step_chips * static_cast(d_code_samples_per_chip), d_current_prn_length_samples); + //printf("d_cloop = %d\n", d_cloop); + //printf("trk_parameters.extend_correlation_symbols = %d\n", trk_parameters.extend_correlation_symbols); save_correlation_results(); // check lock status @@ -1652,6 +1676,8 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un update_tracking_vars(); // ########### Output the tracking results to Telemetry block ########## + //printf("state 4 interchange_iq = %d\n", interchange_iq); + //printf("state 4 trk_parameters.track_pilot = %d\n", trk_parameters.track_pilot); if (interchange_iq) { if (trk_parameters.track_pilot) diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 8c069314c..15417294a 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -423,6 +423,7 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR //printf("kkk select_fpga_correlator = %x\n", select_fpga_correlator); d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; + //printf("trk lib d_code_length_chips = %d, d_code_samples_per_chip = %d\n", d_code_length_chips, d_code_samples_per_chip); for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { //if (d_local_code_in[k] == 1) @@ -708,6 +709,7 @@ void fpga_multicorrelator_8sc::unlock_channel(void) // unlock the channel to let the next samples go through //printf("www writing 1 to d map base %d = drop samples\n", d_DROP_SAMPLES_REG_ADDR); d_map_base[d_DROP_SAMPLES_REG_ADDR] = 1; // unlock the channel + d_map_base[23] = 1; // set the tracking module back to idle } void fpga_multicorrelator_8sc::close_device() diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 9c6d520e9..1ced23735 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -79,7 +79,7 @@ #define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define TEST_OBS_NSAMPLES_TRACKING 850000000 // number of samples during which we test the tracking module +#define TEST_OBS_NSAMPLES_TRACKING 1000000000 // number of samples during which we test the tracking module #define TEST_OBS_NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop #define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter @@ -442,6 +442,7 @@ void *handler_DMA_obs_test(void *arguments) //printf("enter kk"); //scanf("%d", &kk); + //printf("args->freq_band = %d\n", (int) args->freq_band); while (file_completed == false) { //printf("samples sent = %d\n", nsamples); @@ -455,11 +456,11 @@ void *handler_DMA_obs_test(void *arguments) file_completed = true; } - nread_elements = fread(input_samples, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) { - printf("could not read the desired number of samples from the input file\n"); + printf("file completed\n"); file_completed = true; } @@ -474,25 +475,25 @@ void *handler_DMA_obs_test(void *arguments) if (args->freq_band == 0) { // channel 1 (queue 1) -> E5/L5 - input_samples_dma[dma_index] = 0; - input_samples_dma[dma_index+1] = 0; + input_samples_dma_obs_test[dma_index] = 0; + input_samples_dma_obs_test[dma_index+1] = 0; // channel 0 (queue 0) -> E1/L1 - input_samples_dma[dma_index+2] = input_samples[index0]; - input_samples_dma[dma_index+3] = input_samples[index0+1]; + input_samples_dma_obs_test[dma_index+2] = input_samples_obs_test[index0]; + input_samples_dma_obs_test[dma_index+3] = input_samples_obs_test[index0+1]; } else { // channel 1 (queue 1) -> E5/L5 - input_samples_dma[dma_index] = input_samples[index0]; - input_samples_dma[dma_index+1] = input_samples[index0+1]; + input_samples_dma_obs_test[dma_index] = input_samples_obs_test[index0]; + input_samples_dma_obs_test[dma_index+1] = input_samples_obs_test[index0+1]; // channel 0 (queue 0) -> E1/L1 - input_samples_dma[dma_index+2] = 0; - input_samples_dma[dma_index+3] = 0; + input_samples_dma_obs_test[dma_index+2] = 0; + input_samples_dma_obs_test[dma_index+3] = 0; } dma_index += 4; } //printf("writing samples to send\n"); - nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); + nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements*NUM_QUEUES); //printf("exited writing samples to send\n"); if (nsamples_transmitted != nread_elements*NUM_QUEUES) { @@ -527,6 +528,10 @@ bool HybridObservablesTestFpga::acquire_signal() baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } + else + { + baseband_sampling_freq_acquisition = baseband_sampling_freq; + } // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; @@ -546,8 +551,8 @@ bool HybridObservablesTestFpga::acquire_signal() config->set_property("Acquisition.item_type", "cshort"); config->set_property("Acquisition.if", "0"); - config->set_property("Acquisition.sampled_ms", "4"); - config->set_property("Acquisition.select_queue_Fpga", "0"); + //config->set_property("Acquisition.sampled_ms", "4"); + //config->set_property("Acquisition.select_queue_Fpga", "0"); config->set_property("Acquisition.devicename", "/dev/uio0"); if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -567,6 +572,8 @@ bool HybridObservablesTestFpga::acquire_signal() //printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { + config->set_property("Acquisition.select_queue_Fpga", "0"); + config->set_property("Acquisition.sampled_ms", "1"); //printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; @@ -585,6 +592,8 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { + config->set_property("Acquisition.select_queue_Fpga", "0"); + config->set_property("Acquisition.sampled_ms", "4"); tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); @@ -628,6 +637,8 @@ bool HybridObservablesTestFpga::acquire_signal() else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { + config->set_property("Acquisition.select_queue_Fpga", "1"); + config->set_property("Acquisition.sampled_ms", "1"); tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); @@ -644,6 +655,8 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { + config->set_property("Acquisition.select_queue_Fpga", "1"); + config->set_property("Acquisition.sampled_ms", "1"); tmp_gnss_synchro.System = 'G'; std::string signal = "L5"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); @@ -755,13 +768,13 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E5a_CODE_CHIP_RATE_HZ / Galileo_E5a_CODE_LENGTH_CHIPS))); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / GPS_L5i_CODE_LENGTH_CHIPS))); } @@ -1199,12 +1212,14 @@ bool HybridObservablesTestFpga::acquire_signal() args.file = file; + send_samples_start_obs_test = 0; + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) { //printf("gggggggg \n"); //---------------------------------------------------------------------------------- // send the previous samples to set the downsampling filter in a good condition - send_samples_start = 0; + //send_samples_start = 0; args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before @@ -1212,15 +1227,15 @@ bool HybridObservablesTestFpga::acquire_signal() //printf("sending pre init %d\n", args.nsamples_tx); - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } pthread_mutex_lock(&mutex); - send_samples_start = 1; + send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex); pthread_join(thread_DMA, NULL); - send_samples_start = 0; + send_samples_start_obs_test = 0; //printf("finished sending samples init filter status\n"); //----------------------------------------------------------------------------------- @@ -1241,10 +1256,11 @@ bool HybridObservablesTestFpga::acquire_signal() + // create DMA child process //printf("||||||||1 args freq_band = %d\n", args.freq_band); //printf("sending samples main DMA %d\n", args.nsamples_tx); - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } @@ -1253,7 +1269,7 @@ bool HybridObservablesTestFpga::acquire_signal() top_block->start(); pthread_mutex_lock(&mutex); - send_samples_start = 1; + send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) @@ -1290,7 +1306,7 @@ bool HybridObservablesTestFpga::acquire_signal() pthread_join(thread_DMA, NULL); pthread_mutex_lock(&mutex); - send_samples_start = 0; + send_samples_start_obs_test = 0; pthread_mutex_unlock(&mutex); while (msg_rx->rx_message == 0) @@ -2193,7 +2209,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) gnss_synchro_vec.push_back(tmp_gnss_synchro); } } - printf("KKKKKKKKK FIRST PART FINISHED\n"); + //printf("KKKKKKKKK FIRST PART FINISHED\n"); //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Signal Acquired\n"); configure_receiver(FLAGS_PLL_bw_hz_start, @@ -2486,7 +2502,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) //{ // skip the samples that have already been used - args.skip_used_samples = args.nsamples_tx; + args.skip_used_samples = 0; //args.nsamples_tx; //} //else //{ diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 28f2e0263..a947d30af 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -589,12 +589,16 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); + } + else + { + baseband_sampling_freq_acquisition = baseband_sampling_freq; } // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) @@ -614,8 +618,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) config->set_property("Acquisition.item_type", "cshort"); config->set_property("Acquisition.if", "0"); - config->set_property("Acquisition.sampled_ms", "4"); - config->set_property("Acquisition.select_queue_Fpga", "0"); + //config->set_property("Acquisition.sampled_ms", "4"); + //config->set_property("Acquisition.select_queue_Fpga", "0"); config->set_property("Acquisition.devicename", "/dev/uio0"); if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -632,7 +636,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - tmp_gnss_synchro.System = 'G'; + config->set_property("Acquisition.sampled_ms", "1"); + config->set_property("Acquisition.select_queue_Fpga", "0"); + + tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; const char* str = signal.c_str(); // get a C style null terminated string std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null @@ -649,6 +656,9 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { + config->set_property("Acquisition.sampled_ms", "4"); + config->set_property("Acquisition.select_queue_Fpga", "0"); + tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; const char* str = signal.c_str(); // get a C style null terminated string @@ -667,6 +677,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { + config->set_property("Acquisition.sampled_ms", "1"); + config->set_property("Acquisition.select_queue_Fpga", "1"); tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; const char* str = signal.c_str(); // get a C style null terminated string @@ -684,6 +696,9 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { + config->set_property("Acquisition.sampled_ms", "1"); + config->set_property("Acquisition.select_queue_Fpga", "1"); + printf("CORRECT L5 A!!!\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "L5"; const char* str = signal.c_str(); // get a C style null terminated string @@ -739,6 +754,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { + printf("CORRECT L5 B!!!\n"); top_block->msg_connect(acquisition_GpsL5_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); } @@ -794,6 +810,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { + printf("CORRECT L5 C !!!!"); code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } @@ -830,6 +847,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { + acquisition_GpsL5_Fpga->set_single_doppler_flag(1); } @@ -1326,6 +1344,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) start_msg = false; } + //printf("wait for DMA to finish\n"); // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); @@ -1620,7 +1639,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) unsigned int fft_size = pow(2, nbits); - printf("####################################\n"); + //printf("####################################\n"); for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) { std::vector pull_in_results_v; @@ -1641,8 +1660,12 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) //simulate Code Delay error in acquisition gnss_synchro.Acq_delay_samples = true_acq_delay_samples + (acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) / GPS_L1_CA_CODE_RATE_HZ) * static_cast(baseband_sampling_freq); - - + // debug + //printf("forcing data\n"); + //gnss_synchro.Acq_samplestamp_samples = 37500; + //gnss_synchro.Acq_delay_samples = 2933; + //printf("acq_samplestamp_samples = %d\n", (int)gnss_synchro.Acq_samplestamp_samples); + //printf("true_acq_delay_samples = %d\n", (int)gnss_synchro.Acq_delay_samples); //create flowgraph From e436aadfd993b57b5297de11cee0e1daf72c3a75 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 5 Dec 2018 11:23:30 +0100 Subject: [PATCH 23/53] minor modifications to the Galileo E5a and GPS L5 acquisition adapters. Now the acquisition opens and closes the acquisition HW device every time an acquisition is done, to prevent the acquisition interrupt from interrupting all the acquisition processes at the same time. --- .../galileo_e5a_pcps_acquisition_fpga.cc | 5 +- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 3 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 61 +++++++++++++------ .../acquisition/libs/fpga_acquisition.cc | 39 ++++++++++-- .../acquisition/libs/fpga_acquisition.h | 6 +- 5 files changed, 84 insertions(+), 30 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 90c1695d7..0d779abc7 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -115,6 +115,9 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf acq_parameters.samples_per_ms = nsamples_total / sampled_ms; acq_parameters.samples_per_code = nsamples_total; + + acq_parameters.excludelimit = static_cast(ceil((1.0 / Galileo_E5a_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters.fs_in))); + //vector_length_ = code_length_ * sampled_ms_; // compute all the GALILEO E5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time @@ -128,7 +131,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf //printf("creating the E5A acquisition CONT"); //printf("nsamples_total = %d\n", nsamples_total); - printf("number of codes = %d\n", Galileo_E5a_NUMBER_OF_CODES); + //printf("number of codes = %d\n", Galileo_E5a_NUMBER_OF_CODES); for (unsigned int PRN = 1; PRN <= Galileo_E5a_NUMBER_OF_CODES; PRN++) { diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index dd9ee99f7..a765f9f9d 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -112,7 +112,8 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( acq_parameters.samples_per_ms = nsamples_total/sampled_ms; acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L5i_CODE_RATE_HZ)); + //acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L5i_CODE_RATE_HZ)); + acq_parameters.excludelimit = static_cast(ceil((1.0 / GPS_L5i_CODE_RATE_HZ) * static_cast(acq_parameters.fs_in))); //printf("L5 ACQ CLASS MID 01\n"); // compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index db20977b4..1b8cb73c6 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -315,17 +315,38 @@ void pcps_acquisition_fpga::set_active(bool active) //read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index); - - //printf("reading results for channel %d\n", (int) d_channel); acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); + + //printf("returned d_doppler_index = %d\n", d_doppler_index); //printf("gnuradio block : d_total_block_exp = %d total_block_exp = %d\n", (int) d_total_block_exp, (int) total_block_exp); - - + //printf("d_fft_size = %d = %d\n", d_fft_size, acq_parameters.samples_per_code); + //printf("indext = %d\n", (int) indext); + //printf("initial_sample = %d\n", (int) initial_sample); + //printf("firstpeak = %d\n", (int) firstpeak); + //printf("secondpeak = %d\n", (int) secondpeak); + //printf("total_block_exp = %d\n", (int) total_block_exp); +// if (total_block_exp == 11) +// { +// printf("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n"); +// getchar(); +// +// } +// if (total_block_exp > d_total_block_exp) +// { +// usleep(5000000); +// acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); +// printf("second time d_fft_size = %d = %d", d_fft_size, acq_parameters.samples_per_code); +// printf("second time indext = %d\n", (int) indext); +// printf("second time initial_sample = %d\n", (int) initial_sample); +// printf("second time firstpeak = %d\n", (int) firstpeak); +// printf("second time secondpeak = %d\n", (int) secondpeak); +// printf("second time total_block_exp = %d\n", (int) total_block_exp); +// } if (total_block_exp > d_total_block_exp) { @@ -336,14 +357,7 @@ void pcps_acquisition_fpga::set_active(bool active) } -// // debug -// if (acq_parameters.code_length == 12500) -// { -// doppler = 0; -// d_test_statistics = 0; -// } -// else -// { + //printf("end channel %d -----------------------------------------------------\n", (int) d_channel); //printf("READ ACQ RESULTS\n"); @@ -359,6 +373,8 @@ void pcps_acquisition_fpga::set_active(bool active) // NEW SATELLITE DETECTION ALGORITHM STARTS HERE ---------------------------------------------------- + + if (d_single_doppler_flag == false) { doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); @@ -379,7 +395,7 @@ void pcps_acquisition_fpga::set_active(bool active) } -// } // debug condition + // // OLD SATELLITE DETECTION ALGORITHM STARTS HERE ---------------------------------------------------- // @@ -419,8 +435,10 @@ void pcps_acquisition_fpga::set_active(bool active) { if (d_downsampling_factor > 1) { + //printf("yes here\n"); - d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext % acq_parameters.samples_per_code)); + //d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext % acq_parameters.samples_per_code)); + d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext)); //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81/d_downsampling_factor; // delay due to the downsampling filter in the acquisition @@ -434,7 +452,8 @@ void pcps_acquisition_fpga::set_active(bool active) else { //printf("xxxxxxxxxxxxxxxx no here\n"); - d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + d_gnss_synchro->Acq_delay_samples = static_cast(indext); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5*d_downsampling_factor; @@ -442,7 +461,8 @@ void pcps_acquisition_fpga::set_active(bool active) } else { - d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); + d_gnss_synchro->Acq_delay_samples = static_cast(indext); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition } @@ -491,10 +511,11 @@ void pcps_acquisition_fpga::set_active(bool active) send_positive_acquisition(); d_state = 0; // Positive acquisition - //printf("acq d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); - //printf("acq d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); - //printf("acq d_gnss_synchro->Acq_doppler_hz = %f\n", d_gnss_synchro->Acq_doppler_hz); - //printf("acq d_gnss_synchro->PRN = %d\n", (int) d_gnss_synchro->PRN); + //printf("acq POSITIVE ACQ d_fft_size = %d = %d\n", d_fft_size, acq_parameters.samples_per_code); + //printf("acq POSITIVE ACQ d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); + //printf("acq POSITIVE ACQ d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); + //printf("acq POSITIVE ACQ d_gnss_synchro->Acq_doppler_hz = %f\n", d_gnss_synchro->Acq_doppler_hz); + //printf("acq POSITIVE ACQ d_gnss_synchro->PRN = %d\n", (int) d_gnss_synchro->PRN); } else { diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 77ca6b4ff..bddbd784a 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -175,8 +175,10 @@ fpga_acquisition::fpga_acquisition(std::string device_name, //std::cout << "Acquisition test register sanity check success!" << std::endl; } */ - fpga_acquisition::open_device(); + fpga_acquisition::reset_acquisition(); + + fpga_acquisition::open_device(); fpga_acquisition::fpga_acquisition_test_register(); fpga_acquisition::close_device(); @@ -329,9 +331,16 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local void fpga_acquisition::run_acquisition(void) { + + //uint32_t result_valid = 0; + //while(result_valid == 0) + //{ + // read_result_valid(&result_valid); // polling + //} //printf("acq lib run_acqisition called\n"); // enable interrupts int32_t reenable = 1; + int32_t disable_int = 0; //reenable = 1; write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); @@ -345,7 +354,7 @@ void fpga_acquisition::run_acquisition(void) //uint32_t result_valid = 0; - //usleep(500000); + //usleep(5000000); //printf("acq lib waiting for result valid\n"); //while(result_valid == 0) //{ @@ -363,6 +372,7 @@ void fpga_acquisition::run_acquisition(void) } + write(d_fd, reinterpret_cast(&disable_int), sizeof(int32_t)); } @@ -529,8 +539,9 @@ void fpga_acquisition::configure_acquisition() fpga_acquisition::open_device(); //printf("acq lib configure acquisition called\n"); - //printf("AAA d_select_queue = %d\n", d_select_queue); + d_map_base[0] = d_select_queue; + //printf("AAA d_select_queue = %d\n", d_select_queue); //d_map_base[0] = 1; //printf("acq internal writing d_vector_length = %d to d map base 1\n ", d_vector_length); d_map_base[1] = d_vector_length; @@ -547,20 +558,27 @@ void fpga_acquisition::configure_acquisition() + + //void fpga_acquisition::configure_acquisition_debug() //{ +// fpga_acquisition::open_device(); +// // //printf("acq lib configure acquisition called\n"); +// // d_map_base[0] = d_select_queue; // //printf("AAA d_select_queue = %d\n", d_select_queue); -// d_map_base[0] = d_select_queue; +// +// //usleep(500000); +// //d_map_base[0] = 1; // //printf("acq internal writing d_vector_length = %d to d map base 1\n ", d_vector_length); -// d_map_base[1] = d_vector_length; +///* d_map_base[1] = d_vector_length; // //printf("acq interal writing d_nsamples = %d to d map base 2\n ", d_nsamples); // d_map_base[2] = d_nsamples; // //printf("AAA writing LOG2 d_vector_length = %d to d map base 7\n ", (int)log2((float)d_vector_length)); // d_map_base[7] = static_cast(log2(static_cast(d_vector_length))); // log2 FFTlength // //printf("AAA writing excludelimit = %d to d map base 12\n", (int) d_excludelimit); // d_map_base[12] = d_excludelimit; -// +//*/ // //printf("acquisition debug vector length = %d\n", d_vector_length); // //printf("acquisition debug vector length = %d\n", (int)log2((float)d_vector_length)); //} @@ -600,6 +618,10 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp) { + //do + //{ + + //usleep(500000); //printf("reading results\n"); @@ -651,6 +673,9 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, readval = d_map_base[15]; // read dummy + //} while (*total_blk_exp == 11); + + fpga_acquisition::close_device(); @@ -686,8 +711,10 @@ void fpga_acquisition::close_device() void fpga_acquisition::reset_acquisition(void) { + fpga_acquisition::open_device(); //printf("acq lib reset acquisition called\n"); d_map_base[8] = RESET_ACQUISITION; // writing a 2 to d_map_base[8] resets the multicorrelator + fpga_acquisition::close_device(); } // this function is only used for the unit tests diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index bab0cbabc..401369788 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -116,6 +116,8 @@ public: void configure_acquisition(void); //void configure_acquisition_debug(void); + void close_device(); + void open_device(); private: int64_t d_fs_in; @@ -136,8 +138,8 @@ private: void fpga_acquisition_test_register(void); void fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]); //void configure_acquisition(); - void close_device(); - void open_device(); +// void close_device(); +// void open_device(); void read_result_valid(uint32_t *result_valid); // test parameters From ae616462700cf283ef00697e9d7667e02bce2542 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Tue, 11 Dec 2018 14:44:42 +0100 Subject: [PATCH 24/53] Solved two bugs: - a minor bug in the E5A fpga acquisition adapter module: a config parameter was not correctly read. - a bug in the tracking fpga multicorrelator module: if pilot tracking was enabled then the results of the pilot correlator were not correctly read when using the multicorrelator 3-1 HW Accelerator in the FPGA (used for GPS L5 and Galileo E5A). --- .../adapters/galileo_e5a_pcps_acquisition_fpga.cc | 2 +- src/algorithms/tracking/libs/fpga_multicorrelator.cc | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 0d779abc7..a0f4a5070 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -61,7 +61,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 12500000); long fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - float downsampling_factor = configuration_->property("GNSS-SDR.downsampling_factor", 1.0); + float downsampling_factor = configuration_->property(role + ".downsampling_factor", 1.0); acq_parameters.downsampling_factor = downsampling_factor; printf("downsampling_factor = %f\n", downsampling_factor); fs_in = fs_in/downsampling_factor; diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 15417294a..1f0cccb49 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -276,8 +276,8 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int32_t n_correlators, // { // other types of multicorrelators (32 registers) d_RESULT_REG_IMAG_BASE_ADDR = 7; - d_RESULT_REG_DATA_REAL_BASE_ADDR = 6; // no pilot tracking - d_RESULT_REG_DATA_IMAG_BASE_ADDR = 12; + //d_RESULT_REG_DATA_REAL_BASE_ADDR = 6; // no pilot tracking + //d_RESULT_REG_DATA_IMAG_BASE_ADDR = 12; d_SAMPLE_COUNTER_REG_ADDR_LSW = 13; d_SAMPLE_COUNTER_REG_ADDR_MSW = 14; @@ -688,13 +688,15 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) if (d_track_pilot) { //printf("reading pilot !!!\n"); - readval_real = d_map_base[d_RESULT_REG_DATA_REAL_BASE_ADDR]; + //readval_real = d_map_base[d_RESULT_REG_DATA_REAL_BASE_ADDR]; + readval_real = d_map_base[d_RESULT_REG_REAL_BASE_ADDR + d_n_correlators]; // if (readval_real >= d_result_SAT_value) // 0x100000 (21 bits two's complement) // { // readval_real = -2*d_result_SAT_value + readval_real; // } - readval_imag = d_map_base[d_RESULT_REG_DATA_IMAG_BASE_ADDR]; + //readval_imag = d_map_base[d_RESULT_REG_DATA_IMAG_BASE_ADDR]; + readval_imag = d_map_base[d_RESULT_REG_IMAG_BASE_ADDR + d_n_correlators]; // if (readval_imag >= d_result_SAT_value) // 0x100000 (21 bits two's complement) // { // readval_imag = -2*d_result_SAT_value + readval_imag; From 7da82dbaea2598e0080658112f4defd780cc6224 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Fri, 14 Dec 2018 18:15:21 +0100 Subject: [PATCH 25/53] updated the FPGA tracking gnuradioblock according to the latest changes in the SW tracking gnuradioblock. --- .../dll_pll_veml_tracking_fpga.cc | 630 ++++++++++-------- .../dll_pll_veml_tracking_fpga.h | 50 +- .../tracking/libs/dll_pll_conf_fpga.cc | 4 +- .../tracking/libs/dll_pll_conf_fpga.h | 2 + .../tracking/libs/fpga_multicorrelator.cc | 2 + .../tracking/libs/fpga_multicorrelator.h | 2 + 6 files changed, 383 insertions(+), 307 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index cffdfa95e..3655f9ffc 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -2,8 +2,8 @@ * \file dll_pll_veml_tracking_fpga.cc * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA * \author Marc Majoral, 2018. marc.majoral(at)cttc.es - * Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com - * Javier Arribas, 2018. jarribas(at)cttc.es + * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com + * \author Javier Arribas, 2018. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, @@ -41,8 +41,11 @@ #include "control_message_factory.h" #include "MATH_CONSTANTS.h" #include "Galileo_E1.h" +#include "galileo_e1_signal_processing.h" #include "Galileo_E5a.h" +#include "galileo_e5_signal_processing.h" #include "GPS_L1_CA.h" +#include "gps_sdr_signal_processing.h" #include "GPS_L2C.h" #include "gps_l2c_signal.h" #include "GPS_L5.h" @@ -57,7 +60,7 @@ #include #include #include - +#include using google::LogMessage; @@ -68,7 +71,7 @@ dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Co dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_) : gr::block("dll_pll_veml_tracking_fpga", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { trk_parameters = conf_; // Telemetry bit synchronization message port input @@ -81,10 +84,10 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & // initialize internal vars d_veml = false; d_cloop = true; - d_synchonizing = false; d_code_chip_rate = 0.0; - d_secondary_code_length = 0; + d_secondary_code_length = 0U; d_secondary_code_string = nullptr; + d_gps_l1ca_preambles_symbols = nullptr; signal_type = std::string(trk_parameters.signal); std::map map_signal_pretty_name; @@ -98,7 +101,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & signal_pretty_name = map_signal_pretty_name[signal_type]; - d_prompt_data_shift = nullptr; + d_code_samples_per_chip = trk_parameters.code_samples_per_chip; // number of samples per chip + d_code_length_chips = trk_parameters.code_length_chips; if (trk_parameters.system == 'G') { @@ -111,13 +115,12 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_symbols_per_bit = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; d_correlation_length_ms = 1; //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS); + //d_code_length_chips = static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS); // GPS L1 C/A does not have pilot component nor secondary code d_secondary = false; trk_parameters.track_pilot = false; interchange_iq = false; - // set the preamble uint16_t preambles_bits[GPS_CA_PREAMBLE_LENGTH_BITS] = GPS_PREAMBLE; @@ -147,7 +150,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_signal_carrier_freq = GPS_L2_FREQ_HZ; d_code_period = GPS_L2_M_PERIOD; d_code_chip_rate = GPS_L2_M_CODE_RATE_HZ; - //d_code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); + //d_code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); d_symbols_per_bit = GPS_L2_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 20; //d_code_samples_per_chip = 1; @@ -164,9 +167,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_symbols_per_bit = GPS_L5_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 1; //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); + //d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); d_secondary = true; - // interchange_iq = false; if (trk_parameters.track_pilot) { d_secondary_code_length = static_cast(GPS_L5q_NH_CODE_LENGTH); @@ -191,8 +193,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0; - //d_code_samples_per_chip = 0; + //d_code_length_chips = 0U; + //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } } @@ -204,7 +206,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_signal_carrier_freq = Galileo_E1_FREQ_HZ; d_code_period = Galileo_E1_CODE_PERIOD; d_code_chip_rate = Galileo_E1_CODE_CHIP_RATE_HZ; - //d_code_length_chips = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); + //d_code_length_chips = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); d_symbols_per_bit = 1; d_correlation_length_ms = 4; //d_code_samples_per_chip = 2; // CBOC disabled: 2 samples per chip. CBOC enabled: 12 samples per chip @@ -231,19 +233,19 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_symbols_per_bit = 20; d_correlation_length_ms = 1; //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); - d_secondary = true; - //interchange_iq = false; + //d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); + if (trk_parameters.track_pilot) { + d_secondary = true; d_secondary_code_length = static_cast(Galileo_E5a_Q_SECONDARY_CODE_LENGTH); signal_pretty_name = signal_pretty_name + "Q"; interchange_iq = true; } else { - d_secondary_code_length = static_cast(Galileo_E5a_I_SECONDARY_CODE_LENGTH); - d_secondary_code_string = const_cast(&Galileo_E5a_I_SECONDARY_CODE); + //Do not acquire secondary code in data component. It is done in telemetry decoder + d_secondary = false; signal_pretty_name = signal_pretty_name + "I"; interchange_iq = false; } @@ -257,8 +259,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0; - //d_code_samples_per_chip = 0; + //d_code_length_chips = 0U; + //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } } @@ -271,8 +273,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0; - //d_code_samples_per_chip = 0; + //d_code_length_chips = 0U; + //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } T_chip_seconds = 0.0; @@ -281,11 +283,15 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & K_blk_samples = 0.0; // Initialize tracking ========================================== + d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); + d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); d_code_loop_filter = Tracking_2nd_DLL_filter(static_cast(d_code_period)); d_carrier_loop_filter = Tracking_2nd_PLL_filter(static_cast(d_code_period)); - d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); - d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); + // Initialization of local code replica + // Get space for a vector with the sinboc(1,1) replica sampled 2x/chip + //d_tracking_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); + // correlator outputs (scalar) if (d_veml) { // Very-Early, Early, Prompt, Late, Very-Late @@ -299,9 +305,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_local_code_shift_chips = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); - //std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); - - d_code_samples_per_chip = trk_parameters.code_samples_per_chip; // number of samples per chip // map memory pointers of correlator outputs if (d_veml) @@ -311,11 +314,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_Prompt = &d_correlator_outs[2]; d_Late = &d_correlator_outs[3]; d_Very_Late = &d_correlator_outs[4]; - // printf("aaaa very early %f\n",-trk_parameters.very_early_late_space_chips); - // printf("aaaa early %f\n",-trk_parameters.early_late_space_chips); - // printf("aaaa normal %f\n",0); - // printf("aaaa late %f\n",trk_parameters.early_late_space_chips); - // printf("aaaa very late %f\n",trk_parameters.very_early_late_space_chips); d_local_code_shift_chips[0] = -trk_parameters.very_early_late_space_chips * static_cast(d_code_samples_per_chip); d_local_code_shift_chips[1] = -trk_parameters.early_late_space_chips * static_cast(d_code_samples_per_chip); d_local_code_shift_chips[2] = 0.0; @@ -330,16 +328,14 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_Prompt = &d_correlator_outs[1]; d_Late = &d_correlator_outs[2]; d_Very_Late = nullptr; - // printf("aaaa early %f\n",-trk_parameters.early_late_space_chips); - // printf("aaaa normal %f\n",0); - // printf("aaaa late %f\n",trk_parameters.early_late_space_chips); - d_local_code_shift_chips[0] = -trk_parameters.early_late_space_chips * static_cast(d_code_samples_per_chip); d_local_code_shift_chips[1] = 0.0; d_local_code_shift_chips[2] = trk_parameters.early_late_space_chips * static_cast(d_code_samples_per_chip); d_prompt_data_shift = &d_local_code_shift_chips[1]; } + //multicorrelator_cpu.init(2 * trk_parameters.vector_length, d_n_correlator_taps); + if (trk_parameters.extend_correlation_symbols > 1) { d_enable_extended_integration = true; @@ -354,15 +350,17 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & if (trk_parameters.track_pilot) { // Extra correlator for the data component - //d_Prompt_Data = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); - //d_Prompt_Data[0] = gr_complex(0.0, 0.0); + //correlator_data_cpu.init(2 * trk_parameters.vector_length, 1); + //correlator_data_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); + //d_data_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); } else { - //d_Prompt_Data = nullptr; + //d_data_code = nullptr; } - //--- Initializations ---// + // --- Initializations --- + //multicorrelator_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); // Initial code frequency basis of NCO d_code_freq_chips = d_code_chip_rate; // Residual code phase (in chips) @@ -388,8 +386,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_carrier_lock_threshold = trk_parameters.carrier_lock_th; d_Prompt_Data = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); - //clear_tracking_vars(); - d_acquisition_gnss_synchro = nullptr; d_channel = 0; d_acq_code_phase_samples = 0.0; @@ -399,28 +395,24 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_extend_correlation_symbols_count = 0; d_code_phase_step_chips = 0.0; + d_code_phase_rate_step_chips = 0.0; d_carrier_phase_step_rad = 0.0; + d_carrier_phase_rate_step_rad = 0.0; d_rem_code_phase_chips = 0.0; - d_K_blk_samples = 0.0; - d_code_phase_samples = 0.0; d_last_prompt = gr_complex(0.0, 0.0); d_state = 0; // initial state: standby clear_tracking_vars(); - //printf("hhhhhhhhhhh d_n_correlator_taps = %d\n", d_n_correlator_taps); - - // create multicorrelator class - std::string device_name = trk_parameters.device_name; - uint32_t device_base = trk_parameters.device_base; - int32_t *ca_codes = trk_parameters.ca_codes; - int32_t *data_codes = trk_parameters.data_codes; - //uint32_t code_length = trk_parameters.code_length_chips; - d_code_length_chips = trk_parameters.code_length_chips; - uint32_t multicorr_type = trk_parameters.multicorr_type; - multicorrelator_fpga = std::make_shared(d_n_correlator_taps, device_name, device_base, ca_codes, data_codes, d_code_length_chips, trk_parameters.track_pilot, multicorr_type, d_code_samples_per_chip); - multicorrelator_fpga->set_output_vectors(d_correlator_outs, d_Prompt_Data); - - d_pull_in = 0; + if (trk_parameters.smoother_length > 0) + { + d_carr_ph_history.resize(trk_parameters.smoother_length * 2); + d_code_ph_history.resize(trk_parameters.smoother_length * 2); + } + else + { + d_carr_ph_history.resize(1); + d_code_ph_history.resize(1); + } d_dump = trk_parameters.dump; d_dump_mat = trk_parameters.dump_mat and d_dump; @@ -428,6 +420,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & { d_dump_filename = trk_parameters.dump_filename; std::string dump_path; + // Get path if (d_dump_filename.find_last_of("/") != std::string::npos) { std::string dump_filename_ = d_dump_filename.substr(d_dump_filename.find_last_of("/") + 1); @@ -449,83 +442,65 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & } d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; - // create directory if (!gnss_sdr_create_directory(dump_path)) { std::cerr << "GNSS-SDR cannot create dump files for the tracking block. Wrong permissions?" << std::endl; d_dump = false; - }; + } } + // create multicorrelator class + std::string device_name = trk_parameters.device_name; + uint32_t device_base = trk_parameters.device_base; + int32_t *ca_codes = trk_parameters.ca_codes; + int32_t *data_codes = trk_parameters.data_codes; + uint32_t multicorr_type = trk_parameters.multicorr_type; + multicorrelator_fpga = std::make_shared(d_n_correlator_taps, device_name, device_base, ca_codes, data_codes, d_code_length_chips, trk_parameters.track_pilot, multicorr_type, d_code_samples_per_chip); + multicorrelator_fpga->set_output_vectors(d_correlator_outs, d_Prompt_Data); + + } void dll_pll_veml_tracking_fpga::start_tracking() { + + //gr::thread::scoped_lock l(d_setlock); + // correct the code phase according to the delay between acq and trk d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - //printf("start tracking Acq_delay_samples = %d\n", (unsigned int) d_acq_code_phase_samples); - //printf("start tracking Acq_samplestamp_samples = %d\n", (unsigned int) d_acq_sample_stamp); - //printf("start tracking Acq_doppler_hz = %f\n", d_acq_carrier_doppler_hz); - //printf("PRN = %d\n", (unsigned int) d_acquisition_gnss_synchro->PRN); - double acq_trk_diff_seconds = 0; // when using the FPGA we don't use the global sample counter - // Doppler effect Fd = (C / (C + Vr)) * F - double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; - // new chip and PRN sequence periods based on acq Doppler - d_code_freq_chips = radial_velocity * d_code_chip_rate; - d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; - - double T_chip_mod_seconds = 1.0 / d_code_freq_chips; - double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); - double T_prn_mod_samples = T_prn_mod_seconds * trk_parameters.fs_in; - - //d_current_prn_length_samples = std::round(T_prn_mod_samples); - d_current_prn_length_samples = std::floor(T_prn_mod_samples); - d_next_prn_length_samples = d_current_prn_length_samples; - double T_prn_true_seconds = static_cast(d_code_length_chips) / d_code_chip_rate; - double T_prn_true_samples = T_prn_true_seconds * trk_parameters.fs_in; - double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; - double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; - double corrected_acq_phase_samples = std::fmod(d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * trk_parameters.fs_in, T_prn_true_samples); - if (corrected_acq_phase_samples < 0.0) - { - corrected_acq_phase_samples += T_prn_mod_samples; - } - double delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples; - - d_acq_code_phase_samples = corrected_acq_phase_samples; - - d_carrier_doppler_hz = d_acq_carrier_doppler_hz; d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / trk_parameters.fs_in; - - //printf("d_carrier_doppler_hz = %f\n", d_carrier_doppler_hz); - //printf("d_carrier_phase_step_rad = %f\n", d_carrier_phase_step_rad); - + d_carrier_phase_rate_step_rad = 0.0; + d_carr_ph_history.clear(); + d_code_ph_history.clear(); // DLL/PLL filter initialization d_carrier_loop_filter.initialize(); // initialize the carrier filter d_code_loop_filter.initialize(); // initialize the code filter if (systemName.compare("GPS") == 0 and signal_type.compare("1C") == 0) { - // nothing to compute : the local codes are pre-computed in the adapter class + //gps_l1_ca_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); } else if (systemName.compare("GPS") == 0 and signal_type.compare("2S") == 0) { - // nothing to compute : the local codes are pre-computed in the adapter class + //gps_l2c_m_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); } else if (systemName.compare("GPS") == 0 and signal_type.compare("L5") == 0) { if (trk_parameters.track_pilot) { + //gps_l5q_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); + //gps_l5i_code_gen_float(d_data_code, d_acquisition_gnss_synchro->PRN); d_Prompt_Data[0] = gr_complex(0.0, 0.0); + //correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); } else { - // nothing to compute : the local codes are pre-computed in the adapter class + //gps_l5i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); } } else if (systemName.compare("Galileo") == 0 and signal_type.compare("1B") == 0) @@ -533,34 +508,42 @@ void dll_pll_veml_tracking_fpga::start_tracking() if (trk_parameters.track_pilot) { //char pilot_signal[3] = "1C"; + //galileo_e1_code_gen_sinboc11_float(d_tracking_code, pilot_signal, d_acquisition_gnss_synchro->PRN); + //galileo_e1_code_gen_sinboc11_float(d_data_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); d_Prompt_Data[0] = gr_complex(0.0, 0.0); - // MISSING _: set_local_code_and_taps for the data correlator + //correlator_data_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_data_code, d_prompt_data_shift); } else { - // nothing to compute : the local codes are pre-computed in the adapter class + //galileo_e1_code_gen_sinboc11_float(d_tracking_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); } } else if (systemName.compare("Galileo") == 0 and signal_type.compare("5X") == 0) { + //gr_complex *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * d_code_length_chips, volk_gnsssdr_get_alignment())); + //galileo_e5_a_code_gen_complex_primary(aux_code, d_acquisition_gnss_synchro->PRN, const_cast(signal_type.c_str())); if (trk_parameters.track_pilot) { d_secondary_code_string = const_cast(&Galileo_E5a_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]); - for (uint32_t i = 0; i < d_code_length_chips; i++) - { - // nothing to compute : the local codes are pre-computed in the adapter class - } + //for (uint32_t i = 0; i < d_code_length_chips; i++) + // { + // d_tracking_code[i] = aux_code[i].imag(); + // d_data_code[i] = aux_code[i].real(); //the same because it is generated the full signal (E5aI + E5aQ) + // } d_Prompt_Data[0] = gr_complex(0.0, 0.0); + //correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); } else { - for (uint32_t i = 0; i < d_code_length_chips; i++) - { - // nothing to compute : the local codes are pre-computed in the adapter class - } + //for (uint32_t i = 0; i < d_code_length_chips; i++) + // { + // d_tracking_code[i] = aux_code[i].real(); + // } } + //volk_gnsssdr_free(aux_code); } + //multicorrelator_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_tracking_code, d_local_code_shift_chips); std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); d_carrier_lock_fail_counter = 0; @@ -585,7 +568,6 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_local_code_shift_chips[2] = trk_parameters.early_late_space_chips * static_cast(d_code_samples_per_chip); } - d_code_phase_samples = d_acq_code_phase_samples; d_code_loop_filter.set_DLL_BW(trk_parameters.dll_bw_hz); d_carrier_loop_filter.set_PLL_BW(trk_parameters.pll_bw_hz); d_carrier_loop_filter.set_pdi(static_cast(d_code_period)); @@ -593,25 +575,22 @@ void dll_pll_veml_tracking_fpga::start_tracking() // DEBUG OUTPUT std::cout << "Tracking of " << systemName << " " << signal_pretty_name << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + DLOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; - d_synchonizing = false; + + multicorrelator_fpga->set_local_code_and_taps(d_local_code_shift_chips, d_prompt_data_shift, d_acquisition_gnss_synchro->PRN); + // enable tracking pull-in + d_state = 1; d_cloop = true; d_Prompt_buffer_deque.clear(); d_last_prompt = gr_complex(0.0, 0.0); - LOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz - << ". Code Phase correction [samples] = " << delay_correction_samples - << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; - //multicorrelator_fpga->set_local_code_and_taps(d_code_length_chips, d_local_code_shift_chips, d_acquisition_gnss_synchro->PRN); - multicorrelator_fpga->set_local_code_and_taps(d_local_code_shift_chips, d_prompt_data_shift, d_acquisition_gnss_synchro->PRN); - d_pull_in = 1; - // enable tracking pull-in and d_state at the end to avoid general work from starting pull-in before the start tracking function is finished - d_state = 1; + } dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { + if (signal_type.compare("1C") == 0) { volk_gnsssdr_free(d_gps_l1ca_preambles_symbols); @@ -636,23 +615,28 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { volk_gnsssdr_free(d_local_code_shift_chips); volk_gnsssdr_free(d_correlator_outs); + //volk_gnsssdr_free(d_tracking_code); volk_gnsssdr_free(d_Prompt_Data); - // if (trk_parameters.track_pilot) - // { - // volk_gnsssdr_free(d_Prompt_Data); - // } + if (trk_parameters.track_pilot) + { + //volk_gnsssdr_free(d_data_code); + //correlator_data_cpu.free(); + } delete[] d_Prompt_buffer; + //multicorrelator_cpu.free(); multicorrelator_fpga->free(); } catch (const std::exception &ex) { LOG(WARNING) << "Exception in destructor " << ex.what(); } + } bool dll_pll_veml_tracking_fpga::acquire_secondary() { + // ******* preamble correlation ******** int32_t corr_value = 0; for (uint32_t i = 0; i < d_secondary_code_length; i++) @@ -681,7 +665,6 @@ bool dll_pll_veml_tracking_fpga::acquire_secondary() } } - // if (abs(corr_value) == d_secondary_code_length) if (abs(corr_value) == static_cast(d_secondary_code_length)) { return true; @@ -690,15 +673,13 @@ bool dll_pll_veml_tracking_fpga::acquire_secondary() { return false; } + } bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integration_time_s) { - //printf("kkkkkkkkkkkkk d_cn0_estimation_counter = %d\n", d_cn0_estimation_counter); - //printf("trk_parameters.cn0_samples = %d\n", trk_parameters.cn0_samples); -// printf("trk_parameters.cn0_samples = %d\n", trk_parameters.cn0_samples); -// printf("d_cn0_estimation_counter = %d\n", d_cn0_estimation_counter); + // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### if (d_cn0_estimation_counter < trk_parameters.cn0_samples) @@ -710,30 +691,12 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra } else { - //printf("KKKKKKKKKKK checking count fail ...\n"); d_cn0_estimation_counter = 0; // Code lock indicator d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, trk_parameters.cn0_samples, coh_integration_time_s); - - - // Carrier lock indicator d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, trk_parameters.cn0_samples); // Loss of lock detection - //printf("d_carrier_lock_test = %f\n", d_carrier_lock_test); - //printf("d_carrier_lock_threshold = %f\n", d_carrier_lock_threshold); - //printf("d_CN0_SNV_dB_Hz = %f\n", d_CN0_SNV_dB_Hz); - //printf("trk_parameters.cn0_min = %f\n", trk_parameters.cn0_min); - //printf("d_carrier_lock_fail_counter = %d\n", d_carrier_lock_fail_counter); - //printf("trk_parameters.max_lock_fail = %d\n", trk_parameters.max_lock_fail); - -// printf("d_CN0_SNV_dB_Hz = %f\n", d_CN0_SNV_dB_Hz); -// printf("d_carrier_lock_threshold = %f\n", d_carrier_lock_threshold); -// printf("trk_parameters.cn0_min = %d\n", trk_parameters.cn0_min); -// printf("trk_parameters.cn0_samples = %d\n", trk_parameters.cn0_samples); -// printf("d_carrier_lock_test = %f\n", d_carrier_lock_test); -// printf("d_carrier_lock_threshold = %f\n", d_carrier_lock_threshold); - if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < trk_parameters.cn0_min) { d_carrier_lock_fail_counter++; @@ -756,11 +719,61 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra return true; } } + +} + + +// correlation requires: +// - updated remnant carrier phase in radians (rem_carr_phase_rad) +// - updated remnant code phase in samples (d_rem_code_phase_samples) +// - d_code_freq_chips +// - d_carrier_doppler_hz +//void dll_pll_veml_tracking_fpga::do_correlation_step(const gr_complex *input_samples) +void dll_pll_veml_tracking_fpga::do_correlation_step(void) +{ + +// // ################# CARRIER WIPEOFF AND CORRELATORS ############################## +// // perform carrier wipe-off and compute Early, Prompt and Late correlation +// multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, input_samples); +// multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler( +// d_rem_carr_phase_rad, +// d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, +// static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), +// static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), +// static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), +// trk_parameters.vector_length); +// +// // DATA CORRELATOR (if tracking tracks the pilot signal) +// if (trk_parameters.track_pilot) +// { +// correlator_data_cpu.set_input_output_vectors(d_Prompt_Data, input_samples); +// correlator_data_cpu.Carrier_wipeoff_multicorrelator_resampler( +// d_rem_carr_phase_rad, +// d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, +// static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), +// static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), +// static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), +// trk_parameters.vector_length); +// } +// +// + + multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( + d_rem_carr_phase_rad, + d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, + static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), + d_current_prn_length_samples); + + + } void dll_pll_veml_tracking_fpga::run_dll_pll() { + // ################## PLL ########################################################## // PLL discriminator if (d_cloop) @@ -778,8 +791,7 @@ void dll_pll_veml_tracking_fpga::run_dll_pll() d_carr_error_filt_hz = d_carrier_loop_filter.get_carrier_nco(d_carr_error_hz); // New carrier Doppler frequency estimation d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_carr_error_filt_hz; - // New code Doppler frequency estimation - d_code_freq_chips = (1.0 + (d_carrier_doppler_hz / d_signal_carrier_freq)) * d_code_chip_rate; + // ################## DLL ########################################################## // DLL discriminator @@ -793,13 +805,17 @@ void dll_pll_veml_tracking_fpga::run_dll_pll() } // Code discriminator filter d_code_error_filt_chips = d_code_loop_filter.get_code_nco(d_code_error_chips); // [chips/second] + + // New code Doppler frequency estimation + d_code_freq_chips = (1.0 + (d_carrier_doppler_hz / d_signal_carrier_freq)) * d_code_chip_rate - d_code_error_filt_chips; + } void dll_pll_veml_tracking_fpga::clear_tracking_vars() { + std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); - //if (trk_parameters.track_pilot) *d_Prompt_Data = gr_complex(0.0, 0.0); if (trk_parameters.track_pilot) d_Prompt_Data[0] = gr_complex(0.0, 0.0); d_carr_error_hz = 0.0; d_carr_error_filt_hz = 0.0; @@ -808,47 +824,96 @@ void dll_pll_veml_tracking_fpga::clear_tracking_vars() d_current_symbol = 0; d_Prompt_buffer_deque.clear(); d_last_prompt = gr_complex(0.0, 0.0); + d_carrier_phase_rate_step_rad = 0.0; + d_code_phase_rate_step_chips = 0.0; + d_carr_ph_history.clear(); + d_code_ph_history.clear(); + } void dll_pll_veml_tracking_fpga::update_tracking_vars() { + T_chip_seconds = 1.0 / d_code_freq_chips; T_prn_seconds = T_chip_seconds * static_cast(d_code_length_chips); - double code_error_filt_secs = T_prn_seconds * d_code_error_filt_chips * T_chip_seconds; //[seconds] // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation T_prn_samples = T_prn_seconds * trk_parameters.fs_in; - K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * trk_parameters.fs_in; - //d_next_prn_length_samples = round(K_blk_samples); + K_blk_samples = T_prn_samples + d_rem_code_phase_samples; + //d_current_prn_length_samples = static_cast(round(K_blk_samples)); // round to a discrete number of samples d_next_prn_length_samples = static_cast(std::floor(K_blk_samples)); // round to a discrete number of samples + //d_current_prn_length_samples = static_cast(std::floor(K_blk_samples)); // round to a discrete number of samples //################### PLL COMMANDS ################################################# // carrier phase step (NCO phase increment per sample) [rads/sample] d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / trk_parameters.fs_in; + // carrier phase rate step (NCO phase increment rate per sample) [rads/sample^2] + if (trk_parameters.high_dyn) + { + d_carr_ph_history.push_back(std::pair(d_carrier_phase_step_rad, static_cast(d_current_prn_length_samples))); + if (d_carr_ph_history.full()) + { + double tmp_cp1 = 0.0; + double tmp_cp2 = 0.0; + double tmp_samples = 0.0; + for (unsigned int k = 0; k < trk_parameters.smoother_length; k++) + { + tmp_cp1 += d_carr_ph_history.at(k).first; + tmp_cp2 += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; + tmp_samples += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).second; + } + tmp_cp1 /= static_cast(trk_parameters.smoother_length); + tmp_cp2 /= static_cast(trk_parameters.smoother_length); + d_carrier_phase_rate_step_rad = (tmp_cp2 - tmp_cp1) / tmp_samples; + } + } + //std::cout << d_carrier_phase_rate_step_rad * trk_parameters.fs_in * trk_parameters.fs_in / PI_2 << std::endl; // remnant carrier phase to prevent overflow in the code NCO - d_rem_carr_phase_rad += d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, PI_2); + + // carrier phase accumulator - d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + //double a = d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + //double b = 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples); + //std::cout << fmod(b, PI_2) / fmod(a, PI_2) << std::endl; + d_acc_carrier_phase_rad -= (d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); //################### DLL COMMANDS ################################################# // code phase step (Code resampler phase increment per sample) [chips/sample] d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; + if (trk_parameters.high_dyn) + { + d_code_ph_history.push_back(std::pair(d_code_phase_step_chips, static_cast(d_current_prn_length_samples))); + if (d_code_ph_history.full()) + { + double tmp_cp1 = 0.0; + double tmp_cp2 = 0.0; + double tmp_samples = 0.0; + for (unsigned int k = 0; k < trk_parameters.smoother_length; k++) + { + tmp_cp1 += d_code_ph_history.at(k).first; + tmp_cp2 += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; + tmp_samples += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).second; + } + tmp_cp1 /= static_cast(trk_parameters.smoother_length); + tmp_cp2 /= static_cast(trk_parameters.smoother_length); + d_code_phase_rate_step_chips = (tmp_cp2 - tmp_cp1) / tmp_samples; + } + } // remnant code phase [chips] d_rem_code_phase_samples = K_blk_samples - static_cast(d_current_prn_length_samples); // rounding error < 1 sample d_rem_code_phase_chips = d_code_freq_chips * d_rem_code_phase_samples / trk_parameters.fs_in; - //printf("lll d_code_freq_chips = %f\n", d_code_freq_chips); - //printf("lll d_rem_code_phase_samples = %f\n", d_rem_code_phase_samples); - //printf("lll trk_parameters.fs_in = %f\n", trk_parameters.fs_in); - //printf("lll d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); + } void dll_pll_veml_tracking_fpga::save_correlation_results() { + if (d_secondary) { if (d_secondary_code_string->at(d_current_symbol) == '0') @@ -895,11 +960,13 @@ void dll_pll_veml_tracking_fpga::save_correlation_results() d_cloop = false; else d_cloop = true; + } void dll_pll_veml_tracking_fpga::log_data(bool integrating) { + if (d_dump) { // Dump results to file @@ -983,8 +1050,14 @@ void dll_pll_veml_tracking_fpga::log_data(bool integrating) // carrier and code frequency tmp_float = d_carrier_doppler_hz; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // carrier phase rate [Hz/s] + tmp_float = d_carrier_phase_rate_step_rad * trk_parameters.fs_in * trk_parameters.fs_in / PI_2; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); tmp_float = d_code_freq_chips; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // code phase rate [chips/s^2] + tmp_float = d_code_phase_rate_step_chips * trk_parameters.fs_in * trk_parameters.fs_in; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // PLL commands tmp_float = d_carr_error_hz; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); @@ -1014,15 +1087,17 @@ void dll_pll_veml_tracking_fpga::log_data(bool integrating) LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } + } int32_t dll_pll_veml_tracking_fpga::save_matfile() { + // READ DUMP FILE std::ifstream::pos_type size; int32_t number_of_double_vars = 1; - int32_t number_of_float_vars = 17; + int32_t number_of_float_vars = 19; int32_t epoch_size_bytes = sizeof(uint64_t) + sizeof(double) * number_of_double_vars + sizeof(float) * number_of_float_vars + sizeof(uint32_t); std::ifstream dump_file; @@ -1064,7 +1139,9 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() uint64_t *PRN_start_sample_count = new uint64_t[num_epoch]; float *acc_carrier_phase_rad = new float[num_epoch]; float *carrier_doppler_hz = new float[num_epoch]; + float *carrier_doppler_rate_hz = new float[num_epoch]; float *code_freq_chips = new float[num_epoch]; + float *code_freq_rate_chips = new float[num_epoch]; float *carr_error_hz = new float[num_epoch]; float *carr_error_filt_hz = new float[num_epoch]; float *code_error_chips = new float[num_epoch]; @@ -1091,7 +1168,9 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(uint64_t)); dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_doppler_rate_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_freq_rate_chips[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(float)); dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(float)); @@ -1118,7 +1197,9 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() delete[] PRN_start_sample_count; delete[] acc_carrier_phase_rad; delete[] carrier_doppler_hz; + delete[] carrier_doppler_rate_hz; delete[] code_freq_chips; + delete[] code_freq_rate_chips; delete[] carr_error_hz; delete[] carr_error_filt_hz; delete[] code_error_chips; @@ -1181,10 +1262,18 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); + matvar = Mat_VarCreate("carrier_doppler_rate_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_doppler_rate_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + matvar = Mat_VarCreate("code_freq_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_chips, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); + matvar = Mat_VarCreate("code_freq_rate_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_rate_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + matvar = Mat_VarCreate("carr_error_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_hz, 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); @@ -1232,7 +1321,9 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() delete[] PRN_start_sample_count; delete[] acc_carrier_phase_rad; delete[] carrier_doppler_hz; + delete[] carrier_doppler_rate_hz; delete[] code_freq_chips; + delete[] code_freq_rate_chips; delete[] carr_error_hz; delete[] carr_error_filt_hz; delete[] code_error_chips; @@ -1243,11 +1334,14 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() delete[] aux2; delete[] PRN; return 0; + } void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) { + + //gr::thread::scoped_lock l(d_setlock); d_channel = channel; multicorrelator_fpga->set_channel(d_channel); LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -1264,6 +1358,8 @@ void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) { try { + //trk_parameters.dump_filename.append(boost::lexical_cast(d_channel)); + //trk_parameters.dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(dump_filename_.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << dump_filename_.c_str(); @@ -1274,124 +1370,136 @@ void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) } } } + } void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) { + //gr::thread::scoped_lock l(d_setlock); d_acquisition_gnss_synchro = p_gnss_synchro; } + void dll_pll_veml_tracking_fpga::stop_tracking() { - gr::thread::scoped_lock l(d_setlock); + //gr::thread::scoped_lock l(d_setlock); d_state = 0; } -int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), +int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - // Block input data and block output stream pointers - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); - // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder + //gr::thread::scoped_lock l(d_setlock); + //const gr_complex *in = reinterpret_cast(input_items[0]); + Gnss_Synchro **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); d_current_prn_length_samples = d_next_prn_length_samples; - current_synchro_data = *d_acquisition_gnss_synchro; + switch (d_state) { case 0: // Standby - Consume samples at full throttle, do nothing { - for (int32_t n = 0; n < d_n_correlator_taps; n++) - { - d_correlator_outs[n] = gr_complex(0, 0); - } - - current_synchro_data.Tracking_sample_counter = 0ULL; // in order to reduce computational workload do not read the sample counter until we start tracking d_sample_counter + d_current_prn_length_samples; - current_synchro_data.System = {'G'}; - current_synchro_data.correlation_length_ms = 1; + //d_sample_counter += static_cast(ninput_items[0]); + //consume_each(ninput_items[0]); + return 0; break; } - case 1: // Standby - Consume samples at full throttle, do nothing + case 1: // Pull-in { - //printf("d_state = 1\n"); - d_pull_in = 0; + int64_t acq_trk_diff_samples; + double acq_trk_diff_seconds; + double delta_trk_to_acq_prn_start_samples; + + //printf("state 1\n"); multicorrelator_fpga->lock_channel(); uint64_t counter_value = multicorrelator_fpga->read_sample_counter(); - //printf("333333 counter_value = %llu\n", counter_value); - //printf("333333 current_synchro_data.Acq_samplestamp_samples = %llu\n", current_synchro_data.Acq_samplestamp_samples); - //printf("333333 current_synchro_data.Acq_delay_samples = %f\n", current_synchro_data.Acq_delay_samples); - //printf("333333 d_correlation_length_samples = %d\n", d_correlation_length_samples); - uint64_t absolute_samples_offset; - - if (counter_value > (current_synchro_data.Acq_samplestamp_samples + current_synchro_data.Acq_delay_samples)) + if (counter_value > (d_acq_sample_stamp + d_acq_code_phase_samples)) { - // normal operation - //printf("normal operation\n"); - uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples - current_synchro_data.Acq_delay_samples) / d_correlation_length_samples); - //uint32_t num_frames = ceil((counter_value - current_synchro_data.Acq_samplestamp_samples*2 - current_synchro_data.Acq_delay_samples*2 + 40) / d_correlation_length_samples); - //printf("333333 num_frames = %d\n", num_frames); - absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples + num_frames * d_correlation_length_samples); - //absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples*2 + current_synchro_data.Acq_samplestamp_samples*2 -40 + num_frames * d_correlation_length_samples); - //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); + // Signal alignment (skip samples until the incoming signal is aligned with local replica) + //int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); + acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; + delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; + + //uint32_t num_frames = ceil((counter_value - d_acq_sample_stamp - d_acq_code_phase_samples) / d_correlation_length_samples); + uint32_t num_frames = ceil((delta_trk_to_acq_prn_start_samples) / d_correlation_length_samples); + //absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); + absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); } else { - //printf("test operation\n"); - // during the unit tests the counter value may be reset after the acquisition process. We have to take this into account - absolute_samples_offset = static_cast(current_synchro_data.Acq_delay_samples + current_synchro_data.Acq_samplestamp_samples); - //printf("333333 absolute_samples_offset = %llu\n", absolute_samples_offset); - } + // test mode + acq_trk_diff_samples = - static_cast(counter_value) + static_cast(d_acq_sample_stamp); + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; + delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) + d_acq_code_phase_samples; + + //absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp); + absolute_samples_offset = static_cast(delta_trk_to_acq_prn_start_samples); + } multicorrelator_fpga->set_initial_sample(absolute_samples_offset); d_absolute_samples_offset = absolute_samples_offset; d_sample_counter = absolute_samples_offset; current_synchro_data.Tracking_sample_counter = absolute_samples_offset; d_sample_counter_next = d_sample_counter; - d_state = 2; - return 0; - break; - } - case 2: + +// // Signal alignment (skip samples until the incoming signal is aligned with local replica) +// //int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); +// int64_t acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); +// double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; +// double delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; + + // Doppler effect Fd = (C / (C + Vr)) * F + double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; + // new chip and PRN sequence periods based on acq Doppler + d_code_freq_chips = radial_velocity * d_code_chip_rate; + d_code_phase_step_chips = d_code_freq_chips / trk_parameters.fs_in; + d_code_phase_rate_step_chips = 0.0; + double T_chip_mod_seconds = 1.0 / d_code_freq_chips; + double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); + double T_prn_mod_samples = T_prn_mod_seconds * trk_parameters.fs_in; + + //d_acq_code_phase_samples = T_prn_mod_samples - std::fmod(delta_trk_to_acq_prn_start_samples, T_prn_mod_samples); + d_acq_code_phase_samples = absolute_samples_offset; + + d_current_prn_length_samples = round(T_prn_mod_samples); + + d_next_prn_length_samples = d_current_prn_length_samples; + int32_t samples_offset = round(d_acq_code_phase_samples); + d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(samples_offset); + d_state = 2; + + DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples << " ( " << acq_trk_diff_seconds << " s)"; + DLOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz + << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; + + //consume_each(samples_offset); // shift input to perform alignment with local replica + return 0; + } + case 2: // Wide tracking and symbol synchronization { - //printf("d_state = 2\n"); - //printf("trk state 2 counter value = %" PRIu64 "\n", multicorrelator_fpga->read_sample_counter()); + //printf("state 2\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); - // ################# CARRIER WIPEOFF AND CORRELATORS ############################## - // perform carrier wipe-off and compute Early, Prompt and Late correlation - multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips * static_cast(d_code_samples_per_chip), d_code_phase_step_chips * static_cast(d_code_samples_per_chip), - d_current_prn_length_samples); - + do_correlation_step(); // Save single correlation step variables if (d_veml) { d_VE_accu = *d_Very_Early; d_VL_accu = *d_Very_Late; - //printf("very early real = %f\n", d_VE_accu.real()); - //printf("very early imag = %f\n", d_VE_accu.imag()); - //printf("very late real = %f\n", d_VL_accu.real()); - //printf("very late imag = %f\n", d_VL_accu.imag()); } d_E_accu = *d_Early; d_P_accu = *d_Prompt; d_L_accu = *d_Late; - //printf("early real = %f\n", d_E_accu.real()); - //printf("early imag = %f\n", d_E_accu.imag()); - //printf("prompt real = %f\n", d_P_accu.real()); - //printf("prompt imag = %f\n", d_P_accu.imag()); - //printf("late real = %f\n", d_L_accu.real()); - //printf("late imag = %f\n", d_L_accu.imag()); - - //printf("d_code_period = %f\n", d_code_period); + // Check lock status if (!cn0_and_tracking_lock_status(d_code_period)) { clear_tracking_vars(); @@ -1412,7 +1520,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un d_Prompt_buffer_deque.push_back(*d_Prompt); if (d_Prompt_buffer_deque.size() == d_secondary_code_length) { - //printf("Secondary code lock\n"); next_state = acquire_secondary(); if (next_state) { @@ -1425,37 +1532,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } else if (d_symbols_per_bit > 1) //Signal does not have secondary code. Search a bit transition by sign change { - // if (d_synchonizing) - // { - // if (d_Prompt->real() * d_last_prompt.real() > 0.0) - // { - // d_current_symbol++; - // } - // else if (d_current_symbol > d_symbols_per_bit) - // { - // d_synchonizing = false; - // d_current_symbol = 1; - // } - // else - // { - // d_current_symbol = 1; - // d_last_prompt = *d_Prompt; - // } - // } - // else if (d_last_prompt.real() != 0.0) - // { - // d_current_symbol++; - // if (d_current_symbol == d_symbols_per_bit) next_state = true; - // } - // else - // { - // d_last_prompt = *d_Prompt; - // d_synchonizing = true; - // d_current_symbol = 1; - // } - // } - //=========================================================================================================== - //float current_tracking_time_s = static_cast(d_sample_counter - d_acq_sample_stamp) / trk_parameters.fs_in; float current_tracking_time_s = static_cast(d_sample_counter - d_absolute_samples_offset) / trk_parameters.fs_in; if (current_tracking_time_s > 10) { @@ -1542,7 +1618,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un d_last_prompt = gr_complex(0.0, 0.0); d_Prompt_buffer_deque.clear(); d_current_symbol = 0; - d_synchonizing = false; if (d_enable_extended_integration) { @@ -1576,29 +1651,22 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } else { - //printf(" do not enable extended integration\n"); d_state = 4; } } } - break; } - - case 3: + case 3: // coherent integration (correlation time extension) { - //printf("d_state = 3\n"); - //printf("trk state 3 counter value = %" PRIu64 "\n", multicorrelator_fpga->read_sample_counter()); + //printf("state 3\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); // Fill the acquisition data current_synchro_data = *d_acquisition_gnss_synchro; // perform a correlation step - multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips * static_cast(d_code_samples_per_chip), d_code_phase_step_chips * static_cast(d_code_samples_per_chip), - d_current_prn_length_samples); + do_correlation_step(); update_tracking_vars(); save_correlation_results(); @@ -1646,22 +1714,16 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un log_data(true); break; } - case 4: // narrow tracking { - //printf("trk state 4 counter value = %" PRIu64 "\n", multicorrelator_fpga->read_sample_counter()); + //printf("state 4\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); + // Fill the acquisition data + current_synchro_data = *d_acquisition_gnss_synchro; // perform a correlation step - //do_correlation_step(in); - multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, d_carrier_phase_step_rad, - d_rem_code_phase_chips * static_cast(d_code_samples_per_chip), d_code_phase_step_chips * static_cast(d_code_samples_per_chip), - d_current_prn_length_samples); - - //printf("d_cloop = %d\n", d_cloop); - //printf("trk_parameters.extend_correlation_symbols = %d\n", trk_parameters.extend_correlation_symbols); + do_correlation_step(); save_correlation_results(); // check lock status @@ -1676,8 +1738,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un update_tracking_vars(); // ########### Output the tracking results to Telemetry block ########## - //printf("state 4 interchange_iq = %d\n", interchange_iq); - //printf("state 4 trk_parameters.track_pilot = %d\n", trk_parameters.track_pilot); if (interchange_iq) { if (trk_parameters.track_pilot) @@ -1706,7 +1766,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); } } - current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; @@ -1728,11 +1787,16 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } } } + //consume_each(d_current_prn_length_samples); + //d_sample_counter += static_cast(d_current_prn_length_samples); if (current_synchro_data.Flag_valid_symbol_output) { - //printf("tracking sending synchro data "); current_synchro_data.fs = static_cast(trk_parameters.fs_in); - current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); + // two choices for the reporting of the sample counter: + // either the sample counter position that should be (d_sample_counter_next) + //or the sample counter corresponding to the number of samples that the FPGA actually consumed. + //current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); + current_synchro_data.Tracking_sample_counter = d_sample_counter_next; *out[0] = current_synchro_data; return 1; } diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index 91e34d400..8070a7eaa 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -1,19 +1,13 @@ /*! - * \file gps_l1_ca_dll_pll_tracking_fpga.h - * \brief Interface of a code DLL + carrier PLL tracking block + * \file dll_pll_veml_tracking.h + * \brief Implementation of a code DLL + carrier PLL tracking block. * \author Marc Majoral, 2018. marc.majoral(at)cttc.es - * Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * Javier Arribas, 2011. jarribas(at)cttc.es - * Cillian O'Driscoll, 2017. cillian.odriscoll(at)gmail.com - * - * Code DLL + carrier PLL according to the algorithms described in: - * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, - * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, - * Birkhauser, 2007 + * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -31,7 +25,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . + * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- */ @@ -49,19 +43,18 @@ #include #include #include +#include #include -#include "fpga_multicorrelator.h" class dll_pll_veml_tracking_fpga; -typedef boost::shared_ptr - dll_pll_veml_tracking_fpga_sptr; +typedef boost::shared_ptr dll_pll_veml_tracking_fpga_sptr; dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); /*! - * \brief This class implements a DLL + PLL tracking loop block + * \brief This class implements a code DLL + carrier PLL tracking block. */ class dll_pll_veml_tracking_fpga : public gr::block { @@ -72,6 +65,7 @@ public: void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro); void start_tracking(); void stop_tracking(); + int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); @@ -85,6 +79,8 @@ private: bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool acquire_secondary(); + //void do_correlation_step(const gr_complex *input_samples); + void do_correlation_step(void); void run_dll_pll(); void update_tracking_vars(); void clear_tracking_vars(); @@ -94,7 +90,6 @@ private: // tracking configuration vars Dll_Pll_Conf_Fpga trk_parameters; - //dllpllconf_fpga_t trk_parameters; bool d_veml; bool d_cloop; uint32_t d_channel; @@ -120,14 +115,20 @@ private: //tracking state machine int32_t d_state; - bool d_synchonizing; //Integration period in samples int32_t d_correlation_length_ms; int32_t d_n_correlator_taps; + + float *d_tracking_code; + float *d_data_code; float *d_local_code_shift_chips; float *d_prompt_data_shift; std::shared_ptr multicorrelator_fpga; - + /* TODO: currently the multicorrelator does not support adding extra correlator + with different local code, thus we need extra multicorrelator instance. + Implement this functionality inside multicorrelator class + as an enhancement to increase the performance + */ gr_complex *d_correlator_outs; gr_complex *d_Very_Early; gr_complex *d_Early; @@ -149,10 +150,14 @@ private: gr_complex *d_Prompt_Data; double d_code_phase_step_chips; + double d_code_phase_rate_step_chips; + boost::circular_buffer> d_code_ph_history; double d_carrier_phase_step_rad; + double d_carrier_phase_rate_step_rad; + boost::circular_buffer> d_carr_ph_history; // remaining code phase and carrier phase between tracking loops double d_rem_code_phase_samples; - double d_rem_carr_phase_rad; + float d_rem_carr_phase_rad; // PLL and DLL filter library Tracking_2nd_DLL_filter d_code_loop_filter; @@ -167,12 +172,10 @@ private: double d_carr_error_filt_hz; double d_code_error_chips; double d_code_error_filt_chips; - double d_K_blk_samples; double d_code_freq_chips; double d_carrier_doppler_hz; double d_acc_carrier_phase_rad; double d_rem_code_phase_chips; - double d_code_phase_samples; double T_chip_seconds; double T_prn_seconds; double T_prn_samples; @@ -182,11 +185,13 @@ private: // processing samples counters uint64_t d_sample_counter; uint64_t d_acq_sample_stamp; + uint64_t d_absolute_samples_offset; // CN0 estimation and lock detector int32_t d_cn0_estimation_counter; int32_t d_carrier_lock_fail_counter; + std::deque d_carrier_lock_detector_queue; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; @@ -203,7 +208,6 @@ private: int32_t d_correlation_length_samples; int32_t d_next_prn_length_samples; uint64_t d_sample_counter_next; - uint32_t d_pull_in = 0U; }; #endif //GNSS_SDR_DLL_PLL_VEML_TRACKING_FPGA_H diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc index 87b66a911..855a336b5 100644 --- a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc @@ -36,12 +36,14 @@ Dll_Pll_Conf_Fpga::Dll_Pll_Conf_Fpga() { /* DLL/PLL tracking configuration */ + high_dyn = false; + smoother_length = 10; fs_in = 0.0; vector_length = 0U; dump = false; dump_mat = true; dump_filename = std::string("./dll_pll_dump.dat"); - pll_bw_hz = 40.0; + pll_bw_hz = 35.0; dll_bw_hz = 2.0; pll_bw_narrow_hz = 5.0; dll_bw_narrow_hz = 0.75; diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.h b/src/algorithms/tracking/libs/dll_pll_conf_fpga.h index 8fd81fb36..95878f592 100644 --- a/src/algorithms/tracking/libs/dll_pll_conf_fpga.h +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.h @@ -54,9 +54,11 @@ public: float early_late_space_narrow_chips; float very_early_late_space_narrow_chips; int32_t extend_correlation_symbols; + bool high_dyn; int32_t cn0_samples; int32_t cn0_min; int32_t max_lock_fail; + uint32_t smoother_length; double carrier_lock_th; bool track_pilot; char system; diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 1f0cccb49..20f6a127a 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -131,7 +131,9 @@ void fpga_multicorrelator_8sc::update_local_code(float rem_code_phase_chips) void fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( float rem_carrier_phase_in_rad, float phase_step_rad, + float carrier_phase_rate_step_rad, float rem_code_phase_chips, float code_phase_step_chips, + float code_phase_rate_step_chips, int32_t signal_length_samples) { update_local_code(rem_code_phase_chips); diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index f7fffe1aa..ad0d44233 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -66,7 +66,9 @@ public: //bool Carrier_wipeoff_multicorrelator_resampler( void Carrier_wipeoff_multicorrelator_resampler( float rem_carrier_phase_in_rad, float phase_step_rad, + float carrier_phase_rate_step_rad, float rem_code_phase_chips, float code_phase_step_chips, + float code_phase_rate_step_chips, int32_t signal_length_samples); bool free(); void set_channel(uint32_t channel); From ed5dc6a4429eab7a38a012af60aa7a0a14ba46e3 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 30 Jan 2019 14:45:12 +0100 Subject: [PATCH 26/53] solved bug resulting from the last merging process --- src/core/receiver/gnss_flowgraph.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 0662f8194..a52f7fa1b 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -289,7 +289,9 @@ void GNSSFlowgraph::connect() std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); } - ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); + int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); + ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); + //ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse } From ec80df40dc073db23a86f9226363e04584791b67 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Thu, 31 Jan 2019 15:36:11 +0100 Subject: [PATCH 27/53] minor corrections --- .../gps_l1_ca_pcps_acquisition_fpga.cc | 2 +- .../hybrid_observables_test_fpga.cc | 1095 ++++++++--------- 2 files changed, 548 insertions(+), 549 deletions(-) diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 1b4bd050d..68c00b082 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -82,7 +82,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 4); + unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms; auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 1ced23735..ea36193c2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -543,22 +543,24 @@ bool HybridObservablesTestFpga::acquire_signal() tmp_gnss_synchro.Channel_ID = 0; config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); - config->set_property("Acquisition.blocking_on_standby", "true"); - config->set_property("Acquisition.blocking", "true"); - config->set_property("Acquisition.dump", "false"); - config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); - config->set_property("Acquisition.use_CFAR_algorithm", "false"); + //config->set_property("Acquisition.blocking_on_standby", "true"); -- not used in the HW + //config->set_property("Acquisition.blocking", "true"); -- not used in the HW + //config->set_property("Acquisition.dump", "false"); -- not used in the HW + //config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); -- not used in the HW + //config->set_property("Acquisition.use_CFAR_algorithm", "false"); -- not used in the HW at this moment - config->set_property("Acquisition.item_type", "cshort"); - config->set_property("Acquisition.if", "0"); + //config->set_property("Acquisition.item_type", "cshort"); + //config->set_property("Acquisition.if", "0"); //config->set_property("Acquisition.sampled_ms", "4"); //config->set_property("Acquisition.select_queue_Fpga", "0"); - config->set_property("Acquisition.devicename", "/dev/uio0"); + //config->set_property("Acquisition.devicename", "/dev/uio0"); - if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - config->set_property("Acquisition.acquire_pilot", "false"); - } + config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + + //if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + //{ + // config->set_property("Acquisition.acquire_pilot", "false"); -- ALREADY THE DEFAULT VALUE + //} //std::shared_ptr acquisition; @@ -572,15 +574,15 @@ bool HybridObservablesTestFpga::acquire_signal() //printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - config->set_property("Acquisition.select_queue_Fpga", "0"); - config->set_property("Acquisition.sampled_ms", "1"); + //config->set_property("Acquisition.select_queue_Fpga", "0"); + //config->set_property("Acquisition.sampled_ms", "1"); //printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L1 CA"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); ////acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); @@ -592,14 +594,14 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - config->set_property("Acquisition.select_queue_Fpga", "0"); - config->set_property("Acquisition.sampled_ms", "4"); + //config->set_property("Acquisition.select_queue_Fpga", "0"); + //config->set_property("Acquisition.sampled_ms", "4"); tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E1B"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); @@ -637,14 +639,14 @@ bool HybridObservablesTestFpga::acquire_signal() else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - config->set_property("Acquisition.select_queue_Fpga", "1"); - config->set_property("Acquisition.sampled_ms", "1"); + //config->set_property("Acquisition.select_queue_Fpga", "1"); + //config->set_property("Acquisition.sampled_ms", "1"); tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E5a"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); @@ -655,14 +657,14 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - config->set_property("Acquisition.select_queue_Fpga", "1"); - config->set_property("Acquisition.sampled_ms", "1"); + //config->set_property("Acquisition.select_queue_Fpga", "1"); + //config->set_property("Acquisition.sampled_ms", "1"); tmp_gnss_synchro.System = 'G'; std::string signal = "L5"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L5I"; - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); @@ -752,421 +754,105 @@ bool HybridObservablesTestFpga::acquire_signal() setup_fpga_switch_obs_test(); - unsigned int code_length; - unsigned int nsamples_to_transfer; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E5a_CODE_CHIP_RATE_HZ / Galileo_E5a_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / GPS_L5i_CODE_LENGTH_CHIPS))); - } + unsigned int code_length; + unsigned int nsamples_to_transfer; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E5a_CODE_CHIP_RATE_HZ / Galileo_E5a_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / GPS_L5i_CODE_LENGTH_CHIPS))); + } + + float nbits = ceilf(log2f((float)code_length*2)); + unsigned int fft_size = pow(2, nbits); + unsigned int nsamples_total = fft_size; + //printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); + + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + + if (doppler_loop_control_in_sw_obs_test == 1) + { + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + //printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); + acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->set_single_doppler_flag(1); + } + int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - //printf("DDDDDDD3 code_length = %d\n", code_length); - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); - unsigned int nsamples_total = fft_size; - //printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); + float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); - int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + uint32_t index_debug[MAX_PRN_IDX]; + uint32_t samplestamp_debug[MAX_PRN_IDX]; - if (doppler_loop_control_in_sw_obs_test == 1) + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 6; PRN < 8; PRN++) { + //printf("PRN %d\n", PRN); + uint32_t max_index = 0; + float max_magnitude = 0.0; + float second_magnitude = 0.0; + uint64_t initial_sample = 0; + //float power_sum = 0; + uint32_t doppler_index = 0; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + uint32_t max_index_iteration; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; + float max_magnitude_iteration; + float second_magnitude_iteration; + uint64_t initial_sample_iteration; + //float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; + + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) { - //printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_single_doppler_flag(1); - } - - - int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - - float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - - uint32_t index_debug[MAX_PRN_IDX]; - uint32_t samplestamp_debug[MAX_PRN_IDX]; - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 6; PRN < 8; PRN++) - { - //printf("PRN %d\n", PRN); - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - - //printf("main loop doppler_shift = %d\n", doppler_shift); - tmp_gnss_synchro.PRN = PRN; - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } - - args.file = file; - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - send_samples_start_obs_test = 0; - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - else - { - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); - - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - pthread_mutex_lock(&mutex); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start_obs_test = 0; - - //printf("finished sending samples init filter status and back to main thread\n"); - //----------------------------------------------------------------------------------- - - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - else - { - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } - } - - - - // create DMA child process - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); - } - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("iiiiiiiiiiiiii\n"); - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - - result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = second_magnitude_iteration; - result_table[PRN][doppler_num][2] = total_fft_scaling_factor; - doppler_num = doppler_num + 1; - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("jjjjjjjjjjjjjjj\n"); - if (max_magnitude_iteration > max_magnitude) - { - int interpolation_factor = 4; - index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - samplestamp_debug[PRN - 1] = initial_sample_iteration; - initial_sample = 0; //initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - else - { - - if (max_magnitude_iteration > max_magnitude) - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - top_block->stop(); - } - - - // power_sum = (power_sum - max_magnitude) / (fft_size - 1); - // float test_statistics = (max_magnitude / power_sum); - // float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - // if (test_statistics > threshold) - float test_statistics = max_magnitude/second_magnitude; - float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - if (test_statistics > threshold) - { - std::cout << " " << PRN << " "; - - //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) - - tmp_gnss_synchro.Acq_doppler_hz = doppler_shift_selected; - tmp_gnss_synchro.Acq_delay_samples = max_index; - tmp_gnss_synchro.Acq_samplestamp_samples = initial_sample; // delay due to the downsampling filter in the acquisition - - - gnss_synchro_vec.push_back(tmp_gnss_synchro); - } - else - { - std::cout << " . "; - } - - std::cout.flush(); - - } - - uint32_t max_index = 0; - uint32_t total_fft_scaling_factor; - //uint32_t fw_fft_scaling_factor; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float second_magnitude = 0; - float peak_to_power = 0; - float test_statistics; - uint32_t doppler_index = 0; - - if (test_observables_show_results_table == 1) - { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - max_magnitude = result_table[PRN][doppler_num][0]; - //power_sum = result_table[PRN][doppler_num][1]; - second_magnitude = result_table[PRN][doppler_num][1]; - total_fft_scaling_factor = result_table[PRN][doppler_num][2]; - doppler_num = doppler_num + 1; - - std::cout << "==================== Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << std::endl; - std::cout << "Second magnitude = " << second_magnitude << std::endl; - std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; - test_statistics = (max_magnitude / second_magnitude); - std::cout << " test_statistics = " << test_statistics << std::endl; - - } - int dummy_val; - std::cout << "Enter a value to continue"; - std::cin >> dummy_val; - } - } - } - else // DOPPLER CONTROL IN HW - { - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 0; PRN < 17; PRN++) - { - - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; + //printf("main loop doppler_shift = %d\n", doppler_shift); tmp_gnss_synchro.PRN = PRN; + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex_obs_test); + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsL1Ca_Fpga->set_doppler_step(acq_doppler_step); + acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL1Ca_Fpga->set_doppler_step(0); acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); acquisition_GpsL1Ca_Fpga->init(); @@ -1177,8 +863,8 @@ bool HybridObservablesTestFpga::acquire_signal() { //printf("starting configuring acquisition\n"); acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsE1_Fpga->set_doppler_step(acq_doppler_step); + acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE1_Fpga->set_doppler_step(0); acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); acquisition_GpsE1_Fpga->init(); @@ -1189,8 +875,8 @@ bool HybridObservablesTestFpga::acquire_signal() else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsE5a_Fpga->set_doppler_step(acq_doppler_step); + acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsE5a_Fpga->set_doppler_step(0); acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); acquisition_GpsE5a_Fpga->init(); @@ -1200,8 +886,8 @@ bool HybridObservablesTestFpga::acquire_signal() else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsL5_Fpga->set_doppler_step(acq_doppler_step); + acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); + acquisition_GpsL5_Fpga->set_doppler_step(0); acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); acquisition_GpsL5_Fpga->init(); @@ -1211,20 +897,21 @@ bool HybridObservablesTestFpga::acquire_signal() args.file = file; - - send_samples_start_obs_test = 0; - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) { //printf("gggggggg \n"); //---------------------------------------------------------------------------------- // send the previous samples to set the downsampling filter in a good condition - //send_samples_start = 0; - - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - + send_samples_start_obs_test = 0; + if (test_observables_skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } + else + { + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + } args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) @@ -1236,30 +923,40 @@ bool HybridObservablesTestFpga::acquire_signal() pthread_mutex_unlock(&mutex); pthread_join(thread_DMA, NULL); send_samples_start_obs_test = 0; - //printf("finished sending samples init filter status\n"); + + //printf("finished sending samples init filter status and back to main thread\n"); //----------------------------------------------------------------------------------- // debug args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - + if (test_observables_skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + } + else + { + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + } } else { // debug args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - args.skip_used_samples = 0; + if (test_observables_skip_samples_already_used == 1) + { + args.skip_used_samples = (PRN -1)*fft_size; + } + else + { + args.skip_used_samples = 0; + } } - - // create DMA child process - //printf("||||||||1 args freq_band = %d\n", args.freq_band); - //printf("sending samples main DMA %d\n", args.nsamples_tx); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); @@ -1268,32 +965,27 @@ bool HybridObservablesTestFpga::acquire_signal() msg_rx->rx_message = 0; top_block->start(); - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&mutex_obs_test); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL1Ca_Fpga->reset(); // set active + acquisition_GpsL1Ca_Fpga->reset(); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - //printf("hhhhhhhhhhhh\n"); - acquisition_GpsE1_Fpga->reset(); // set active + acquisition_GpsE1_Fpga->reset(); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsE5a_Fpga->reset(); // set active + acquisition_GpsE5a_Fpga->reset(); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL5_Fpga->reset(); // set active + acquisition_GpsL5_Fpga->reset(); } - // pthread_mutex_lock(&mutex); // it doesn't work if it is done here - // send_samples_start = 1; - // pthread_mutex_unlock(&mutex); - if (start_msg == true) { std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; @@ -1305,109 +997,416 @@ bool HybridObservablesTestFpga::acquire_signal() // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); - pthread_mutex_lock(&mutex); + pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(&mutex_obs_test); - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - if (msg_rx->rx_message == 1) - { - std::cout << " " << PRN << " "; + while (msg_rx->rx_message == 0) + { + usleep(100000); + } - tmp_gnss_synchro.Acq_doppler_hz = tmp_gnss_synchro.Acq_doppler_hz; - tmp_gnss_synchro.Acq_delay_samples = tmp_gnss_synchro.Acq_delay_samples; - tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation - tmp_gnss_synchro.Acq_samplestamp_samples = tmp_gnss_synchro.Acq_samplestamp_samples; // delay due to the downsampling filter in the acquisition + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("iiiiiiiiiiiiii\n"); + acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); + //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); + } + + result_table[PRN][doppler_num][0] = max_magnitude_iteration; + result_table[PRN][doppler_num][1] = second_magnitude_iteration; + result_table[PRN][doppler_num][2] = total_fft_scaling_factor; + doppler_num = doppler_num + 1; + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("jjjjjjjjjjjjjjj\n"); + if (max_magnitude_iteration > max_magnitude) + { + int interpolation_factor = 4; + index_debug[PRN - 1] = max_index_iteration; + max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + samplestamp_debug[PRN - 1] = initial_sample_iteration; + initial_sample = 0; //initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + } + else + { + + if (max_magnitude_iteration > max_magnitude) + { + max_index = max_index_iteration; + max_magnitude = max_magnitude_iteration; + second_magnitude = second_magnitude_iteration; + initial_sample = initial_sample_iteration; + doppler_index = doppler_index_iteration; + doppler_shift_selected = doppler_shift; + } + } + top_block->stop(); + } - gnss_synchro_vec.push_back(tmp_gnss_synchro); +// power_sum = (power_sum - max_magnitude) / (fft_size - 1); +// float test_statistics = (max_magnitude / power_sum); +// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); +// if (test_statistics > threshold) + float test_statistics = max_magnitude/second_magnitude; + float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); + if (test_statistics > threshold) + { + std::cout << " " << PRN << " "; + + //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); + //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); + //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) + + tmp_gnss_synchro.Acq_doppler_hz = doppler_shift_selected; + tmp_gnss_synchro.Acq_delay_samples = max_index; + tmp_gnss_synchro.Acq_samplestamp_samples = initial_sample; // delay due to the downsampling filter in the acquisition + + + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + else + { + std::cout << " . "; + } + + std::cout.flush(); + + } + + uint32_t max_index = 0; + uint32_t total_fft_scaling_factor; + //uint32_t fw_fft_scaling_factor; + float max_magnitude = 0.0; + uint64_t initial_sample = 0; + float second_magnitude = 0; + float peak_to_power = 0; + float test_statistics; + uint32_t doppler_index = 0; + + if (test_observables_show_results_table == 1) + { + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; + int doppler_num = 0; + for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) + { + max_magnitude = result_table[PRN][doppler_num][0]; + //power_sum = result_table[PRN][doppler_num][1]; + second_magnitude = result_table[PRN][doppler_num][1]; + total_fft_scaling_factor = result_table[PRN][doppler_num][2]; + doppler_num = doppler_num + 1; + + std::cout << "==================== Doppler shift " << doppler_shift << std::endl; + std::cout << "Max magnitude = " << max_magnitude << std::endl; + std::cout << "Second magnitude = " << second_magnitude << std::endl; + std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; + test_statistics = (max_magnitude / second_magnitude); + std::cout << " test_statistics = " << test_statistics << std::endl; + + } + int dummy_val; + std::cout << "Enter a value to continue"; + std::cin >> dummy_val; + } + } + } + else // DOPPLER CONTROL IN HW + { + + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + //for (unsigned int PRN = 0; PRN < 17; PRN++) + { + + uint32_t max_index = 0; + float max_magnitude = 0.0; + float second_magnitude = 0.0; + uint64_t initial_sample = 0; + //float power_sum = 0; + uint32_t doppler_index = 0; + + uint32_t max_index_iteration; + uint32_t total_fft_scaling_factor; + uint32_t fw_fft_scaling_factor; + float max_magnitude_iteration; + float second_magnitude_iteration; + uint64_t initial_sample_iteration; + //float power_sum_iteration; + uint32_t doppler_index_iteration; + int doppler_shift_selected; + int doppler_num = 0; + + tmp_gnss_synchro.PRN = PRN; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL1Ca_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsL1Ca_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL1Ca_Fpga->init(); + acquisition_GpsL1Ca_Fpga->set_local_code(); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("starting configuring acquisition\n"); + acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE1_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsE1_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE1_Fpga->init(); + acquisition_GpsE1_Fpga->set_local_code(); + args.freq_band = 0; + //printf("ffffffffffff ending configuring acquisition\n"); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsE5a_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsE5a_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsE5a_Fpga->init(); + acquisition_GpsE5a_Fpga->set_local_code(); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters + acquisition_GpsL5_Fpga->set_doppler_max(acq_doppler_max); + acquisition_GpsL5_Fpga->set_doppler_step(acq_doppler_step); + + acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); + acquisition_GpsL5_Fpga->init(); + acquisition_GpsL5_Fpga->set_local_code(); + args.freq_band = 1; + } + + args.file = file; + + + send_samples_start_obs_test = 0; + + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + //printf("gggggggg \n"); + //---------------------------------------------------------------------------------- + // send the previous samples to set the downsampling filter in a good condition + //send_samples_start = 0; + + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT + + //printf("sending pre init %d\n", args.nsamples_tx); + + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start_obs_test = 0; + //printf("finished sending samples init filter status\n"); + //----------------------------------------------------------------------------------- + + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + + } + else + { + // debug + args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + args.skip_used_samples = 0; + } + + + + + + // create DMA child process + //printf("||||||||1 args freq_band = %d\n", args.freq_band); + //printf("sending samples main DMA %d\n", args.nsamples_tx); + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + { + printf("ERROR cannot create DMA Process\n"); + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex); + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset(); // set active + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //printf("hhhhhhhhhhhh\n"); + acquisition_GpsE1_Fpga->reset(); // set active + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset(); // set active + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset(); // set active + } + +// pthread_mutex_lock(&mutex); // it doesn't work if it is done here +// send_samples_start = 1; +// pthread_mutex_unlock(&mutex); + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } + + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex); + + while (msg_rx->rx_message == 0) + { + usleep(100000); + } + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + + tmp_gnss_synchro.Acq_doppler_hz = tmp_gnss_synchro.Acq_doppler_hz; + tmp_gnss_synchro.Acq_delay_samples = tmp_gnss_synchro.Acq_delay_samples; + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + tmp_gnss_synchro.Acq_samplestamp_samples = tmp_gnss_synchro.Acq_samplestamp_samples; // delay due to the downsampling filter in the acquisition + + + gnss_synchro_vec.push_back(tmp_gnss_synchro); // doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); // code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); // tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation // acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); - } - else - { - std::cout << " . "; - } - - // while (msg_rx->rx_message == 0) - // { - // usleep(100000); - // } - - // if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - // { - // acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - // //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - // } - // else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - // { - // //printf("iiiiiiiiiiiiii\n"); - // acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - // //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - // } - // else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - // { - // acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - // //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - // } - // else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - // { - // acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - // //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - // } - // - // if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - // { - // int interpolation_factor = 4; - // //index_debug[PRN - 1] = max_index_iteration; - // max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - // max_magnitude = max_magnitude_iteration; - // second_magnitude = second_magnitude_iteration; - // //samplestamp_debug[PRN - 1] = initial_sample_iteration; - // initial_sample = 0; //initial_sample_iteration; - // doppler_index = doppler_index_iteration; - // doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); - // } - // else - // { - // max_index = max_index_iteration; - // max_magnitude = max_magnitude_iteration; - // second_magnitude = second_magnitude_iteration; - // initial_sample = initial_sample_iteration; - // doppler_index = doppler_index_iteration; - // doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); - // } - top_block->stop(); - - - // float test_statistics = max_magnitude/second_magnitude; - // float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - // if (test_statistics > threshold) - // { - // //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); - // std::cout << " " << PRN << " "; - // doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - // code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - // code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); - // acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) - // } - // else - // { - // std::cout << " . "; - // } - - std::cout.flush(); - + } + else + { + std::cout << " . "; } - } +// while (msg_rx->rx_message == 0) +// { +// usleep(100000); +// } + +// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); +// //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); +// } +// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) +// { +// //printf("iiiiiiiiiiiiii\n"); +// acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); +// //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); +// } +// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); +// //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); +// } +// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) +// { +// acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); +// //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); +// } +// +// if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) +// { +// int interpolation_factor = 4; +// //index_debug[PRN - 1] = max_index_iteration; +// max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); +// max_magnitude = max_magnitude_iteration; +// second_magnitude = second_magnitude_iteration; +// //samplestamp_debug[PRN - 1] = initial_sample_iteration; +// initial_sample = 0; //initial_sample_iteration; +// doppler_index = doppler_index_iteration; +// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); +// } +// else +// { +// max_index = max_index_iteration; +// max_magnitude = max_magnitude_iteration; +// second_magnitude = second_magnitude_iteration; +// initial_sample = initial_sample_iteration; +// doppler_index = doppler_index_iteration; +// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); +// } + top_block->stop(); + + +// float test_statistics = max_magnitude/second_magnitude; +// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); +// if (test_statistics > threshold) +// { +// //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); +// std::cout << " " << PRN << " "; +// doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); +// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); +// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); +// acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) +// } +// else +// { +// std::cout << " . "; +// } + + std::cout.flush(); + + } + + } // } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; From a379a896d42cdfa0552ed838cae06930522b2b98 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 4 Feb 2019 15:01:50 +0100 Subject: [PATCH 28/53] FPGA unit tests need to reset the HW at the beginning of each iteration --- .../hybrid_observables_test_fpga.cc | 801 +++++++++--------- .../tracking/tracking_pull-in_test_fpga.cc | 291 +++---- 2 files changed, 529 insertions(+), 563 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index ea36193c2..f001baa1c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -555,7 +555,7 @@ bool HybridObservablesTestFpga::acquire_signal() //config->set_property("Acquisition.select_queue_Fpga", "0"); //config->set_property("Acquisition.devicename", "/dev/uio0"); - config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) //{ @@ -610,32 +610,6 @@ bool HybridObservablesTestFpga::acquire_signal() acquisition_GpsE1_Fpga->connect(top_block); } -// else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) -// { -// tmp_gnss_synchro.System = 'G'; -// std::string signal = "2S"; -// signal.copy(tmp_gnss_synchro.Signal, 2, 0); -// tmp_gnss_synchro.PRN = SV_ID; -// System_and_Signal = "GPS L2CM"; -// config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); -// acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); -// } -// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) -// { -// tmp_gnss_synchro.System = 'E'; -// std::string signal = "5X"; -// signal.copy(tmp_gnss_synchro.Signal, 2, 0); -// tmp_gnss_synchro.PRN = SV_ID; -// System_and_Signal = "Galileo E5a"; -// config->set_property("Acquisition_5X.coherent_integration_time_ms", "1"); -// config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); -// config->set_property("Acquisition.CAF_window_hz", "0"); // **Only for E5a** Resolves doppler ambiguity averaging the specified BW in the winner code delay. If set to 0 CAF filter is desactivated. Recommended value 3000 Hz -// config->set_property("Acquisition.Zero_padding", "0"); //**Only for E5a** Avoids power loss and doppler ambiguity in bit transitions by correlating one code with twice the input data length, ensuring that at least one full code is present without transitions. If set to 1 it is ON, if set to 0 it is OFF. -// config->set_property("Acquisition.bit_transition_flag", "false"); -// acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); -// -// -// } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -679,20 +653,8 @@ bool HybridObservablesTestFpga::acquire_signal() throw(std::exception()); } - //printf("BBBBBBBBBBBBBBBBBBBBBBBBBB\n"); - - - //gr::blocks::file_source::sptr file_source; std::string file = FLAGS_signal_file; const char* file_name = file.c_str(); - //file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample - //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); - //gr::blocks::head::sptr head_samples = gr::blocks::head::make(sizeof(gr_complex), baseband_sampling_freq * FLAGS_duration); - - //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - //top_block->connect(gr_interleaved_char_to_complex, 0, acquisition->get_left_block(), 0); - //top_block->connect(head_samples, 0, acquisition->get_left_block(), 0); struct DMA_handler_args_obs_test args; @@ -712,7 +674,6 @@ bool HybridObservablesTestFpga::acquire_signal() if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - //printf("BBBBBBBBBBBBBBBBBBBBBBBBBB2222222222\n"); top_block->msg_connect(acquisition_GpsL1Ca_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -787,6 +748,7 @@ bool HybridObservablesTestFpga::acquire_signal() int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + /* if (doppler_loop_control_in_sw_obs_test == 1) { @@ -1136,6 +1098,7 @@ bool HybridObservablesTestFpga::acquire_signal() } else // DOPPLER CONTROL IN HW { + */ for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) //for (unsigned int PRN = 0; PRN < 17; PRN++) @@ -1308,10 +1271,19 @@ bool HybridObservablesTestFpga::acquire_signal() send_samples_start_obs_test = 0; pthread_mutex_unlock(&mutex); - while (msg_rx->rx_message == 0) - { - usleep(100000); - } +// while (msg_rx->rx_message == 0) +// { +// usleep(100000); +// } + + // the DMA sends the exact number of samples needed for the acquisition. + // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate + // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra + // sample the DMA might have sent. + do { + usleep(100000); + } while (msg_rx->rx_message == 0); + if (msg_rx->rx_message == 1) { std::cout << " " << PRN << " "; @@ -1404,7 +1376,7 @@ bool HybridObservablesTestFpga::acquire_signal() std::cout.flush(); - } +/* } */ } // } @@ -2278,32 +2250,63 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - printf("sssssss code_length = %d \n", code_length); + //printf("sssssss code_length = %d \n", code_length); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - printf("sssssss code_length = %d \n", code_length); + //printf("sssssss code_length = %d \n", code_length); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - printf("sssssss code_length = %d \n", code_length); + //printf("sssssss code_length = %d \n", code_length); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - printf("sssssss code_length = %d \n", code_length); + //printf("sssssss code_length = %d \n", code_length); } float nbits = ceilf(log2f((float)code_length*2)); unsigned int fft_size = pow(2, nbits); - //printf("000000000000 nbits = %f\n", nbits); - //printf("000000000000 fft_size = %d\n", fft_size); + + // The HW has been reset after the acquisition phase when the acquisition class was destroyed. + // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the + // GPS L1 / Galileo E1 filter has been cleared. + // During this test all the samples coming from the DMA are consumed so in principle there would be + // no need to reset the HW. However we need to clear the sample counter in each test. Therefore we have + // to reset the HW at the beginning of each test. + + // instantiate the acquisition modules in order to use them to reset the HW. + // (note that the constructor of the acquisition modules resets the HW too) + std::shared_ptr acquisition_GpsL1Ca_Fpga; + std::shared_ptr acquisition_GpsE1_Fpga; + std::shared_ptr acquisition_GpsE5a_Fpga; + std::shared_ptr acquisition_GpsL5_Fpga; + // reset the HW to clear the sample counters: the acquisition constructor generates a reset + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + + std::vector> tracking_ch_vec; std::vector> tlm_ch_vec; @@ -2349,139 +2352,141 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) }) << "Failure setting gnss_synchro."; } - top_block = gr::make_top_block("Telemetry_Decoder test"); - boost::shared_ptr dummy_msg_rx_trk = HybridObservablesTest_msg_rx_Fpga_make(); - boost::shared_ptr dummy_tlm_msg_rx = HybridObservablesTest_tlm_msg_rx_Fpga_make(); - //Observables - std::shared_ptr observables(new HybridObservables(config.get(), "Observables", tracking_ch_vec.size() + 1, tracking_ch_vec.size())); + top_block = gr::make_top_block("Telemetry_Decoder test"); + boost::shared_ptr dummy_msg_rx_trk = HybridObservablesTest_msg_rx_Fpga_make(); + boost::shared_ptr dummy_tlm_msg_rx = HybridObservablesTest_tlm_msg_rx_Fpga_make(); + //Observables + std::shared_ptr observables(new HybridObservables(config.get(), "Observables", tracking_ch_vec.size() + 1, tracking_ch_vec.size())); - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - ASSERT_NO_THROW({ - tracking_ch_vec.at(n)->connect(top_block); - }) << "Failure connecting tracking to the top_block."; - } + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + ASSERT_NO_THROW({ + tracking_ch_vec.at(n)->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + } - std::string file; - const char* file_name; + std::string file; + const char* file_name; - ASSERT_NO_THROW({ - //std::string file; - if (!FLAGS_enable_external_signal_file) - { - file = "./" + filename_raw_data; - } - else - { - file = FLAGS_signal_file; - } - //const char* file_name = file.c_str(); - file_name = file.c_str(); - //gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); - int observable_interval_ms = 20; - //gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); - //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - //top_block->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); + ASSERT_NO_THROW({ + //std::string file; + if (!FLAGS_enable_external_signal_file) + { + file = "./" + filename_raw_data; + } + else + { + file = FLAGS_signal_file; + } + //const char* file_name = file.c_str(); + file_name = file.c_str(); + //gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); + //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); + int observable_interval_ms = 20; + //gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); + //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); + //top_block->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); - double fs = static_cast(config->property("GNSS-SDR.internal_fs_sps", 0)); + double fs = static_cast(config->property("GNSS-SDR.internal_fs_sps", 0)); - gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter; - ch_out_fpga_sample_counter = gnss_sdr_make_fpga_sample_counter(fs, observable_interval_ms); + gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter; + ch_out_fpga_sample_counter = gnss_sdr_make_fpga_sample_counter(fs, observable_interval_ms); - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - //top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); - top_block->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); - top_block->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); - top_block->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); - top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); - } - //connect sample counter and timmer to the last channel in observables block (extra channel) - //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); - top_block->connect(ch_out_fpga_sample_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //extra port for the sample counter pulse + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + //top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); + top_block->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); + top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); + } + //connect sample counter and timmer to the last channel in observables block (extra channel) + //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); + top_block->connect(ch_out_fpga_sample_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //extra port for the sample counter pulse - //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample - }) << "Failure connecting the blocks."; - - // create acquisition class such that a global Reset is produced for all the HW and the sample counters are reset to 0 - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - //printf("111111111111\n"); - std::shared_ptr acquisition_Fpga; - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - std::shared_ptr acquisition_Fpga; - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - std::shared_ptr acquisition_Fpga; - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - std::shared_ptr acquisition_Fpga; - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else - { - std::cout << "The test can not run with the selected tracking implementation\n "; - throw(std::exception()); - } - - args.file = file; - args.nsamples_tx = TEST_OBS_NSAMPLES_TRACKING; // number of samples to transfer + //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample + }) << "Failure connecting the blocks."; - //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) - //{ - // args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; - //} - //else - //{ - args.skip_used_samples = 0; - //} + // create acquisition class such that a global Reset is produced for all the HW and the sample counters are reset to 0 + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + //printf("111111111111\n"); + //std::shared_ptr acquisition_Fpga; + //acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + //std::shared_ptr acquisition_Fpga; + //acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + //std::shared_ptr acquisition_Fpga; + //acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + //std::shared_ptr acquisition_Fpga; + //acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } - //printf("2222222222222 CREATE PROCES\n"); - printf("%s\n", file.c_str()); - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + + args.file = file; + //args.nsamples_tx = TEST_OBS_NSAMPLES_TRACKING; // number of samples to transfer + args.nsamples_tx = baseband_sampling_freq*FLAGS_duration;; + + //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) + //{ + // args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; + //} + //else + //{ + args.skip_used_samples = 0; + //} + + //printf("2222222222222 CREATE PROCES\n"); + //printf("%s\n", file.c_str()); + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - tracking_ch_vec.at(n)->start_tracking(); - } + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + tracking_ch_vec.at(n)->start_tracking(); + } - //printf("222222222222222222 bis\n"); - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex_obs_test); + //printf("222222222222222222 bis\n"); + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex_obs_test); - top_block->start(); - //printf("33333333333333333333 top block started\n"); + top_block->start(); + //printf("33333333333333333333 top block started\n"); - EXPECT_NO_THROW({ - start = std::chrono::system_clock::now(); - //top_block->run(); // Start threads and wait - end = std::chrono::system_clock::now(); - elapsed_seconds = end - start; - }) << "Failure running the top_block."; + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + //top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + }) << "Failure running the top_block."; // wait for the child DMA process to finish @@ -2497,19 +2502,19 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) //printf("55555555555 TOP BLOCK STOPPED\n"); // send more samples to unblock the tracking process in case it was waiting for samples - args.file = file; - //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) - //{ - // skip the samples that have already been used - args.skip_used_samples = 0; //args.nsamples_tx; - //} - //else - //{ - // args.skip_used_samples = 0; - //} - args.nsamples_tx = TEST_OBS_NSAMPLES_FINAL; - //printf("666666666 CREATE PROCESS TO SEND EXTRA SAMPLES\n"); - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) + args.file = file; + //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) + //{ + // skip the samples that have already been used + args.skip_used_samples = 0; //args.nsamples_tx; + //} + //else + //{ + // args.skip_used_samples = 0; + //} + args.nsamples_tx = TEST_OBS_NSAMPLES_FINAL; + //printf("666666666 CREATE PROCESS TO SEND EXTRA SAMPLES\n"); + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { printf("ERROR cannot create DMA Process\n"); } @@ -2517,250 +2522,270 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) //printf("777777777 PROCESS FINISHED \n"); + // reset the HW AGAIN + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset_acquisition(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); + } -// pthread_mutex_lock(&mutex_obs_test); -// send_samples_start_obs_test = 0; -// pthread_mutex_unlock(&mutex_obs_test); + +/* + + // pthread_mutex_lock(&mutex_obs_test); + // send_samples_start_obs_test = 0; + // pthread_mutex_unlock(&mutex_obs_test); - //check results - // Matrices for storing columnwise true GPS time, Range, Doppler and Carrier phase - std::vector true_obs_vec; + //check results + // Matrices for storing columnwise true GPS time, Range, Doppler and Carrier phase + std::vector true_obs_vec; - if (!FLAGS_enable_external_signal_file) - { - //load the true values - true_observables_reader true_observables; - ASSERT_NO_THROW({ - if (true_observables.open_obs_file(std::string("./obs_out.bin")) == false) - { - throw std::exception(); - } - }) << "Failure opening true observables file"; + if (!FLAGS_enable_external_signal_file) + { + //load the true values + true_observables_reader true_observables; + ASSERT_NO_THROW({ + if (true_observables.open_obs_file(std::string("./obs_out.bin")) == false) + { + throw std::exception(); + } + }) << "Failure opening true observables file"; - unsigned int nepoch = static_cast(true_observables.num_epochs()); + unsigned int nepoch = static_cast(true_observables.num_epochs()); - std::cout << "True observation epochs = " << nepoch << std::endl; + std::cout << "True observation epochs = " << nepoch << std::endl; - true_observables.restart(); - int64_t epoch_counter = 0; - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - true_obs_vec.push_back(arma::zeros(nepoch, 4)); - } + true_observables.restart(); + int64_t epoch_counter = 0; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + true_obs_vec.push_back(arma::zeros(nepoch, 4)); + } - ASSERT_NO_THROW({ - while (true_observables.read_binary_obs()) - { - for (unsigned int n = 0; n < true_obs_vec.size(); n++) - { - if (round(true_observables.prn[n]) != gnss_synchro_vec.at(n).PRN) - { - std::cout << "True observables SV PRN does not match measured ones: " - << round(true_observables.prn[n]) << " vs. " << gnss_synchro_vec.at(n).PRN << std::endl; - throw std::exception(); - } - true_obs_vec.at(n)(epoch_counter, 0) = true_observables.gps_time_sec[n]; - true_obs_vec.at(n)(epoch_counter, 1) = true_observables.dist_m[n]; - true_obs_vec.at(n)(epoch_counter, 2) = true_observables.doppler_l1_hz[n]; - true_obs_vec.at(n)(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[n]; - } - epoch_counter++; - } - }); - } - else - { - ASSERT_EQ(ReadRinexObs(&true_obs_vec, gnss_synchro_master), true) - << "Failure reading RINEX file"; - } + ASSERT_NO_THROW({ + while (true_observables.read_binary_obs()) + { + for (unsigned int n = 0; n < true_obs_vec.size(); n++) + { + if (round(true_observables.prn[n]) != gnss_synchro_vec.at(n).PRN) + { + std::cout << "True observables SV PRN does not match measured ones: " + << round(true_observables.prn[n]) << " vs. " << gnss_synchro_vec.at(n).PRN << std::endl; + throw std::exception(); + } + true_obs_vec.at(n)(epoch_counter, 0) = true_observables.gps_time_sec[n]; + true_obs_vec.at(n)(epoch_counter, 1) = true_observables.dist_m[n]; + true_obs_vec.at(n)(epoch_counter, 2) = true_observables.doppler_l1_hz[n]; + true_obs_vec.at(n)(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[n]; + } + epoch_counter++; + } + }); + } + else + { + ASSERT_EQ(ReadRinexObs(&true_obs_vec, gnss_synchro_master), true) + << "Failure reading RINEX file"; + } - //read measured values - observables_dump_reader estimated_observables(tracking_ch_vec.size()); - ASSERT_NO_THROW({ - if (estimated_observables.open_obs_file(std::string("./observables.dat")) == false) - { - throw std::exception(); - } - }) << "Failure opening dump observables file"; + //read measured values + observables_dump_reader estimated_observables(tracking_ch_vec.size()); + ASSERT_NO_THROW({ + if (estimated_observables.open_obs_file(std::string("./observables.dat")) == false) + { + throw std::exception(); + } + }) << "Failure opening dump observables file"; - unsigned int nepoch = static_cast(estimated_observables.num_epochs()); - std::cout << "Measured observations epochs = " << nepoch << std::endl; + unsigned int nepoch = static_cast(estimated_observables.num_epochs()); + std::cout << "Measured observations epochs = " << nepoch << std::endl; - // Matrices for storing columnwise measured RX_time, TOW, Doppler, Carrier phase and Pseudorange - std::vector measured_obs_vec; - std::vector epoch_counters_vec; - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - measured_obs_vec.push_back(arma::zeros(nepoch, 5)); - epoch_counters_vec.push_back(0); - } + // Matrices for storing columnwise measured RX_time, TOW, Doppler, Carrier phase and Pseudorange + std::vector measured_obs_vec; + std::vector epoch_counters_vec; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + measured_obs_vec.push_back(arma::zeros(nepoch, 5)); + epoch_counters_vec.push_back(0); + } - estimated_observables.restart(); - //printf("Observables : ............................\n"); - while (estimated_observables.read_binary_obs()) - { - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - if (static_cast(estimated_observables.valid[n])) - { - //printf("estimated_observables.RX_time[%d] = %d\n", n, estimated_observables.RX_time[n]); - //printf("estimated_observables.TOW_at_current_symbol_s[%d] = %d\n", n, estimated_observables.TOW_at_current_symbol_s[n]); - //printf("estimated_observables.Carrier_Doppler_hz[%d] = %d\n", n, estimated_observables.Carrier_Doppler_hz[n]); - //printf("estimated_observables.Acc_carrier_phase_hz[%d] = %d\n", n, estimated_observables.Acc_carrier_phase_hz[n]); - //printf("estimated_observables.Pseudorange_m[%d] = %d\n", n, estimated_observables.Pseudorange_m[n]); - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 3) = estimated_observables.Acc_carrier_phase_hz[n]; - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 4) = estimated_observables.Pseudorange_m[n]; - epoch_counters_vec.at(n)++; - } - } - } + estimated_observables.restart(); + //printf("Observables : ............................\n"); + while (estimated_observables.read_binary_obs()) + { + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (static_cast(estimated_observables.valid[n])) + { + //printf("estimated_observables.RX_time[%d] = %d\n", n, estimated_observables.RX_time[n]); + //printf("estimated_observables.TOW_at_current_symbol_s[%d] = %d\n", n, estimated_observables.TOW_at_current_symbol_s[n]); + //printf("estimated_observables.Carrier_Doppler_hz[%d] = %d\n", n, estimated_observables.Carrier_Doppler_hz[n]); + //printf("estimated_observables.Acc_carrier_phase_hz[%d] = %d\n", n, estimated_observables.Acc_carrier_phase_hz[n]); + //printf("estimated_observables.Pseudorange_m[%d] = %d\n", n, estimated_observables.Pseudorange_m[n]); + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 3) = estimated_observables.Acc_carrier_phase_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 4) = estimated_observables.Pseudorange_m[n]; + epoch_counters_vec.at(n)++; + } + } + } - //Cut measurement tail zeros - arma::uvec index; - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - index = arma::find(measured_obs_vec.at(n).col(0) > 0.0, 1, "last"); - if ((index.size() > 0) and index(0) < (nepoch - 1)) - { - measured_obs_vec.at(n).shed_rows(index(0) + 1, nepoch - 1); - } - } + //Cut measurement tail zeros + arma::uvec index; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + index = arma::find(measured_obs_vec.at(n).col(0) > 0.0, 1, "last"); + if ((index.size() > 0) and index(0) < (nepoch - 1)) + { + measured_obs_vec.at(n).shed_rows(index(0) + 1, nepoch - 1); + } + } - //Cut measurement initial transitory of the measurements + //Cut measurement initial transitory of the measurements - double initial_transitory_s = FLAGS_skip_obs_transitory_s; + double initial_transitory_s = FLAGS_skip_obs_transitory_s; - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - index = arma::find(measured_obs_vec.at(n).col(0) >= (measured_obs_vec.at(n)(0, 0) + initial_transitory_s), 1, "first"); - if ((index.size() > 0) and (index(0) > 0)) - { - measured_obs_vec.at(n).shed_rows(0, index(0)); - } + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + index = arma::find(measured_obs_vec.at(n).col(0) >= (measured_obs_vec.at(n)(0, 0) + initial_transitory_s), 1, "first"); + if ((index.size() > 0) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } - index = arma::find(measured_obs_vec.at(n).col(0) >= true_obs_vec.at(n)(0, 0), 1, "first"); - if ((index.size() > 0) and (index(0) > 0)) - { - measured_obs_vec.at(n).shed_rows(0, index(0)); - } - } + index = arma::find(measured_obs_vec.at(n).col(0) >= true_obs_vec.at(n)(0, 0), 1, "first"); + if ((index.size() > 0) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } + } - //Correct the clock error using true values (it is not possible for a receiver to correct - //the receiver clock offset error at the observables level because it is required the - //decoding of the ephemeris data and solve the PVT equations) + //Correct the clock error using true values (it is not possible for a receiver to correct + //the receiver clock offset error at the observables level because it is required the + //decoding of the ephemeris data and solve the PVT equations) - //Find the reference satellite (the nearest) and compute the receiver time offset at observable level - double min_pr = std::numeric_limits::max(); - unsigned int min_pr_ch_id = 0; - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - if (epoch_counters_vec.at(n) > 10) //discard non-valid channels - { - { - if (measured_obs_vec.at(n)(0, 4) < min_pr) - { - min_pr = measured_obs_vec.at(n)(0, 4); - min_pr_ch_id = n; - } - } - } - else - { - std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; - } - } + //Find the reference satellite (the nearest) and compute the receiver time offset at observable level + double min_pr = std::numeric_limits::max(); + unsigned int min_pr_ch_id = 0; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + { + if (measured_obs_vec.at(n)(0, 4) < min_pr) + { + min_pr = measured_obs_vec.at(n)(0, 4); + min_pr_ch_id = n; + } + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } - arma::vec receiver_time_offset_ref_channel_s; - receiver_time_offset_ref_channel_s = true_obs_vec.at(min_pr_ch_id).col(1) / GPS_C_m_s - GPS_STARTOFFSET_ms / 1000.0; - std::cout << "Ref channel initial Receiver time offset " << receiver_time_offset_ref_channel_s(0) * 1e3 << " [ms]" << std::endl; + arma::vec receiver_time_offset_ref_channel_s; + receiver_time_offset_ref_channel_s = true_obs_vec.at(min_pr_ch_id).col(1) / GPS_C_m_s - GPS_STARTOFFSET_ms / 1000.0; + std::cout << "Ref channel initial Receiver time offset " << receiver_time_offset_ref_channel_s(0) * 1e3 << " [ms]" << std::endl; - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - //debug save to .mat - std::vector tmp_vector_x(true_obs_vec.at(n).col(0).colptr(0), - true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); - std::vector tmp_vector_y(true_obs_vec.at(n).col(1).colptr(0), - true_obs_vec.at(n).col(1).colptr(0) + true_obs_vec.at(n).col(1).n_rows); - save_mat_xy(tmp_vector_x, tmp_vector_y, std::string("true_pr_ch_" + std::to_string(n))); + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + //debug save to .mat + std::vector tmp_vector_x(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y(true_obs_vec.at(n).col(1).colptr(0), + true_obs_vec.at(n).col(1).colptr(0) + true_obs_vec.at(n).col(1).n_rows); + save_mat_xy(tmp_vector_x, tmp_vector_y, std::string("true_pr_ch_" + std::to_string(n))); - std::vector tmp_vector_x2(measured_obs_vec.at(n).col(0).colptr(0), - measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); - std::vector tmp_vector_y2(measured_obs_vec.at(n).col(4).colptr(0), - measured_obs_vec.at(n).col(4).colptr(0) + measured_obs_vec.at(n).col(4).n_rows); - save_mat_xy(tmp_vector_x2, tmp_vector_y2, std::string("measured_pr_ch_" + std::to_string(n))); + std::vector tmp_vector_x2(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y2(measured_obs_vec.at(n).col(4).colptr(0), + measured_obs_vec.at(n).col(4).colptr(0) + measured_obs_vec.at(n).col(4).n_rows); + save_mat_xy(tmp_vector_x2, tmp_vector_y2, std::string("measured_pr_ch_" + std::to_string(n))); - std::vector tmp_vector_x3(true_obs_vec.at(n).col(0).colptr(0), - true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); - std::vector tmp_vector_y3(true_obs_vec.at(n).col(2).colptr(0), - true_obs_vec.at(n).col(2).colptr(0) + true_obs_vec.at(n).col(2).n_rows); - save_mat_xy(tmp_vector_x3, tmp_vector_y3, std::string("true_doppler_ch_" + std::to_string(n))); + std::vector tmp_vector_x3(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y3(true_obs_vec.at(n).col(2).colptr(0), + true_obs_vec.at(n).col(2).colptr(0) + true_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x3, tmp_vector_y3, std::string("true_doppler_ch_" + std::to_string(n))); - std::vector tmp_vector_x4(measured_obs_vec.at(n).col(0).colptr(0), - measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); - std::vector tmp_vector_y4(measured_obs_vec.at(n).col(2).colptr(0), - measured_obs_vec.at(n).col(2).colptr(0) + measured_obs_vec.at(n).col(2).n_rows); - save_mat_xy(tmp_vector_x4, tmp_vector_y4, std::string("measured_doppler_ch_" + std::to_string(n))); + std::vector tmp_vector_x4(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y4(measured_obs_vec.at(n).col(2).colptr(0), + measured_obs_vec.at(n).col(2).colptr(0) + measured_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x4, tmp_vector_y4, std::string("measured_doppler_ch_" + std::to_string(n))); - if (epoch_counters_vec.at(n) > 10) //discard non-valid channels - { - arma::vec true_TOW_ref_ch_s = true_obs_vec.at(min_pr_ch_id).col(0) - receiver_time_offset_ref_channel_s(0); - arma::vec true_TOW_ch_s = true_obs_vec.at(n).col(0) - receiver_time_offset_ref_channel_s(0); - //Compare measured observables - if (min_pr_ch_id != n) - { - check_results_code_pseudorange(true_obs_vec.at(n), - true_obs_vec.at(min_pr_ch_id), - true_TOW_ch_s, - true_TOW_ref_ch_s, - measured_obs_vec.at(n), - measured_obs_vec.at(min_pr_ch_id), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - check_results_carrier_phase_double_diff(true_obs_vec.at(n), - true_obs_vec.at(min_pr_ch_id), - true_TOW_ch_s, - true_TOW_ref_ch_s, - measured_obs_vec.at(n), - measured_obs_vec.at(min_pr_ch_id), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + arma::vec true_TOW_ref_ch_s = true_obs_vec.at(min_pr_ch_id).col(0) - receiver_time_offset_ref_channel_s(0); + arma::vec true_TOW_ch_s = true_obs_vec.at(n).col(0) - receiver_time_offset_ref_channel_s(0); + //Compare measured observables + if (min_pr_ch_id != n) + { + check_results_code_pseudorange(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_phase_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - check_results_carrier_doppler_double_diff(true_obs_vec.at(n), - true_obs_vec.at(min_pr_ch_id), - true_TOW_ch_s, - true_TOW_ref_ch_s, - measured_obs_vec.at(n), - measured_obs_vec.at(min_pr_ch_id), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - } - else - { - std::cout << "[CH " << std::to_string(n) << "] PRN " << std::to_string(gnss_synchro_vec.at(n).PRN) << " is the reference satellite" << std::endl; - } - if (FLAGS_compute_single_diffs) - { - check_results_carrier_phase(true_obs_vec.at(n), - true_TOW_ch_s, - measured_obs_vec.at(n), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - check_results_carrier_doppler(true_obs_vec.at(n), - true_TOW_ch_s, - measured_obs_vec.at(n), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - } - } - else - { - std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; - } - } + check_results_carrier_doppler_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + else + { + std::cout << "[CH " << std::to_string(n) << "] PRN " << std::to_string(gnss_synchro_vec.at(n).PRN) << " is the reference satellite" << std::endl; + } + if (FLAGS_compute_single_diffs) + { + check_results_carrier_phase(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_doppler(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } +*/ - - std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; + std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index c0282c92a..6b0b08ff6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -7,7 +7,6 @@ * * * ------------------------------------------------------------------------- - * * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation @@ -80,8 +79,8 @@ #define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define NSAMPLES_TRACKING 850000000 // number of samples during which we test the tracking module -#define NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module +#define NSAMPLES_TRACKING 1000000000 // number of samples during which we test the tracking module +#define NSAMPLES_FINAL 60000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module #define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop #define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter #define DOWNSAMPLING_FILTER_DELAY 48 @@ -478,7 +477,6 @@ void *handler_DMA(void *arguments) struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; unsigned int nsamples_tx = args->nsamples_tx; - //printf("in handler DMA to send %d\n", nsamples_tx); std::string file = args->file; // input filename unsigned int skip_used_samples = args->skip_used_samples; @@ -486,7 +484,7 @@ void *handler_DMA(void *arguments) tx_fd = open("/dev/loop_tx", O_WRONLY); if ( tx_fd < 0 ) { - printf("DMA can't open loop device\n"); + std::cout << "DMA can't open loop device" << std::endl; exit(1); } else @@ -495,33 +493,21 @@ void *handler_DMA(void *arguments) rx_signal_file_id = fopen(file.c_str(), "rb"); if (rx_signal_file_id < 0) { - printf("DMA can't open input file\n"); + std::cout << "DMA can't open input file" << std::endl; exit(1); } - //printf("in handler DMA waiting for send samples start\n"); - while(send_samples_start == 0); // wait until acquisition starts - //printf("in handler DMA going to send samples\n"); + while(send_samples_start == 0); // wait until main thread tells the DMA to start + // skip initial samples int skip_samples = (int) FLAGS_skip_samples; fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); - //printf("sending %d samples starting at position %d\n", nsamples_tx,skip_samples + skip_used_samples); - //printf("\n dma skip_samples = %d\n", skip_samples); - //printf("\n dma skip used samples = %d\n", skip_used_samples); - //printf("dma skip_samples = %d\n", skip_samples); - //printf("dma skip used samples = %d\n", skip_used_samples); - //printf("dma file_completed = %d\n", file_completed); - //printf("dma nsamples = %d\n", nsamples); - //printf("dma nsamples_tx = %d\n", nsamples_tx); usleep(50000); // wait some time to give time to the main thread to start the acquisition module unsigned int kk; - //printf("enter kk"); - //scanf("%d", &kk); while (file_completed == false) { - //printf("samples sent = %d\n", nsamples); if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) { nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; @@ -536,7 +522,7 @@ void *handler_DMA(void *arguments) if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) { - printf("could not read the desired number of samples from the input file\n"); + std::cout << "file completed" << std::endl; file_completed = true; } @@ -568,9 +554,7 @@ void *handler_DMA(void *arguments) } dma_index += 4; } - //printf("writing samples to send\n"); nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); - //printf("exited writing samples to send\n"); if (nsamples_transmitted != nread_elements*NUM_QUEUES) { std::cout << "Error : DMA could not send all the requested samples" << std::endl; @@ -581,7 +565,6 @@ void *handler_DMA(void *arguments) close(tx_fd); fclose(rx_signal_file_id); - //printf("DMA finished\n"); return NULL; } @@ -599,12 +582,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else { @@ -620,22 +601,24 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) tmp_gnss_synchro.Channel_ID = 0; config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); - config->set_property("Acquisition.blocking_on_standby", "true"); - config->set_property("Acquisition.blocking", "true"); - config->set_property("Acquisition.dump", "false"); - config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); - config->set_property("Acquisition.use_CFAR_algorithm", "false"); + //config->set_property("Acquisition.blocking_on_standby", "true"); + //config->set_property("Acquisition.blocking", "true"); + //config->set_property("Acquisition.dump", "false"); + //config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); + //config->set_property("Acquisition.use_CFAR_algorithm", "false"); - config->set_property("Acquisition.item_type", "cshort"); - config->set_property("Acquisition.if", "0"); + //config->set_property("Acquisition.item_type", "cshort"); + //config->set_property("Acquisition.if", "0"); //config->set_property("Acquisition.sampled_ms", "4"); //config->set_property("Acquisition.select_queue_Fpga", "0"); - config->set_property("Acquisition.devicename", "/dev/uio0"); + //config->set_property("Acquisition.devicename", "/dev/uio0"); - if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - config->set_property("Acquisition.acquire_pilot", "false"); - } + //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); + + //if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + //{ + // config->set_property("Acquisition.acquire_pilot", "false"); + //} std::shared_ptr acquisition_GpsL1Ca_Fpga; std::shared_ptr acquisition_GpsE1_Fpga; std::shared_ptr acquisition_GpsE5a_Fpga; @@ -646,10 +629,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - config->set_property("Acquisition.sampled_ms", "1"); - config->set_property("Acquisition.select_queue_Fpga", "0"); + //config->set_property("Acquisition.sampled_ms", "1"); + //config->set_property("Acquisition.select_queue_Fpga", "0"); - tmp_gnss_synchro.System = 'G'; + tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; const char* str = signal.c_str(); // get a C style null terminated string std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null @@ -666,8 +649,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - config->set_property("Acquisition.sampled_ms", "4"); - config->set_property("Acquisition.select_queue_Fpga", "0"); + //config->set_property("Acquisition.sampled_ms", "4"); + //config->set_property("Acquisition.select_queue_Fpga", "0"); tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; @@ -683,12 +666,11 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) acquisition_GpsE1_Fpga->set_channel(0); acquisition_GpsE1_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); acquisition_GpsE1_Fpga->connect(top_block); - //printf(" bbbbbbbb baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - config->set_property("Acquisition.sampled_ms", "1"); - config->set_property("Acquisition.select_queue_Fpga", "1"); + //config->set_property("Acquisition.sampled_ms", "1"); + //config->set_property("Acquisition.select_queue_Fpga", "1"); tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; const char* str = signal.c_str(); // get a C style null terminated string @@ -706,9 +688,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - config->set_property("Acquisition.sampled_ms", "1"); - config->set_property("Acquisition.select_queue_Fpga", "1"); - printf("CORRECT L5 A!!!\n"); + //config->set_property("Acquisition.sampled_ms", "1"); + //config->set_property("Acquisition.select_queue_Fpga", "1"); tmp_gnss_synchro.System = 'G'; std::string signal = "L5"; const char* str = signal.c_str(); // get a C style null terminated string @@ -756,7 +737,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { top_block->msg_connect(acquisition_GpsE1_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - //printf(" cccccc baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -764,7 +744,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - printf("CORRECT L5 B!!!\n"); top_block->msg_connect(acquisition_GpsL5_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); } @@ -811,7 +790,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -820,7 +798,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - printf("CORRECT L5 C !!!!"); code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } @@ -832,12 +809,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); - printf("acq_doppler_max = %d\n", acq_doppler_max); - printf("acq_doppler_step = %d\n", acq_doppler_step); - +/* if (doppler_loop_control_in_sw == 1) { @@ -1192,7 +1167,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else // DOPPLER CONTROL IN HW { - +*/ for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) //for (unsigned int PRN = 0; PRN < 17; PRN++) { @@ -1230,7 +1205,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - //printf("starting configuring acquisition\n"); acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters acquisition_GpsE1_Fpga->set_doppler_max(acq_doppler_max); acquisition_GpsE1_Fpga->set_doppler_step(acq_doppler_step); @@ -1239,7 +1213,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) acquisition_GpsE1_Fpga->init(); acquisition_GpsE1_Fpga->set_local_code(); args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -1269,7 +1242,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) { - //printf("gggggggg \n"); //---------------------------------------------------------------------------------- // send the previous samples to set the downsampling filter in a good condition send_samples_start = 0; @@ -1278,18 +1250,15 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } pthread_mutex_lock(&mutex); send_samples_start = 1; pthread_mutex_unlock(&mutex); pthread_join(thread_DMA, NULL); send_samples_start = 0; - //printf("finished sending samples init filter status\n"); //----------------------------------------------------------------------------------- // debug @@ -1309,12 +1278,10 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) - // create DMA child process - //printf("||||||||1 args freq_band = %d\n", args.freq_band); - //printf("sending samples main DMA %d\n", args.nsamples_tx); + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } msg_rx->rx_message = 0; @@ -1330,7 +1297,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - //printf("hhhhhhhhhhhh\n"); acquisition_GpsE1_Fpga->reset(); // set active } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) @@ -1342,9 +1308,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) acquisition_GpsL5_Fpga->reset(); // set active } - // pthread_mutex_lock(&mutex); // it doesn't work if it is done here - // send_samples_start = 1; - // pthread_mutex_unlock(&mutex); if (start_msg == true) { @@ -1354,7 +1317,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) start_msg = false; } - //printf("wait for DMA to finish\n"); // wait for the child DMA process to finish pthread_join(thread_DMA, NULL); @@ -1362,10 +1324,19 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) send_samples_start = 0; pthread_mutex_unlock(&mutex); - while (msg_rx->rx_message == 0) - { - usleep(100000); - } +// while (msg_rx->rx_message == 0) +// { +// usleep(100000); +// } + + // the DMA sends the exact number of samples needed for the acquisition. + // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate + // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra + // sample the DMA might have sent. + do { + usleep(100000); + } while (msg_rx->rx_message == 0); + if (msg_rx->rx_message == 1) { std::cout << " " << PRN << " "; @@ -1379,81 +1350,16 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::cout << " . "; } -// while (msg_rx->rx_message == 0) -// { -// usleep(100000); -// } -// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) -// { -// //printf("iiiiiiiiiiiiii\n"); -// acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// -// if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) -// { -// int interpolation_factor = 4; -// //index_debug[PRN - 1] = max_index_iteration; -// max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); -// max_magnitude = max_magnitude_iteration; -// second_magnitude = second_magnitude_iteration; -// //samplestamp_debug[PRN - 1] = initial_sample_iteration; -// initial_sample = 0; //initial_sample_iteration; -// doppler_index = doppler_index_iteration; -// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); -// } -// else -// { -// max_index = max_index_iteration; -// max_magnitude = max_magnitude_iteration; -// second_magnitude = second_magnitude_iteration; -// initial_sample = initial_sample_iteration; -// doppler_index = doppler_index_iteration; -// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); -// } top_block->stop(); - -// float test_statistics = max_magnitude/second_magnitude; -// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); -// if (test_statistics > threshold) -// { -// //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); -// std::cout << " " << PRN << " "; -// doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); -// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); -// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); -// acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) -// } -// else -// { -// std::cout << " . "; -// } - std::cout.flush(); - } +/* } */ } -// } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -1463,11 +1369,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } -// for (unsigned k=0;k acquisition_GpsL1Ca_Fpga; + std::shared_ptr acquisition_GpsE1_Fpga; + std::shared_ptr acquisition_GpsE5a_Fpga; + std::shared_ptr acquisition_GpsL5_Fpga; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + } - //printf("####################################\n"); for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) { std::vector pull_in_results_v; @@ -1658,32 +1580,37 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++) { + // reset the HW to clear the sample counters + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset_acquisition(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); + } - printf("acq_samplestamp_samples = %d\n", (int)acq_samplestamp_samples); - printf("true_acq_delay_samples = %d\n", (int)true_acq_delay_samples); - gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; //simulate a Doppler error in acquisition gnss_synchro.Acq_doppler_hz = true_acq_doppler_hz + acq_doppler_error_hz_values.at(current_acq_doppler_error_idx); //simulate Code Delay error in acquisition gnss_synchro.Acq_delay_samples = true_acq_delay_samples + (acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) / GPS_L1_CA_CODE_RATE_HZ) * static_cast(baseband_sampling_freq); - // debug - //printf("forcing data\n"); - //gnss_synchro.Acq_samplestamp_samples = 37500; - //gnss_synchro.Acq_delay_samples = 2933; - //printf("acq_samplestamp_samples = %d\n", (int)gnss_synchro.Acq_samplestamp_samples); - //printf("true_acq_delay_samples = %d\n", (int)gnss_synchro.Acq_delay_samples); - - //create flowgraph top_block = gr::make_top_block("Tracking test"); std::shared_ptr trk_ = factory->GetBlock(config, "Tracking", config->property("Tracking.implementation", std::string("undefined")), 1, 1); std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); boost::shared_ptr msg_rx = TrackingPullInTestFpga_msg_rx_make(); - //printf("loop part b2\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { @@ -1753,13 +1680,14 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) //******************************************************************** - args.nsamples_tx = NSAMPLES_TRACKING; // number of samples to transfer + //args.nsamples_tx = NSAMPLES_TRACKING; // number of samples to transfer + args.nsamples_tx = baseband_sampling_freq*FLAGS_duration; //if (pthread_create(&thread_DMA, NULL, handler_DMA_tracking, (void *)&args) < 0) if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } std::cout << "--- START TRACKING WITH PULL-IN ERROR: " << acq_doppler_error_hz_values.at(current_acq_doppler_error_idx) << " [Hz] and " << acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) << " [Chips] ---" << std::endl; @@ -1777,8 +1705,15 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) top_block->stop(); - printf("going to send more samples\n"); // send more samples to unblock the tracking process in case it was waiting for samples + // In this case the DMA may finish sending the current file while the signal is being + // tracked by the HW accelerators. Some tracking HW accelerators may be left in a state + // where they are waiting for more samples. In this case we can not bring them back to their + // default state using a HW reset because the SW would be waiting forever to receive the + // HW interrupt from those accelerators. The correct way to bring the system back to the default state + // is to send some extra samples that will ensure that all the aforementioned accelerators + // trigger an interrupt to the SW. After this last interrupt all the HW accelerators go back to their + // default state. args.file = file; if (skip_samples_already_used == 1) { @@ -1790,16 +1725,19 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) args.skip_used_samples = 0; } args.nsamples_tx = NSAMPLES_FINAL; - //printf("||||||||1 args freq_band = %d\n", args.freq_band); + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); send_samples_start = 0; pthread_mutex_unlock(&mutex); + pull_in_results_v.push_back(msg_rx->rx_message != 3); //save last asynchronous tracking message in order to detect a loss of lock //******************************** @@ -1968,6 +1906,9 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } //end plot } //end acquisition Delay errors loop + + usleep(100000); // give time to the HW to consume all the remaining samples + } //end acquisition Doppler errors loop pull_in_results_v_v.push_back(pull_in_results_v); From fd3eb2a80e28b9e2eed57a3d342be85457e3f053 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 13 Feb 2019 17:48:14 +0100 Subject: [PATCH 29/53] The termination process is now done correctly when using the FPGA. --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 2 + .../galileo_e5a_pcps_acquisition_fpga.cc | 2 + .../gps_l1_ca_pcps_acquisition_fpga.cc | 2 + .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 2 + src/core/receiver/control_thread.cc | 37 +- src/core/receiver/control_thread.h | 1 + src/core/receiver/gnss_flowgraph.cc | 335 ++++++++++++------ src/core/receiver/gnss_flowgraph.h | 4 +- .../hybrid_observables_test_fpga.cc | 8 +- .../tracking/tracking_pull-in_test_fpga.cc | 22 +- 10 files changed, 302 insertions(+), 113 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 636b600c5..a3c391313 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -345,6 +345,8 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::~GalileoE1PcpsAmbiguousAcquisitionFpga() void GalileoE1PcpsAmbiguousAcquisitionFpga::stop_acquisition() { + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index ac235e524..7b83848e6 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -254,6 +254,8 @@ GalileoE5aPcpsAcquisitionFpga::~GalileoE5aPcpsAcquisitionFpga() void GalileoE5aPcpsAcquisitionFpga::stop_acquisition() { + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 68c00b082..27e9839de 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -212,6 +212,8 @@ GpsL1CaPcpsAcquisitionFpga::~GpsL1CaPcpsAcquisitionFpga() void GpsL1CaPcpsAcquisitionFpga::stop_acquisition() { + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index 1c7aa1932..336164646 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -249,6 +249,8 @@ GpsL5iPcpsAcquisitionFpga::~GpsL5iPcpsAcquisitionFpga() void GpsL5iPcpsAcquisitionFpga::stop_acquisition() { + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); } diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 463815bcb..5a2667052 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -258,12 +258,15 @@ int ControlThread::run() cmd_interface_.set_pvt(flowgraph_->get_pvt()); cmd_interface_thread_ = boost::thread(&ControlThread::telecommand_listener, this); - bool enable_FPGA = configuration_->property("Channel.enable_FPGA", false); - if (enable_FPGA == true) - { - flowgraph_->start_acquisition_helper(); - } - +#ifdef ENABLE_FPGA +// bool enable_FPGA = configuration_->property("Channel.enable_FPGA", false); +// if (enable_FPGA == true) +// { + // Create a task for the acquisition such that id doesn't block the flow of the control thread + fpga_helper_thread_=boost::thread(&GNSSFlowgraph::start_acquisition_helper, + flowgraph_); +// } +#endif // Main loop to read and process the control messages while (flowgraph_->running() && !stop_) { @@ -276,18 +279,40 @@ int ControlThread::run() stop_ = true; flowgraph_->disconnect(); +#ifdef ENABLE_FPGA + // trigger a HW reset + // The HW reset causes any HW accelerator module that is waiting for more samples to complete its calculations + // to trigger an interrupt and finish its signal processing tasks immediately. In this way all SW threads that + // are waiting for interrupts in the HW can exit in a normal way. + flowgraph_->perform_hw_reset(); +#endif + // Join keyboard thread #ifdef OLD_BOOST keyboard_thread_.timed_join(boost::posix_time::seconds(1)); sysv_queue_thread_.timed_join(boost::posix_time::seconds(1)); cmd_interface_thread_.timed_join(boost::posix_time::seconds(1)); +#ifdef ENABLE_FPGA +// if (enable_FPGA == true) +// { + fpga_helper_thread_.timed_join(boost::posix_time::seconds(1)); +// } +#endif + #endif #ifndef OLD_BOOST keyboard_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); sysv_queue_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); cmd_interface_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); +#ifdef ENABLE_FPGA +// if (enable_FPGA == true) +// { + fpga_helper_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); +// } #endif + #endif + LOG(INFO) << "Flowgraph stopped"; if (restart_) diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index b500e43fa..78bdf5c8a 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -171,6 +171,7 @@ private: boost::thread keyboard_thread_; boost::thread sysv_queue_thread_; boost::thread gps_acq_assist_data_collector_thread_; + boost::thread fpga_helper_thread_; void keyboard_listener(); void sysv_queue_listener(); diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index a52f7fa1b..0cf20bd99 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -123,10 +123,11 @@ void GNSSFlowgraph::connect() return; } +#ifndef ENABLE_FPGA for (int i = 0; i < sources_count_; i++) { - if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) - { +// if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) +// { try { sig_source_.at(i)->connect(top_block_); @@ -138,14 +139,15 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } - } +// } } + // Signal Source > Signal conditioner > for (unsigned int i = 0; i < sig_conditioner_.size(); i++) { - if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false) - { +// if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false) +// { try { sig_conditioner_.at(i)->connect(top_block_); @@ -157,9 +159,9 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } - } +// } } - +#endif for (unsigned int i = 0; i < channels_count_; i++) { try @@ -205,12 +207,15 @@ void GNSSFlowgraph::connect() int RF_Channels = 0; int signal_conditioner_ID = 0; + +#ifndef ENABLE_FPGA + for (int i = 0; i < sources_count_; i++) { - //FPGA Accelerators do not need signal sources or conditioners - //as the samples are feed directly to the FPGA fabric, so, if enabled, do not connect any source - if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) - { +// //FPGA Accelerators do not need signal sources or conditioners +// //as the samples are feed directly to the FPGA fabric, so, if enabled, do not connect any source +// if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) +// { try { //TODO: Remove this array implementation and create generic multistream connector @@ -270,41 +275,43 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } - } +// } } DLOG(INFO) << "Signal source connected to signal conditioner"; - bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); +// bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); + +#endif #if ENABLE_FPGA - if (FPGA_enabled == false) - { - //connect the signal source to sample counter - //connect the sample counter to Observables - try - { - double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); - if (fs == 0.0) - { - LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; - std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; - throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); - } - int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); - ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); - //ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); - top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); - top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse - } - catch (const std::exception& e) - { - LOG(WARNING) << "Can't connect sample counter"; - LOG(ERROR) << e.what(); - top_block_->disconnect_all(); - return; - } - } - else - { +// if (FPGA_enabled == false) +// { +// //connect the signal source to sample counter +// //connect the sample counter to Observables +// try +// { +// double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); +// if (fs == 0.0) +// { +// LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; +// std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; +// throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); +// } +// int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); +// ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); +// //ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); +// top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); +// top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse +// } +// catch (const std::exception& e) +// { +// LOG(WARNING) << "Can't connect sample counter"; +// LOG(ERROR) << e.what(); +// top_block_->disconnect_all(); +// return; +// } +// } +// else +// { //create a hardware-defined gnss_synchro pulse for the observables block try { @@ -326,7 +333,7 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } - } +// } #else // connect the signal source to sample counter // connect the sample counter to Observables @@ -353,14 +360,19 @@ void GNSSFlowgraph::connect() return; } #endif + + //bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); + // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) int selected_signal_conditioner_ID = 0; bool use_acq_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false); uint32_t fs = configuration_->property("GNSS-SDR.internal_fs_sps", 0); for (unsigned int i = 0; i < channels_count_; i++) { - if (FPGA_enabled == false) - { + +#ifndef ENABLE_FPGA +// if (FPGA_enabled == false) +// { try { selected_signal_conditioner_ID = configuration_->property("Channel" + std::to_string(i) + ".RF_channel_ID", 0); @@ -497,7 +509,8 @@ void GNSSFlowgraph::connect() } DLOG(INFO) << "signal conditioner " << selected_signal_conditioner_ID << " connected to channel " << i; - } +// } +#endif // Signal Source > Signal conditioner >> Channels >> Observables try { @@ -656,16 +669,18 @@ void GNSSFlowgraph::connect() } } + +#ifndef ENABLE_FPGA // Activate acquisition in enabled channels for (unsigned int i = 0; i < channels_count_; i++) { LOG(INFO) << "Channel " << i << " assigned to " << channels_.at(i)->get_signal(); if (channels_state_[i] == 1) { - if (FPGA_enabled == false) - { +// if (FPGA_enabled == false) +// { channels_.at(i)->start_acquisition(); - } +// } LOG(INFO) << "Channel " << i << " connected to observables and ready for acquisition"; } else @@ -673,6 +688,7 @@ void GNSSFlowgraph::connect() LOG(INFO) << "Channel " << i << " connected to observables in standby mode"; } } +#endif connected_ = true; LOG(INFO) << "Flowgraph connected"; @@ -694,60 +710,123 @@ void GNSSFlowgraph::disconnect() int RF_Channels = 0; int signal_conditioner_ID = 0; - for (int i = 0; i < sources_count_; i++) - { - try - { - // TODO: Remove this array implementation and create generic multistream connector - // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") - { - //Multichannel Array - for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) - { - top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); - } - } - else - { - // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - // Include GetRFChannels in the interface to avoid read config parameters here - // read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); - for (int j = 0; j < RF_Channels; j++) - { - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) - { - top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - if (j == 0) - { - // RF_channel 0 backward compatibility with single channel sources - top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - } - signal_conditioner_ID++; - } - } - } - catch (const std::exception& e) - { - LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); - top_block_->disconnect_all(); - return; - } - } - -#if ENABLE_FPGA +#ifdef ENABLE_FPGA bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); + if (FPGA_enabled == false) + { + for (int i = 0; i < sources_count_; i++) + { + try + { + // TODO: Remove this array implementation and create generic multistream connector + // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + { + //Multichannel Array + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + + for (int j = 0; j < RF_Channels; j++) + { + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); + top_block_->disconnect_all(); + return; + } + } + } + + +#else + + for (int i = 0; i < sources_count_; i++) + { + try + { + // TODO: Remove this array implementation and create generic multistream connector + // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + { + //Multichannel Array + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + + for (int j = 0; j < RF_Channels; j++) + { + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); + top_block_->disconnect_all(); + return; + } + } +#endif + + //printf("disconnect process point 1\n"); +#ifdef ENABLE_FPGA + //bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); if (FPGA_enabled == false) { // disconnect the signal source to sample counter @@ -809,6 +888,7 @@ void GNSSFlowgraph::disconnect() top_block_->disconnect_all(); return; } +#ifndef ENABLE_FPGA try { top_block_->disconnect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0, @@ -820,7 +900,7 @@ void GNSSFlowgraph::disconnect() top_block_->disconnect_all(); return; } - +#endif // Signal Source > Signal conditioner >> Channels >> Observables try { @@ -1057,7 +1137,14 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) } acq_channels_count_++; DLOG(INFO) << "Channel " << ch_index << " Starting acquisition " << channels_[ch_index]->get_signal().get_satellite() << ", Signal " << channels_[ch_index]->get_signal().get_signal_str(); + +#ifndef ENABLE_FPGA channels_[ch_index]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[ch_index]); + tmp_thread.detach(); +#endif } DLOG(INFO) << "Channel " << ch_index << " in state " << channels_state_[ch_index]; } @@ -1128,7 +1215,13 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) } acq_channels_count_++; DLOG(INFO) << "Channel " << i << " Starting acquisition " << channels_[i]->get_signal().get_satellite() << ", Signal " << channels_[i]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA channels_[i]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[i]); + tmp_thread.detach(); +#endif } DLOG(INFO) << "Channel " << i << " in state " << channels_state_[i]; } @@ -1143,7 +1236,13 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_state_[who] = 1; acq_channels_count_++; LOG(INFO) << "Channel " << who << " Starting acquisition " << channels_[who]->get_signal().get_satellite() << ", Signal " << channels_[who]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA channels_[who]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[who]); + tmp_thread.detach(); +#endif } else { @@ -1272,7 +1371,13 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) } acq_channels_count_++; DLOG(INFO) << "Channel " << ch_index << " Starting acquisition " << channels_[ch_index]->get_signal().get_satellite() << ", Signal " << channels_[ch_index]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA channels_[ch_index]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[ch_index]); + tmp_thread.detach(); +#endif } DLOG(INFO) << "Channel " << ch_index << " in state " << channels_state_[ch_index]; } @@ -1300,7 +1405,13 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) } acq_channels_count_++; DLOG(INFO) << "Channel " << ch_index << " Starting acquisition " << channels_[ch_index]->get_signal().get_satellite() << ", Signal " << channels_[ch_index]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA channels_[ch_index]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[ch_index]); + tmp_thread.detach(); +#endif } DLOG(INFO) << "Channel " << ch_index << " in state " << channels_state_[ch_index]; } @@ -1329,7 +1440,13 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) } acq_channels_count_++; DLOG(INFO) << "Channel " << ch_index << " Starting acquisition " << channels_[ch_index]->get_signal().get_satellite() << ", Signal " << channels_[ch_index]->get_signal().get_signal_str(); +#ifndef ENABLE_FPGA channels_[ch_index]->start_acquisition(); +#else + // create a task for the FPGA such that it doesn't stop the flow + std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[ch_index]); + tmp_thread.detach(); +#endif } DLOG(INFO) << "Channel " << ch_index << " in state " << channels_state_[ch_index]; } @@ -1409,6 +1526,7 @@ void GNSSFlowgraph::set_configuration(std::shared_ptr co configuration_ = configuration; } +#ifdef ENABLE_FPGA void GNSSFlowgraph::start_acquisition_helper() { @@ -1422,6 +1540,19 @@ void GNSSFlowgraph::start_acquisition_helper() } + +void GNSSFlowgraph::perform_hw_reset() +{ + + // a stop acquisition command causes the SW to reset the HW + std::shared_ptr channel_ptr; + channel_ptr = std::dynamic_pointer_cast(channels_.at(0)); + channel_ptr->acquisition()->stop_acquisition(); + +} + +#endif + void GNSSFlowgraph::init() { /* diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 67f86bc6b..97ab7f1c2 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -95,9 +95,11 @@ public: void disconnect(); void wait(); - +#ifdef ENABLE_FPGA void start_acquisition_helper(); + void perform_hw_reset(); +#endif /*! * \brief Applies an action to the flow graph * diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index f001baa1c..5f70cad6e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -2501,6 +2501,8 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) //printf("55555555555 TOP BLOCK STOPPED\n"); + + /* // send more samples to unblock the tracking process in case it was waiting for samples args.file = file; //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) @@ -2520,7 +2522,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } pthread_join(thread_DMA, NULL); //printf("777777777 PROCESS FINISHED \n"); - +*/ // reset the HW AGAIN if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) @@ -2541,7 +2543,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } -/* + // pthread_mutex_lock(&mutex_obs_test); // send_samples_start_obs_test = 0; @@ -2785,7 +2787,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; } } -*/ + std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 6b0b08ff6..5e42f5387 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -1704,7 +1704,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) pthread_join(thread_DMA, NULL); top_block->stop(); - +/* // send more samples to unblock the tracking process in case it was waiting for samples // In this case the DMA may finish sending the current file while the signal is being // tracked by the HW accelerators. Some tracking HW accelerators may be left in a state @@ -1731,6 +1731,26 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) std::cout << "ERROR cannot create DMA Process" << std::endl; } pthread_join(thread_DMA, NULL); +*/ + + + // reset the HW to launch the pending interrupts + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL1Ca_Fpga->reset_acquisition(); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition_GpsE1_Fpga->reset_acquisition(); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsE5a_Fpga->reset_acquisition(); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition_GpsL5_Fpga->reset_acquisition(); + } pthread_mutex_lock(&mutex); From 28959c154223d9ad45182ae976d7684719cad1a8 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Thu, 14 Feb 2019 18:02:18 +0100 Subject: [PATCH 30/53] now the FPGA tracking pull-in tests can use the generic acquisition class interface --- .../tracking/tracking_pull-in_test_fpga.cc | 344 ++++-------------- 1 file changed, 80 insertions(+), 264 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 5e42f5387..fdb70ff00 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -601,36 +601,16 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) tmp_gnss_synchro.Channel_ID = 0; config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); - //config->set_property("Acquisition.blocking_on_standby", "true"); - //config->set_property("Acquisition.blocking", "true"); - //config->set_property("Acquisition.dump", "false"); - //config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); - //config->set_property("Acquisition.use_CFAR_algorithm", "false"); - //config->set_property("Acquisition.item_type", "cshort"); - //config->set_property("Acquisition.if", "0"); - //config->set_property("Acquisition.sampled_ms", "4"); - //config->set_property("Acquisition.select_queue_Fpga", "0"); - //config->set_property("Acquisition.devicename", "/dev/uio0"); - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - - //if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - //{ - // config->set_property("Acquisition.acquire_pilot", "false"); - //} - std::shared_ptr acquisition_GpsL1Ca_Fpga; - std::shared_ptr acquisition_GpsE1_Fpga; - std::shared_ptr acquisition_GpsE5a_Fpga; - std::shared_ptr acquisition_GpsL5_Fpga; + std::shared_ptr acquisition; std::string System_and_Signal; + struct DMA_handler_args args; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.sampled_ms", "1"); - //config->set_property("Acquisition.select_queue_Fpga", "0"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; @@ -638,19 +618,16 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L1 CA"; - acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - acquisition_GpsL1Ca_Fpga->set_channel(0); - acquisition_GpsL1Ca_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition_GpsL1Ca_Fpga->connect(top_block); + args.freq_band = 0; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.sampled_ms", "4"); - //config->set_property("Acquisition.select_queue_Fpga", "0"); tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; @@ -658,14 +635,11 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E1B"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - //std::shared_ptr acquisition_Fpga; - acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - acquisition_GpsE1_Fpga->set_channel(0); - acquisition_GpsE1_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition_GpsE1_Fpga->connect(top_block); + args.freq_band = 0; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -677,33 +651,25 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E5a"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - //std::shared_ptr acquisition_Fpga; - acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - acquisition_GpsE5a_Fpga->set_channel(0); - acquisition_GpsE5a_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition_GpsE5a_Fpga->connect(top_block); + args.freq_band = 1; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + + } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.sampled_ms", "1"); - //config->set_property("Acquisition.select_queue_Fpga", "1"); tmp_gnss_synchro.System = 'G'; std::string signal = "L5"; const char* str = signal.c_str(); // get a C style null terminated string std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L5I"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - //std::shared_ptr acquisition_Fpga; - acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - acquisition_GpsL5_Fpga->set_channel(0); - acquisition_GpsL5_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition_GpsL5_Fpga->connect(top_block); + args.freq_band = 1; + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + } else { @@ -711,9 +677,14 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) throw(std::exception()); } + + acquisition->set_channel(0); + acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition->connect(top_block); + std::string file = FLAGS_signal_file; - struct DMA_handler_args args; + //struct DMA_handler_args args; const char* file_name = file.c_str(); @@ -730,22 +701,9 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) msg_rx->top_block = top_block; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - top_block->msg_connect(acquisition_GpsL1Ca_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - top_block->msg_connect(acquisition_GpsE1_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - top_block->msg_connect(acquisition_GpsE5a_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - top_block->msg_connect(acquisition_GpsL5_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } + + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + // 5. Run the flowgraph // Get visible GPS satellites (positive acquisitions with Doppler measurements) @@ -774,40 +732,37 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) MAX_PRN_IDX = 33; } - // debug - //MAX_PRN_IDX = 10; - setup_fpga_switch(); - unsigned int code_length; - unsigned int nsamples_to_transfer; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } + unsigned int code_length; + unsigned int nsamples_to_transfer; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / Galileo_E5a_CODE_CHIP_RATE_HZ * static_cast(Galileo_E5a_CODE_LENGTH_CHIPS))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5i_CODE_RATE_HZ / static_cast(GPS_L5i_CODE_LENGTH_CHIPS)))); + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); - unsigned int nsamples_total = fft_size; + float nbits = ceilf(log2f((float)code_length*2)); + unsigned int fft_size = pow(2, nbits); + unsigned int nsamples_total = fft_size; - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); - int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); @@ -1169,7 +1124,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { */ for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 0; PRN < 17; PRN++) { uint32_t max_index = 0; @@ -1192,48 +1146,27 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) tmp_gnss_synchro.PRN = PRN; + acquisition->stop_acquisition(); // reset the whole system including the sample counters + acquisition->set_doppler_max(acq_doppler_max); + acquisition->set_doppler_step(acq_doppler_step); + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsL1Ca_Fpga->set_doppler_step(acq_doppler_step); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); args.freq_band = 0; } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsE1_Fpga->set_doppler_step(acq_doppler_step); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); args.freq_band = 0; } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsE5a_Fpga->set_doppler_step(acq_doppler_step); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); args.freq_band = 1; } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsL5_Fpga->set_doppler_step(acq_doppler_step); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); args.freq_band = 1; } @@ -1291,23 +1224,8 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) send_samples_start = 1; pthread_mutex_unlock(&mutex); - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); // set active - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); // set active - } + acquisition->reset(); // set active if (start_msg == true) { @@ -1324,11 +1242,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) send_samples_start = 0; pthread_mutex_unlock(&mutex); -// while (msg_rx->rx_message == 0) -// { -// usleep(100000); -// } - // the DMA sends the exact number of samples needed for the acquisition. // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra @@ -1388,20 +1301,6 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) struct DMA_handler_args args; -/* - int interpolation_factor; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - interpolation_factor = 4; // downsampling filter in L1/E1 - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - interpolation_factor = 4; // downsampling filter in L1/E1 - } -*/ - - - //************************************************* @@ -1551,26 +1450,35 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) // instantiate the acquisition modules in order to use them to reset the HW. // (note that the constructor of the acquisition modules resets the HW too) - std::shared_ptr acquisition_GpsL1Ca_Fpga; - std::shared_ptr acquisition_GpsE1_Fpga; - std::shared_ptr acquisition_GpsE5a_Fpga; - std::shared_ptr acquisition_GpsL5_Fpga; + + std::shared_ptr acquisition; + + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) { @@ -1581,24 +1489,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) { // reset the HW to clear the sample counters - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset_acquisition(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); - } - - + acquisition->stop_acquisition(); gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; //simulate a Doppler error in acquisition @@ -1612,36 +1503,6 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) std::shared_ptr tracking = std::dynamic_pointer_cast(trk_); boost::shared_ptr msg_rx = TrackingPullInTestFpga_msg_rx_make(); - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - std::shared_ptr acquisition_Fpga; - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - std::shared_ptr acquisition_Fpga; - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - std::shared_ptr acquisition_Fpga; - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - std::shared_ptr acquisition_Fpga; - acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else - { - std::cout << "The test can not run with the selected tracking implementation\n "; - throw(std::exception()); - } - ASSERT_NO_THROW({ tracking->set_channel(gnss_synchro.Channel_ID); }) << "Failure setting channel."; @@ -1704,54 +1565,9 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) pthread_join(thread_DMA, NULL); top_block->stop(); -/* - // send more samples to unblock the tracking process in case it was waiting for samples - // In this case the DMA may finish sending the current file while the signal is being - // tracked by the HW accelerators. Some tracking HW accelerators may be left in a state - // where they are waiting for more samples. In this case we can not bring them back to their - // default state using a HW reset because the SW would be waiting forever to receive the - // HW interrupt from those accelerators. The correct way to bring the system back to the default state - // is to send some extra samples that will ensure that all the aforementioned accelerators - // trigger an interrupt to the SW. After this last interrupt all the HW accelerators go back to their - // default state. - args.file = file; - if (skip_samples_already_used == 1) - { - // skip the samples that have already been used - args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size + args.nsamples_tx; - } - else - { - args.skip_used_samples = 0; - } - args.nsamples_tx = NSAMPLES_FINAL; - - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } - pthread_join(thread_DMA, NULL); -*/ - // reset the HW to launch the pending interrupts - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset_acquisition(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); - } - + acquisition->stop_acquisition(); pthread_mutex_lock(&mutex); send_samples_start = 0; From 2eebd31483917e043b7c4b1e9808fa90595eda7e Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Fri, 15 Feb 2019 10:12:20 +0100 Subject: [PATCH 31/53] cleanup use of standard acquisition interface for the FPGA unit tests. --- .../hybrid_observables_test_fpga.cc | 211 ++++-------------- .../tracking/tracking_pull-in_test_fpga.cc | 17 -- 2 files changed, 48 insertions(+), 180 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 5f70cad6e..e2c4eda3f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -562,14 +562,12 @@ bool HybridObservablesTestFpga::acquire_signal() // config->set_property("Acquisition.acquire_pilot", "false"); -- ALREADY THE DEFAULT VALUE //} - //std::shared_ptr acquisition; - - std::shared_ptr acquisition_GpsL1Ca_Fpga; - std::shared_ptr acquisition_GpsE1_Fpga; - std::shared_ptr acquisition_GpsE5a_Fpga; - std::shared_ptr acquisition_GpsL5_Fpga; + std::shared_ptr acquisition; std::string System_and_Signal; + + struct DMA_handler_args_obs_test args; + //create the correspondign acquisition block according to the desired tracking signal //printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) @@ -585,11 +583,10 @@ bool HybridObservablesTestFpga::acquire_signal() //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); ////acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - acquisition_GpsL1Ca_Fpga->set_channel(0); - acquisition_GpsL1Ca_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition_GpsL1Ca_Fpga->connect(top_block); + args.freq_band = 0; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) @@ -603,11 +600,10 @@ bool HybridObservablesTestFpga::acquire_signal() System_and_Signal = "Galileo E1B"; //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - acquisition_GpsE1_Fpga->set_channel(0); - acquisition_GpsE1_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition_GpsE1_Fpga->connect(top_block); + args.freq_band = 0; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); } @@ -622,11 +618,10 @@ bool HybridObservablesTestFpga::acquire_signal() System_and_Signal = "Galileo E5a"; //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - acquisition_GpsE5a_Fpga->set_channel(0); - acquisition_GpsE5a_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition_GpsE5a_Fpga->connect(top_block); + args.freq_band = 1; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) @@ -640,11 +635,10 @@ bool HybridObservablesTestFpga::acquire_signal() System_and_Signal = "GPS L5I"; //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - acquisition_GpsL5_Fpga->set_channel(0); - acquisition_GpsL5_Fpga->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); - acquisition_GpsL5_Fpga->connect(top_block); + args.freq_band = 1; + + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); } else @@ -653,10 +647,14 @@ bool HybridObservablesTestFpga::acquire_signal() throw(std::exception()); } + acquisition->set_channel(0); + acquisition->set_threshold(config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold)); + acquisition->connect(top_block); + std::string file = FLAGS_signal_file; const char* file_name = file.c_str(); - struct DMA_handler_args_obs_test args; +// struct DMA_handler_args_obs_test args; boost::shared_ptr msg_rx; try @@ -670,24 +668,8 @@ bool HybridObservablesTestFpga::acquire_signal() } msg_rx->top_block = top_block; - //top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - top_block->msg_connect(acquisition_GpsL1Ca_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - top_block->msg_connect(acquisition_GpsE1_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - top_block->msg_connect(acquisition_GpsE5a_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - top_block->msg_connect(acquisition_GpsL5_Fpga->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); - } + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); // 5. Run the flowgraph @@ -1124,52 +1106,12 @@ bool HybridObservablesTestFpga::acquire_signal() tmp_gnss_synchro.PRN = PRN; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsL1Ca_Fpga->set_doppler_step(acq_doppler_step); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsE1_Fpga->set_doppler_step(acq_doppler_step); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsE5a_Fpga->set_doppler_step(acq_doppler_step); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(acq_doppler_max); - acquisition_GpsL5_Fpga->set_doppler_step(acq_doppler_step); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } + acquisition->stop_acquisition(); // reset the whole system including the sample counters + acquisition->set_doppler_max(acq_doppler_max); + acquisition->set_doppler_step(acq_doppler_step); + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); args.file = file; @@ -1234,23 +1176,7 @@ bool HybridObservablesTestFpga::acquire_signal() send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex); - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("hhhhhhhhhhhh\n"); - acquisition_GpsE1_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); // set active - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); // set active - } + acquisition->reset(); // set active // pthread_mutex_lock(&mutex); // it doesn't work if it is done here // send_samples_start = 1; @@ -2284,28 +2210,37 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // instantiate the acquisition modules in order to use them to reset the HW. // (note that the constructor of the acquisition modules resets the HW too) - std::shared_ptr acquisition_GpsL1Ca_Fpga; - std::shared_ptr acquisition_GpsE1_Fpga; - std::shared_ptr acquisition_GpsE5a_Fpga; - std::shared_ptr acquisition_GpsL5_Fpga; + + + std::shared_ptr acquisition; + // reset the HW to clear the sample counters: the acquisition constructor generates a reset if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL1Ca_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - acquisition_GpsE1_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsE5a_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - acquisition_GpsL5_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); } - std::vector> tracking_ch_vec; @@ -2410,39 +2345,6 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) }) << "Failure connecting the blocks."; - // create acquisition class such that a global Reset is produced for all the HW and the sample counters are reset to 0 - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - //printf("111111111111\n"); - //std::shared_ptr acquisition_Fpga; - //acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //std::shared_ptr acquisition_Fpga; - //acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - //std::shared_ptr acquisition_Fpga; - //acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - //std::shared_ptr acquisition_Fpga; - //acquisition_Fpga = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else - { - std::cout << "The test can not run with the selected tracking implementation\n "; - throw(std::exception()); - } - - args.file = file; //args.nsamples_tx = TEST_OBS_NSAMPLES_TRACKING; // number of samples to transfer args.nsamples_tx = baseband_sampling_freq*FLAGS_duration;; @@ -2525,24 +2427,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) */ // reset the HW AGAIN - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset_acquisition(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); - } - - + acquisition->stop_acquisition(); // pthread_mutex_lock(&mutex_obs_test); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index fdb70ff00..9c0a88c38 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -1153,23 +1153,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) acquisition->init(); acquisition->set_local_code(); - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - args.freq_band = 1; - } - args.file = file; From 40029f789c5810cde2d74e5d8a60aade09e8c1ab Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Mon, 25 Feb 2019 12:10:50 +0100 Subject: [PATCH 32/53] FPGA hybrid observables tests set track_pilot by default. --- .../observables/hybrid_observables_test_fpga.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index e2c4eda3f..e9de57455 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -1418,7 +1418,7 @@ void HybridObservablesTestFpga::configure_receiver( // config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); // } config->set_property("Tracking.early_late_space_chips", "0.5"); - config->set_property("Tracking.track_pilot", "false"); + config->set_property("Tracking.track_pilot", "true"); config->set_property("Tracking.order", "2"); config->set_property("TelemetryDecoder.implementation", "Galileo_E5a_Telemetry_Decoder"); @@ -1432,7 +1432,7 @@ void HybridObservablesTestFpga::configure_receiver( std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null config->set_property("Tracking.early_late_space_chips", "0.5"); - config->set_property("Tracking.track_pilot", "false"); + config->set_property("Tracking.track_pilot", "true"); config->set_property("Tracking.order", "2"); config->set_property("TelemetryDecoder.implementation", "GPS_L5_Telemetry_Decoder"); From dd91ffe139b0602ef79fe612885208ce79f67d2c Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 26 Feb 2019 18:04:59 +0100 Subject: [PATCH 33/53] Bug fix that solves a random deadlock of the observables block rx time selector --- .../gnuradio_blocks/hybrid_observables_cc.cc | 36 +++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 429931dd0..382414c44 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -570,9 +570,41 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) if (n_valid > 0) { update_TOW(epoch_data); - if (T_rx_TOW_ms % 20 != 0) + int tow_inc_loop_count = 0; + while (T_rx_TOW_ms % 20 != 0 and tow_inc_loop_count < 20) { - T_rx_TOW_offset_ms = T_rx_TOW_ms % 20; + tow_inc_loop_count++; + T_rx_TOW_offset_ms++; + T_rx_TOW_offset_ms = T_rx_TOW_offset_ms % 20; + //check if effectively the receiver TOW is now multiple of 20 ms + n_valid = 0; + epoch_data.clear(); + for (uint32_t n = 0; n < d_nchannels_out; n++) + { + Gnss_Synchro interpolated_gnss_synchro{}; + if (!interp_trk_obs(interpolated_gnss_synchro, n, d_Rx_clock_buffer.front() + T_rx_TOW_offset_ms * T_rx_clock_step_samples)) + { + // Produce an empty observation + interpolated_gnss_synchro = Gnss_Synchro(); + interpolated_gnss_synchro.Flag_valid_pseudorange = false; + interpolated_gnss_synchro.Flag_valid_word = false; + interpolated_gnss_synchro.Flag_valid_acquisition = false; + interpolated_gnss_synchro.fs = 0; + interpolated_gnss_synchro.Channel_ID = n; + } + else + { + n_valid++; + } + epoch_data.push_back(interpolated_gnss_synchro); + } + update_TOW(epoch_data); + //debug code: + // if (T_rx_TOW_ms % 20 != 0) + // { + // std::cout << "Warning: RX TOW is not multiple of 20 ms\n"; + // } + // std::cout << "T_rx_TOW_ms=" << T_rx_TOW_ms << " T_rx_TOW_offset_ms=" << T_rx_TOW_offset_ms << " ->" << T_rx_TOW_ms % 20 << std::endl; } } From 5e22e4c50ad236574649d3c62729220f7b3e3cbb Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Tue, 26 Feb 2019 18:28:14 +0100 Subject: [PATCH 34/53] cleaned the FPGA acquisition code --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 370 +---------------- ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 43 +- .../galileo_e5a_pcps_acquisition_fpga.cc | 226 +---------- .../galileo_e5a_pcps_acquisition_fpga.h | 33 +- .../gps_l1_ca_pcps_acquisition_fpga.cc | 103 +---- .../gps_l1_ca_pcps_acquisition_fpga.h | 30 +- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 238 +---------- .../adapters/gps_l5i_pcps_acquisition_fpga.h | 30 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 350 +--------------- .../gnuradio_blocks/pcps_acquisition_fpga.h | 45 +- .../acquisition/libs/fpga_acquisition.cc | 383 +----------------- .../acquisition/libs/fpga_acquisition.h | 26 +- 12 files changed, 125 insertions(+), 1752 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 30ebc957f..8690c6a1f 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -1,12 +1,13 @@ /*! - * \file galileo_e1_pcps_ambiguous_acquisition.cc + * \file galileo_e1_pcps_ambiguous_acquisition_fpga.cc * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * Galileo E1 Signals + * Galileo E1 Signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.es * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -27,7 +28,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" #include "Galileo_E1.h" @@ -50,7 +51,6 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - //printf("top acq constructor start\n"); pcpsconf_fpga_t acq_parameters; configuration_ = configuration; @@ -68,67 +68,27 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( float downsampling_factor = configuration_->property(role + ".downsampling_factor", 4.0); acq_parameters.downsampling_factor = downsampling_factor; - //fs_in = fs_in/2.0; // downampling filter - //printf("fs_in pre downsampling = %ld\n", fs_in); - printf("fs_in pre downsampling = %ld\n", fs_in); - fs_in = fs_in/downsampling_factor; - printf("fs_in post downsampling = %ld\n", fs_in); - - //printf("fs_in post downsampling = %ld\n", fs_in); - acq_parameters.fs_in = fs_in; - //if_ = configuration_->property(role + ".if", 0); - //acq_parameters.freq = if_; - // dump_ = configuration_->property(role + ".dump", false); - // acq_parameters.dump = dump_; - // blocking_ = configuration_->property(role + ".blocking", true); - // acq_parameters.blocking = blocking_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - //unsigned int sampled_ms = 4; - //acq_parameters.sampled_ms = sampled_ms; unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 4); acq_parameters.sampled_ms = sampled_ms; - // bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - // acq_parameters.bit_transition_flag = bit_transition_flag_; - // use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions - // acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; acquire_pilot_ = configuration_->property(role + ".acquire_pilot", false); //will be true in future versions - // max_dwells_ = configuration_->property(role + ".max_dwells", 1); - // acq_parameters.max_dwells = max_dwells_; - // dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - // acq_parameters.dump_filename = dump_filename_; //--- Find number of samples per spreading code (4 ms) ----------------- auto code_length = static_cast(std::round(static_cast(fs_in) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - //acq_parameters.samples_per_code = code_length_; - //int samples_per_ms = static_cast(std::round(static_cast(fs_in_) * 0.001)); - //acq_parameters.samples_per_ms = samples_per_ms; - //unsigned int vector_length = sampled_ms * samples_per_ms; - // if (bit_transition_flag_) - // { - // vector_length_ *= 2; - // } - - //printf("fs_in = %d\n", fs_in); - //printf("GALILEO_E1_B_CODE_LENGTH_CHIPS = %f\n", GALILEO_E1_B_CODE_LENGTH_CHIPS); - //printf("GALILEO_E1_CODE_CHIP_RATE_HZ = %f\n", GALILEO_E1_CODE_CHIP_RATE_HZ); - //printf("acq adapter code_length = %d\n", code_length); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; - printf("acq adapter vector_length = %d\n", vector_length); - //printf("acq adapter nsamples_total (= vector_length) = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); - printf("select queue = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; @@ -138,7 +98,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( acq_parameters.samples_per_code = nsamples_total; acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GALILEO_E1_CODE_CHIP_RATE_HZ)); - // compute all the GALILEO E1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time + // compute all the GALILEO E1 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT auto* code = new std::complex[nsamples_total]; // buffer for the local code @@ -146,20 +106,13 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( d_all_fft_codes_ = new lv_16sc_t[nsamples_total * GALILEO_E1_NUMBER_OF_CODES]; // memory containing all the possible fft codes for PRN 0 to 32 float max; // temporary maxima search - //int tmp_re, tmp_im; - for (unsigned int PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) { - //code_ = new gr_complex[vector_length_]; - bool cboc = false; // cboc is set to 0 when using the FPGA - //std::complex* code = new std::complex[code_length_]; - if (acquire_pilot_ == true) { - //printf("yes acquiring pilot!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1\n"); //set local signal generator to Galileo E1 pilot component (1C) char pilot_signal[3] = "1C"; galileo_e1_code_gen_complex_sampled(code, pilot_signal, @@ -172,56 +125,22 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( cboc, PRN, fs_in, 0, false); } -// for (unsigned int i = 0; i < sampled_ms / 4; i++) -// { -// //memcpy(&(code_[i * code_length_]), code, sizeof(gr_complex) * code_length_); -// memcpy(&(d_all_fft_codes_[i * code_length_]), code, sizeof(gr_complex) * code_length_); -// } - - -// // debug -// char filename[25]; -// FILE *fid; -// sprintf(filename,"gal_prn%d.txt", PRN); -// fid = fopen(filename, "w"); -// for (unsigned int kk=0;kk< nsamples_total; kk++) -// { -// fprintf(fid, "%f\n", code[kk].real()); -// fprintf(fid, "%f\n", code[kk].imag()); -// } -// fclose(fid); - for (int s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; - //code[s] = 0; } -// // fill in zero padding + // fill in zero padding for (int s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(static_cast(0,0)); - //code[s] = 0; } memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values -// // debug -// char filename[25]; -// FILE *fid; -// sprintf(filename,"fft_gal_prn%d.txt", PRN); -// fid = fopen(filename, "w"); -// for (unsigned int kk=0;kk< nsamples_total; kk++) -// { -// fprintf(fid, "%f\n", fft_codes_padded[kk].real()); -// fprintf(fid, "%f\n", fft_codes_padded[kk].imag()); -// } -// fclose(fid); - - // normalize the code max = 0; // initialize maximum value for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima @@ -237,109 +156,34 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( } for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(4096*fft_codes_padded[i].real() * (pow(2, 3) - 1) / max)), - // static_cast(floor(4096*fft_codes_padded[i].imag() * (pow(2, 3) - 1) / max))); -// d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(1024*fft_codes_padded[i].real() * (pow(2, 5) - 1) / max)), -// static_cast(floor(1024*fft_codes_padded[i].imag() * (pow(2, 5) - 1) / max))); - // d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(256*fft_codes_padded[i].real() * (pow(2, 7) - 1) / max)), - // static_cast(floor(256*fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max))); -// d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(16*fft_codes_padded[i].real() * (pow(2, 11) - 1) / max)), -// static_cast(floor(16*fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); - -// tmp_re = static_cast(floor(fft_codes_padded[i].real() * (pow(2, 7) - 1) / max)); -// tmp_im = static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max)); - -// if (tmp_re > 127) -// { -// tmp_re = 127; -// } -// if (tmp_re < -128) -// { -// tmp_re = -128; -// } -// if (tmp_im > 127) -// { -// tmp_im = 127; -// } -// if (tmp_im < -128) -// { -// tmp_im = -128; -// } -// d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(tmp_re), static_cast(tmp_im)); -// } -// // debug -// char filename2[25]; -// FILE *fid2; -// sprintf(filename2,"fft_gal_prn%d_norm.txt", PRN); -// fid2 = fopen(filename2, "w"); -// for (unsigned int kk=0;kk< nsamples_total; kk++) -// { -// fprintf(fid2, "%d\n", d_all_fft_codes_[kk + nsamples_total * (PRN - 1)].real()); -// fprintf(fid2, "%d\n", d_all_fft_codes_[kk + nsamples_total * (PRN - 1)].imag()); -// } -// fclose(fid2); - - - } - - // for (unsigned int PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) - // { - // // debug - // char filename2[25]; - // FILE *fid2; - // sprintf(filename2,"fft_gal_prn%d_norm_last.txt", PRN); - // fid2 = fopen(filename2, "w"); - // for (unsigned int kk=0;kk< nsamples_total; kk++) - // { - // fprintf(fid2, "%d\n", d_all_fft_codes_[kk + nsamples_total * (PRN - 1)].real()); - // fprintf(fid2, "%d\n", d_all_fft_codes_[kk + nsamples_total * (PRN - 1)].imag()); - // } - // fclose(fid2); - // } - - //acq_parameters - acq_parameters.all_fft_codes = d_all_fft_codes_; + // reference for the FPGA FFT-IFFT attenuation factor + acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 14); + + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + + channel_ = 0; + doppler_step_ = 0; + gnss_synchro_ = nullptr; + // temporary buffers that we can delete delete[] code; delete fft_if; delete[] fft_codes_padded; - - acq_parameters.total_block_exp = 12; - - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); - DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; - - // stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - // DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - - // if (item_type_.compare("cbyte") == 0) - // { - // cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); - // float_to_complex_ = gr::blocks::float_to_complex::make(); - // } - - channel_ = 0; - //threshold_ = 0.0; - doppler_step_ = 0; - gnss_synchro_ = nullptr; - //printf("top acq constructor end\n"); } GalileoE1PcpsAmbiguousAcquisitionFpga::~GalileoE1PcpsAmbiguousAcquisitionFpga() { - //printf("top acq destructor start\n"); - //delete[] code_; delete[] d_all_fft_codes_; - //printf("top acq destructor end\n"); } @@ -352,266 +196,88 @@ void GalileoE1PcpsAmbiguousAcquisitionFpga::stop_acquisition() void GalileoE1PcpsAmbiguousAcquisitionFpga::set_channel(unsigned int channel) { - //printf("top acq set channel start\n"); channel_ = channel; acquisition_fpga_->set_channel(channel_); - //printf("top acq set channel end\n"); } void GalileoE1PcpsAmbiguousAcquisitionFpga::set_threshold(float threshold) { - //printf("top acq set threshold start\n"); - // the .pfa parameter and the threshold calculation is only used for the CFAR algorithm. - // We don't use the CFAR algorithm in the FPGA. Therefore the threshold is set as such. - - // float pfa = configuration_->property(role_ + boost::lexical_cast(channel_) + ".pfa", 0.0); - // - // if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); - // - // if (pfa == 0.0) - // { - // threshold_ = threshold; - // } - // else - // { - // threshold_ = calculate_threshold(pfa); - // } - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold; acquisition_fpga_->set_threshold(threshold); - // acquisition_fpga_->set_threshold(threshold_); - //printf("top acq set threshold end\n"); } void GalileoE1PcpsAmbiguousAcquisitionFpga::set_doppler_max(unsigned int doppler_max) { - //printf("top acq set doppler max start\n"); doppler_max_ = doppler_max; - acquisition_fpga_->set_doppler_max(doppler_max_); - //printf("top acq set doppler max end\n"); } void GalileoE1PcpsAmbiguousAcquisitionFpga::set_doppler_step(unsigned int doppler_step) { - //printf("top acq set doppler step start\n"); doppler_step_ = doppler_step; - acquisition_fpga_->set_doppler_step(doppler_step_); - //printf("top acq set doppler step end\n"); } void GalileoE1PcpsAmbiguousAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro) { - //printf("top acq set gnss synchro start\n"); gnss_synchro_ = gnss_synchro; - acquisition_fpga_->set_gnss_synchro(gnss_synchro_); - //printf("top acq set gnss synchro end\n"); } signed int GalileoE1PcpsAmbiguousAcquisitionFpga::mag() { - // printf("top acq mag start\n"); return acquisition_fpga_->mag(); - //printf("top acq mag end\n"); } void GalileoE1PcpsAmbiguousAcquisitionFpga::init() { - // printf("top acq init start\n"); acquisition_fpga_->init(); - // printf("top acq init end\n"); - //set_local_code(); } void GalileoE1PcpsAmbiguousAcquisitionFpga::set_local_code() { - // printf("top acq set local code start\n"); - // bool cboc = configuration_->property( - // "Acquisition" + boost::lexical_cast(channel_) + ".cboc", false); - // - // std::complex* code = new std::complex[code_length_]; - // - // if (acquire_pilot_ == true) - // { - // //set local signal generator to Galileo E1 pilot component (1C) - // char pilot_signal[3] = "1C"; - // galileo_e1_code_gen_complex_sampled(code, pilot_signal, - // cboc, gnss_synchro_->PRN, fs_in_, 0, false); - // } - // else - // { - // galileo_e1_code_gen_complex_sampled(code, gnss_synchro_->Signal, - // cboc, gnss_synchro_->PRN, fs_in_, 0, false); - // } - // - // - // for (unsigned int i = 0; i < sampled_ms_ / 4; i++) - // { - // memcpy(&(code_[i * code_length_]), code, sizeof(gr_complex) * code_length_); - // } - - //acquisition_fpga_->set_local_code(code_); acquisition_fpga_->set_local_code(); - // delete[] code; - // printf("top acq set local code end\n"); } void GalileoE1PcpsAmbiguousAcquisitionFpga::reset() { - // printf("top acq reset start\n"); + // This command starts the acquisition process acquisition_fpga_->set_active(true); - // printf("top acq reset end\n"); } void GalileoE1PcpsAmbiguousAcquisitionFpga::set_state(int state) { - // printf("top acq set state start\n"); acquisition_fpga_->set_state(state); - // printf("top acq set state end\n"); } - -//float GalileoE1PcpsAmbiguousAcquisitionFpga::calculate_threshold(float pfa) -//{ -// unsigned int frequency_bins = 0; -// for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += doppler_step_) -// { -// frequency_bins++; -// } -// -// DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; -// -// unsigned int ncells = vector_length_ * frequency_bins; -// double exponent = 1 / static_cast(ncells); -// double val = pow(1.0 - pfa, exponent); -// double lambda = double(vector_length_); -// boost::math::exponential_distribution mydist(lambda); -// float threshold = static_cast(quantile(mydist, val)); -// -// return threshold; -//} - -// this function is only used for the unit tests -void GalileoE1PcpsAmbiguousAcquisitionFpga::set_single_doppler_flag(unsigned int single_doppler_flag) -{ - acquisition_fpga_->set_single_doppler_flag(single_doppler_flag); -} -// this function is only used for the unit tests -void GalileoE1PcpsAmbiguousAcquisitionFpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) - -{ - acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, second_magnitude, - initial_sample, doppler_index, total_fft_scaling_factor); -} - - -// this function is only used for the unit tests -void GalileoE1PcpsAmbiguousAcquisitionFpga::reset_acquisition(void) -{ - acquisition_fpga_->reset_acquisition(); -} - -// this function is only used for the unit tests -//void GalileoE1PcpsAmbiguousAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) -//{ -// acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); -//} - void GalileoE1PcpsAmbiguousAcquisitionFpga::connect(gr::top_block_sptr top_block) { - // printf("top acq connect\n"); - // if (item_type_.compare("gr_complex") == 0) - // { - // top_block->connect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // top_block->connect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); - // top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - // top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - // top_block->connect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } - // nothing to connect } void GalileoE1PcpsAmbiguousAcquisitionFpga::disconnect(gr::top_block_sptr top_block) { - // if (item_type_.compare("gr_complex") == 0) - // { - // top_block->disconnect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // top_block->disconnect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // // Since a byte-based acq implementation is not available, - // // we just convert cshorts to gr_complex - // top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); - // top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - // top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - // top_block->disconnect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } - // nothing to disconnect - // printf("top acq disconnect\n"); } gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisitionFpga::get_left_block() { - // printf("top acq get left block start\n"); - // if (item_type_.compare("gr_complex") == 0) - // { - // return stream_to_vector_; - // } - // else if (item_type_.compare("cshort") == 0) - // { - // return stream_to_vector_; - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // return cbyte_to_float_x2_; - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; return nullptr; - // } - // printf("top acq get left block end\n"); } gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisitionFpga::get_right_block() { - // printf("top acq get right block start\n"); return acquisition_fpga_; - // printf("top acq get right block end\n"); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index a24462b8f..96a5a90fa 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -1,12 +1,13 @@ /*! - * \file galileo_e1_pcps_ambiguous_acquisition.h + * \file galileo_e1_pcps_ambiguous_acquisition_fpga.h * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for * Galileo E1 Signals + * \author Marc Majoral, 2019. mmajoral(at)cttc.es * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -27,7 +28,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #ifndef GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ #define GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ @@ -60,7 +61,6 @@ public: inline std::string role() override { - // printf("top acq role\n"); return role_; } @@ -69,13 +69,11 @@ public: */ inline std::string implementation() override { - // printf("top acq implementation\n"); return "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga"; } size_t item_size() override { - // printf("top acq item size\n"); size_t item_size = sizeof(lv_16sc_t); return item_size; } @@ -137,27 +135,6 @@ public: */ void set_state(int state) override; - /*! - * \brief This function is only used in the unit tests - */ - void set_single_doppler_flag(unsigned int single_doppler_flag); - /*! - * \brief This function is only used in the unit tests - */ - void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); - - - /*! - * \brief This function is only used in the unit tests - */ - void reset_acquisition(void); - - /*! - * \brief This function is only used in the unit tests - */ - //void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); - /*! * \brief Stop running acquisition */ @@ -167,37 +144,25 @@ public: private: ConfigurationInterface* configuration_; - //pcps_acquisition_sptr acquisition_; pcps_acquisition_fpga_sptr acquisition_fpga_; gr::blocks::stream_to_vector::sptr stream_to_vector_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; - // size_t item_size_; - // std::string item_type_; - //unsigned int vector_length_; - //unsigned int code_length_; bool bit_transition_flag_; bool use_CFAR_algorithm_flag_; bool acquire_pilot_; unsigned int channel_; - //float threshold_; unsigned int doppler_max_; unsigned int doppler_step_; - //unsigned int sampled_ms_; unsigned int max_dwells_; - //long fs_in_; - //long if_; bool dump_; bool blocking_; std::string dump_filename_; - //std::complex* code_; Gnss_Synchro* gnss_synchro_; std::string role_; unsigned int in_streams_; unsigned int out_streams_; - //float calculate_threshold(float pfa); - // extra for the FPGA lv_16sc_t* d_all_fft_codes_; // memory that contains all the code ffts }; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 56b154fb1..29ce3778b 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -1,11 +1,12 @@ /*! - * \file galileo_e5a_pcps_acquisition.cc + * \file galileo_e5a_pcps_acquisition_fpga.cc * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * Galileo E5a data and pilot Signals + * Galileo E5a data and pilot Signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.es * \author Antonio Ramos, 2018. antonio.ramos(at)cttc.es * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -26,7 +27,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "galileo_e5a_pcps_acquisition_fpga.h" #include "Galileo_E5a.h" @@ -48,48 +49,27 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf in_streams_(in_streams), out_streams_(out_streams) { - //printf("creating the E5A acquisition"); pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - //std::string default_item_type = "cshort"; std::string default_dump_filename = "../data/acquisition.dat"; DLOG(INFO) << "Role " << role; - //item_type_ = configuration_->property(role + ".item_type", default_item_type); - - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); float downsampling_factor = configuration_->property(role + ".downsampling_factor", 1.0); acq_parameters.downsampling_factor = downsampling_factor; - printf("downsampling_factor = %f\n", downsampling_factor); fs_in = fs_in/downsampling_factor; acq_parameters.fs_in = fs_in; - //acq_parameters.freq = 0; - - //dump_ = configuration_->property(role + ".dump", false); - //acq_parameters.dump = dump_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms; - //max_dwells_ = configuration_->property(role + ".max_dwells", 1); - //acq_parameters.max_dwells = max_dwells_; - //dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - //acq_parameters.dump_filename = dump_filename_; - //bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - //acq_parameters.bit_transition_flag = bit_transition_flag_; - //use_CFAR_ = configuration_->property(role + ".use_CFAR_algorithm", false); - //acq_parameters.use_CFAR_algorithm_flag = use_CFAR_; - //blocking_ = configuration_->property(role + ".blocking", true); - //acq_parameters.blocking = blocking_; - //--- Find number of samples per spreading code (1ms)------------------------- acq_pilot_ = configuration_->property(role + ".acquire_pilot", false); acq_iq_ = configuration_->property(role + ".acquire_iq", false); @@ -100,15 +80,12 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf auto code_length = static_cast(std::round(static_cast(fs_in) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; + // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; - printf("code_length = %d\n", code_length); - printf("vector_length = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); - printf("select queue = %d\n", select_queue_Fpga); - //printf("acq adapter select_queue_Fpga = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); @@ -116,12 +93,9 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf acq_parameters.samples_per_ms = nsamples_total / sampled_ms; acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(ceil((1.0 / GALILEO_E5A_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters.fs_in))); - //vector_length_ = code_length_ * sampled_ms_; - - // compute all the GALILEO E5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time + // compute all the GALILEO E5 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT auto* code = new std::complex[nsamples_total]; // buffer for the local code @@ -129,27 +103,20 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf d_all_fft_codes_ = new lv_16sc_t[nsamples_total * GALILEO_E5A_NUMBER_OF_CODES]; // memory containing all the possible fft codes for PRN 0 to 32 float max; // temporary maxima search - //printf("creating the E5A acquisition CONT"); - //printf("nsamples_total = %d\n", nsamples_total); - for (unsigned int PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) { - // gr_complex* code = new gr_complex[code_length_]; char signal_[3]; if (acq_iq_) { - //printf("aaaaaaaaaaaaa\n"); strcpy(signal_, "5X"); } else if (acq_pilot_) { - //printf("bbbbbbbbbbbbb\n"); strcpy(signal_, "5Q"); } else { - //printf("cccccccccccc\n"); strcpy(signal_, "5I"); } @@ -159,14 +126,12 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf for (int s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; - //code[s] = 0; } // fill in zero padding for (int s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(0.0, 0.0); - //code[s] = 0; } memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer @@ -189,63 +154,32 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf { d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); - - //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t((2^3)*static_cast(floor(fft_codes_padded[i].real() * (pow(2, 6) - 1) / max)), - // (2^3)*static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 6) - 1) / max))); } } acq_parameters.all_fft_codes = d_all_fft_codes_; + // reference for the FPGA FFT-IFFT attenuation factor + acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 14); + + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + + channel_ = 0; + doppler_step_ = 0; + gnss_synchro_ = nullptr; + // temporary buffers that we can delete delete[] code; delete fft_if; delete[] fft_codes_padded; - //code_ = new gr_complex[vector_length_]; - - // if (item_type_.compare("gr_complex") == 0) - // { - // item_size_ = sizeof(gr_complex); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // item_size_ = sizeof(lv_16sc_t); - // } - // else - // { - // item_size_ = sizeof(gr_complex); - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } - //acq_parameters.it_size = item_size_; - //acq_parameters.samples_per_code = code_length_; - //acq_parameters.samples_per_ms = code_length_; - //acq_parameters.sampled_ms = sampled_ms_; - //acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); - //acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); - //acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); - //acquisition_ = pcps_make_acquisition(acq_parameters); - //acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); - //DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; - - acq_parameters.total_block_exp = 10; - - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); - DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; - - //stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - channel_ = 0; - //threshold_ = 0.0; - doppler_step_ = 0; - gnss_synchro_ = nullptr; - //printf("creating the E5A acquisition end"); } GalileoE5aPcpsAcquisitionFpga::~GalileoE5aPcpsAcquisitionFpga() { - //delete[] code_; delete[] d_all_fft_codes_; } @@ -260,33 +194,13 @@ void GalileoE5aPcpsAcquisitionFpga::stop_acquisition() void GalileoE5aPcpsAcquisitionFpga::set_channel(unsigned int channel) { channel_ = channel; - //acquisition_->set_channel(channel_); acquisition_fpga_->set_channel(channel_); } void GalileoE5aPcpsAcquisitionFpga::set_threshold(float threshold) { - // float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - // - // if (pfa == 0.0) - // { - // pfa = configuration_->property(role_ + ".pfa", 0.0); - // } - // - // if (pfa == 0.0) - // { - // threshold_ = threshold; - // } - // - // else - // { - // threshold_ = calculate_threshold(pfa); - // } - DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold; - - //acquisition_->set_threshold(threshold_); acquisition_fpga_->set_threshold(threshold); } @@ -294,7 +208,6 @@ void GalileoE5aPcpsAcquisitionFpga::set_threshold(float threshold) void GalileoE5aPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max) { doppler_max_ = doppler_max; - //acquisition_->set_doppler_max(doppler_max_); acquisition_fpga_->set_doppler_max(doppler_max_); } @@ -302,7 +215,6 @@ void GalileoE5aPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max) void GalileoE5aPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step) { doppler_step_ = doppler_step; - //acquisition_->set_doppler_step(doppler_step_); acquisition_fpga_->set_doppler_step(doppler_step_); } @@ -310,157 +222,57 @@ void GalileoE5aPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step) void GalileoE5aPcpsAcquisitionFpga::set_gnss_synchro(Gnss_Synchro* gnss_synchro) { gnss_synchro_ = gnss_synchro; - //acquisition_->set_gnss_synchro(gnss_synchro_); acquisition_fpga_->set_gnss_synchro(gnss_synchro_); } signed int GalileoE5aPcpsAcquisitionFpga::mag() { - //return acquisition_->mag(); return acquisition_fpga_->mag(); } void GalileoE5aPcpsAcquisitionFpga::init() { - //acquisition_->init(); acquisition_fpga_->init(); } void GalileoE5aPcpsAcquisitionFpga::set_local_code() { - // gr_complex* code = new gr_complex[code_length_]; - // char signal_[3]; - // - // if (acq_iq_) - // { - // strcpy(signal_, "5X"); - // } - // else if (acq_pilot_) - // { - // strcpy(signal_, "5Q"); - // } - // else - // { - // strcpy(signal_, "5I"); - // } - // - // galileo_e5_a_code_gen_complex_sampled(code, signal_, gnss_synchro_->PRN, fs_in_, 0); - // - // for (unsigned int i = 0; i < sampled_ms_; i++) - // { - // memcpy(code_ + (i * code_length_), code, sizeof(gr_complex) * code_length_); - // } - - //acquisition_->set_local_code(code_); acquisition_fpga_->set_local_code(); - // delete[] code; } void GalileoE5aPcpsAcquisitionFpga::reset() { - //acquisition_->set_active(true); acquisition_fpga_->set_active(true); } - -//float GalileoE5aPcpsAcquisitionFpga::calculate_threshold(float pfa) -//{ -// unsigned int frequency_bins = 0; -// for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += doppler_step_) -// { -// frequency_bins++; -// } -// DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; -// unsigned int ncells = vector_length_ * frequency_bins; -// double exponent = 1 / static_cast(ncells); -// double val = pow(1.0 - pfa, exponent); -// double lambda = double(vector_length_); -// boost::math::exponential_distribution mydist(lambda); -// float threshold = static_cast(quantile(mydist, val)); -// -// return threshold; -//} - - void GalileoE5aPcpsAcquisitionFpga::set_state(int state) { - //acquisition_->set_state(state); acquisition_fpga_->set_state(state); } -// this function is only used for the unit tests -void GalileoE5aPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_doppler_flag) -{ - acquisition_fpga_->set_single_doppler_flag(single_doppler_flag); -} -// this function is only used for the unit tests -void GalileoE5aPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) - -{ - acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, second_magnitude, - initial_sample, doppler_index, total_fft_scaling_factor); -} - -// this function is only used for the unit tests -void GalileoE5aPcpsAcquisitionFpga::reset_acquisition(void) -{ - acquisition_fpga_->reset_acquisition(); -} - -// this function is only used for the unit tests -//void GalileoE5aPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) -//{ -// acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); -//} - void GalileoE5aPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { - // if (item_type_.compare("gr_complex") == 0) - // { - // top_block->connect(stream_to_vector_, 0, acquisition_, 0); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // top_block->connect(stream_to_vector_, 0, acquisition_, 0); - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } + // nothing to connect } void GalileoE5aPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) { - // if (item_type_.compare("gr_complex") == 0) - // { - // top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } + // nothing to connect } gr::basic_block_sptr GalileoE5aPcpsAcquisitionFpga::get_left_block() { - //return stream_to_vector_; return nullptr; } gr::basic_block_sptr GalileoE5aPcpsAcquisitionFpga::get_right_block() { - //return acquisition_; return acquisition_fpga_; } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index 785a27622..9c63431f2 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -1,11 +1,12 @@ /*! - * \file galileo_e5a_pcps_acquisition.h + * \file galileo_e5a_pcps_acquisition_fpga.h * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * Galileo E5a data and pilot Signals + * Galileo E5a data and pilot Signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.es * \author Antonio Ramos, 2018. antonio.ramos(at)cttc.es * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -129,32 +130,18 @@ public: * \brief This function is only used in the unit tests */ void set_single_doppler_flag(unsigned int single_doppler_flag); - /*! - * \brief This function is only used in the unit tests - */ - void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); - - - /*! - * \brief This function is only used in the unit tests - */ - void reset_acquisition(void); - - /*! - * \brief This function is only used in the unit tests - */ - //void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); /*! * \brief Stop running acquisition */ void stop_acquisition() override; + /*! + * \brief Sets the resampler latency to account it in the acquisition code delay estimation + */ void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - //float calculate_threshold(float pfa); ConfigurationInterface* configuration_; @@ -189,16 +176,10 @@ private: float threshold_; - /* - std::complex* codeI_; - std::complex* codeQ_; - */ - gr_complex* code_; Gnss_Synchro* gnss_synchro_; - // extra for the FPGA lv_16sc_t* d_all_fft_codes_; // memory that contains all the code ffts }; #endif /* GALILEO_E5A_PCPS_ACQUISITION_FPGA_H_ */ diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index a9a61a116..2b3ec116f 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -1,9 +1,9 @@ /*! * \file gps_l1_ca_pcps_acquisition_fpga.cc - * \brief Adapts a PCPS acquisition block to an FPGA AcquisitionInterface - * for GPS L1 C/A signals + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface + * for GPS L1 C/A signals for the FPGA * \authors
    - *
  • Marc Majoral, 2018. mmajoral(at)cttc.es + *
  • Marc Majoral, 2019. mmajoral(at)cttc.es *
  • Javier Arribas, 2011. jarribas(at)cttc.es *
  • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
  • Marc Molina, 2013. marc.molina.pena(at)gmail.com @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -32,7 +32,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "gps_l1_ca_pcps_acquisition_fpga.h" #include "GPS_L1_CA.h" @@ -67,18 +67,11 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); float downsampling_factor = configuration_->property(role + ".downsampling_factor", 4.0); - printf("downsampling_factor = %f\n", downsampling_factor); acq_parameters.downsampling_factor = downsampling_factor; - //fs_in = fs_in/2.0; // downampling filter - //printf("fs_in pre downsampling = %ld\n", fs_in); - fs_in = fs_in/downsampling_factor; - //printf("fs_in post downsampling = %ld\n", fs_in); - //printf("####### DEBUG Acq: fs_in = %d\n", fs_in); acq_parameters.fs_in = fs_in; - //acq_parameters.samples_per_code = static_cast(ceil(GPS_L1_CA_CHIP_PERIOD * static_cast(acq_parameters.fs_in))); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; @@ -86,24 +79,19 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( acq_parameters.sampled_ms = sampled_ms; auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; - //printf("acq adapter code_length = %d\n", code_length); // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length*2)); unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; - //printf("acq adapter vector_length = %d\n", vector_length); unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); - //printf("select queue = %d\n", select_queue_Fpga); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); - //printf("acq adapter device name = %s\n", device_name.c_str()); acq_parameters.device_name = device_name; acq_parameters.samples_per_ms = nsamples_total / sampled_ms; - //printf("acq adapter samples_per_ms = %d\n", nsamples_total / sampled_ms); acq_parameters.samples_per_code = nsamples_total; acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L1_CA_CODE_RATE_HZ)); - //printf("excludelimit = %d\n", (int) acq_parameters.excludelimit); + // compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) auto* fft_if = new gr::fft::fft_complex(vector_length, true); // Direct FFT @@ -119,14 +107,12 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( for (int s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; - //code[s] = 0; } // fill in zero padding for (int s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(0.0, 0.0); - //code[s] = 0; } int offset = 0; @@ -134,19 +120,6 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( fft_if->execute(); // Run the FFT of local code volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values - - // // debug - // char filename[25]; - // FILE *fid; - // sprintf(filename,"fft_gps_prn%d.txt", PRN); - // fid = fopen(filename, "w"); - // for (unsigned int kk=0;kk< nsamples_total; kk++) - // { - // fprintf(fid, "%f\n", fft_codes_padded[kk].real()); - // fprintf(fid, "%f\n", fft_codes_padded[kk].imag()); - // } - // fclose(fid); - max = 0; // initialize maximum value for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima { @@ -161,39 +134,17 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( } for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(256*fft_codes_padded[i].real() * (pow(2, 7) - 1) / max)), - // static_cast(floor(256*fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max))); - //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(16*floor(fft_codes_padded[i].real() * (pow(2, 11) - 1) / max)), - // static_cast(16*floor(fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); - //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), - // static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } - - //// // debug - // char filename2[25]; - // FILE *fid2; - // sprintf(filename2,"fft_gps_prn%d_norm_new.txt", PRN); - // fid2 = fopen(filename2, "w"); - // for (unsigned int kk=0;kk< nsamples_total; kk++) - // { - // fprintf(fid2, "%d\n", d_all_fft_codes_[kk + nsamples_total * (PRN - 1)].real()); - // fprintf(fid2, "%d\n", d_all_fft_codes_[kk + nsamples_total * (PRN - 1)].imag()); - // } - // fclose(fid2); } //acq_parameters acq_parameters.all_fft_codes = d_all_fft_codes_; - // temporary buffers that we can delete - delete[] code; - delete fft_if; - delete[] fft_codes_padded; - - acq_parameters.total_block_exp = 14; + // reference for the FPGA FFT-IFFT attenuation factor + acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 14); acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; @@ -201,6 +152,12 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( channel_ = 0; doppler_step_ = 0; gnss_synchro_ = nullptr; + + // temporary buffers that we can delete + delete[] code; + delete fft_if; + delete[] fft_codes_padded; + } @@ -226,8 +183,6 @@ void GpsL1CaPcpsAcquisitionFpga::set_channel(unsigned int channel) void GpsL1CaPcpsAcquisitionFpga::set_threshold(float threshold) { - // the .pfa parameter and the threshold calculation is only used for the CFAR algorithm. - // We don't use the CFAR algorithm in the FPGA. Therefore the threshold is set as such. DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold; acquisition_fpga_->set_threshold(threshold); } @@ -274,9 +229,8 @@ void GpsL1CaPcpsAcquisitionFpga::set_local_code() void GpsL1CaPcpsAcquisitionFpga::reset() { - //printf("######### acq RESET called\n"); + // this function starts the acquisition process acquisition_fpga_->set_active(true); - //printf("acq reset end dddsss\n"); } @@ -286,33 +240,6 @@ void GpsL1CaPcpsAcquisitionFpga::set_state(int state) } -// this function is only used for the unit tests -void GpsL1CaPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_doppler_flag) -{ - acquisition_fpga_->set_single_doppler_flag(single_doppler_flag); -} -// this function is only used for the unit tests -void GpsL1CaPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) - -{ - acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, second_magnitude, - initial_sample, doppler_index, total_fft_scaling_factor); -} - -// this function is only used for the unit tests -void GpsL1CaPcpsAcquisitionFpga::reset_acquisition(void) -{ - acquisition_fpga_->reset_acquisition(); -} - -// this function is only used for the unit tests -//void GpsL1CaPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) -//{ -// acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); -//} - - void GpsL1CaPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { // nothing to connect diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index 1514763a5..ce5cdfc4a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -1,9 +1,9 @@ /*! * \file gps_l1_ca_pcps_acquisition_fpga.h - * \brief Adapts a PCPS acquisition block that uses the FPGA to - * an AcquisitionInterface for GPS L1 C/A signals + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface + * for GPS L1 C/A signals for the FPGA * \authors
      - *
    • Marc Majoral, 2018. mmajoral(at)cttc.es + *
    • Marc Majoral, 2019. mmajoral(at)cttc.es *
    • Javier Arribas, 2011. jarribas(at)cttc.es *
    • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
    • Marc Molina, 2013. marc.molina.pena(at)gmail.com @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -32,7 +32,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FPGA_H_ #define GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FPGA_H_ @@ -135,26 +135,6 @@ public: */ void set_state(int state) override; - /*! - * \brief This function is only used in the unit tests - */ - void set_single_doppler_flag(unsigned int single_doppler_flag); - /*! - * \brief This function is only used in the unit tests - */ - void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); - - /*! - * \brief This function is only used in the unit tests - */ - void reset_acquisition(void); - - /*! - * \brief This function is only used in the unit tests - */ - //void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); - /*! * \brief Stop running acquisition */ diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index f4a2ff2b5..cba789547 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -1,14 +1,15 @@ /*! - * \file gps_l5i pcps_acquisition.cc + * \file gps_l5i pcps_acquisition_fpga.cc * \brief Adapts a PCPS acquisition block to an Acquisition Interface for - * GPS L5i signals + * GPS L5i signals for the FPGA * \authors
        + *
      • Marc Majoral, 2017. mmajoral(at)cttc.es *
      • Javier Arribas, 2017. jarribas(at)cttc.es *
      * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -52,16 +53,12 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - //printf("L5 ACQ CLASS CREATED\n"); pcpsconf_fpga_t acq_parameters; configuration_ = configuration; - //std::string default_item_type = "cshort"; std::string default_dump_filename = "./data/acquisition.dat"; LOG(INFO) << "role " << role; - //item_type_ = configuration_->property(role + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); @@ -72,29 +69,12 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( acq_parameters.fs_in = fs_in; - //if_ = configuration_->property(role + ".if", 0); - //acq_parameters.freq = if_; - //dump_ = configuration_->property(role + ".dump", false); - //acq_parameters.dump = dump_; - //blocking_ = configuration_->property(role + ".blocking", true); - //acq_parameters.blocking = blocking_; doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - //acq_parameters.sampled_ms = 1; unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms; - //printf("L5 ACQ CLASS MID 0\n"); - - //bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - //acq_parameters.bit_transition_flag = bit_transition_flag_; - //use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions - //acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; - //max_dwells_ = configuration_->property(role + ".max_dwells", 1); - //acq_parameters.max_dwells = max_dwells_; - //dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - //acq_parameters.dump_filename = dump_filename_; //--- Find number of samples per spreading code ------------------------- auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); acq_parameters.code_length = code_length; @@ -103,10 +83,6 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( unsigned int nsamples_total = pow(2, nbits); unsigned int vector_length = nsamples_total; unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); - printf("code_length = %d\n", (int) code_length); - printf("vector length = %d\n", (int) vector_length); - printf("select queue = %d\n", select_queue_Fpga); - printf("sampled_ms = %d\n", sampled_ms); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); @@ -114,40 +90,29 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( acq_parameters.samples_per_ms = nsamples_total/sampled_ms; acq_parameters.samples_per_code = nsamples_total; - //acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L5i_CODE_RATE_HZ)); acq_parameters.excludelimit = static_cast(ceil((1.0 / GPS_L5I_CODE_RATE_HZ) * static_cast(acq_parameters.fs_in))); - //printf("L5 ACQ CLASS MID 01\n"); // compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) gr::fft::fft_complex* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT - //printf("L5 ACQ CLASS MID 02\n"); std::complex* code = new gr_complex[nsamples_total]; - //printf("L5 ACQ CLASS MID 03\n"); auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - //printf("L5 ACQ CLASS MID 04\n"); d_all_fft_codes_ = new lv_16sc_t[nsamples_total * NUM_PRNs]; // memory containing all the possible fft codes for PRN 0 to 32 - //printf("L5 ACQ CLASS MID 1 vector_length = %d\n", vector_length); - float max; // temporary maxima search for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) { - //printf("L5 ACQ CLASS processing PRN = %d\n", PRN); gps_l5i_code_gen_complex_sampled(code, PRN, fs_in); - //printf("L5 ACQ CLASS processing PRN = %d (cont) \n", PRN); - // fill in zero padding for (int s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; - //code[s] = 0; } for (int s = 2*code_length; s < nsamples_total; s++) { + // fill in zero padding code[s] = std::complex(static_cast(0,0)); - //code[s] = 0; } memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code @@ -167,76 +132,29 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( } for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(256*fft_codes_padded[i].real() * (pow(2, 7) - 1) / max)), - // static_cast(floor(256*fft_codes_padded[i].imag() * (pow(2, 7) - 1) / max))); - //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(16*floor(fft_codes_padded[i].real() * (pow(2, 11) - 1) / max)), - // static_cast(16*floor(fft_codes_padded[i].imag() * (pow(2, 11) - 1) / max))); - //d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 15) - 1) / max)), - // static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 15) - 1) / max))); d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } - - } - - - //printf("L5 ACQ CLASS MID 2\n"); - //acq_parameters acq_parameters.all_fft_codes = d_all_fft_codes_; + // reference for the FPGA FFT-IFFT attenuation factor + acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 14); + + acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); + DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; + + channel_ = 0; + doppler_step_ = 0; + gnss_synchro_ = nullptr; + // temporary buffers that we can delete delete[] code; delete fft_if; delete[] fft_codes_padded; - // vector_length_ = code_length_; - // - // if (bit_transition_flag_) - // { - // vector_length_ *= 2; - // } - // - // code_ = new gr_complex[vector_length_]; - // - // if (item_type_.compare("cshort") == 0) - // { - // item_size_ = sizeof(lv_16sc_t); - // } - // else - // { - // item_size_ = sizeof(gr_complex); - // } - // acq_parameters.samples_per_code = code_length_; - // acq_parameters.samples_per_ms = code_length_; - // acq_parameters.it_size = item_size_; - //acq_parameters.sampled_ms = 1; - // acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); - // acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); - // acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", false); - // acquisition_fpga_ = pcps_make_acquisition(acq_parameters); - // DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; - acq_parameters.total_block_exp = 10; - - acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); - DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; - - // stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - // DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - // - // if (item_type_.compare("cbyte") == 0) - // { - // cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); - // float_to_complex_ = gr::blocks::float_to_complex::make(); - // } - - channel_ = 0; - // threshold_ = 0.0; - doppler_step_ = 0; - gnss_synchro_ = nullptr; - //printf("L5 ACQ CLASS FINISHED\n"); } @@ -263,25 +181,6 @@ void GpsL5iPcpsAcquisitionFpga::set_channel(unsigned int channel) void GpsL5iPcpsAcquisitionFpga::set_threshold(float threshold) { - // float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - // - // if (pfa == 0.0) - // { - // pfa = configuration_->property(role_ + ".pfa", 0.0); - // } - // if (pfa == 0.0) - // { - // threshold_ = threshold; - // } - // else - // { - // threshold_ = calculate_threshold(pfa); - // } - - // DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - - // the .pfa parameter and the threshold calculation is only used for the CFAR algorithm. - // We don't use the CFAR algorithm in the FPGA. Therefore the threshold is set as such. DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold; acquisition_fpga_->set_threshold(threshold); } @@ -293,7 +192,6 @@ void GpsL5iPcpsAcquisitionFpga::set_doppler_max(unsigned int doppler_max) acquisition_fpga_->set_doppler_max(doppler_max_); } - // Be aware that Doppler step should be set to 2/(3T) Hz, where T is the coherent integration time (GPS L2 period is 0.02s) // Doppler bin minimum size= 33 Hz void GpsL5iPcpsAcquisitionFpga::set_doppler_step(unsigned int doppler_step) @@ -337,126 +235,20 @@ void GpsL5iPcpsAcquisitionFpga::set_state(int state) acquisition_fpga_->set_state(state); } - -//float GpsL5iPcpsAcquisitionFpga::calculate_threshold(float pfa) -//{ -// //Calculate the threshold -// unsigned int frequency_bins = 0; -// for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += doppler_step_) -// { -// frequency_bins++; -// } -// DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; -// unsigned int ncells = vector_length_ * frequency_bins; -// double exponent = 1.0 / static_cast(ncells); -// double val = pow(1.0 - pfa, exponent); -// double lambda = double(vector_length_); -// boost::math::exponential_distribution mydist(lambda); -// float threshold = static_cast(quantile(mydist, val)); -// -// return threshold; -//} - - -// this function is only used for the unit tests -void GpsL5iPcpsAcquisitionFpga::set_single_doppler_flag(unsigned int single_doppler_flag) -{ - acquisition_fpga_->set_single_doppler_flag(single_doppler_flag); -} -// this function is only used for the unit tests -void GpsL5iPcpsAcquisitionFpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) - -{ - acquisition_fpga_->read_acquisition_results(max_index, max_magnitude, second_magnitude, - initial_sample, doppler_index, total_fft_scaling_factor); -} - - - -// this function is only used for the unit tests -void GpsL5iPcpsAcquisitionFpga::reset_acquisition(void) -{ - acquisition_fpga_->reset_acquisition(); -} - -// this function is only used for the unit tests -//void GpsL5iPcpsAcquisitionFpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) -//{ -// acquisition_fpga_->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); -//} - void GpsL5iPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { - // if (item_type_.compare("gr_complex") == 0) - // { - // top_block->connect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // top_block->connect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); - // top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - // top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - // top_block->connect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } // nothing to connect } void GpsL5iPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) { - // if (item_type_.compare("gr_complex") == 0) - // { - // top_block->disconnect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // top_block->disconnect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // // Since a byte-based acq implementation is not available, - // // we just convert cshorts to gr_complex - // top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); - // top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - // top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - // top_block->disconnect(stream_to_vector_, 0, acquisition_fpga_, 0); - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } // nothing to disconnect } gr::basic_block_sptr GpsL5iPcpsAcquisitionFpga::get_left_block() { - // if (item_type_.compare("gr_complex") == 0) - // { - // return stream_to_vector_; - // } - // else if (item_type_.compare("cshort") == 0) - // { - // return stream_to_vector_; - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // return cbyte_to_float_x2_; - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // return nullptr; - // } return nullptr; } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index f06533097..7e15f4df7 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -1,14 +1,15 @@ /*! - * \file GPS_L5i_PCPS_Acquisition.h + * \file GPS_L5i_PCPS_Acquisition_fpga.h * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * GPS L5i signals + * GPS L5i signals for the FPGA * \authors
        + *
      • Marc Majoral, 2019. mmajoral(at)cttc.es *
      • Javier Arribas, 2017. jarribas(at)cttc.es *
      * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -135,27 +136,6 @@ public: */ void set_state(int state) override; - /*! - * \brief This function is only used in the unit tests - */ - void set_single_doppler_flag(unsigned int single_doppler_flag); - /*! - * \brief This function is only used in the unit tests - */ - void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); - - - /*! - * \brief This function is only used in the unit tests - */ - void reset_acquisition(void); - - /*! - * \brief This function is only used in the unit tests - */ - //void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); - /*! * \brief Stop running acquisition */ @@ -165,7 +145,6 @@ public: private: ConfigurationInterface* configuration_; - //pcps_acquisition_sptr acquisition_; pcps_acquisition_fpga_sptr acquisition_fpga_; gr::blocks::stream_to_vector::sptr stream_to_vector_; gr::blocks::float_to_complex::sptr float_to_complex_; @@ -182,7 +161,6 @@ private: unsigned int doppler_step_; unsigned int max_dwells_; int64_t fs_in_; - //long if_; bool dump_; bool blocking_; std::string dump_filename_; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 205c8a366..34c2a2cf0 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -1,12 +1,8 @@ /*! * \file pcps_acquisition_fpga.cc - * \brief This class implements a Parallel Code Phase Search Acquisition in the FPGA - * - * Note: The CFAR algorithm is not implemented in the FPGA. - * Note 2: The bit transition flag is not implemented in the FPGA - * + * \brief This class implements a Parallel Code Phase Search Acquisition for the FPGA * \authors
        - *
      • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
      • Marc Majoral, 2019. mmajoral(at)cttc.es *
      • Javier Arribas, 2011. jarribas(at)cttc.es *
      • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
      • Marc Molina, 2013. marc.molina.pena@gmail.com @@ -15,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -33,10 +29,10 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . + * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "pcps_acquisition_fpga.h" @@ -60,14 +56,12 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) { - // printf("acq constructor start\n"); this->message_port_register_out(pmt::mp("events")); acq_parameters = std::move(conf_); d_sample_counter = 0ULL; // SAMPLE COUNTER d_active = false; d_state = 0; - //d_fft_size = acq_parameters.sampled_ms * acq_parameters.samples_per_ms; d_fft_size = acq_parameters.samples_per_code; d_mag = 0; d_input_power = 0.0; @@ -77,58 +71,32 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( d_test_statistics = 0.0; d_channel = 0U; d_gnss_synchro = nullptr; - d_single_doppler_flag = false; d_downsampling_factor = acq_parameters.downsampling_factor; - //printf("CONSTRUCTOR downsampling_factor = %d\n", (int) d_downsampling_factor); d_select_queue_Fpga = acq_parameters.select_queue_Fpga; - //printf("zzzz acq_parameters.code_length = %d\n", acq_parameters.code_length); - //printf("zzzz acq_parameters.samples_per_ms = %d\n", acq_parameters.samples_per_ms); - //printf("zzzz d_fft_size = %d\n", d_fft_size); - - // this one works we don't know why - // acquisition_fpga = std::make_shared - // (acq_parameters.device_name, acq_parameters.code_length, acq_parameters.doppler_max, acq_parameters.samples_per_ms, - // acq_parameters.fs_in, acq_parameters.freq, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes); - d_total_block_exp = acq_parameters.total_block_exp; - // this one is the one it should be but it doesn't work acquisition_fpga = std::make_shared(acq_parameters.device_name, acq_parameters.code_length, acq_parameters.doppler_max, d_fft_size, acq_parameters.fs_in, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes, acq_parameters.excludelimit); - // acquisition_fpga = std::make_shared - // (acq_parameters.device_name, acq_parameters.samples_per_code, acq_parameters.doppler_max, acq_parameters.samples_per_code, - // acq_parameters.fs_in, acq_parameters.freq, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes); - - - // debug - //debug_d_max_absolute = 0.0; - //debug_d_input_power_absolute = 0.0; - // printf("acq constructor end\n"); } pcps_acquisition_fpga::~pcps_acquisition_fpga() { - // printf("acq destructor start\n"); acquisition_fpga->free(); - // printf("acq destructor end\n"); } void pcps_acquisition_fpga::set_local_code() { - // printf("acq set local code start\n"); acquisition_fpga->set_local_code(d_gnss_synchro->PRN); - // printf("acq set local code end\n"); } void pcps_acquisition_fpga::init() { - // printf("acq init start\n"); d_gnss_synchro->Flag_valid_acquisition = false; d_gnss_synchro->Flag_valid_symbol_output = false; d_gnss_synchro->Flag_valid_pseudorange = false; @@ -139,32 +107,20 @@ void pcps_acquisition_fpga::init() d_mag = 0.0; d_input_power = 0.0; - if (d_single_doppler_flag == 1) - { - d_num_doppler_bins = 1; - } - else - { - d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))) + 1; - } - //printf("acq gnuradioblock doppler_max = %lu\n", (unsigned long) static_cast(acq_parameters.doppler_max)); - //printf("acq gnuradioblock doppler_step = %lu\n", (unsigned long) d_doppler_step); - //printf("acq gnuradioblock d_num_doppler_bins = %lu\n", (unsigned long) d_num_doppler_bins); - acquisition_fpga->init(); - // printf("acq init end\n"); + d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))) + 1; + + acquisition_fpga->init(); } void pcps_acquisition_fpga::set_state(int32_t state) { - // printf("acq set state start\n"); d_state = state; if (d_state == 1) { d_gnss_synchro->Acq_delay_samples = 0.0; d_gnss_synchro->Acq_doppler_hz = 0.0; d_gnss_synchro->Acq_samplestamp_samples = 0; - //d_well_count = 0; d_mag = 0.0; d_input_power = 0.0; d_test_statistics = 0.0; @@ -177,14 +133,12 @@ void pcps_acquisition_fpga::set_state(int32_t state) { LOG(ERROR) << "State can only be set to 0 or 1"; } - // printf("acq set state end\n"); } void pcps_acquisition_fpga::send_positive_acquisition() { - // printf("acq send positive acquisition start\n"); - // 6.1- Declare positive acquisition using a message port + // Declare positive acquisition using a message port //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL DLOG(INFO) << "positive acquisition" << ", satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN @@ -196,17 +150,13 @@ void pcps_acquisition_fpga::send_positive_acquisition() << ", magnitude " << d_mag << ", input signal power " << d_input_power; - //printf("acq sending positive acquisition\n"); this->message_port_pub(pmt::mp("events"), pmt::from_long(1)); - // printf("acq send positive acquisition end\n"); } void pcps_acquisition_fpga::send_negative_acquisition() { - // printf("acq send negative acquisition start\n"); - // 6.2- Declare negative acquisition using a message port - //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + // Declare negative acquisition using a message port DLOG(INFO) << "negative acquisition" << ", satellite " << d_gnss_synchro->System << " " << d_gnss_synchro->PRN << ", sample_stamp " << d_sample_counter @@ -217,16 +167,13 @@ void pcps_acquisition_fpga::send_negative_acquisition() << ", magnitude " << d_mag << ", input signal power " << d_input_power; - //printf("acq sending negative acquisition\n"); this->message_port_pub(pmt::mp("events"), pmt::from_long(2)); - // printf("acq send negative acquisition end\n"); } void pcps_acquisition_fpga::set_active(bool active) { - // printf("acq set active start\n"); d_active = active; // initialize acquisition algorithm @@ -234,7 +181,6 @@ void pcps_acquisition_fpga::set_active(bool active) float firstpeak = 0.0; float secondpeak = 0.0; uint32_t total_block_exp; - //float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); d_input_power = 0.0; d_mag = 0.0; @@ -255,136 +201,22 @@ void pcps_acquisition_fpga::set_active(bool active) float temp_d_input_power; - // debug - //acquisition_fpga->block_samples(); - - - // while(1) - //{ - - //printf("######### acq ENTERING SET ACTIVE\n"); - - // run loop in hw - //printf("LAUNCH ACQ\n"); - //printf("acq lib d_num_doppler_bins = %d\n", d_num_doppler_bins); - //printf("writing config for channel %d -----------------------------------------\n", (int) d_channel); - - - //printf("d_downsampling_factor = %f\n", d_downsampling_factor); - - //printf("acq_parameters.code_length = %d\n", (int) acq_parameters.code_length); - // debug -// if (acq_parameters.code_length == 12500) -// { -// acquisition_fpga->configure_acquisition_debug(); -// acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); -// acquisition_fpga->write_local_code(); -// acquisition_fpga->set_block_exp(d_total_block_exp); -// -// acquisition_fpga->run_acquisition(); -// acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); -// -// doppler = 0; -// d_test_statistics = 0; -// } -// else -// { - - - acquisition_fpga->configure_acquisition(); acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); - - - - //printf("d_num_doppler_bins = %d\n", (int) d_num_doppler_bins); acquisition_fpga->write_local_code(); - - - - //acquisition_fpga->set_doppler_sweep(2); - //printf("acq lib going to launch acquisition\n"); acquisition_fpga->set_block_exp(d_total_block_exp); - - - - - //printf("running acq for channel %d\n", (int) d_channel); - acquisition_fpga->run_acquisition(); - //printf("acq lib going to read the acquisition results\n"); - //read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index); - - - //printf("reading results for channel %d\n", (int) d_channel); acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); - - - //printf("returned d_doppler_index = %d\n", d_doppler_index); - - //printf("gnuradio block : d_total_block_exp = %d total_block_exp = %d\n", (int) d_total_block_exp, (int) total_block_exp); - - //printf("d_fft_size = %d = %d\n", d_fft_size, acq_parameters.samples_per_code); - //printf("indext = %d\n", (int) indext); - //printf("initial_sample = %d\n", (int) initial_sample); - //printf("firstpeak = %d\n", (int) firstpeak); - //printf("secondpeak = %d\n", (int) secondpeak); - //printf("total_block_exp = %d\n", (int) total_block_exp); -// if (total_block_exp == 11) -// { -// printf("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE\n"); -// getchar(); -// -// } -// if (total_block_exp > d_total_block_exp) -// { -// usleep(5000000); -// acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); -// printf("second time d_fft_size = %d = %d", d_fft_size, acq_parameters.samples_per_code); -// printf("second time indext = %d\n", (int) indext); -// printf("second time initial_sample = %d\n", (int) initial_sample); -// printf("second time firstpeak = %d\n", (int) firstpeak); -// printf("second time secondpeak = %d\n", (int) secondpeak); -// printf("second time total_block_exp = %d\n", (int) total_block_exp); -// } - if (total_block_exp > d_total_block_exp) { - printf("changing blk exp..... d_total_block_exp = %d total_block_exp = %d chan = %d\n", d_total_block_exp, total_block_exp, d_channel); - //getchar(); + // if the attenuation factor of the FPGA FFT-IFFT is smaller than the reference attenuation factor then we need to update the reference attenuation factor + std::cout << "changing blk exp..... d_total_block_exp = " << d_total_block_exp << " total_block_exp = " << total_block_exp << " chan = " << d_channel << std::endl; d_total_block_exp = total_block_exp; } - - - - //printf("end channel %d -----------------------------------------------------\n", (int) d_channel); - //printf("READ ACQ RESULTS\n"); - - // debug - //acquisition_fpga->unblock_samples(); - - - //usleep(5000000); - //} // end while test - - //int32_t doppler; - - // NEW SATELLITE DETECTION ALGORITHM STARTS HERE ---------------------------------------------------- - - - - if (d_single_doppler_flag == false) - { - doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); - //doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index); // this is the wrong one - } - else - { - doppler = static_cast(acq_parameters.doppler_max); - } + doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); if (secondpeak > 0) { @@ -395,40 +227,6 @@ void pcps_acquisition_fpga::set_active(bool active) d_test_statistics = 0.0; } - - - -// // OLD SATELLITE DETECTION ALGORITHM STARTS HERE ---------------------------------------------------- -// -// d_mag = magt; -// -// -// // debug -// //debug_d_max_absolute = magt; -// //debug_d_input_power_absolute = d_input_power; -// //debug_indext = indext; -// //debug_doppler_index = d_doppler_index; -// -// // temp_d_input_power = d_input_power; -// -// d_input_power = (d_input_power - d_mag) / (d_fft_size - 1); -// //int32_t doppler; -// if (d_single_doppler_flag == false) -// { -// doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); -// //doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index); // this is the wrong one -// } -// else -// { -// doppler = static_cast(acq_parameters.doppler_max); -// } -// //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % (2*acq_parameters.samples_per_code))); -// -// -// //printf("acq gnuradioblock doppler = %d\n", doppler); -// -// // END OF OLD SATELLITE ALGORITHM -------------------------------------------------------------------- - d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_sample_counter = initial_sample; @@ -437,86 +235,27 @@ void pcps_acquisition_fpga::set_active(bool active) if (d_downsampling_factor > 1) { - //printf("yes here\n"); - //d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext % acq_parameters.samples_per_code)); d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext)); - //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81/d_downsampling_factor; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % acq_parameters.samples_per_code)); - //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext)); - //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter*2 - 81; - //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); - //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; } else { - //printf("xxxxxxxxxxxxxxxx no here\n"); - //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); d_gnss_synchro->Acq_delay_samples = static_cast(indext); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5*d_downsampling_factor; } } else { - //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); d_gnss_synchro->Acq_delay_samples = static_cast(indext); d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition } - - - //d_gnss_synchro->Acq_samplestamp_samples = 2*d_sample_counter - 81; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition - -// // OLD SATELLITE DETECTION ALGORITHM STARTS HERE AGAIN ----------------------------------------------- -// -// d_test_statistics = (d_mag / d_input_power); //* correction_factor; -// -// // END OF OLD SATELLITE ALGORITHM AGAIN -------------------------------------------------------------------- - - - - // debug - // if (d_gnss_synchro->Acq_delay_samples > acq_parameters.code_length) - // { - // printf("d_gnss_synchro->Acq_samplestamp_samples = %d\n", d_gnss_synchro->Acq_samplestamp_samples); - // printf("d_gnss_synchro->Acq_delay_samples = %f\n", d_gnss_synchro->Acq_delay_samples); - // } - - // if (temp_d_input_power > debug_d_input_power_absolute) - // { - // debug_d_max_absolute = d_mag; - // debug_d_input_power_absolute = temp_d_input_power; - // } - // printf ("max debug_d_max_absolute = %f\n", debug_d_max_absolute); - // printf ("debug_d_input_power_absolute = %f\n", debug_d_input_power_absolute); - - // printf("&&&&& d_test_statistics = %f\n", d_test_statistics); - // printf("&&&&& debug_d_max_absolute =%f\n",debug_d_max_absolute); - // printf("&&&&& debug_d_input_power_absolute =%f\n",debug_d_input_power_absolute); - // printf("&&&&& debug_indext = %d\n",debug_indext); - // printf("&&&&& debug_doppler_index = %d\n",debug_doppler_index); - if (d_test_statistics > d_threshold) { d_active = false; -// printf("##### d_test_statistics = %f\n", d_test_statistics); -// printf("##### firstpeak =%f\n",firstpeak); -// printf("##### secondpeak =%f\n",secondpeak); -// printf("##### d_gnss_synchro->Acq_delay_samples = %d\n",(int) d_gnss_synchro->Acq_delay_samples); -// printf("##### d_gnss_synchro->Acq_samplestamp_samples = %d\n",(int) d_gnss_synchro->Acq_samplestamp_samples); send_positive_acquisition(); d_state = 0; // Positive acquisition - - //printf("acq POSITIVE ACQ d_fft_size = %d = %d\n", d_fft_size, acq_parameters.samples_per_code); - //printf("acq POSITIVE ACQ d_gnss_synchro->Acq_delay_samples = %f\n: ",d_gnss_synchro->Acq_delay_samples); - //printf("acq POSITIVE ACQ d_gnss_synchro->Acq_samplestamp_samples = %d\n", (unsigned int) d_gnss_synchro->Acq_samplestamp_samples); - //printf("acq POSITIVE ACQ d_gnss_synchro->Acq_doppler_hz = %f\n", d_gnss_synchro->Acq_doppler_hz); - //printf("acq POSITIVE ACQ d_gnss_synchro->PRN = %d\n", (int) d_gnss_synchro->PRN); } else { @@ -524,9 +263,6 @@ void pcps_acquisition_fpga::set_active(bool active) d_active = false; send_negative_acquisition(); } - - //printf("######### acq LEAVING SET ACTIVE\n"); - //printf("acq set active end\n"); } @@ -534,71 +270,13 @@ int pcps_acquisition_fpga::general_work(int noutput_items __attribute__((unused) gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, gr_vector_void_star& output_items __attribute__((unused))) { - //printf("ACQ GENERAL WORK CALLED\n"); // the general work is not used with the acquisition that uses the FPGA return noutput_items; } - -// this function is only used for the unit tests -void pcps_acquisition_fpga::set_single_doppler_flag(unsigned int single_doppler_flag) -{ - acquisition_fpga->set_single_doppler_flag(single_doppler_flag); - d_single_doppler_flag = true; -} - -// this function is only used for the unit tests -void pcps_acquisition_fpga::read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor) -{ - float input_power; // not used - uint32_t max_index_tmp; - uint64_t initial_sample_tmp; - acquisition_fpga->read_acquisition_results(&max_index_tmp, max_magnitude, second_magnitude, &initial_sample_tmp, &input_power, doppler_index, total_fft_scaling_factor); - - - if (d_select_queue_Fpga == 0) - { - if (d_downsampling_factor > 1) - { - //printf("yes here\n"); - *max_index = static_cast(d_downsampling_factor*(max_index_tmp)); - //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.25*d_downsampling_factor; // delay due to the downsampling filter in the acquisition - *initial_sample = (initial_sample_tmp)*d_downsampling_factor - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81/d_downsampling_factor; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext % acq_parameters.samples_per_code)); - //d_gnss_synchro->Acq_delay_samples = static_cast(2*(indext)); - //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter*2 - 81; - //d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); - //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; - - } - else - { - //printf("xxxxxxxxxxxxxxxx no here\n"); - //max_index = static_cast(indext % acq_parameters.samples_per_code); - //initial_sample = d_sample_counter; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter - 40; // delay due to the downsampling filter in the acquisition - //d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 81*0.5*d_downsampling_factor; - } - } -// printf("gnuradioblock acq samplestamp = %d\n", (int) *initial_sample); -// else -// { -// d_gnss_synchro->Acq_delay_samples = static_cast(indext % acq_parameters.samples_per_code); -// d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition -// } - - - - -// acquisition_fpga->read_acquisition_results(max_index, max_magnitude, -// initial_sample, power_sum, doppler_index); -} - -// this function is only used for the unit tests void pcps_acquisition_fpga::reset_acquisition(void) { + // this function triggers a HW reset of the FPGA PL. acquisition_fpga->reset_acquisition(); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index acf505bde..f551e0778 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -1,26 +1,14 @@ /*! * \file pcps_acquisition_fpga.h - * \brief This class implements a Parallel Code Phase Search Acquisition in the FPGA. + * \brief This class implements a Parallel Code Phase Search Acquisition for the FPGA * - * Note: The CFAR algorithm is not implemented in the FPGA. - * Note 2: The bit transition flag is not implemented in the FPGA - * - * Acquisition strategy (Kay Borre book + CFAR threshold). - *
          - *
        1. Compute the input signal power estimation - *
        2. Doppler serial search loop - *
        3. Perform the FFT-based circular convolution (parallel time search) - *
        4. Record the maximum peak and the associated synchronization parameters - *
        5. Compute the test statistics and compare to the threshold - *
        6. Declare positive or negative acquisition using a message queue - *
        * * Kay Borre book: K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, * "A Software-Defined GPS and Galileo Receiver. A Single-Frequency * Approach", Birkhauser, 2007. pp 81-84 * * \authors
          - *
        • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
        • Marc Majoral, 2019. mmajoral(at)cttc.es *
        • Javier Arribas, 2011. jarribas(at)cttc.es *
        • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
        • Marc Molina, 2013. marc.molina.pena@gmail.com @@ -30,7 +18,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -51,7 +39,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #ifndef GNSS_SDR_PCPS_ACQUISITION_FPGA_H_ #define GNSS_SDR_PCPS_ACQUISITION_FPGA_H_ @@ -122,15 +110,8 @@ private: Gnss_Synchro* d_gnss_synchro; std::shared_ptr acquisition_fpga; - // debug - //float debug_d_max_absolute; - //float debug_d_input_power_absolute; - //int32_t debug_indext; - //int32_t debug_doppler_index; - float d_downsampling_factor; uint32_t d_select_queue_Fpga; - bool d_single_doppler_flag; uint32_t d_total_block_exp; @@ -145,9 +126,7 @@ public: */ inline void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { - // printf("acq set gnss synchro start\n"); d_gnss_synchro = p_gnss_synchro; - // printf("acq set gnss synchro end\n"); } /*! @@ -155,9 +134,7 @@ public: */ inline uint32_t mag() const { - // printf("acq dmag start\n"); return d_mag; - // printf("acq dmag end\n"); } /*! @@ -238,19 +215,7 @@ public: gr_vector_void_star& output_items); /*! - * \brief This function is only used for the unit tests - */ - void set_single_doppler_flag(unsigned int single_doppler_flag); - - /*! - * \brief This funciton is only used for the unit tests - */ - void read_acquisition_results(uint32_t *max_index, - float *max_magnitude, float *second_magnitude, uint64_t *initial_sample, uint32_t *doppler_index, uint32_t *total_fft_scaling_factor); - - - /*! - * \brief This funciton is only used for the unit tests + * \brief This funciton triggers a HW reset of the FPGA PL. */ void reset_acquisition(void); diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 1a9924c11..18264bc58 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -2,7 +2,7 @@ * \file fpga_acquisition.cc * \brief High optimized FPGA vector correlator class * \authors
            - *
          • Marc Majoral, 2018. mmajoral(at)cttc.cat + *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat *
          * * Class that controls and executes a high optimized acquisition HW @@ -31,7 +31,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "fpga_acquisition.h" #include "GPS_L1_CA.h" @@ -42,10 +42,9 @@ #include // libraries used by the GIPO #include -#include // for the usleep function only (debug) - +// FPGA register parameters #define PAGE_SIZE 0x10000 // default page size for the multicorrelator memory map #define MAX_PHASE_STEP_RAD 0.999999999534339 // 1 - pow(2,-31); #define RESET_ACQUISITION 2 // command to reset the multicorrelator @@ -59,50 +58,28 @@ #define SELECT_MSB 0XFF00 // value to select the most significant byte #define SELECT_16_BITS 0xFFFF // value to select 16 bits #define SHL_8_BITS 256 // value used to shift a value 8 bits to the left - -// 12-bits -//#define SELECT_LSBits 0x0FFF -//#define SELECT_MSBbits 0x00FFF000 -//#define SELECT_24_BITS 0x00FFFFFF -//#define SHL_12_BITS 4096 -// 16-bits -#define SELECT_LSBits 0x000003FF -#define SELECT_MSBbits 0x000FFC00 -#define SELECT_ALL_CODE_BITS 0x000FFFFF -#define SHL_CODE_BITS 1024 +#define SELECT_LSBits 0x000003FF // Select the 10 LSbits out of a 20-bit word +#define SELECT_MSBbits 0x000FFC00 // Select the 10 MSbits out of a 20-bit word +#define SELECT_ALL_CODE_BITS 0x000FFFFF // Select a 20 bit word +#define SHL_CODE_BITS 1024 // shift left by 10 bits bool fpga_acquisition::init() { - //printf("acq lib init called\n"); - // configure the acquisition with the main initialization values - //fpga_acquisition::configure_acquisition(); return true; } bool fpga_acquisition::set_local_code(uint32_t PRN) { - //printf("acq lib set_local_code_called\n"); // select the code with the chosen PRN d_PRN = PRN; -// printf("#### ACQ: WRITING LOCAL CODE for PRN %d\n", (int) PRN); -// -// fpga_acquisition::fpga_configure_acquisition_local_code( -// &d_all_fft_codes[d_nsamples_total * (PRN - 1)]); - - //fpga_acquisition::fpga_configure_acquisition_local_code( - // &d_all_fft_codes[0]); - return true; } void fpga_acquisition::write_local_code() { - //printf("#### ACQ: WRITING LOCAL CODE for PRN %d\n", (int) d_PRN); - - fpga_acquisition::fpga_configure_acquisition_local_code( &d_all_fft_codes[d_nsamples_total * (d_PRN - 1)]); @@ -116,15 +93,10 @@ fpga_acquisition::fpga_acquisition(std::string device_name, lv_16sc_t *all_fft_codes, uint32_t excludelimit) { - //printf("acq lib constructor called\n"); - //printf("AAA- sampled_ms = %d\n ", sampled_ms); + uint32_t vector_length = nsamples_total; - uint32_t vector_length = nsamples_total; // * sampled_ms; - - //printf("AAA- vector_length = %d\n ", vector_length); // initial values d_device_name = std::move(device_name); - //d_freq = freq; d_fs_in = fs_in; d_vector_length = vector_length; d_excludelimit = excludelimit; @@ -136,56 +108,12 @@ fpga_acquisition::fpga_acquisition(std::string device_name, d_fd = 0; // driver descriptor d_map_base = nullptr; // driver memory map d_all_fft_codes = all_fft_codes; -/* - //printf("acq internal device name = %s\n", d_device_name.c_str()); - // open communication with HW accelerator - if ((d_fd = open(d_device_name.c_str(), O_RDWR | O_SYNC)) == -1) - { - LOG(WARNING) << "Cannot open deviceio" << d_device_name; - std::cout << "Acq: cannot open deviceio" << d_device_name << std::endl; - } - else - { - //printf("acq lib DEVICE OPENED CORRECTLY\n"); - } - d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, - PROT_READ | PROT_WRITE, MAP_SHARED, d_fd, 0)); - - if (d_map_base == reinterpret_cast(-1)) - { - LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory"; - std::cout << "Acq: cannot map deviceio" << d_device_name << std::endl; - } - else - { - //printf("acq lib MAP BASE MAPPED CORRECTLY\n"); - } - - // sanity check : check test register - uint32_t writeval = TEST_REG_SANITY_CHECK; - uint32_t readval; - readval = fpga_acquisition::fpga_acquisition_test_register(writeval); - if (writeval != readval) - { - LOG(WARNING) << "Acquisition test register sanity check failed"; - } - else - { - LOG(INFO) << "Acquisition test register sanity check success!"; - //printf("acq lib REG SANITY CHECK SUCCESS\n"); - //std::cout << "Acquisition test register sanity check success!" << std::endl; - } - */ fpga_acquisition::reset_acquisition(); - fpga_acquisition::open_device(); fpga_acquisition::fpga_acquisition_test_register(); fpga_acquisition::close_device(); - // flag used for testing purposes - d_single_doppler_flag = 0; - d_PRN = 0; DLOG(INFO) << "Acquisition FPGA class created"; @@ -193,17 +121,12 @@ fpga_acquisition::fpga_acquisition(std::string device_name, void fpga_acquisition::open_device() { - //printf("acq internal device name = %s\n", d_device_name.c_str()); // open communication with HW accelerator if ((d_fd = open(d_device_name.c_str(), O_RDWR | O_SYNC)) == -1) { LOG(WARNING) << "Cannot open deviceio" << d_device_name; std::cout << "Acq: cannot open deviceio" << d_device_name << std::endl; } - else - { - //printf("acq lib DEVICE OPENED CORRECTLY\n"); - } d_map_base = reinterpret_cast(mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_fd, 0)); @@ -212,41 +135,17 @@ void fpga_acquisition::open_device() LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory"; std::cout << "Acq: cannot map deviceio" << d_device_name << std::endl; } - else - { - //printf("acq lib MAP BASE MAPPED CORRECTLY\n"); - } - - /* - // sanity check : check test register - uint32_t writeval = TEST_REG_SANITY_CHECK; - uint32_t readval; - readval = fpga_acquisition::fpga_acquisition_test_register(writeval); - if (writeval != readval) - { - LOG(WARNING) << "Acquisition test register sanity check failed"; - } - else - { - LOG(INFO) << "Acquisition test register sanity check success!"; - //printf("acq lib REG SANITY CHECK SUCCESS\n"); - //std::cout << "Acquisition test register sanity check success!" << std::endl; - } - - */ } fpga_acquisition::~fpga_acquisition() { - //printf("acq lib destructor called\n"); - //fpga_acquisition::close_device(); + } bool fpga_acquisition::free() { - //printf("acq lib free called\n"); return true; } @@ -258,15 +157,12 @@ void fpga_acquisition::fpga_acquisition_test_register() uint32_t writeval = TEST_REG_SANITY_CHECK; uint32_t readval; - //printf("acq lib test register called\n"); - //uint32_t readval; // write value to test register d_map_base[15] = writeval; // read value from test register readval = d_map_base[15]; - //readval = fpga_acquisition::fpga_acquisition_test_register(writeval); if (writeval != readval) { LOG(WARNING) << "Acquisition test register sanity check failed"; @@ -274,20 +170,7 @@ void fpga_acquisition::fpga_acquisition_test_register() else { LOG(INFO) << "Acquisition test register sanity check success!"; - //printf("acq lib REG SANITY CHECK SUCCESS\n"); - //std::cout << "Acquisition test register sanity check success!" << std::endl; } - -/* - //printf("acq lib test register called\n"); - uint32_t readval; - // write value to test register - d_map_base[15] = writeval; - // read value from test register - readval = d_map_base[15]; - // return read value - return readval; - */ } @@ -296,305 +179,109 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local uint32_t local_code; uint32_t k, tmp, tmp2; uint32_t fft_data; - //printf("acq lib fpga_configure_acquisition_local_code_called\n"); - // clear memory address counter - //d_map_base[6] = LOCAL_CODE_CLEAR_MEM; - //printf("writing local code for d_PRN = %d\n", (int) d_PRN); - //printf("writing local code d_nsamples_total = %d\n", (int) d_nsamples_total); - //printf("writing local code d_vector_length = %d\n", (int) d_vector_length); d_map_base[9] = LOCAL_CODE_CLEAR_MEM; // write local code for (k = 0; k < d_vector_length; k++) { tmp = fft_local_code[k].real(); tmp2 = fft_local_code[k].imag(); - //tmp = k; - //tmp2 = k; - //local_code = (tmp & SELECT_LSB) | ((tmp2 * SHL_8_BITS) & SELECT_MSB); // put together the real part and the imaginary part - //fft_data = MEM_LOCAL_CODE_WR_ENABLE | (local_code & SELECT_16_BITS); - //local_code = (tmp & SELECT_LSBits) | ((tmp2 * SHL_12_BITS) & SELECT_MSBbits); // put together the real part and the imaginary part local_code = (tmp & SELECT_LSBits) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBbits); // put together the real part and the imaginary part - //fft_data = MEM_LOCAL_CODE_WR_ENABLE | (local_code & SELECT_24_BITS); fft_data = local_code & SELECT_ALL_CODE_BITS; d_map_base[6] = fft_data; - - //printf("debug local code %d real = %d imag = %d local_code = %d fft_data = %d\n", k, tmp, tmp2, local_code, fft_data); - //printf("debug local code %d real = 0x%08X imag = 0x%08X local_code = 0x%08X fft_data = 0x%08X\n", k, tmp, tmp2, local_code, fft_data); } - //printf("acq d_vector_length = %d\n", d_vector_length); - //while(1); } void fpga_acquisition::run_acquisition(void) { - - //uint32_t result_valid = 0; - //while(result_valid == 0) - //{ - // read_result_valid(&result_valid); // polling - //} - //printf("acq lib run_acqisition called\n"); // enable interrupts int32_t reenable = 1; int32_t disable_int = 0; - //reenable = 1; write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); // launch the acquisition process - //printf("acq lib launchin acquisition ...\n"); - //printf("acq lib launch acquisition\n"); d_map_base[8] = LAUNCH_ACQUISITION; // writing a 1 to reg 8 launches the acquisition process - //printf("acq lib waiting for interrupt ...\n"); int32_t irq_count; ssize_t nb; - //uint32_t result_valid = 0; - - //usleep(5000000); - //printf("acq lib waiting for result valid\n"); - //while(result_valid == 0) - //{ - // read_result_valid(&result_valid); // polling - //} - //printf("result valid\n"); // wait for interrupt nb = read(d_fd, &irq_count, sizeof(irq_count)); - //usleep(500000); // debug - //printf("interrupt received\n"); if (nb != sizeof(irq_count)) { printf("acquisition module Read failed to retrieve 4 bytes!\n"); printf("acquisition module Interrupt number %d\n", irq_count); } - write(d_fd, reinterpret_cast(&disable_int), sizeof(int32_t)); } void fpga_acquisition::set_block_exp(uint32_t total_block_exp) { - //printf("******* acq writing total exponent = %d\n", (int) total_block_exp); d_map_base[11] = total_block_exp; } void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) { - //printf("writing doppler_max = %d\n", (int) d_doppler_max); - //printf("writing doppler_step = %d\n", (int) d_doppler_step); - //printf("num_sweeps = %d\n", num_sweeps); - if (d_single_doppler_flag == 0) - { - //printf("acq lib set_doppler_sweep called\n"); float phase_step_rad_real; float phase_step_rad_int_temp; int32_t phase_step_rad_int; - //int32_t doppler = static_cast(-d_doppler_max) + d_doppler_step * doppler_index; int32_t doppler = static_cast(-d_doppler_max); - //float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing - // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) - // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) - // while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x) - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - // avoid saturation of the fixed point representation in the fpga - // (only the positive value can saturate due to the 2's complement representation) + // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing + // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) + // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - //printf("AAA phase_step_rad_real for initial doppler = %f\n", phase_step_rad_real); + // avoid saturation of the fixed point representation in the fpga + // (only the positive value can saturate due to the 2's complement representation) if (phase_step_rad_real >= 1.0) { phase_step_rad_real = MAX_PHASE_STEP_RAD; } - //printf("AAA phase_step_rad_real for initial doppler after checking = %f\n", phase_step_rad_real); phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAA writing phase_step_rad_int for initial doppler = %d to d map base 3\n", phase_step_rad_int); d_map_base[3] = phase_step_rad_int; // repeat the calculation with the doppler step doppler = static_cast(d_doppler_step); phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - //printf("AAA phase_step_rad_real for doppler step = %f\n", phase_step_rad_real); if (phase_step_rad_real >= 1.0) { phase_step_rad_real = MAX_PHASE_STEP_RAD; } - //printf("AAA phase_step_rad_real for doppler step after checking = %f\n", phase_step_rad_real); phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAA writing phase_step_incr for doppler step = %d to d map base 4\n", phase_step_rad_int); d_map_base[4] = phase_step_rad_int; - //printf("AAA writing num sweeps to d map base 5 = %d\n", num_sweeps); d_map_base[5] = num_sweeps; - } - else - { - //printf("acq lib set_doppler_sweep called\n"); - float phase_step_rad_real; - float phase_step_rad_int_temp; - int32_t phase_step_rad_int; - //int32_t doppler = static_cast(-d_doppler_max) + d_doppler_step * doppler_index; - //printf("executing with doppler = %d\n", (int) d_doppler_max); - int32_t doppler = static_cast(d_doppler_max); - //float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); - float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing - // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) - // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) - // while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x) - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - // avoid saturation of the fixed point representation in the fpga - // (only the positive value can saturate due to the 2's complement representation) - - //printf("AAA phase_step_rad_real for initial doppler = %f\n", phase_step_rad_real); - if (phase_step_rad_real >= 1.0) - { - phase_step_rad_real = MAX_PHASE_STEP_RAD; - } - //printf("AAA phase_step_rad_real for initial doppler after checking = %f\n", phase_step_rad_real); - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAA writing phase_step_rad_int for initial doppler = %d to d map base 3\n", phase_step_rad_int); - d_map_base[3] = phase_step_rad_int; - - //printf("executing with doppler step = %d\n", (int) d_doppler_step); - // repeat the calculation with the doppler step - doppler = static_cast(d_doppler_step); - phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - //printf("AAA phase_step_rad_real for doppler step = %f\n", phase_step_rad_real); - if (phase_step_rad_real >= 1.0) - { - phase_step_rad_real = MAX_PHASE_STEP_RAD; - } - //printf("AAA phase_step_rad_real for doppler step after checking = %f\n", phase_step_rad_real); - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAA writing phase_step_rad_int for doppler step = %d to d map base 4\n", phase_step_rad_int); - d_map_base[4] = phase_step_rad_int; - //printf("AAA writing num sweeps to d map base 5 = 1\n"); - d_map_base[5] = 1; // 1 sweep - - } - } -/* -void fpga_acquisition::set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t doppler_index) -{ - //printf("acq lib set_doppler_sweep_debug called\n"); - float phase_step_rad_real; - float phase_step_rad_int_temp; - int32_t phase_step_rad_int; - int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - //int32_t doppler = static_cast(-d_doppler_max); - //float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); - float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing - // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) - // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) - // while the gnss-sdr software (volk_gnsssdr_s32f_sincos_32fc) generates cos(x) + j*sin(x) - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - // avoid saturation of the fixed point representation in the fpga - // (only the positive value can saturate due to the 2's complement representation) - - //printf("AAAh phase_step_rad_real for initial doppler = %f\n", phase_step_rad_real); - if (phase_step_rad_real >= 1.0) - { - phase_step_rad_real = MAX_PHASE_STEP_RAD; - } - //printf("AAAh phase_step_rad_real for initial doppler after checking = %f\n", phase_step_rad_real); - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAAh writing phase_step_rad_int for initial doppler = %d to d map base 3\n", phase_step_rad_int); - d_map_base[3] = phase_step_rad_int; - - // repeat the calculation with the doppler step - doppler = static_cast(d_doppler_step); - phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - //printf("AAAh phase_step_rad_real for doppler step = %f\n", phase_step_rad_real); - if (phase_step_rad_real >= 1.0) - { - phase_step_rad_real = MAX_PHASE_STEP_RAD; - } - //printf("AAAh phase_step_rad_real for doppler step after checking = %f\n", phase_step_rad_real); - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("AAAh writing phase_step_rad_int for doppler step = %d to d map base 4\n", phase_step_rad_int); - d_map_base[4] = phase_step_rad_int; - //printf("AAAh writing num sweeps to d map base 5 = %d\n", num_sweeps); - d_map_base[5] = num_sweeps; -} -*/ void fpga_acquisition::configure_acquisition() { fpga_acquisition::open_device(); - //printf("acq lib configure acquisition called\n"); - d_map_base[0] = d_select_queue; - //printf("AAA d_select_queue = %d\n", d_select_queue); - //d_map_base[0] = 1; - //printf("acq internal writing d_vector_length = %d to d map base 1\n ", d_vector_length); d_map_base[1] = d_vector_length; - //printf("acq interal writing d_nsamples = %d to d map base 2\n ", d_nsamples); d_map_base[2] = d_nsamples; - //printf("AAA writing LOG2 d_vector_length = %d to d map base 7\n ", (int)log2((float)d_vector_length)); d_map_base[7] = static_cast(log2(static_cast(d_vector_length))); // log2 FFTlength - //printf("AAA writing excludelimit = %d to d map base 12\n", (int) d_excludelimit); d_map_base[12] = d_excludelimit; - //printf("acquisition debug vector length = %d\n", d_vector_length); - //printf("acquisition debug vector length = %d\n", (int)log2((float)d_vector_length)); } - - - -//void fpga_acquisition::configure_acquisition_debug() -//{ -// fpga_acquisition::open_device(); -// -// //printf("acq lib configure acquisition called\n"); -// // d_map_base[0] = d_select_queue; -// //printf("AAA d_select_queue = %d\n", d_select_queue); -// -// //usleep(500000); -// //d_map_base[0] = 1; -// //printf("acq internal writing d_vector_length = %d to d map base 1\n ", d_vector_length); -///* d_map_base[1] = d_vector_length; -// //printf("acq interal writing d_nsamples = %d to d map base 2\n ", d_nsamples); -// d_map_base[2] = d_nsamples; -// //printf("AAA writing LOG2 d_vector_length = %d to d map base 7\n ", (int)log2((float)d_vector_length)); -// d_map_base[7] = static_cast(log2(static_cast(d_vector_length))); // log2 FFTlength -// //printf("AAA writing excludelimit = %d to d map base 12\n", (int) d_excludelimit); -// d_map_base[12] = d_excludelimit; -//*/ -// //printf("acquisition debug vector length = %d\n", d_vector_length); -// //printf("acquisition debug vector length = %d\n", (int)log2((float)d_vector_length)); -//} - - - void fpga_acquisition::set_phase_step(uint32_t doppler_index) { - //printf("acq lib set phase step SHOULD NOT BE called\n"); float phase_step_rad_real; float phase_step_rad_int_temp; int32_t phase_step_rad_int; int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; - //float phase_step_rad = GPS_TWO_PI * (d_freq + doppler) / static_cast(d_fs_in); float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) @@ -603,15 +290,12 @@ void fpga_acquisition::set_phase_step(uint32_t doppler_index) phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); // avoid saturation of the fixed point representation in the fpga // (only the positive value can saturate due to the 2's complement representation) - //printf("AAA+ phase_step_rad_real = %f\n", phase_step_rad_real); if (phase_step_rad_real >= 1.0) { phase_step_rad_real = MAX_PHASE_STEP_RAD; } - //printf("AAA+ phase_step_rad_real after checking = %f\n", phase_step_rad_real); phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - //printf("writing phase_step_rad_int = %d to d_map_base 3 THE SECOND FUNCTION\n", phase_step_rad_int); d_map_base[3] = phase_step_rad_int; } @@ -620,22 +304,11 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp) { - //do - //{ - - - //usleep(500000); - //printf("reading results\n"); - - //printf("acq lib read_acquisition_results_called\n"); uint64_t initial_sample_tmp = 0; - uint32_t readval = 0; uint64_t readval_long = 0; uint64_t readval_long_shifted = 0; - - readval = d_map_base[1]; initial_sample_tmp = readval; @@ -644,42 +317,26 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, initial_sample_tmp = initial_sample_tmp + readval_long_shifted; // 2^32 *initial_sample = initial_sample_tmp; - //printf("-------> acq initial sample TOTAL = %llu\n", *initial_sample); readval = d_map_base[3]; *firstpeak = static_cast(readval); - //printf("-------> read first peak = %f\n", *firstpeak); readval = d_map_base[4]; *secondpeak = static_cast(readval); - //printf("-------> read second peak = %f\n", *secondpeak); readval = d_map_base[5]; *max_index = readval; - //printf("-------> read max index = %d\n", (int) *max_index); - //printf("acq lib read max_magnitude dmap 2 = %d = %f\n", readval, *max_magnitude); - //readval = d_map_base[4]; *power_sum = 0; - //printf("acq lib read power sum dmap 4 = %d = %f\n", readval, *power_sum); - - readval = d_map_base[8]; *total_blk_exp = readval; - //printf("---------> read total block exponent = %d\n", (int) *total_blk_exp); readval = d_map_base[7]; // read doppler index -- this read releases the interrupt line *doppler_index = readval; - //printf("---------> read doppler_index = %d\n", (int) *doppler_index ); readval = d_map_base[15]; // read dummy - //} while (*total_blk_exp == 11); - - - - fpga_acquisition::close_device(); } @@ -687,21 +344,18 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, void fpga_acquisition::block_samples() { - //printf("acq lib block samples called\n"); d_map_base[14] = 1; // block the samples } void fpga_acquisition::unblock_samples() { - //printf("acq lib unblock samples called\n"); d_map_base[14] = 0; // unblock the samples } void fpga_acquisition::close_device() { - //printf("acq lib close device called\n"); uint32_t *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { @@ -714,16 +368,10 @@ void fpga_acquisition::close_device() void fpga_acquisition::reset_acquisition(void) { fpga_acquisition::open_device(); - //printf("acq lib reset acquisition called\n"); d_map_base[8] = RESET_ACQUISITION; // writing a 2 to d_map_base[8] resets the multicorrelator fpga_acquisition::close_device(); } -// this function is only used for the unit tests -void fpga_acquisition::set_single_doppler_flag(unsigned int single_doppler_flag) -{ - d_single_doppler_flag = single_doppler_flag; -} // this function is only used for the unit tests void fpga_acquisition::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) @@ -736,7 +384,6 @@ void fpga_acquisition::read_fpga_total_scale_factor(uint32_t *total_scale_factor //readval = d_map_base[8]; *fw_scale_factor = 0; - //printf("reading scale factor of %d\n", (int) readval); } void fpga_acquisition::read_result_valid(uint32_t *result_valid) diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index 401369788..d1628c787 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -2,7 +2,7 @@ * \file fpga_acquisition.h * \brief High optimized FPGA vector correlator class * \authors
            - *
          • Marc Majoral, 2018. mmajoral(at)cttc.cat + *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat *
          * * Class that controls and executes a high optimized acquisition HW @@ -10,7 +10,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -61,14 +61,10 @@ public: bool set_local_code(uint32_t PRN); bool free(); void set_doppler_sweep(uint32_t num_sweeps); - //void set_doppler_sweep_debug(uint32_t num_sweeps, uint32_t doppler_index); void run_acquisition(void); void set_phase_step(uint32_t doppler_index); - //void read_acquisition_results(uint32_t *max_index, float *max_magnitude, - // uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index); void read_acquisition_results(uint32_t *max_index, float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp); - void block_samples(); void unblock_samples(); @@ -78,9 +74,7 @@ public: */ void set_doppler_max(uint32_t doppler_max) { - //printf("acq lib set doppler max called\n"); d_doppler_max = doppler_max; - //printf("set acq lib d_doppler_max = %d\n", (int) d_doppler_max); } /*! @@ -89,23 +83,16 @@ public: */ void set_doppler_step(uint32_t doppler_step) { - //printf("acq lib set doppler step called\n"); d_doppler_step = doppler_step; - //printf("set acq lib d_doppler_step = %d\n", (int) d_doppler_step); } /*! - * \brief this function is only used in the unit test - */ - void set_single_doppler_flag(unsigned int single_doppler_flag); - - /*! - * \brief this function is only used in the unit test + * \brief Reset the FPGA PL. */ void reset_acquisition(void); /*! - * \brief this function is only used in the unit test + * \brief read the scaling factor that has been used by the FFT-IFFT */ void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); @@ -137,13 +124,8 @@ private: // FPGA private functions void fpga_acquisition_test_register(void); void fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]); - //void configure_acquisition(); -// void close_device(); -// void open_device(); void read_result_valid(uint32_t *result_valid); - // test parameters - unsigned int d_single_doppler_flag; // this flag is only used for testing purposes }; #endif /* GNSS_SDR_FPGA_ACQUISITION_H_ */ From 2b6e7749a873d29d7f53c7e8fd218ae05ec6bbde Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Tue, 26 Feb 2019 19:30:08 +0100 Subject: [PATCH 35/53] cleaned the source code of the FPGA switch and the FPGA tracking adapters --- .../signal_source/libs/fpga_switch.cc | 2 +- .../signal_source/libs/fpga_switch.h | 2 +- .../galileo_e1_dll_pll_veml_tracking_fpga.cc | 29 ++----------- .../galileo_e1_dll_pll_veml_tracking_fpga.h | 10 ++--- .../galileo_e5a_dll_pll_tracking_fpga.cc | 33 +++----------- .../galileo_e5a_dll_pll_tracking_fpga.h | 13 +++--- .../gps_l1_ca_dll_pll_tracking_fpga.cc | 14 ++---- .../gps_l1_ca_dll_pll_tracking_fpga.h | 6 +-- .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 43 +------------------ .../adapters/gps_l5_dll_pll_tracking_fpga.h | 4 +- 10 files changed, 33 insertions(+), 123 deletions(-) diff --git a/src/algorithms/signal_source/libs/fpga_switch.cc b/src/algorithms/signal_source/libs/fpga_switch.cc index 3f1caec12..1a93a11a8 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.cc +++ b/src/algorithms/signal_source/libs/fpga_switch.cc @@ -2,7 +2,7 @@ * \file fpga_switch.cc * \brief Switch that connects the HW accelerator queues to the analog front end or the DMA. * \authors
            - *
          • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat *
          • Javier Arribas, 2015. jarribas(at)cttc.es *
          * diff --git a/src/algorithms/signal_source/libs/fpga_switch.h b/src/algorithms/signal_source/libs/fpga_switch.h index f535bce7d..24eb9efba 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.h +++ b/src/algorithms/signal_source/libs/fpga_switch.h @@ -2,7 +2,7 @@ * \file fpga_switch.h * \brief Switch that connects the HW accelerator queues to the analog front end or the DMA. * \authors
            - *
          • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat *
          • Javier Arribas, 2016. jarribas(at)cttc.es *
          * diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index 179e80a91..7836f7a19 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -1,7 +1,8 @@ /*! - * \file galileo_e1_dll_pll_veml_tracking.cc + * \file galileo_e1_dll_pll_veml_tracking_fpga.cc * \brief Adapts a DLL+PLL VEML (Very Early Minus Late) tracking loop block - * to a TrackingInterface for Galileo E1 signals + * to a TrackingInterface for Galileo E1 signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com * * Code DLL + carrier PLL according to the algorithms described in: @@ -11,7 +12,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -42,8 +43,6 @@ #include "gnss_sdr_flags.h" #include -//#define NUM_PRNs_GALILEO_E1 50 - using google::LogMessage; void GalileoE1DllPllVemlTrackingFpga::stop_tracking() @@ -54,7 +53,6 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - //dllpllconf_t trk_param; Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## @@ -131,7 +129,6 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( trk_param_fpga.device_name = device_name; unsigned int device_base = configuration->property(role + ".device_base", 15); trk_param_fpga.device_base = device_base; - //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 1); trk_param_fpga.multicorr_type = 1; // 0 -> 3 correlators, 1 -> 5 correlators //################# PRE-COMPUTE ALL THE CODES ################# @@ -141,7 +138,6 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( float* data_codes_f; - printf("trk_param_fpga.track_pilot = %d\n", trk_param_fpga.track_pilot); if (trk_param_fpga.track_pilot) { d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int), volk_gnsssdr_get_alignment())); @@ -153,16 +149,11 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( data_codes_f = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); } - //printf("pppppppp trk_param_fpga.track_pilot = %d\n", trk_param_fpga.track_pilot); - - //int kk; - for (unsigned int PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) { char data_signal[3] = "1B"; if (trk_param_fpga.track_pilot) { - //printf("yes tracking pilot !!!!!!!!!!!!!!!\n"); char pilot_signal[3] = "1C"; galileo_e1_code_gen_sinboc11_float(ca_codes_f, pilot_signal, PRN); galileo_e1_code_gen_sinboc11_float(data_codes_f, data_signal, PRN); @@ -171,23 +162,16 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( { d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); d_data_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(data_codes_f[s]); - //printf("%f %d | ", data_codes_f[s], d_data_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); } - //printf("\n next \n"); - //scanf ("%d",&kk); } else { - //printf("no tracking pilot\n"); galileo_e1_code_gen_sinboc11_float(ca_codes_f, data_signal, PRN); for (unsigned int s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) { d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); - //printf("%f %d | ", ca_codes_f[s], d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); } - //printf("\n next \n"); - //scanf ("%d",&kk); } } @@ -218,7 +202,6 @@ GalileoE1DllPllVemlTrackingFpga::~GalileoE1DllPllVemlTrackingFpga() void GalileoE1DllPllVemlTrackingFpga::start_tracking() { - //tracking_->start_tracking(); tracking_fpga_sc->start_tracking(); } @@ -229,14 +212,12 @@ void GalileoE1DllPllVemlTrackingFpga::start_tracking() void GalileoE1DllPllVemlTrackingFpga::set_channel(unsigned int channel) { channel_ = channel; - //tracking_->set_channel(channel); tracking_fpga_sc->set_channel(channel); } void GalileoE1DllPllVemlTrackingFpga::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) { - //tracking_->set_gnss_synchro(p_gnss_synchro); tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); } @@ -261,13 +242,11 @@ void GalileoE1DllPllVemlTrackingFpga::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GalileoE1DllPllVemlTrackingFpga::get_left_block() { - //return tracking_; return tracking_fpga_sc; } gr::basic_block_sptr GalileoE1DllPllVemlTrackingFpga::get_right_block() { - //return tracking_; return tracking_fpga_sc; } diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h index 794aa22d4..c81fa696f 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h @@ -1,7 +1,8 @@ /*! - * \file galileo_e1_dll_pll_veml_tracking.h + * \file galileo_e1_dll_pll_veml_tracking_fpga.h * \brief Adapts a DLL+PLL VEML (Very Early Minus Late) tracking loop block - * to a TrackingInterface for Galileo E1 signals + * to a TrackingInterface for Galileo E1 signals for the FPGA + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com * * Code DLL + carrier PLL according to the algorithms described in: @@ -11,7 +12,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -63,7 +64,7 @@ public: return role_; } - //! Returns "Galileo_E1_DLL_PLL_VEML_Tracking" + //! Returns "Galileo_E1_DLL_PLL_VEML_Tracking_Fpga" inline std::string implementation() override { return "Galileo_E1_DLL_PLL_VEML_Tracking_Fpga"; @@ -100,7 +101,6 @@ public: private: - //dll_pll_veml_tracking_sptr tracking_; dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; unsigned int channel_; diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index 47ce428cd..4d7df5ca0 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -1,19 +1,20 @@ /*! - * \file galileo_e5a_dll_pll_tracking.cc + * \file galileo_e5a_dll_pll_tracking_fpga.cc * \brief Adapts a code DLL + carrier PLL - * tracking block to a TrackingInterface for Galileo E5a signals + * tracking block to a TrackingInterface for Galileo E5a signals for the FPGA * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * Galileo E5a data and pilot Signals + * Galileo E5a data and pilot Signals for the FPGA * \author Marc Sales, 2014. marcsales92(at)gmail.com * \based on work from: *
            + *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat *
          • Javier Arribas, 2011. jarribas(at)cttc.es *
          • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
          * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -54,8 +55,6 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( ConfigurationInterface *configuration, const std::string &role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - //printf("creating the E5A tracking"); - Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); DLOG(INFO) << "role " << role; @@ -131,7 +130,6 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( trk_param_fpga.device_name = device_name; unsigned int device_base = configuration->property(role + ".device_base", 27); trk_param_fpga.device_base = device_base; - //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 1); trk_param_fpga.multicorr_type = 1; // 0 -> 3 correlators, 1 -> up to 5+1 correlators //################# PRE-COMPUTE ALL THE CODES ################# @@ -159,11 +157,9 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( for (unsigned int PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) { - //galileo_e5_a_code_gen_complex_primary(aux_code, PRN, const_cast(trk_param_fpga.signal.c_str())); galileo_e5_a_code_gen_complex_primary(aux_code, PRN, const_cast(sig_)); if (trk_param_fpga.track_pilot) { - //d_secondary_code_string = const_cast(&Galileo_E5a_Q_SECONDARY_CODE[PRN - 1]); for (unsigned int i = 0; i < code_length_chips; i++) { tracking_code[i] = aux_code[i].imag(); @@ -173,7 +169,6 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( { d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); - //printf("%f %d | ", data_codes_f[s], d_data_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); } } else @@ -186,7 +181,6 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( for (unsigned int s = 0; s < code_length_chips; s++) { d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); - //printf("%f %d | ", ca_codes_f[s], d_ca_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); } } } @@ -203,19 +197,8 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( trk_param_fpga.code_samples_per_chip = code_samples_per_chip; // 2 sample per chip //################# MAKE TRACKING GNURadio object ################### tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); - // if (item_type.compare("gr_complex") == 0) - // { - // item_size_ = sizeof(gr_complex); - // tracking_ = dll_pll_veml_make_tracking(trk_param_fpga); - // } - // else - // { - // item_size_ = sizeof(gr_complex); - // LOG(WARNING) << item_type << " unknown tracking item type."; - // } channel_ = 0; - //DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; } @@ -232,7 +215,6 @@ GalileoE5aDllPllTrackingFpga::~GalileoE5aDllPllTrackingFpga() void GalileoE5aDllPllTrackingFpga::start_tracking() { - //tracking_->start_tracking(); tracking_fpga_sc->start_tracking(); } @@ -242,16 +224,13 @@ void GalileoE5aDllPllTrackingFpga::start_tracking() */ void GalileoE5aDllPllTrackingFpga::set_channel(unsigned int channel) { - //printf("blabla channel = %d\n", channel); channel_ = channel; - //tracking_->set_channel(channel); tracking_fpga_sc->set_channel(channel); } void GalileoE5aDllPllTrackingFpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) { - //tracking_->set_gnss_synchro(p_gnss_synchro); tracking_fpga_sc->set_gnss_synchro(p_gnss_synchro); } @@ -276,13 +255,11 @@ void GalileoE5aDllPllTrackingFpga::disconnect(gr::top_block_sptr top_block) gr::basic_block_sptr GalileoE5aDllPllTrackingFpga::get_left_block() { - //return tracking_; return tracking_fpga_sc; } gr::basic_block_sptr GalileoE5aDllPllTrackingFpga::get_right_block() { - //return tracking_; return tracking_fpga_sc; } diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h index 49c52de5e..3dffd0738 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h @@ -1,19 +1,20 @@ /*! - * \file galileo_e5a_dll_pll_tracking.h + * \file galileo_e5a_dll_pll_tracking_fpga.h * \brief Adapts a code DLL + carrier PLL - * tracking block to a TrackingInterface for Galileo E5a signals + * tracking block to a TrackingInterface for Galileo E5a signals for the FPGA * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * Galileo E5a data and pilot Signals + * Galileo E5a data and pilot Signals for the FPGA * \author Marc Sales, 2014. marcsales92(at)gmail.com * \based on work from: *
            + *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat *
          • Javier Arribas, 2011. jarribas(at)cttc.es *
          • Luis Esteve, 2012. luis(at)epsilon-formacion.com *
          * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -63,10 +64,10 @@ public: return role_; } - //! Returns "Galileo_E5a_DLL_PLL_Tracking" + //! Returns "Galileo_E5a_DLL_PLL_Tracking_Fpga" inline std::string implementation() override { - return "Galileo_E5a_DLL_PLL_Tracking"; + return "Galileo_E5a_DLL_PLL_Tracking_Fpga"; } inline size_t item_size() override diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index 971947fe4..4687269d3 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -1,8 +1,8 @@ /*! * \file gps_l1_ca_dll_pll_tracking_fpga.cc * \brief Implementation of an adapter of a DLL+PLL tracking loop block - * for GPS L1 C/A to a TrackingInterface that uses the FPGA - * \author Marc Majoral, 2018, mmajoral(at)cttc.es + * for GPS L1 C/A to a TrackingInterface for the FPGA + * \author Marc Majoral, 2019, mmajoral(at)cttc.es * Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com * Javier Arribas, 2011. jarribas(at)cttc.es * @@ -13,7 +13,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -60,8 +60,6 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## - //std::string default_item_type = "gr_complex"; - //std::string item_type = configuration->property(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; @@ -134,7 +132,6 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( trk_param_fpga.device_name = device_name; unsigned int device_base = configuration->property(role + ".device_base", 3); trk_param_fpga.device_base = device_base; - //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 0); trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators //################# PRE-COMPUTE ALL THE CODES ################# @@ -142,11 +139,6 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); - // debug -// for (int kk=0;kkproperty(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 12500000); int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; @@ -133,12 +130,10 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.device_name = device_name; unsigned int device_base = configuration->property(role + ".device_base", 27); trk_param_fpga.device_base = device_base; - //unsigned int multicorr_type = configuration->property(role + ".multicorr_type", 0); trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators //################# PRE-COMPUTE ALL THE CODES ################# unsigned int code_samples_per_chip = 1; auto code_length_chips = static_cast(GPS_L5I_CODE_LENGTH_CHIPS); - //printf("TRK code_length_chips = %d\n", code_length_chips); float *tracking_code; float *data_code; @@ -170,7 +165,6 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( { d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); - //printf("%f %d | ", data_codes_f[s], d_data_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); } } @@ -180,29 +174,9 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( for (unsigned int s = 0; s < code_length_chips; s++) { d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); - -// if (d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] == -1) -// { -// d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = 1; -// } -// else -// { -// d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = 0; -// } - // printf("tracking_code[%d] = %f\n", s, tracking_code[s]); - // printf("d_ca_codes[%d] = %d\n", static_cast(code_length_chips) * (PRN - 1) + s, d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s]); - //printf("%f %d | ", ca_codes_f[s], d_ca_codes[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)* 2 * (PRN - 1) + s]); - //printf("d_ca_codes[%d] = %d\n", static_cast(code_length_chips) * (PRN - 1) + s, d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s]); - - } } } - //printf("end \n"); - - - - delete[] tracking_code; if (trk_param_fpga.track_pilot) @@ -213,20 +187,7 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.data_codes = d_data_codes; trk_param_fpga.code_length_chips = code_length_chips; trk_param_fpga.code_samples_per_chip = code_samples_per_chip; // 2 sample per chip - //################# MAKE TRACKING GNURadio object ################### - // if (item_type.compare("gr_complex") == 0) - // { - // item_size_ = sizeof(gr_complex); - // tracking_ = dll_pll_veml_make_tracking(trk_param_fpga); - // } - // else - // { - // item_size_ = sizeof(gr_complex); - // LOG(WARNING) << item_type << " unknown tracking item type."; - // } - //printf("call \n"); tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); - //printf("end2 \n"); channel_ = 0; DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; } diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h index 087f3730c..eeb75b069 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h @@ -2,6 +2,7 @@ * \file gps_l5_dll_pll_tracking.h * \brief Interface of an adapter of a DLL+PLL tracking loop block * for GPS L5 to a TrackingInterface + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * \author Javier Arribas, 2017. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: @@ -11,7 +12,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -95,7 +96,6 @@ public: void stop_tracking() override; private: - //dll_pll_veml_tracking_sptr tracking_; dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; unsigned int channel_; From 17297ee18ffd89a1466825baf424ea97d3fbf438 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 27 Feb 2019 02:09:23 +0100 Subject: [PATCH 36/53] Fix Galileo telemetry --- .../gnuradio_blocks/galileo_telemetry_decoder_cc.cc | 8 ++++---- .../gnuradio_blocks/galileo_telemetry_decoder_cc.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc index cf794ca49..f2b4a3896 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc @@ -88,7 +88,7 @@ galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc( { case 1: // INAV { - d_PRN_code_period_ms = static_cast(GALILEO_E5A_CODE_PERIOD_MS); + d_PRN_code_period_ms = static_cast(GALILEO_E1_CODE_PERIOD_MS); d_samples_per_symbol = GALILEO_E1_B_SAMPLES_PER_SYMBOL; d_bits_per_preamble = GALILEO_INAV_PREAMBLE_LENGTH_BITS; // set the preamble @@ -634,7 +634,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( { // TOW_5 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay d_TOW_at_Preamble_ms = static_cast(d_inav_nav.TOW_5 * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS); d_inav_nav.flag_TOW_5 = false; } @@ -642,13 +642,13 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( { // TOW_6 refers to the even preamble, but when we decode it we are in the odd part, so 1 second later plus the decoding delay d_TOW_at_Preamble_ms = static_cast(d_inav_nav.TOW_6 * 1000.0); - d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E5A_CODE_PERIOD_MS); + d_TOW_at_current_symbol_ms = d_TOW_at_Preamble_ms + static_cast(GALILEO_INAV_PAGE_PART_MS + (d_required_symbols + 1) * GALILEO_E1_CODE_PERIOD_MS); d_inav_nav.flag_TOW_6 = false; } else { // this page has no timing information - d_TOW_at_current_symbol_ms += static_cast(GALILEO_E5A_CODE_PERIOD_MS); // + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD; + d_TOW_at_current_symbol_ms += static_cast(GALILEO_E1_CODE_PERIOD_MS); // + GALILEO_INAV_PAGE_PART_SYMBOLS*GALILEO_E1_CODE_PERIOD; } } break; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h index 96bd0081b..91aecd117 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h @@ -80,7 +80,7 @@ private: void deinterleaver(int32_t rows, int32_t cols, const double *in, double *out); - void decode_INAV_word(double *symbols, int32_t frame_length); + void decode_INAV_word(double *page_part_symbols, int32_t frame_length); void decode_FNAV_word(double *page_symbols, int32_t frame_length); int d_frame_type; From 8d770d9be9e99640ce9ce2c90b0ba4b93938335a Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 27 Feb 2019 13:30:09 +0100 Subject: [PATCH 37/53] more code cleaning removed some non used variables --- ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 2 +- .../galileo_e5a_pcps_acquisition_fpga.h | 3 + .../gps_l1_ca_pcps_acquisition_fpga.h | 2 +- .../adapters/gps_l5i_pcps_acquisition_fpga.h | 4 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 6 - .../gnuradio_blocks/pcps_acquisition_fpga.h | 6 - .../acquisition/libs/fpga_acquisition.cc | 6 +- .../acquisition/libs/fpga_acquisition.h | 1 - .../libs/gnss_sdr_fpga_sample_counter.cc | 26 +- .../adapters/gps_l2_m_dll_pll_tracking_fpga.h | 2 +- .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 2 - .../dll_pll_veml_tracking_fpga.cc | 183 +---- .../dll_pll_veml_tracking_fpga.h | 9 +- .../tracking/libs/dll_pll_conf_fpga.cc | 7 +- .../tracking/libs/dll_pll_conf_fpga.h | 8 +- .../tracking/libs/fpga_multicorrelator.cc | 371 ++------- .../tracking/libs/fpga_multicorrelator.h | 91 +-- src/core/receiver/control_thread.cc | 45 +- src/core/receiver/gnss_block_factory.cc | 2 +- src/core/receiver/gnss_flowgraph.cc | 234 +++--- .../hybrid_observables_test_fpga.cc | 744 +----------------- .../tracking/tracking_pull-in_test_fpga.cc | 673 +++------------- 22 files changed, 370 insertions(+), 2057 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 96a5a90fa..7086c62ac 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -65,7 +65,7 @@ public: } /*! - * \brief Returns "Galileo_E1_PCPS_Ambiguous_Acquisition" + * \brief Returns "Galileo_E1_PCPS_Ambiguous_Acquisition_Fpga" */ inline std::string implementation() override { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index 9c63431f2..abe993526 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -57,6 +57,9 @@ public: return role_; } + /*! + * \brief Returns "Galileo_E5a_Pcps_Acquisition_Fpga" + */ inline std::string implementation() override { return "Galileo_E5a_Pcps_Acquisition_Fpga"; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index ce5cdfc4a..9615338bc 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -65,7 +65,7 @@ public: } /*! - * \brief Returns "GPS_L1_CA_PCPS_Acquisition" + * \brief Returns "GPS_L1_CA_PCPS_Acquisition_Fpga" */ inline std::string implementation() override { diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index 7e15f4df7..836d46cee 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -67,11 +67,11 @@ public: } /*! - * \brief Returns "GPS_L5i_PCPS_Acquisition" + * \brief Returns "GPS_L5i_PCPS_Acquisition_Fpga" */ inline std::string implementation() override { - return "GPS_L5i_PCPS_Acquisition"; + return "GPS_L5i_PCPS_Acquisition_Fpga"; } inline size_t item_size() override diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 34c2a2cf0..091092c89 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -40,8 +40,6 @@ #include #include -#include // for the usleep function only (debug) - #define AQ_DOWNSAMPLING_DELAY 40 // delay due to the downsampling filter in the acquisition using google::LogMessage; @@ -196,10 +194,6 @@ void pcps_acquisition_fpga::set_active(bool active) << ", use_CFAR_algorithm_flag: false"; uint64_t initial_sample; - float input_power_all = 0.0; - float input_power_computed = 0.0; - - float temp_d_input_power; acquisition_fpga->configure_acquisition(); acquisition_fpga->set_doppler_sweep(d_num_doppler_bins); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index f551e0778..a08cd5363 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -178,9 +178,7 @@ public: */ inline void set_threshold(float threshold) { - // printf("acq set threshold start\n"); d_threshold = threshold; - // printf("acq set threshold end\n"); } /*! @@ -189,10 +187,8 @@ public: */ inline void set_doppler_max(uint32_t doppler_max) { - // printf("acq set doppler max start\n"); acq_parameters.doppler_max = doppler_max; acquisition_fpga->set_doppler_max(doppler_max); - // printf("acq set doppler max end\n"); } /*! @@ -201,10 +197,8 @@ public: */ inline void set_doppler_step(uint32_t doppler_step) { - // printf("acq set doppler step start\n"); d_doppler_step = doppler_step; acquisition_fpga->set_doppler_step(doppler_step); - // printf("acq set doppler step end\n"); } /*! diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 18264bc58..9a14f779a 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -212,8 +212,8 @@ void fpga_acquisition::run_acquisition(void) nb = read(d_fd, &irq_count, sizeof(irq_count)); if (nb != sizeof(irq_count)) { - printf("acquisition module Read failed to retrieve 4 bytes!\n"); - printf("acquisition module Interrupt number %d\n", irq_count); + std::cout << "acquisition module Read failed to retrieve 4 bytes!" << std::endl; + std::cout << "acquisition module Interrupt number " << irq_count << std::endl; } write(d_fd, reinterpret_cast(&disable_int), sizeof(int32_t)); @@ -359,7 +359,7 @@ void fpga_acquisition::close_device() uint32_t *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } close(d_fd); } diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index d1628c787..ff599f4ff 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -102,7 +102,6 @@ public: void configure_acquisition(void); - //void configure_acquisition_debug(void); void close_device(); void open_device(); diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc index 211137535..9a5427c60 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc @@ -53,10 +53,7 @@ gnss_sdr_fpga_sample_counter::gnss_sdr_fpga_sample_counter( set_max_noutput_items(1); interval_ms = _interval_ms; fs = _fs; - //printf("CREATOR fs = %f\n", fs); - //printf("CREATOR interval_ms = %" PRIu32 "\n", interval_ms); samples_per_output = std::round(fs * static_cast(interval_ms) / 1e3); - //printf("CREATOR samples_per_output = %" PRIu32 "\n", samples_per_output); //todo: Load here the hardware counter register with this amount of samples. It should produce an //interrupt every samples_per_output count. //The hardware timer must keep always interrupting the PS. It must not wait for the interrupt to @@ -122,7 +119,6 @@ int gnss_sdr_fpga_sample_counter::general_work(int noutput_items __attribute__(( uint32_t counter = wait_for_interrupt_and_read_counter(); uint64_t samples_passed = 2 * static_cast(samples_per_output) - static_cast(counter); // ellapsed samples - //printf("============================================ interrupter : samples_passed = %" PRIu64 "\n", samples_passed); // Note: at this moment the sample counter is implemented as a sample counter that decreases to zero and then it is automatically // reloaded again and keeps counter. It is done in this way to minimize the logic in the FPGA and maximize the FPGA clock performance // (it takes less resources and latency in the FPGA to compare a number against a fixed value like zero than to compare it to a programmable @@ -137,10 +133,6 @@ int gnss_sdr_fpga_sample_counter::general_work(int noutput_items __attribute__(( out[0].fs = fs; if ((current_T_rx_ms % report_interval_ms) == 0) { - //printf("time to print sample_counter = %" PRIu64 "\n", sample_counter); - //printf("time to print current Tx ms : %" PRIu64 "\n", current_T_rx_ms); - //printf("time to print report_interval_ms : %" PRIu32 "\n", report_interval_ms); - //printf("time to print %f\n", (current_T_rx_ms % report_interval_ms)); current_s++; if ((current_s % 60) == 0) { @@ -217,15 +209,7 @@ uint32_t gnss_sdr_fpga_sample_counter::test_register(uint32_t writeval) void gnss_sdr_fpga_sample_counter::configure_samples_per_output(uint32_t interval) { // note : the counter is a 48-bit value in the HW. - //printf("============================================ total counter - interrupted interval : %" PRIu32 "\n", interval); - //uint64_t temp_interval; - //temp_interval = (interval & static_cast(0xFFFFFFFF)); - //printf("LSW counter - interrupted interval : %" PRIu32 "\n", static_cast(temp_interval)); - //map_base[0] = static_cast(temp_interval); map_base[0] = interval - 1; - //temp_interval = (interval >> 32) & static_cast(0xFFFFFFFF); - //printf("MSbits counter - interrupted interval : %" PRIu32 "\n", static_cast(temp_interval)); - //map_base[1] = static_cast(temp_interval); // writing the most significant bits also enables the interrupts } void gnss_sdr_fpga_sample_counter::open_device() @@ -262,13 +246,12 @@ void gnss_sdr_fpga_sample_counter::open_device() void gnss_sdr_fpga_sample_counter::close_device() { - //printf("=========================================== NOW closing device ...\n"); map_base[2] = 0; // disable the generation of the interrupt in the device auto *aux = const_cast(map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } close(fd); } @@ -284,14 +267,11 @@ uint32_t gnss_sdr_fpga_sample_counter::wait_for_interrupt_and_read_counter() write(fd, reinterpret_cast(&reenable), sizeof(int32_t)); // wait for interrupt - //printf("============================================ interrupter : going to wait for interupt\n"); nb = read(fd, &irq_count, sizeof(irq_count)); - //printf("============================================ interrupter : interrupt received\n"); - //printf("interrupt received\n"); if (nb != sizeof(irq_count)) { - printf("acquisition module Read failed to retrieve 4 bytes!\n"); - printf("acquisition module Interrupt number %d\n", irq_count); + std::cout << "fpga sample counter module read failed to retrieve 4 bytes!" << std::endl; + std::cout << "fpga sample counter module interrupt number " << irq_count << std::endl; } // it is a rising edge interrupt, the interrupt does not need to be acknowledged diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h index 7d36d1e74..e1a606f1f 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h @@ -63,7 +63,7 @@ public: return role_; } - //! Returns "GPS_L2_M_DLL_PLL_Tracking" + //! Returns "GPS_L2_M_DLL_PLL_Tracking_Fpga" inline std::string implementation() override { return "GPS_L2_M_DLL_PLL_Tracking_Fpga"; diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc index d918ca478..ba7b52f9f 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -83,7 +83,6 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.early_late_space_chips = early_late_space_chips; int vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L5I_CODE_RATE_HZ) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS))); trk_param_fpga.vector_length = vector_length; - printf("trk vector length = %d\n", vector_length); int extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; @@ -152,7 +151,6 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * NUM_PRNs * sizeof(int), volk_gnsssdr_get_alignment())); } - //printf("start \n"); for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) { if (track_pilot) diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 0d23430a5..874ed9929 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -1,7 +1,7 @@ /*! * \file dll_pll_veml_tracking_fpga.cc * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA - * \author Marc Majoral, 2018. marc.majoral(at)cttc.es + * \author Marc Majoral, 2019. marc.majoral(at)cttc.es * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * \author Javier Arribas, 2018. jarribas(at)cttc.es * @@ -12,7 +12,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -63,30 +63,6 @@ #include #include -//#include "GPS_L1_CA.h" -//#include "gps_sdr_signal_processing.h" -//#include "GPS_L2C.h" -//#include "GPS_L5.h" -//#include "Galileo_E1.h" -//#include "Galileo_E5a.h" -//#include "MATH_CONSTANTS.h" -//#include "control_message_factory.h" -//#include "gnss_sdr_create_directory.h" -//#include "gps_l2c_signal.h" -//#include "gps_l5_signal.h" -//#include "lock_detectors.h" -//#include "tracking_discriminators.h" -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include - using google::LogMessage; dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_) @@ -139,8 +115,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_code_chip_rate = GPS_L1_CA_CODE_RATE_HZ; d_symbols_per_bit = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; d_correlation_length_ms = 1; - //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS); // GPS L1 C/A does not have pilot component nor secondary code d_secondary = false; trk_parameters.track_pilot = false; @@ -175,10 +149,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_signal_carrier_freq = GPS_L2_FREQ_HZ; d_code_period = GPS_L2_M_PERIOD; d_code_chip_rate = GPS_L2_M_CODE_RATE_HZ; - //d_code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); d_symbols_per_bit = GPS_L2_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 20; - //d_code_samples_per_chip = 1; // GPS L2 does not have pilot component nor secondary code d_secondary = false; trk_parameters.track_pilot = false; @@ -191,8 +163,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_code_chip_rate = GPS_L5I_CODE_RATE_HZ; d_symbols_per_bit = GPS_L5_SAMPLES_PER_SYMBOL; d_correlation_length_ms = 1; - //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); d_secondary = true; if (trk_parameters.track_pilot) { @@ -218,8 +188,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0U; - //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } } @@ -231,10 +199,8 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_signal_carrier_freq = GALILEO_E1_FREQ_HZ; d_code_period = GALILEO_E1_CODE_PERIOD; d_code_chip_rate = GALILEO_E1_CODE_CHIP_RATE_HZ; - //d_code_length_chips = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); d_symbols_per_bit = 1; d_correlation_length_ms = 4; - //d_code_samples_per_chip = 2; // CBOC disabled: 2 samples per chip. CBOC enabled: 12 samples per chip d_veml = true; if (trk_parameters.track_pilot) { @@ -257,8 +223,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_code_chip_rate = GALILEO_E5A_CODE_CHIP_RATE_HZ; d_symbols_per_bit = 20; d_correlation_length_ms = 1; - //d_code_samples_per_chip = 1; - //d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); if (trk_parameters.track_pilot) { @@ -271,10 +235,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & { //Do not acquire secondary code in data component. It is done in telemetry decoder d_secondary = false; -//======= -// d_secondary_code_length = static_cast(GALILEO_E5A_I_SECONDARY_CODE_LENGTH); -// d_secondary_code_string = const_cast(&GALILEO_E5A_I_SECONDARY_CODE); -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 signal_pretty_name = signal_pretty_name + "I"; interchange_iq = false; } @@ -288,8 +248,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0U; - //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } } @@ -302,8 +260,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & interchange_iq = false; d_signal_carrier_freq = 0.0; d_code_period = 0.0; - //d_code_length_chips = 0U; - //d_code_samples_per_chip = 0U; d_symbols_per_bit = 0; } T_chip_seconds = 0.0; @@ -317,10 +273,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_code_loop_filter = Tracking_2nd_DLL_filter(static_cast(d_code_period)); d_carrier_loop_filter = Tracking_2nd_PLL_filter(static_cast(d_code_period)); - // Initialization of local code replica - // Get space for a vector with the sinboc(1,1) replica sampled 2x/chip - //d_tracking_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); - // correlator outputs (scalar) if (d_veml) { // Very-Early, Early, Prompt, Late, Very-Late @@ -363,7 +315,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_prompt_data_shift = &d_local_code_shift_chips[1]; } - //multicorrelator_cpu.init(2 * trk_parameters.vector_length, d_n_correlator_taps); if (trk_parameters.extend_correlation_symbols > 1) { @@ -375,21 +326,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & trk_parameters.extend_correlation_symbols = 1; } - // Enable Data component prompt correlator (slave to Pilot prompt) if tracking uses Pilot signal - if (trk_parameters.track_pilot) - { - // Extra correlator for the data component - //correlator_data_cpu.init(2 * trk_parameters.vector_length, 1); - //correlator_data_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); - //d_data_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); - } - else - { - //d_data_code = nullptr; - } - - // --- Initializations --- - //multicorrelator_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); + // --- Initializations --- // Initial code frequency basis of NCO d_code_freq_chips = d_code_chip_rate; // Residual code phase (in chips) @@ -494,8 +431,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & void dll_pll_veml_tracking_fpga::start_tracking() { - //gr::thread::scoped_lock l(d_setlock); - // correct the code phase according to the delay between acq and trk d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; @@ -510,64 +445,29 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_carrier_loop_filter.initialize(); // initialize the carrier filter d_code_loop_filter.initialize(); // initialize the code filter - if (systemName == "GPS" and signal_type == "1C") - { - //gps_l1_ca_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); - } - else if (systemName == "GPS" and signal_type == "2S") - { - //gps_l2c_m_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); - } - else if (systemName == "GPS" and signal_type == "L5") + if (systemName == "GPS" and signal_type == "L5") { if (trk_parameters.track_pilot) { - //gps_l5q_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); - //gps_l5i_code_gen_float(d_data_code, d_acquisition_gnss_synchro->PRN); d_Prompt_Data[0] = gr_complex(0.0, 0.0); - //correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); - } - else - { - //gps_l5i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); } } else if (systemName == "Galileo" and signal_type == "1B") { if (trk_parameters.track_pilot) { - //char pilot_signal[3] = "1C"; - //galileo_e1_code_gen_sinboc11_float(d_tracking_code, pilot_signal, d_acquisition_gnss_synchro->PRN); - //galileo_e1_code_gen_sinboc11_float(d_data_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); d_Prompt_Data[0] = gr_complex(0.0, 0.0); - //correlator_data_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_data_code, d_prompt_data_shift); - } - else - { - //galileo_e1_code_gen_sinboc11_float(d_tracking_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); } } else if (systemName == "Galileo" and signal_type == "5X") { - //gr_complex *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * d_code_length_chips, volk_gnsssdr_get_alignment())); - //galileo_e5_a_code_gen_complex_primary(aux_code, d_acquisition_gnss_synchro->PRN, const_cast(signal_type.c_str())); if (trk_parameters.track_pilot) { d_secondary_code_string = const_cast(&GALILEO_E5A_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]); d_Prompt_Data[0] = gr_complex(0.0, 0.0); - //correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); } - else - { - //for (uint32_t i = 0; i < d_code_length_chips; i++) - // { - // d_tracking_code[i] = aux_code[i].real(); - // } - } - //volk_gnsssdr_free(aux_code); } - //multicorrelator_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_tracking_code, d_local_code_shift_chips); std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); d_carrier_lock_fail_counter = 0; @@ -645,15 +545,8 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { volk_gnsssdr_free(d_local_code_shift_chips); volk_gnsssdr_free(d_correlator_outs); - //volk_gnsssdr_free(d_tracking_code); volk_gnsssdr_free(d_Prompt_Data); - if (trk_parameters.track_pilot) - { - //volk_gnsssdr_free(d_data_code); - //correlator_data_cpu.free(); - } delete[] d_Prompt_buffer; - //multicorrelator_cpu.free(); multicorrelator_fpga->free(); } catch (const std::exception &ex) @@ -763,30 +656,6 @@ void dll_pll_veml_tracking_fpga::do_correlation_step(void) { // // ################# CARRIER WIPEOFF AND CORRELATORS ############################## -// // perform carrier wipe-off and compute Early, Prompt and Late correlation -// multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, input_samples); -// multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler( -// d_rem_carr_phase_rad, -// d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, -// static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), -// static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), -// static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), -// trk_parameters.vector_length); -// -// // DATA CORRELATOR (if tracking tracks the pilot signal) -// if (trk_parameters.track_pilot) -// { -// correlator_data_cpu.set_input_output_vectors(d_Prompt_Data, input_samples); -// correlator_data_cpu.Carrier_wipeoff_multicorrelator_resampler( -// d_rem_carr_phase_rad, -// d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, -// static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), -// static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), -// static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), -// trk_parameters.vector_length); -// } -// -// multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( d_rem_carr_phase_rad, @@ -873,9 +742,7 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation T_prn_samples = T_prn_seconds * trk_parameters.fs_in; K_blk_samples = T_prn_samples + d_rem_code_phase_samples; - //d_current_prn_length_samples = static_cast(round(K_blk_samples)); // round to a discrete number of samples d_next_prn_length_samples = static_cast(std::floor(K_blk_samples)); // round to a discrete number of samples - //d_current_prn_length_samples = static_cast(std::floor(K_blk_samples)); // round to a discrete number of samples //################### PLL COMMANDS ################################################# // carrier phase step (NCO phase increment per sample) [rads/sample] @@ -900,16 +767,12 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() d_carrier_phase_rate_step_rad = (tmp_cp2 - tmp_cp1) / tmp_samples; } } - //std::cout << d_carrier_phase_rate_step_rad * trk_parameters.fs_in * trk_parameters.fs_in / PI_2 << std::endl; // remnant carrier phase to prevent overflow in the code NCO d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, PI_2); // carrier phase accumulator - //double a = d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); - //double b = 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples); - //std::cout << fmod(b, PI_2) / fmod(a, PI_2) << std::endl; d_acc_carrier_phase_rad -= (d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); //################### DLL COMMANDS ################################################# @@ -1372,7 +1235,6 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) { - //gr::thread::scoped_lock l(d_setlock); d_channel = channel; multicorrelator_fpga->set_channel(d_channel); LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -1389,8 +1251,6 @@ void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) { try { - //trk_parameters.dump_filename.append(boost::lexical_cast(d_channel)); - //trk_parameters.dump_filename.append(".dat"); d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); d_dump_file.open(dump_filename_.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << dump_filename_.c_str(); @@ -1407,14 +1267,12 @@ void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) void dll_pll_veml_tracking_fpga::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) { - //gr::thread::scoped_lock l(d_setlock); d_acquisition_gnss_synchro = p_gnss_synchro; } void dll_pll_veml_tracking_fpga::stop_tracking() { - //gr::thread::scoped_lock l(d_setlock); d_state = 0; } @@ -1423,8 +1281,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un { - //gr::thread::scoped_lock l(d_setlock); - //const gr_complex *in = reinterpret_cast(input_items[0]); Gnss_Synchro **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -1435,8 +1291,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un { case 0: // Standby - Consume samples at full throttle, do nothing { - //d_sample_counter += static_cast(ninput_items[0]); - //consume_each(ninput_items[0]); return 0; break; } @@ -1446,21 +1300,17 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un double acq_trk_diff_seconds; double delta_trk_to_acq_prn_start_samples; - //printf("state 1\n"); multicorrelator_fpga->lock_channel(); uint64_t counter_value = multicorrelator_fpga->read_sample_counter(); uint64_t absolute_samples_offset; if (counter_value > (d_acq_sample_stamp + d_acq_code_phase_samples)) { // Signal alignment (skip samples until the incoming signal is aligned with local replica) - //int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; - //uint32_t num_frames = ceil((counter_value - d_acq_sample_stamp - d_acq_code_phase_samples) / d_correlation_length_samples); uint32_t num_frames = ceil((delta_trk_to_acq_prn_start_samples) / d_correlation_length_samples); - //absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); } else @@ -1471,7 +1321,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) + d_acq_code_phase_samples; - //absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp); absolute_samples_offset = static_cast(delta_trk_to_acq_prn_start_samples); } multicorrelator_fpga->set_initial_sample(absolute_samples_offset); @@ -1481,11 +1330,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un d_sample_counter_next = d_sample_counter; -// // Signal alignment (skip samples until the incoming signal is aligned with local replica) -// //int64_t acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); -// int64_t acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); -// double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; -// double delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; + // Signal alignment (skip samples until the incoming signal is aligned with local replica) // Doppler effect Fd = (C / (C + Vr)) * F double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; @@ -1497,7 +1342,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); double T_prn_mod_samples = T_prn_mod_seconds * trk_parameters.fs_in; - //d_acq_code_phase_samples = T_prn_mod_samples - std::fmod(delta_trk_to_acq_prn_start_samples, T_prn_mod_samples); d_acq_code_phase_samples = absolute_samples_offset; d_current_prn_length_samples = round(T_prn_mod_samples); @@ -1511,11 +1355,11 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un DLOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; + // don't leave the HW module blocking the signal path before the first sample arrives + // start the first tracking process run_state_2(current_synchro_data); break; - //consume_each(samples_offset); // shift input to perform alignment with local replica - //return 0; } case 2: // Wide tracking and symbol synchronization { @@ -1524,7 +1368,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } case 3: // coherent integration (correlation time extension) { - //printf("state 3\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); @@ -1581,7 +1424,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } case 4: // narrow tracking { - //printf("state 4\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); // Fill the acquisition data @@ -1652,15 +1494,12 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } } } - //consume_each(d_current_prn_length_samples); - //d_sample_counter += static_cast(d_current_prn_length_samples); if (current_synchro_data.Flag_valid_symbol_output) { current_synchro_data.fs = static_cast(trk_parameters.fs_in); - // two choices for the reporting of the sample counter: - // either the sample counter position that should be (d_sample_counter_next) - //or the sample counter corresponding to the number of samples that the FPGA actually consumed. - //current_synchro_data.Tracking_sample_counter = d_sample_counter + static_cast(d_current_prn_length_samples); + // two choices for the reporting of the sample counter: + // either the sample counter position that should be (d_sample_counter_next) + //or the sample counter corresponding to the number of samples that the FPGA actually consumed. current_synchro_data.Tracking_sample_counter = d_sample_counter_next; *out[0] = current_synchro_data; return 1; @@ -1670,7 +1509,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) { - //printf("state 2\n"); d_sample_counter = d_sample_counter_next; d_sample_counter_next = d_sample_counter + static_cast(d_current_prn_length_samples); @@ -1740,7 +1578,6 @@ void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) } if (corr_value == GPS_CA_PREAMBLE_LENGTH_SYMBOLS) { - //std::cout << "Preamble detected at tracking!" << std::endl; next_state = true; } else diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index a2fb3ed74..c0411b142 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -1,13 +1,13 @@ /*! - * \file dll_pll_veml_tracking.h - * \brief Implementation of a code DLL + carrier PLL tracking block. - * \author Marc Majoral, 2018. marc.majoral(at)cttc.es + * \file dll_pll_veml_tracking_fpga.h + * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA. + * \author Marc Majoral, 2019. marc.majoral(at)cttc.es * \author Javier Arribas, 2018. jarribas(at)cttc.es * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -80,7 +80,6 @@ private: bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool acquire_secondary(); - //void do_correlation_step(const gr_complex *input_samples); void do_correlation_step(void); void run_dll_pll(); void update_tracking_vars(); diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc index 855a336b5..36cdd264b 100644 --- a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc @@ -1,12 +1,13 @@ /*! - * \file dll_pll_conf.cc + * \file dll_pll_conf_fpga.cc * \brief Class that contains all the configuration parameters for generic - * tracking block based on a DLL and a PLL. + * tracking block based on a DLL and a PLL for the FPGA. + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * \author Javier Arribas, 2018. jarribas(at)cttc.es * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.h b/src/algorithms/tracking/libs/dll_pll_conf_fpga.h index 95878f592..33dd901d7 100644 --- a/src/algorithms/tracking/libs/dll_pll_conf_fpga.h +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.h @@ -1,13 +1,15 @@ /*! - * \file dll_pll_conf.h - * \brief Class that contains all the configuration parameters for generic tracking block based on a DLL and a PLL. + * \file dll_pll_conf_fpga.h + * \brief Class that contains all the configuration parameters for generic + * tracking block based on a DLL and a PLL for the FPGA. + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * \author Javier Arribas, 2018. jarribas(at)cttc.es * * Class that contains all the configuration parameters for generic tracking block based on a DLL and a PLL. * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index 158b02c07..dee4667da 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -2,7 +2,7 @@ * \file fpga_multicorrelator_8sc.cc * \brief High optimized FPGA vector correlator class * \authors
            - *
          • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat *
          • Javier Arribas, 2015. jarribas(at)cttc.es *
          * @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -36,81 +36,62 @@ #include "fpga_multicorrelator.h" #include - -// FPGA stuff #include - -// libraries used by DMA test code and GIPO test code #include #include #include #include - -// libraries used by DMA test code #include #include #include #include - -// libraries used by GPIO test code #include #include #include - -// logging #include - -// string manipulation #include #include -// constants -#include "GPS_L1_CA.h" +// FPGA register access constants +#define PAGE_SIZE 0x10000 +#define MAX_LENGTH_DEVICEIO_NAME 50 +#define CODE_RESAMPLER_NUM_BITS_PRECISION 20 +#define CODE_PHASE_STEP_CHIPS_NUM_NBITS CODE_RESAMPLER_NUM_BITS_PRECISION +#define pwrtwo(x) (1 << (x)) +#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS +#define PHASE_CARR_NBITS 32 +#define PHASE_CARR_NBITS_INT 1 +#define PHASE_CARR_NBITS_FRAC PHASE_CARR_NBITS - PHASE_CARR_NBITS_INT +#define LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT 0x20000000 +#define LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER 0x10000000 +#define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 +#define TEST_REGISTER_TRACK_WRITEVAL 0x55AA + + -//#include "gps_sdr_signal_processing.h" -#define NUM_PRNs 32 -#define PAGE_SIZE 0x10000 -#define MAX_LENGTH_DEVICEIO_NAME 50 -#define CODE_RESAMPLER_NUM_BITS_PRECISION 20 -#define CODE_PHASE_STEP_CHIPS_NUM_NBITS CODE_RESAMPLER_NUM_BITS_PRECISION -#define pwrtwo(x) (1 << (x)) -#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS -#define PHASE_CARR_NBITS 32 -#define PHASE_CARR_NBITS_INT 1 -#define PHASE_CARR_NBITS_FRAC PHASE_CARR_NBITS - PHASE_CARR_NBITS_INT -#define LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT 0x20000000 -#define LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER 0x10000000 -#define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 -#define TEST_REGISTER_TRACK_WRITEVAL 0x55AA uint64_t fpga_multicorrelator_8sc::read_sample_counter() { uint64_t sample_counter_tmp, sample_counter_msw_tmp; - sample_counter_tmp = d_map_base[d_SAMPLE_COUNTER_REG_ADDR_LSW]; - sample_counter_msw_tmp = d_map_base[d_SAMPLE_COUNTER_REG_ADDR_MSW]; + sample_counter_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_LSW]; + sample_counter_msw_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_MSW]; sample_counter_msw_tmp = sample_counter_msw_tmp << 32; sample_counter_tmp = sample_counter_tmp + sample_counter_msw_tmp; // 2^32 - //return d_map_base[d_SAMPLE_COUNTER_REG_ADDR]; return sample_counter_tmp; } void fpga_multicorrelator_8sc::set_initial_sample(uint64_t samples_offset) { d_initial_sample_counter = samples_offset; - //printf("www writing d map base %d = d_initial_sample_counter = %d\n", d_INITIAL_COUNTER_VALUE_REG_ADDR, d_initial_sample_counter); - d_map_base[d_INITIAL_COUNTER_VALUE_REG_ADDR_LSW] = (d_initial_sample_counter & 0xFFFFFFFF); - d_map_base[d_INITIAL_COUNTER_VALUE_REG_ADDR_MSW] = (d_initial_sample_counter >> 32) & 0xFFFFFFFF; + d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_LSW] = (d_initial_sample_counter & 0xFFFFFFFF); + d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_MSW] = (d_initial_sample_counter >> 32) & 0xFFFFFFFF; } -//void fpga_multicorrelator_8sc::set_local_code_and_taps(int32_t code_length_chips, -// float *shifts_chips, int32_t PRN) - void fpga_multicorrelator_8sc::set_local_code_and_taps(float *shifts_chips, float *prompt_data_shift, int32_t PRN) { d_shifts_chips = shifts_chips; d_prompt_data_shift = prompt_data_shift; - //d_code_length_chips = code_length_chips; fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(PRN); } @@ -123,7 +104,6 @@ void fpga_multicorrelator_8sc::set_output_vectors(gr_complex *corr_out, gr_compl void fpga_multicorrelator_8sc::update_local_code(float rem_code_phase_chips) { d_rem_code_phase_chips = rem_code_phase_chips; - //printf("uuuuu d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); fpga_multicorrelator_8sc::fpga_compute_code_shift_parameters(); fpga_multicorrelator_8sc::fpga_configure_code_parameters_in_fpga(); } @@ -146,13 +126,11 @@ void fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(); int32_t irq_count; ssize_t nb; - //printf("$$$$$ waiting for interrupt ... \n"); nb = read(d_device_descriptor, &irq_count, sizeof(irq_count)); - //printf("$$$$$ interrupt received ... \n"); if (nb != sizeof(irq_count)) { - printf("Tracking_module Read failed to retrieve 4 bytes!\n"); - printf("Tracking_module Interrupt number %d\n", irq_count); + std::cout << "Tracking_module Read failed to retrieve 4 bytes!" << std::endl; + std::cout << "Tracking_module Interrupt number " << irq_count << std::endl; } fpga_multicorrelator_8sc::read_tracking_gps_results(); } @@ -161,7 +139,6 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int32_t n_correlators, std::string device_name, uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip) { - //printf("tracking fpga class created\n"); d_n_correlators = n_correlators; d_device_name = std::move(device_name); d_device_base = device_base; @@ -197,103 +174,18 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int32_t n_correlators, d_initial_sample_counter = 0; d_channel = 0; d_correlator_length_samples = 0, - //d_code_length = code_length; - d_code_length_chips = code_length_chips; + d_code_length_chips = code_length_chips; d_ca_codes = ca_codes; d_data_codes = data_codes; d_multicorr_type = multicorr_type; - d_code_samples_per_chip = code_samples_per_chip; - // set up register mapping - // write-only registers - d_CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR = 0; - d_INITIAL_INDEX_REG_BASE_ADDR = 1; - // if (d_multicorr_type == 0) - // { - // // multicorrelator with 3 correlators (16 registers only) - // d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR = 4; - // d_NSAMPLES_MINUS_1_REG_ADDR = 7; - // d_CODE_LENGTH_MINUS_1_REG_ADDR = 8; - // d_REM_CARR_PHASE_RAD_REG_ADDR = 9; - // d_PHASE_STEP_RAD_REG_ADDR = 10; - // d_PROG_MEMS_ADDR = 11; - // d_DROP_SAMPLES_REG_ADDR = 12; - // d_INITIAL_COUNTER_VALUE_REG_ADDR = 13; - // d_START_FLAG_ADDR = 14; - // } - // else - // { - // other types of multicorrelators (32 registers) - d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR = 7; - d_NSAMPLES_MINUS_1_REG_ADDR = 13; - d_CODE_LENGTH_MINUS_1_REG_ADDR = 14; - d_REM_CARR_PHASE_RAD_REG_ADDR = 15; - d_PHASE_STEP_RAD_REG_ADDR = 16; - d_PROG_MEMS_ADDR = 17; - d_DROP_SAMPLES_REG_ADDR = 18; - d_INITIAL_COUNTER_VALUE_REG_ADDR_LSW = 19; - d_INITIAL_COUNTER_VALUE_REG_ADDR_MSW = 20; - d_START_FLAG_ADDR = 30; - // } - - //printf("d_n_correlators = %d\n", d_n_correlators); - //printf("d_multicorr_type = %d\n", d_multicorr_type); - // read-write registers - // if (d_multicorr_type == 0) - // { - // // multicorrelator with 3 correlators (16 registers only) - // d_TEST_REG_ADDR = 15; - // } - // else - // { - // other types of multicorrelators (32 registers) - d_TEST_REG_ADDR = 31; - // } - - // result 2's complement saturation value - // if (d_multicorr_type == 0) - // { - // // multicorrelator with 3 correlators (16 registers only) - // d_result_SAT_value = 1048576; // 21 bits 2's complement -> 2^20 - // } - // else - // { - // // other types of multicorrelators (32 registers) - // d_result_SAT_value = 4194304; // 23 bits 2's complement -> 2^22 - // } - - // read only registers - d_RESULT_REG_REAL_BASE_ADDR = 1; - // if (d_multicorr_type == 0) - // { - // // multicorrelator with 3 correlators (16 registers only) - // d_RESULT_REG_IMAG_BASE_ADDR = 4; - // d_RESULT_REG_DATA_REAL_BASE_ADDR = 0; // no pilot tracking - // d_RESULT_REG_DATA_IMAG_BASE_ADDR = 0; - // d_SAMPLE_COUNTER_REG_ADDR = 7; - // - // } - // else - // { - // other types of multicorrelators (32 registers) - d_RESULT_REG_IMAG_BASE_ADDR = 7; - //d_RESULT_REG_DATA_REAL_BASE_ADDR = 6; // no pilot tracking - //d_RESULT_REG_DATA_IMAG_BASE_ADDR = 12; - d_SAMPLE_COUNTER_REG_ADDR_LSW = 13; - d_SAMPLE_COUNTER_REG_ADDR_MSW = 14; - - // } - - //printf("d_SAMPLE_COUNTER_REG_ADDR = %d\n", d_SAMPLE_COUNTER_REG_ADDR); - //printf("mmmmmmmmmmmmm d_n_correlators = %d\n", d_n_correlators); DLOG(INFO) << "TRACKING FPGA CLASS CREATED"; } fpga_multicorrelator_8sc::~fpga_multicorrelator_8sc() { - //delete[] d_ca_codes; close_device(); } @@ -322,7 +214,6 @@ bool fpga_multicorrelator_8sc::free() void fpga_multicorrelator_8sc::set_channel(uint32_t channel) { - //printf("www trk set channel channel=%lu\n", (unsigned long) channel); char device_io_name[MAX_LENGTH_DEVICEIO_NAME]; // driver io name d_channel = channel; @@ -334,22 +225,13 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) mergedname = d_device_name + devicebasetemp.str(); strcpy(device_io_name, mergedname.c_str()); - //printf("ppps opening device %s\n", device_io_name); - - printf("trk device_io_name = %s\n", device_io_name); + std::cout << "trk device_io_name = " << device_io_name << std::endl; if ((d_device_descriptor = open(device_io_name, O_RDWR | O_SYNC)) == -1) { LOG(WARNING) << "Cannot open deviceio" << device_io_name; std::cout << "Cannot open deviceio" << device_io_name << std::endl; - - //printf("error opening device\n"); } - // else - // { - // std::cout << "deviceio" << device_io_name << " opened successfully" << std::endl; - // - // } d_map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0)); @@ -358,16 +240,7 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) LOG(WARNING) << "Cannot map the FPGA tracking module " << d_channel << "into user memory"; std::cout << "Cannot map deviceio" << device_io_name << std::endl; - //printf("error mapping registers\n"); } - // else - // { - // std::cout << "deviceio" << device_io_name << "mapped successfully" << std::endl; - // } - // else - // { - // printf("trk mapping registers succes\n"); // this is for debug -- remove ! - // } // sanity check : check test register uint32_t writeval = TEST_REGISTER_TRACK_WRITEVAL; @@ -376,15 +249,11 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) if (writeval != readval) { LOG(WARNING) << "Test register sanity check failed"; - printf("tracking test register sanity check failed\n"); - - //printf("lslslls test sanity check reg failure\n"); + std::cout << "tracking test register sanity check failed" << std::endl; } else { LOG(INFO) << "Test register sanity check success !"; - //printf("tracking test register sanity check success\n"); - //printf("lslslls test sanity check reg success\n"); } } @@ -392,13 +261,11 @@ void fpga_multicorrelator_8sc::set_channel(uint32_t channel) uint32_t fpga_multicorrelator_8sc::fpga_acquisition_test_register( uint32_t writeval) { - //printf("d_TEST_REG_ADDR = %d\n", d_TEST_REG_ADDR); - uint32_t readval = 0; // write value to test register - d_map_base[d_TEST_REG_ADDR] = writeval; + d_map_base[TEST_REG_ADDR] = writeval; // read value from test register - readval = d_map_base[d_TEST_REG_ADDR]; + readval = d_map_base[TEST_REG_ADDR]; // return read value return readval; } @@ -409,28 +276,10 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR uint32_t k; uint32_t code_chip; uint32_t select_pilot_corelator = LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; - // select_fpga_correlator = 0; - //printf("kkk d_n_correlators = %x\n", d_n_correlators); - //printf("kkk d_code_length_chips = %d\n", d_code_length_chips); - //printf("programming mems d map base %d\n", d_PROG_MEMS_ADDR); - - //FILE *fp; - //char str[80]; - //sprintf(str, "generated_code_PRN%d", PRN); - //fp = fopen(str,"w"); - // for (s = 0; s < d_n_correlators; s++) - // { - - //printf("kkk select_fpga_correlator = %x\n", select_fpga_correlator); - - d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; - //printf("trk lib d_code_length_chips = %d, d_code_samples_per_chip = %d\n", d_code_length_chips, d_code_samples_per_chip); + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { - //if (d_local_code_in[k] == 1) - //printf("kkk d_ca_codes %d = %d\n", k, d_ca_codes[((int(d_code_length)) * (PRN - 1)) + k]); - //fprintf(fp, "%d\n", d_ca_codes[((int(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k]); if (d_ca_codes[((int(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) { code_chip = 1; @@ -441,21 +290,14 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR } // copy the local code to the FPGA memory one by one - d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip; // | select_fpga_correlator; + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip; // | select_fpga_correlator; } - // select_fpga_correlator = select_fpga_correlator - // + LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT; - // } - //fclose(fp); - //printf("kkk d_track_pilot = %d\n", d_track_pilot); if (d_track_pilot) { - //printf("kkk select_fpga_correlator = %x\n", select_fpga_correlator); - d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { - //if (d_local_code_in[k] == 1) if (d_data_codes[((int(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) { code_chip = 1; @@ -464,12 +306,9 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR { code_chip = 0; } - //printf("%d %d | ", d_data_codes, code_chip); - // copy the local code to the FPGA memory one by one - d_map_base[d_PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip | select_pilot_corelator; + d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip | select_pilot_corelator; } } - //printf("\n"); } @@ -478,39 +317,27 @@ void fpga_multicorrelator_8sc::fpga_compute_code_shift_parameters(void) float temp_calculation; int32_t i; - //printf("ppp d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); for (i = 0; i < d_n_correlators; i++) { - //printf("ppp d_shifts_chips %d = %f\n", i, d_shifts_chips[i]); - //printf("ppp d_code_samples_per_chip = %d\n", d_code_samples_per_chip); temp_calculation = floor( d_shifts_chips[i] - d_rem_code_phase_chips); - //printf("ppp d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); - //printf("ppp temp calculation %d = %f ================================ \n", i, temp_calculation); if (temp_calculation < 0) { temp_calculation = temp_calculation + (d_code_length_chips * d_code_samples_per_chip); // % operator does not work as in Matlab with negative numbers } - //printf("ppp d_rem_code_phase_chips = %f\n", d_rem_code_phase_chips); - //printf("ppp temp calculation %d = %f ================================ \n", i, temp_calculation); d_initial_index[i] = static_cast((static_cast(temp_calculation)) % (d_code_length_chips * d_code_samples_per_chip)); - //printf("ppp d_initial_index %d = %d\n", i, d_initial_index[i]); temp_calculation = fmod(d_shifts_chips[i] - d_rem_code_phase_chips, 1.0); - //printf("ppp fmod %d = fmod(%f, 1) = %f\n", i, d_shifts_chips[i] - d_rem_code_phase_chips, temp_calculation); if (temp_calculation < 0) { temp_calculation = temp_calculation + 1.0; // fmod operator does not work as in Matlab with negative numbers } d_initial_interp_counter[i] = static_cast(floor(MAX_CODE_RESAMPLER_COUNTER * temp_calculation)); - //printf("ppp d_initial_interp_counter %d = %d\n", i, d_initial_interp_counter[i]); - //printf("MAX_CODE_RESAMPLER_COUNTER = %d\n", MAX_CODE_RESAMPLER_COUNTER); } if (d_track_pilot) { - //printf("tracking pilot !!!!!!!!!!!!!!!!\n"); temp_calculation = floor( d_prompt_data_shift[0] - d_rem_code_phase_chips); @@ -527,7 +354,6 @@ void fpga_multicorrelator_8sc::fpga_compute_code_shift_parameters(void) } d_initial_interp_counter[d_n_correlators] = static_cast(floor(MAX_CODE_RESAMPLER_COUNTER * temp_calculation)); } - //while(1); } @@ -536,23 +362,16 @@ void fpga_multicorrelator_8sc::fpga_configure_code_parameters_in_fpga(void) int32_t i; for (i = 0; i < d_n_correlators; i++) { - //printf("www writing d map base %d = d_initial_index %d = %d\n", d_INITIAL_INDEX_REG_BASE_ADDR + i, i, d_initial_index[i]); - d_map_base[d_INITIAL_INDEX_REG_BASE_ADDR + i] = d_initial_index[i]; - //d_map_base[1 + d_n_correlators + i] = d_initial_interp_counter[i]; - //printf("www writing d map base %d = d_initial_interp_counter %d = %d\n", d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR + i, i, d_initial_interp_counter[i]); - d_map_base[d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR + i] = d_initial_interp_counter[i]; + d_map_base[INITIAL_INDEX_REG_BASE_ADDR + i] = d_initial_index[i]; + d_map_base[INITIAL_INTERP_COUNTER_REG_BASE_ADDR + i] = d_initial_interp_counter[i]; } if (d_track_pilot) { - //printf("www writing d map base %d = d_initial_index %d = %d\n", d_INITIAL_INDEX_REG_BASE_ADDR + d_n_correlators, d_n_correlators, d_initial_index[d_n_correlators]); - d_map_base[d_INITIAL_INDEX_REG_BASE_ADDR + d_n_correlators] = d_initial_index[d_n_correlators]; - //d_map_base[1 + d_n_correlators + i] = d_initial_interp_counter[i]; - //printf("www writing d map base %d = d_initial_interp_counter %d = %d\n", d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR + d_n_correlators, d_n_correlators, d_initial_interp_counter[d_n_correlators]); - d_map_base[d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR + d_n_correlators] = d_initial_interp_counter[d_n_correlators]; + d_map_base[INITIAL_INDEX_REG_BASE_ADDR + d_n_correlators] = d_initial_index[d_n_correlators]; + d_map_base[INITIAL_INTERP_COUNTER_REG_BASE_ADDR + d_n_correlators] = d_initial_interp_counter[d_n_correlators]; } - //printf("www writing d map base %d = d_code_length_chips*d_code_samples_per_chip - 1 = %d\n", d_CODE_LENGTH_MINUS_1_REG_ADDR, (d_code_length_chips*d_code_samples_per_chip) - 1); - d_map_base[d_CODE_LENGTH_MINUS_1_REG_ADDR] = (d_code_length_chips * d_code_samples_per_chip) - 1; // number of samples - 1 + d_map_base[CODE_LENGTH_MINUS_1_REG_ADDR] = (d_code_length_chips * d_code_samples_per_chip) - 1; // number of samples - 1 } @@ -563,11 +382,9 @@ void fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(void) d_code_phase_step_chips_num = static_cast(roundf(MAX_CODE_RESAMPLER_COUNTER * d_code_phase_step_chips)); if (d_code_phase_step_chips > 1.0) { - printf("Warning : d_code_phase_step_chips = %f cannot be bigger than one\n", d_code_phase_step_chips); + std::cout << "Warning : d_code_phase_step_chips = " << d_code_phase_step_chips << " cannot be bigger than one" << std::endl; } - //printf("d_rem_carrier_phase_in_rad = %f\n", d_rem_carrier_phase_in_rad); - if (d_rem_carrier_phase_in_rad > M_PI) { d_rem_carrier_phase_in_rad_temp = -2 * M_PI + d_rem_carrier_phase_in_rad; @@ -589,29 +406,23 @@ void fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(void) d_phase_step_rad_int = static_cast(roundf( (fabs(d_phase_step_rad) / M_PI) * pow(2, PHASE_CARR_NBITS_FRAC))); // the FPGA accepts a range for the phase step between -pi and +pi - //printf("d_phase_step_rad_int = %d\n", d_phase_step_rad_int); if (d_phase_step_rad < 0) { d_phase_step_rad_int = -d_phase_step_rad_int; } - //printf("d_phase_step_rad_int = %d\n", d_phase_step_rad_int); } void fpga_multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(void) { - //printf("www d map base %d = d_code_phase_step_chips_num = %d\n", d_CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR, d_code_phase_step_chips_num); - d_map_base[d_CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR] = d_code_phase_step_chips_num; + d_map_base[CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR] = d_code_phase_step_chips_num; - //printf("www d map base %d = d_correlator_length_samples - 1 = %d\n", d_NSAMPLES_MINUS_1_REG_ADDR, d_correlator_length_samples - 1); - d_map_base[d_NSAMPLES_MINUS_1_REG_ADDR] = d_correlator_length_samples - 1; + d_map_base[NSAMPLES_MINUS_1_REG_ADDR] = d_correlator_length_samples - 1; - //printf("www d map base %d = d_rem_carr_phase_rad_int = %d\n", d_REM_CARR_PHASE_RAD_REG_ADDR, d_rem_carr_phase_rad_int); - d_map_base[d_REM_CARR_PHASE_RAD_REG_ADDR] = d_rem_carr_phase_rad_int; + d_map_base[REM_CARR_PHASE_RAD_REG_ADDR] = d_rem_carr_phase_rad_int; - //printf("www d map base %d = d_phase_step_rad_int = %d\n", d_PHASE_STEP_RAD_REG_ADDR, d_phase_step_rad_int); - d_map_base[d_PHASE_STEP_RAD_REG_ADDR] = d_phase_step_rad_int; + d_map_base[PHASE_STEP_RAD_REG_ADDR] = d_phase_step_rad_int; } @@ -622,9 +433,7 @@ void fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(void) write(d_device_descriptor, reinterpret_cast(&reenable), sizeof(int32_t)); // writing 1 to reg 14 launches the tracking - //printf("www writing 1 to d map base %d = start flag\n", d_START_FLAG_ADDR); - d_map_base[d_START_FLAG_ADDR] = 1; - //while(1); + d_map_base[START_FLAG_ADDR] = 1; } @@ -634,76 +443,17 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) int32_t readval_imag; int32_t k; - //printf("www reading trk results\n"); for (k = 0; k < d_n_correlators; k++) { - readval_real = d_map_base[d_RESULT_REG_REAL_BASE_ADDR + k]; - //printf("read real before checking d map base %d = %d\n", d_RESULT_REG_BASE_ADDR + k, readval_real); - //// if (readval_real > debug_max_readval_real[k]) - //// { - //// debug_max_readval_real[k] = readval_real; - //// } - // if (readval_real >= d_result_SAT_value) // 0x100000 (21 bits two's complement) - // { - // readval_real = -2*d_result_SAT_value + readval_real; - // } - //// if (readval_real > debug_max_readval_real_after_check[k]) - //// { - //// debug_max_readval_real_after_check[k] = readval_real; - //// } - //printf("read real d map base %d = %d\n", d_RESULT_REG_BASE_ADDR + k, readval_real); - readval_imag = d_map_base[d_RESULT_REG_IMAG_BASE_ADDR + k]; - //printf("read imag before checking d map base %d = %d\n", d_RESULT_REG_BASE_ADDR + k, readval_imag); - //// if (readval_imag > debug_max_readval_imag[k]) - //// { - //// debug_max_readval_imag[k] = readval_imag; - //// } - // - // if (readval_imag >= d_result_SAT_value) // 0x100000 (21 bits two's complement) - // { - // readval_imag = -2*d_result_SAT_value + readval_imag; - // } - //// if (readval_imag > debug_max_readval_imag_after_check[k]) - //// { - //// debug_max_readval_imag_after_check[k] = readval_real; - //// } - //printf("read imag d map base %d = %d\n", d_RESULT_REG_BASE_ADDR + k, readval_imag); + readval_real = d_map_base[RESULT_REG_REAL_BASE_ADDR + k]; + readval_imag = d_map_base[RESULT_REG_IMAG_BASE_ADDR + k]; d_corr_out[k] = gr_complex(readval_real, readval_imag); - - // if (printcounter > 100) - // { - // printcounter = 0; - // for (int32_t ll=0;ll= d_result_SAT_value) // 0x100000 (21 bits two's complement) - // { - // readval_real = -2*d_result_SAT_value + readval_real; - // } - - //readval_imag = d_map_base[d_RESULT_REG_DATA_IMAG_BASE_ADDR]; - readval_imag = d_map_base[d_RESULT_REG_IMAG_BASE_ADDR + d_n_correlators]; - // if (readval_imag >= d_result_SAT_value) // 0x100000 (21 bits two's complement) - // { - // readval_imag = -2*d_result_SAT_value + readval_imag; - // } - d_Prompt_Data[0] = gr_complex(readval_real, readval_imag); + readval_real = d_map_base[RESULT_REG_REAL_BASE_ADDR + d_n_correlators]; + readval_imag = d_map_base[RESULT_REG_IMAG_BASE_ADDR + d_n_correlators]; + d_Prompt_Data[0] = gr_complex(readval_real, readval_imag); } } @@ -711,9 +461,8 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) void fpga_multicorrelator_8sc::unlock_channel(void) { // unlock the channel to let the next samples go through - //printf("www writing 1 to d map base %d = drop samples\n", d_DROP_SAMPLES_REG_ADDR); - d_map_base[d_DROP_SAMPLES_REG_ADDR] = 1; // unlock the channel - d_map_base[23] = 1; // set the tracking module back to idle + d_map_base[DROP_SAMPLES_REG_ADDR] = 1; // unlock the channel + d_map_base[STOP_TRACKING_REG_ADDR] = 1; // set the tracking module back to idle } void fpga_multicorrelator_8sc::close_device() @@ -721,7 +470,7 @@ void fpga_multicorrelator_8sc::close_device() auto *aux = const_cast(d_map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - printf("Failed to unmap memory uio\n"); + std::cout << "Failed to unmap memory uio" << std::endl; } close(d_device_descriptor); } @@ -730,20 +479,6 @@ void fpga_multicorrelator_8sc::close_device() void fpga_multicorrelator_8sc::lock_channel(void) { // lock the channel for processing - //printf("www writing 0 to d map base %d = drop samples\n", d_DROP_SAMPLES_REG_ADDR); - d_map_base[d_DROP_SAMPLES_REG_ADDR] = 0; // lock the channel + d_map_base[DROP_SAMPLES_REG_ADDR] = 0; // lock the channel } -//void fpga_multicorrelator_8sc::read_sample_counters(int32_t *sample_counter, int32_t *secondary_sample_counter, int32_t *counter_corr_0_in, int32_t *counter_corr_0_out) -//{ -// *sample_counter = d_map_base[11]; -// *secondary_sample_counter = d_map_base[8]; -// *counter_corr_0_in = d_map_base[10]; -// *counter_corr_0_out = d_map_base[9]; -// -//} - -//void fpga_multicorrelator_8sc::reset_multicorrelator(void) -//{ -// d_map_base[14] = 2; // writing a 2 to d_map_base[14] resets the multicorrelator -//} diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index ad0d44233..95d5c580a 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -1,8 +1,8 @@ /*! * \file fpga_multicorrelator_8sc.h - * \brief High optimized FPGA vector correlator class for lv_16sc_t (short int32_t complex) + * \brief High optimized FPGA vector correlator class * \authors
            - *
          • Marc Majoral, 2017. mmajoral(at)cttc.cat + *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat *
          • Javier Arribas, 2016. jarribas(at)cttc.es *
          * @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -41,7 +41,31 @@ #include #include -#define MAX_LENGTH_DEVICEIO_NAME 50 +// FPGA register addresses + +// write addresses +#define CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR 0 +#define INITIAL_INDEX_REG_BASE_ADDR 1 +#define INITIAL_INTERP_COUNTER_REG_BASE_ADDR 7 +#define NSAMPLES_MINUS_1_REG_ADDR 13 +#define CODE_LENGTH_MINUS_1_REG_ADDR 14 +#define REM_CARR_PHASE_RAD_REG_ADDR 15 +#define PHASE_STEP_RAD_REG_ADDR 16 +#define PROG_MEMS_ADDR 17 +#define DROP_SAMPLES_REG_ADDR 18 +#define INITIAL_COUNTER_VALUE_REG_ADDR_LSW 19 +#define INITIAL_COUNTER_VALUE_REG_ADDR_MSW 20 +#define STOP_TRACKING_REG_ADDR 23 +#define START_FLAG_ADDR 30 +// read-write addresses +#define TEST_REG_ADDR 31 +// read addresses +#define RESULT_REG_REAL_BASE_ADDR 1 +#define RESULT_REG_IMAG_BASE_ADDR 7 +#define SAMPLE_COUNTER_REG_ADDR_LSW 13 +#define SAMPLE_COUNTER_REG_ADDR_MSW 14 + + /*! * \brief Class that implements carrier wipe-off and correlators. @@ -50,36 +74,26 @@ class fpga_multicorrelator_8sc { public: fpga_multicorrelator_8sc(int32_t n_correlators, std::string device_name, - uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip); + uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip); ~fpga_multicorrelator_8sc(); - //bool set_output_vectors(gr_complex* corr_out); void set_output_vectors(gr_complex *corr_out, gr_complex *Prompt_Data); - // bool set_local_code_and_taps( - // int32_t code_length_chips, const int* local_code_in, - // float *shifts_chips, int32_t PRN); - //bool set_local_code_and_taps( void set_local_code_and_taps( - // int32_t code_length_chips, - float *shifts_chips, float *prompt_data_shift, int32_t PRN); - //bool set_output_vectors(lv_16sc_t* corr_out); + float *shifts_chips, float *prompt_data_shift, int32_t PRN); void update_local_code(float rem_code_phase_chips); - //bool Carrier_wipeoff_multicorrelator_resampler( void Carrier_wipeoff_multicorrelator_resampler( - float rem_carrier_phase_in_rad, float phase_step_rad, - float carrier_phase_rate_step_rad, - float rem_code_phase_chips, float code_phase_step_chips, - float code_phase_rate_step_chips, - int32_t signal_length_samples); + float rem_carrier_phase_in_rad, float phase_step_rad, + float carrier_phase_rate_step_rad, + float rem_code_phase_chips, float code_phase_step_chips, + float code_phase_rate_step_chips, + int32_t signal_length_samples); bool free(); void set_channel(uint32_t channel); void set_initial_sample(uint64_t samples_offset); uint64_t read_sample_counter(); void lock_channel(void); void unlock_channel(void); - //void read_sample_counters(int32_t *sample_counter, int32_t *secondary_sample_counter, int32_t *counter_corr_0_in, int32_t *counter_corr_0_out); // debug private: - //const int32_t *d_local_code_in; gr_complex *d_corr_out; gr_complex *d_Prompt_Data; float *d_shifts_chips; @@ -115,37 +129,11 @@ private: int32_t *d_ca_codes; int32_t *d_data_codes; - //uint32_t d_code_length; // nominal number of chips - uint32_t d_code_samples_per_chip; bool d_track_pilot; uint32_t d_multicorr_type; - // register addresses - // write-only regs - uint32_t d_CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR; - uint32_t d_INITIAL_INDEX_REG_BASE_ADDR; - uint32_t d_INITIAL_INTERP_COUNTER_REG_BASE_ADDR; - uint32_t d_NSAMPLES_MINUS_1_REG_ADDR; - uint32_t d_CODE_LENGTH_MINUS_1_REG_ADDR; - uint32_t d_REM_CARR_PHASE_RAD_REG_ADDR; - uint32_t d_PHASE_STEP_RAD_REG_ADDR; - uint32_t d_PROG_MEMS_ADDR; - uint32_t d_DROP_SAMPLES_REG_ADDR; - uint32_t d_INITIAL_COUNTER_VALUE_REG_ADDR_LSW; - uint32_t d_INITIAL_COUNTER_VALUE_REG_ADDR_MSW; - uint32_t d_START_FLAG_ADDR; - // read-write regs - uint32_t d_TEST_REG_ADDR; - // read-only regs - uint32_t d_RESULT_REG_REAL_BASE_ADDR; - uint32_t d_RESULT_REG_IMAG_BASE_ADDR; - uint32_t d_RESULT_REG_DATA_REAL_BASE_ADDR; - uint32_t d_RESULT_REG_DATA_IMAG_BASE_ADDR; - uint32_t d_SAMPLE_COUNTER_REG_ADDR_LSW; - uint32_t d_SAMPLE_COUNTER_REG_ADDR_MSW; - // private functions uint32_t fpga_acquisition_test_register(uint32_t writeval); void fpga_configure_tracking_gps_local_code(int32_t PRN); @@ -155,17 +143,8 @@ private: void fpga_configure_signal_parameters_in_fpga(void); void fpga_launch_multicorrelator_fpga(void); void read_tracking_gps_results(void); - //void reset_multicorrelator(void); void close_device(void); - uint32_t d_result_SAT_value; - - int32_t debug_max_readval_real[5] = {0, 0, 0, 0, 0}; - int32_t debug_max_readval_imag[5] = {0, 0, 0, 0, 0}; - - int32_t debug_max_readval_real_after_check[5] = {0, 0, 0, 0, 0}; - int32_t debug_max_readval_imag_after_check[5] = {0, 0, 0, 0, 0}; - int32_t printcounter = 0; }; #endif /* GNSS_SDR_FPGA_MULTICORRELATOR_H_ */ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 0eba503e4..fba66d309 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -274,13 +274,9 @@ int ControlThread::run() cmd_interface_thread_ = std::thread(&ControlThread::telecommand_listener, this); #ifdef ENABLE_FPGA -// bool enable_FPGA = configuration_->property("Channel.enable_FPGA", false); -// if (enable_FPGA == true) -// { - // Create a task for the acquisition such that id doesn't block the flow of the control thread - fpga_helper_thread_=boost::thread(&GNSSFlowgraph::start_acquisition_helper, - flowgraph_); -// } + // Create a task for the acquisition such that id doesn't block the flow of the control thread + fpga_helper_thread_=boost::thread(&GNSSFlowgraph::start_acquisition_helper, + flowgraph_); #endif // Main loop to read and process the control messages while (flowgraph_->running() && !stop_) @@ -306,46 +302,17 @@ int ControlThread::run() flowgraph_->perform_hw_reset(); #endif -// <<<<<<< HEAD - -// Join keyboard thread -//#ifdef OLD_BOOST -// keyboard_thread_.timed_join(boost::posix_time::seconds(1)); -// sysv_queue_thread_.timed_join(boost::posix_time::seconds(1)); -// cmd_interface_thread_.timed_join(boost::posix_time::seconds(1)); -//#ifdef ENABLE_FPGA -//// if (enable_FPGA == true) -//// { -// fpga_helper_thread_.timed_join(boost::posix_time::seconds(1)); -//// } -//#endif -// -//#endif -//#ifndef OLD_BOOST -// keyboard_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); -// sysv_queue_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); -// cmd_interface_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); - pthread_t id = keyboard_thread_.native_handle(); keyboard_thread_.detach(); pthread_cancel(id); #ifdef ENABLE_FPGA -// if (enable_FPGA == true) -// { - fpga_helper_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); -// } + + fpga_helper_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); + #endif -// #endif - LOG(INFO) << "Flowgraph stopped"; -//======= -// // Terminate keyboard thread -// pthread_t id = keyboard_thread_.native_handle(); -// keyboard_thread_.detach(); -// pthread_cancel(id); -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 if (restart_) { diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index a87e5bbba..b1e226ca8 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -11,7 +11,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 50f4d6f96..378c135d2 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -9,7 +9,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -126,8 +126,8 @@ void GNSSFlowgraph::connect() #ifndef ENABLE_FPGA for (int i = 0; i < sources_count_; i++) { -// if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) -// { + if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) + { try { sig_source_.at(i)->connect(top_block_); @@ -139,15 +139,15 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } -// } + } } // Signal Source > Signal conditioner > for (unsigned int i = 0; i < sig_conditioner_.size(); i++) { -// if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false) -// { + if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false) + { try { sig_conditioner_.at(i)->connect(top_block_); @@ -159,7 +159,7 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } -// } + } } #endif for (unsigned int i = 0; i < channels_count_; i++) @@ -212,137 +212,102 @@ void GNSSFlowgraph::connect() for (int i = 0; i < sources_count_; i++) { -// //FPGA Accelerators do not need signal sources or conditioners -// //as the samples are feed directly to the FPGA fabric, so, if enabled, do not connect any source -// if (configuration_->property(sig_source_.at(i)->role() + ".enable_FPGA", false) == false) -// { - try - { - //TODO: Remove this array implementation and create generic multistream connector - //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") - { - //Multichannel Array - std::cout << "ARRAY MODE" << std::endl; - for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) - { - std::cout << "connecting ch " << j << std::endl; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); - } - } - else - { - //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - //Include GetRFChannels in the interface to avoid read config parameters here - //read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + try + { + //TODO: Remove this array implementation and create generic multistream connector + //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + { + //Multichannel Array + std::cout << "ARRAY MODE" << std::endl; + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + std::cout << "connecting ch " << j << std::endl; + top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + //Include GetRFChannels in the interface to avoid read config parameters here + //read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); - for (int j = 0; j < RF_Channels; j++) - { - //Connect the multichannel signal source to multiple signal conditioners - // GNURADIO max_streams=-1 means infinite ports! - LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); - LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); + for (int j = 0; j < RF_Channels; j++) + { + //Connect the multichannel signal source to multiple signal conditioners + // GNURADIO max_streams=-1 means infinite ports! + LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); + LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) - { - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - if (j == 0) - { - // RF_channel 0 backward compatibility with single channel sources - LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - } - signal_conditioner_ID++; - } - } - } - catch (const std::exception& e) - { - LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; - LOG(ERROR) << e.what(); - top_block_->disconnect_all(); - return; - } -// } + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; + } } DLOG(INFO) << "Signal source connected to signal conditioner"; -// bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); #endif #if ENABLE_FPGA -//<<<<<<< HEAD -// if (FPGA_enabled == false) -// { -// //connect the signal source to sample counter -// //connect the sample counter to Observables -// try -// { -// double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); -// if (fs == 0.0) -// { -// LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; -// std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; -// throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); -// } -// int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); -// ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); -// //ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); -// top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); -// top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse -// } -// catch (const std::exception& e) -// { -// LOG(WARNING) << "Can't connect sample counter"; -// LOG(ERROR) << e.what(); -// top_block_->disconnect_all(); -// return; -// } -// } -// else -// { -//======= -// if (FPGA_enabled == false) -// { -// //connect the signal source to sample counter -// //connect the sample counter to Observables -// try -// { -// double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); -// if (fs == 0.0) -// { -// LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; -// std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; -// throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); -// } -// int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); -// ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); -// top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); -// top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse -// } -// catch (const std::exception& e) -// { -// LOG(WARNING) << "Can't connect sample counter"; -// LOG(ERROR) << e.what(); -// top_block_->disconnect_all(); -// return; -// } -// } -// else -// { -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 +// bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); + + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) + { + //connect the signal source to sample counter + //connect the sample counter to Observables + try + { + double fs = static_cast(configuration_->property("GNSS-SDR.internal_fs_sps", 0)); + if (fs == 0.0) + { + LOG(WARNING) << "Set GNSS-SDR.internal_fs_sps in configuration file"; + std::cout << "Set GNSS-SDR.internal_fs_sps in configuration file" << std::endl; + throw(std::invalid_argument("Set GNSS-SDR.internal_fs_sps in configuration")); + } + int observable_interval_ms = static_cast(configuration_->property("GNSS-SDR.observable_interval_ms", 20)); + ch_out_sample_counter = gnss_sdr_make_sample_counter(fs, observable_interval_ms, sig_conditioner_.at(0)->get_right_block()->output_signature()->sizeof_stream_item(0)); + top_block_->connect(sig_conditioner_.at(0)->get_right_block(), 0, ch_out_sample_counter, 0); + top_block_->connect(ch_out_sample_counter, 0, observables_->get_left_block(), channels_count_); //extra port for the sample counter pulse + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect sample counter"; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; + } + } + else + { + //create a hardware-defined gnss_synchro pulse for the observables block try { @@ -364,7 +329,7 @@ void GNSSFlowgraph::connect() top_block_->disconnect_all(); return; } -// } + } #else // connect the signal source to sample counter // connect the sample counter to Observables @@ -402,8 +367,8 @@ void GNSSFlowgraph::connect() { #ifndef ENABLE_FPGA -// if (FPGA_enabled == false) -// { + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) + { try { selected_signal_conditioner_ID = configuration_->property("Channel" + std::to_string(i) + ".RF_channel_ID", 0); @@ -540,7 +505,7 @@ void GNSSFlowgraph::connect() } DLOG(INFO) << "signal conditioner " << selected_signal_conditioner_ID << " connected to channel " << i; -// } + } #endif // Signal Source > Signal conditioner >> Channels >> Observables try @@ -855,7 +820,6 @@ void GNSSFlowgraph::disconnect() } #endif - //printf("disconnect process point 1\n"); #ifdef ENABLE_FPGA //bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); if (FPGA_enabled == false) diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index b171502bc..877ca888b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -7,7 +7,7 @@ * * ------------------------------------------------------------------------- * - * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -63,7 +63,6 @@ #include "gps_l1_ca_dll_pll_tracking_fpga.h" #include "hybrid_observables.h" #include "signal_generator_flags.h" -//#include "gnss_sdr_sample_counter.h" #include "gnss_sdr_fpga_sample_counter.h" #include "test_flags.h" #include "tracking_tests_flags.h" @@ -79,23 +78,15 @@ #define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define TEST_OBS_NSAMPLES_TRACKING 1000000000 // number of samples during which we test the tracking module -#define TEST_OBS_NSAMPLES_FINAL 50000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module -#define TEST_OBS_NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop -#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter -#define DOWNSAMPLING_FILTER_DELAY 48 -#define DOWNSAMPLING_FILTER_OFFSET_SAMPLES 0 +#define TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define TEST_OBS_DOWNSAMPLING_FILTER_DELAY 48 + // HW related options -//bool test_observables_doppler_control_in_sw = 1; // 1 => doppler sweep controlled by the SW test code , 0 => doppler sweep controlled by the HW bool test_observables_show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if test_observables_doppler_control_in_sw = 1), 0=> do not show it bool test_observables_skip_samples_already_used = 1; // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops - // (exactly in the same way as the SW) - // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 0 => the sampe samples are used for each PRN loop - // if test_observables_doppler_control_in_sw = 0 => test_observables_skip_samples_already_used is not applicable -bool doppler_loop_control_in_sw_obs_test = 0; + // (exactly in the same way as the SW) -// ######## GNURADIO BLOCK MESSAGE RECEVER FOR TRACKING MESSAGES ######### class HybridObservablesTest_msg_rx_Fpga; typedef boost::shared_ptr HybridObservablesTest_msg_rx_Fpga_sptr; @@ -145,10 +136,6 @@ HybridObservablesTest_msg_rx_Fpga::~HybridObservablesTest_msg_rx_Fpga() } -// ########################################################### - - -// ######## GNURADIO BLOCK MESSAGE RECEVER FOR TLM MESSAGES ######### class HybridObservablesTest_tlm_msg_rx_Fpga; typedef boost::shared_ptr HybridObservablesTest_tlm_msg_rx_Fpga_sptr; @@ -197,10 +184,6 @@ HybridObservablesTest_tlm_msg_rx_Fpga::~HybridObservablesTest_tlm_msg_rx_Fpga() { } - -// ########################################################### - - class HybridObservablesTestFpga : public ::testing::Test { public: @@ -394,14 +377,12 @@ void *handler_DMA_obs_test(void *arguments) unsigned int nread_elements; // number of elements effectively read from the input file unsigned int nsamples = 0; // number of complex samples effectively transferred unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA - unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes unsigned int nsamples_transmitted; struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; unsigned int nsamples_tx = args->nsamples_tx; - //printf("in handler DMA to send %d\n", nsamples_tx); std::string file = args->file; // input filename unsigned int skip_used_samples = args->skip_used_samples; @@ -409,46 +390,31 @@ void *handler_DMA_obs_test(void *arguments) tx_fd = open("/dev/loop_tx", O_WRONLY); if ( tx_fd < 0 ) { - printf("DMA can't open loop device\n"); + std::cout << "DMA can't open loop device" << std::endl; exit(1); } else // open input file rx_signal_file_id = fopen(file.c_str(), "rb"); - if (rx_signal_file_id < 0) + if (rx_signal_file_id == NULL) { - printf("DMA can't open input file\n"); + std::cout << "DMA can't open input file" << std::endl; exit(1); } - //printf("in handler DMA waiting for send samples start\n"); while(send_samples_start_obs_test == 0); // wait until acquisition starts - //printf("in handler DMA going to send samples\n"); // skip initial samples int skip_samples = (int) FLAGS_skip_samples; fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); - //printf("sending %d samples starting at position %d\n", nsamples_tx,skip_samples + skip_used_samples); - //printf("\n dma skip_samples = %d\n", skip_samples); - //printf("\n dma skip used samples = %d\n", skip_used_samples); - //printf("dma skip_samples = %d\n", skip_samples); - //printf("dma skip used samples = %d\n", skip_used_samples); - //printf("dma file_completed = %d\n", file_completed); - //printf("dma nsamples = %d\n", nsamples); - //printf("dma nsamples_tx = %d\n", nsamples_tx); usleep(50000); // wait some time to give time to the main thread to start the acquisition module - unsigned int kk; - //printf("enter kk"); - //scanf("%d", &kk); - //printf("args->freq_band = %d\n", (int) args->freq_band); while (file_completed == false) { - //printf("samples sent = %d\n", nsamples); - if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + if (nsamples_tx - nsamples > TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL) { - nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + nsamples_block = TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL; } else { @@ -456,21 +422,21 @@ void *handler_DMA_obs_test(void *arguments) file_completed = true; } - nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block*TEST_OBS_COMPLEX_SAMPLE_SIZE, rx_signal_file_id); - if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) + if (nread_elements != nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE) { - printf("file completed\n"); + std::cout << "file completed" << std::endl; file_completed = true; } - nsamples+=(nread_elements/COMPLEX_SAMPLE_SIZE); + nsamples+=(nread_elements/TEST_OBS_COMPLEX_SAMPLE_SIZE); if (nread_elements > 0) { // for the 32-BIT DMA dma_index = 0; - for (index0 = 0;index0 < (nread_elements);index0+=COMPLEX_SAMPLE_SIZE) + for (index0 = 0;index0 < (nread_elements);index0+=TEST_OBS_COMPLEX_SAMPLE_SIZE) { if (args->freq_band == 0) { @@ -492,10 +458,8 @@ void *handler_DMA_obs_test(void *arguments) } dma_index += 4; } - //printf("writing samples to send\n"); - nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements*NUM_QUEUES); - //printf("exited writing samples to send\n"); - if (nsamples_transmitted != nread_elements*NUM_QUEUES) + nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements*TEST_OBS_NUM_QUEUES); + if (nsamples_transmitted != nread_elements*TEST_OBS_NUM_QUEUES) { std::cout << "Error : DMA could not send all the requested samples" << std::endl; } @@ -505,7 +469,6 @@ void *handler_DMA_obs_test(void *arguments) close(tx_fd); fclose(rx_signal_file_id); - //printf("DMA finished\n"); return NULL; } @@ -516,23 +479,6 @@ bool HybridObservablesTestFpga::acquire_signal() pthread_t thread_DMA; - int baseband_sampling_freq_acquisition; - // step 0 determine the sampling frequency - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - //printf(" aaaaaa baseband_sampling_freq_acquisition = %d\n", baseband_sampling_freq_acquisition); - } - else - { - baseband_sampling_freq_acquisition = baseband_sampling_freq; - } - // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); @@ -543,24 +489,6 @@ bool HybridObservablesTestFpga::acquire_signal() tmp_gnss_synchro.Channel_ID = 0; config = std::make_shared(); config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); - //config->set_property("Acquisition.blocking_on_standby", "true"); -- not used in the HW - //config->set_property("Acquisition.blocking", "true"); -- not used in the HW - //config->set_property("Acquisition.dump", "false"); -- not used in the HW - //config->set_property("Acquisition.dump_filename", "./data/acquisition.dat"); -- not used in the HW - //config->set_property("Acquisition.use_CFAR_algorithm", "false"); -- not used in the HW at this moment - - //config->set_property("Acquisition.item_type", "cshort"); - //config->set_property("Acquisition.if", "0"); - //config->set_property("Acquisition.sampled_ms", "4"); - //config->set_property("Acquisition.select_queue_Fpga", "0"); - //config->set_property("Acquisition.devicename", "/dev/uio0"); - - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - - //if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - //{ - // config->set_property("Acquisition.acquire_pilot", "false"); -- ALREADY THE DEFAULT VALUE - //} std::shared_ptr acquisition; @@ -569,20 +497,13 @@ bool HybridObservablesTestFpga::acquire_signal() struct DMA_handler_args_obs_test args; //create the correspondign acquisition block according to the desired tracking signal - //printf("AAAAAAAAAAAAAAAAAAAAA\n"); if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.select_queue_Fpga", "0"); - //config->set_property("Acquisition.sampled_ms", "1"); - //printf("AAAAAAAAAAAAAAAAAAAAA2222\n"); tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L1 CA"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - ////acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); args.freq_band = 0; @@ -591,15 +512,11 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.select_queue_Fpga", "0"); - //config->set_property("Acquisition.sampled_ms", "4"); tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E1B"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); args.freq_band = 0; @@ -609,15 +526,11 @@ bool HybridObservablesTestFpga::acquire_signal() else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.select_queue_Fpga", "1"); - //config->set_property("Acquisition.sampled_ms", "1"); tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "Galileo E5a"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); args.freq_band = 1; @@ -626,15 +539,11 @@ bool HybridObservablesTestFpga::acquire_signal() } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.select_queue_Fpga", "1"); - //config->set_property("Acquisition.sampled_ms", "1"); tmp_gnss_synchro.System = 'G'; std::string signal = "L5"; signal.copy(tmp_gnss_synchro.Signal, 2, 0); tmp_gnss_synchro.PRN = SV_ID; System_and_Signal = "GPS L5I"; - //config->set_property("Acquisition.max_dwells", std::to_string(FLAGS_external_signal_acquisition_dwells)); - //acquisition = std::make_shared(config.get(), "Acquisition", 1, 0); args.freq_band = 1; @@ -652,9 +561,6 @@ bool HybridObservablesTestFpga::acquire_signal() acquisition->connect(top_block); std::string file = FLAGS_signal_file; - const char* file_name = file.c_str(); - -// struct DMA_handler_args_obs_test args; boost::shared_ptr msg_rx; try @@ -697,412 +603,31 @@ bool HybridObservablesTestFpga::acquire_signal() setup_fpga_switch_obs_test(); - unsigned int code_length; unsigned int nsamples_to_transfer; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - //printf("dddddd code_length = %d nsamples_to_transfer = %d\n", code_length, nsamples_to_transfer); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS))); } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / GPS_L5I_CODE_LENGTH_CHIPS))); } - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); - unsigned int nsamples_total = fft_size; - //printf("EEEEEEEEEEEEEEEEEEEEE nbits = %f nsamples_total = %d\n", nbits, fft_size); - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); - /* - if (doppler_loop_control_in_sw_obs_test == 1) - { - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - //printf("EEEEEEEEEEEEEEEEEEEEEEE2\n"); - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->set_single_doppler_flag(1); - } - - - int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - - float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - - uint32_t index_debug[MAX_PRN_IDX]; - uint32_t samplestamp_debug[MAX_PRN_IDX]; for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 6; PRN < 8; PRN++) { - //printf("PRN %d\n", PRN); - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - - //printf("main loop doppler_shift = %d\n", doppler_shift); - tmp_gnss_synchro.PRN = PRN; - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } - - args.file = file; - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - send_samples_start_obs_test = 0; - if (test_observables_skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - else - { - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); - - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - pthread_mutex_lock(&mutex); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start_obs_test = 0; - - //printf("finished sending samples init filter status and back to main thread\n"); - //----------------------------------------------------------------------------------- - - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (test_observables_skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - else - { - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (test_observables_skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } - } - - - - // create DMA child process - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex_obs_test); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->reset(); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); - } - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex_obs_test); - - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("iiiiiiiiiiiiii\n"); - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - - result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = second_magnitude_iteration; - result_table[PRN][doppler_num][2] = total_fft_scaling_factor; - doppler_num = doppler_num + 1; - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("jjjjjjjjjjjjjjj\n"); - if (max_magnitude_iteration > max_magnitude) - { - int interpolation_factor = 4; - index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - samplestamp_debug[PRN - 1] = initial_sample_iteration; - initial_sample = 0; //initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - else - { - - if (max_magnitude_iteration > max_magnitude) - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - top_block->stop(); - } - - -// power_sum = (power_sum - max_magnitude) / (fft_size - 1); -// float test_statistics = (max_magnitude / power_sum); -// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); -// if (test_statistics > threshold) - float test_statistics = max_magnitude/second_magnitude; - float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - if (test_statistics > threshold) - { - std::cout << " " << PRN << " "; - - //doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - //code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - //acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) - - tmp_gnss_synchro.Acq_doppler_hz = doppler_shift_selected; - tmp_gnss_synchro.Acq_delay_samples = max_index; - tmp_gnss_synchro.Acq_samplestamp_samples = initial_sample; // delay due to the downsampling filter in the acquisition - - - gnss_synchro_vec.push_back(tmp_gnss_synchro); - } - else - { - std::cout << " . "; - } - - std::cout.flush(); - - } - - uint32_t max_index = 0; - uint32_t total_fft_scaling_factor; - //uint32_t fw_fft_scaling_factor; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float second_magnitude = 0; - float peak_to_power = 0; - float test_statistics; - uint32_t doppler_index = 0; - - if (test_observables_show_results_table == 1) - { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - max_magnitude = result_table[PRN][doppler_num][0]; - //power_sum = result_table[PRN][doppler_num][1]; - second_magnitude = result_table[PRN][doppler_num][1]; - total_fft_scaling_factor = result_table[PRN][doppler_num][2]; - doppler_num = doppler_num + 1; - - std::cout << "==================== Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << std::endl; - std::cout << "Second magnitude = " << second_magnitude << std::endl; - std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; - test_statistics = (max_magnitude / second_magnitude); - std::cout << " test_statistics = " << test_statistics << std::endl; - - } - int dummy_val; - std::cout << "Enter a value to continue"; - std::cin >> dummy_val; - } - } - } - else // DOPPLER CONTROL IN HW - { - */ - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 0; PRN < 17; PRN++) - { - - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; tmp_gnss_synchro.PRN = PRN; @@ -1120,53 +645,39 @@ bool HybridObservablesTestFpga::acquire_signal() if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - //send_samples_start = 0; - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before + args.skip_used_samples = - TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES; - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - - //printf("sending pre init %d\n", args.nsamples_tx); + args.nsamples_tx = TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES + TEST_OBS_DOWNSAMPLING_FILTER_DELAY; if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } pthread_mutex_lock(&mutex); send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex); pthread_join(thread_DMA, NULL); send_samples_start_obs_test = 0; - //printf("finished sending samples init filter status\n"); - //----------------------------------------------------------------------------------- - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + args.nsamples_tx = nsamples_to_transfer; - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; + args.skip_used_samples = TEST_OBS_DOWNSAMPLING_FILTER_DELAY; } else { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT + + args.nsamples_tx = nsamples_to_transfer; args.skip_used_samples = 0; } - - - // create DMA child process - //printf("||||||||1 args freq_band = %d\n", args.freq_band); - //printf("sending samples main DMA %d\n", args.nsamples_tx); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } msg_rx->rx_message = 0; @@ -1178,10 +689,6 @@ bool HybridObservablesTestFpga::acquire_signal() acquisition->reset(); // set active -// pthread_mutex_lock(&mutex); // it doesn't work if it is done here -// send_samples_start = 1; -// pthread_mutex_unlock(&mutex); - if (start_msg == true) { std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; @@ -1197,11 +704,6 @@ bool HybridObservablesTestFpga::acquire_signal() send_samples_start_obs_test = 0; pthread_mutex_unlock(&mutex); -// while (msg_rx->rx_message == 0) -// { -// usleep(100000); -// } - // the DMA sends the exact number of samples needed for the acquisition. // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra @@ -1223,89 +725,21 @@ bool HybridObservablesTestFpga::acquire_signal() gnss_synchro_vec.push_back(tmp_gnss_synchro); -// doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); -// code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); -// tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation -// acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); } else { std::cout << " . "; } -// while (msg_rx->rx_message == 0) -// { -// usleep(100000); -// } -// if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) -// { -// //printf("iiiiiiiiiiiiii\n"); -// acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) -// { -// acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); -// //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); -// } -// -// if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) -// { -// int interpolation_factor = 4; -// //index_debug[PRN - 1] = max_index_iteration; -// max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); -// max_magnitude = max_magnitude_iteration; -// second_magnitude = second_magnitude_iteration; -// //samplestamp_debug[PRN - 1] = initial_sample_iteration; -// initial_sample = 0; //initial_sample_iteration; -// doppler_index = doppler_index_iteration; -// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); -// } -// else -// { -// max_index = max_index_iteration; -// max_magnitude = max_magnitude_iteration; -// second_magnitude = second_magnitude_iteration; -// initial_sample = initial_sample_iteration; -// doppler_index = doppler_index_iteration; -// doppler_shift_selected = -acq_doppler_max + acq_doppler_step * (doppler_index_iteration - 1); -// } top_block->stop(); -// float test_statistics = max_magnitude/second_magnitude; -// float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); -// if (test_statistics > threshold) -// { -// //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); -// std::cout << " " << PRN << " "; -// doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); -// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); -// code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); -// acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) -// } -// else -// { -// std::cout << " . "; -// } + std::cout.flush(); -/* } */ - } -// } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -1392,19 +826,6 @@ void HybridObservablesTestFpga::configure_receiver( config->set_property("TelemetryDecoder.implementation", "Galileo_E1B_Telemetry_Decoder"); } -// else if (implementation.compare("GPS_L2_M_DLL_PLL_Tracking") == 0) -// { -// gnss_synchro_master.System = 'G'; -// std::string signal = "2S"; -// System_and_Signal = "GPS L2CM"; -// const char* str = signal.c_str(); // get a C style null terminated string -// std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null -// -// config->set_property("Tracking.early_late_space_chips", "0.5"); -// config->set_property("Tracking.track_pilot", "false"); -// -// config->set_property("TelemetryDecoder.implementation", "GPS_L2C_Telemetry_Decoder"); -// } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) { gnss_synchro_master.System = 'E'; @@ -1413,10 +834,6 @@ void HybridObservablesTestFpga::configure_receiver( const char* str = signal.c_str(); // get a C style null terminated string std::memcpy(static_cast(gnss_synchro_master.Signal), str, 3); // copy string into synchro char array: 2 char + null - //if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) - // { - // config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); - // } config->set_property("Tracking.early_late_space_chips", "0.5"); config->set_property("Tracking.track_pilot", "true"); config->set_property("Tracking.order", "2"); @@ -2075,10 +1492,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { generate_signal(); } - else - { - //printf("PATH IS OK 0 \n"); - } + std::chrono::time_point start, end; std::chrono::duration elapsed_seconds(0); @@ -2086,7 +1500,6 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) // use generator or use an external capture file if (FLAGS_enable_external_signal_file) { - //printf("PATH IS OK 1 \n"); //create and configure an acquisition block and perform an acquisition to obtain the synchronization parameters ASSERT_EQ(acquire_signal(), true); } @@ -2106,22 +1519,18 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) gnss_synchro_vec.push_back(tmp_gnss_synchro); } } - //printf("KKKKKKKKK FIRST PART FINISHED\n"); - //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Signal Acquired\n"); configure_receiver(FLAGS_PLL_bw_hz_start, FLAGS_DLL_bw_hz_start, FLAGS_PLL_narrow_bw_hz, FLAGS_DLL_narrow_bw_hz, FLAGS_extend_correlation_symbols); - //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ Receiver Configured\n"); for (unsigned int n = 0; n < gnss_synchro_vec.size(); n++) { //setup the signal synchronization, simulating an acquisition if (!FLAGS_enable_external_signal_file) { - //printf("HERE\n"); //based on true observables metadata (for custom sdr generator) //open true observables log file written by the simulator or based on provided RINEX obs //std::vector> true_reader_vec; @@ -2158,49 +1567,13 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } else { - //printf("OR THERE\n"); //based on the signal acquisition process std::cout << "Estimated Initial Doppler " << gnss_synchro_vec.at(n).Acq_doppler_hz << " [Hz], estimated Initial code delay " << gnss_synchro_vec.at(n).Acq_delay_samples << " [Samples]" << " Acquisition SampleStamp is " << gnss_synchro_vec.at(n).Acq_samplestamp_samples << std::endl; - //gnss_synchro_vec.at(n).Acq_samplestamp_samples = 0; // caution ! samplestamp_samples may not zero if doppler runs inside the FPGA } } - //printf("@@@@@@@@@@@@@@@@@@@@@@@@@@ First part is done\n"); - - unsigned int code_length; - //unsigned int nsamples_to_transfer; - - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("sssssss code_length = %d \n", code_length); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); - //printf("sssssss code_length = %d \n", code_length); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); - //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("sssssss code_length = %d \n", code_length); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); - //nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - //printf("sssssss code_length = %d \n", code_length); - } - - - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); // The HW has been reset after the acquisition phase when the acquisition class was destroyed. // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the @@ -2302,10 +1675,8 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } std::string file; - const char* file_name; ASSERT_NO_THROW({ - //std::string file; if (!FLAGS_enable_external_signal_file) { file = "./" + filename_raw_data; @@ -2314,14 +1685,7 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) { file = FLAGS_signal_file; } - //const char* file_name = file.c_str(); - file_name = file.c_str(); - //gr::blocks::file_source::sptr file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name, false); - //gr::blocks::interleaved_char_to_complex::sptr gr_interleaved_char_to_complex = gr::blocks::interleaved_char_to_complex::make(); int observable_interval_ms = 20; - //gnss_sdr_sample_counter_sptr samp_counter = gnss_sdr_make_sample_counter(static_cast(baseband_sampling_freq), observable_interval_ms, sizeof(gr_complex)); - //top_block->connect(file_source, 0, gr_interleaved_char_to_complex, 0); - //top_block->connect(gr_interleaved_char_to_complex, 0, samp_counter, 0); double fs = static_cast(config->property("GNSS-SDR.internal_fs_sps", 0)); @@ -2342,28 +1706,17 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); top_block->connect(ch_out_fpga_sample_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //extra port for the sample counter pulse - //file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks."; args.file = file; - //args.nsamples_tx = TEST_OBS_NSAMPLES_TRACKING; // number of samples to transfer args.nsamples_tx = baseband_sampling_freq*FLAGS_duration;; - //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) - //{ - // args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; - //} - //else - //{ - args.skip_used_samples = 0; - //} + args.skip_used_samples = 0; - //printf("2222222222222 CREATE PROCES\n"); - //printf("%s\n", file.c_str()); if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) { - printf("ERROR cannot create DMA Process\n"); + std::cout << "ERROR cannot create DMA Process" << std::endl; } @@ -2372,15 +1725,12 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) tracking_ch_vec.at(n)->start_tracking(); } - - //printf("222222222222222222 bis\n"); pthread_mutex_lock(&mutex_obs_test); send_samples_start_obs_test = 1; pthread_mutex_unlock(&mutex_obs_test); top_block->start(); - //printf("33333333333333333333 top block started\n"); @@ -2396,37 +1746,9 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) pthread_join(thread_DMA, NULL); - - //printf("444444444444 CHILD PROCESS FINISHED\n"); - top_block->stop(); - //printf("55555555555 TOP BLOCK STOPPED\n"); - - - /* - // send more samples to unblock the tracking process in case it was waiting for samples - args.file = file; - //if (test_observables_skip_samples_already_used == 1 && test_observables_doppler_control_in_sw == 1) - //{ - // skip the samples that have already been used - args.skip_used_samples = 0; //args.nsamples_tx; - //} - //else - //{ - // args.skip_used_samples = 0; - //} - args.nsamples_tx = TEST_OBS_NSAMPLES_FINAL; - //printf("666666666 CREATE PROCESS TO SEND EXTRA SAMPLES\n"); - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - pthread_join(thread_DMA, NULL); - //printf("777777777 PROCESS FINISHED \n"); -*/ - // reset the HW AGAIN acquisition->stop_acquisition(); @@ -2512,18 +1834,12 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } estimated_observables.restart(); - //printf("Observables : ............................\n"); while (estimated_observables.read_binary_obs()) { for (unsigned int n = 0; n < measured_obs_vec.size(); n++) { if (static_cast(estimated_observables.valid[n])) { - //printf("estimated_observables.RX_time[%d] = %d\n", n, estimated_observables.RX_time[n]); - //printf("estimated_observables.TOW_at_current_symbol_s[%d] = %d\n", n, estimated_observables.TOW_at_current_symbol_s[n]); - //printf("estimated_observables.Carrier_Doppler_hz[%d] = %d\n", n, estimated_observables.Carrier_Doppler_hz[n]); - //printf("estimated_observables.Acc_carrier_phase_hz[%d] = %d\n", n, estimated_observables.Acc_carrier_phase_hz[n]); - //printf("estimated_observables.Pseudorange_m[%d] = %d\n", n, estimated_observables.Pseudorange_m[n]); measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 0ac450cbf..3675efe5d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -2,12 +2,12 @@ * \file tracking_pull-in_test_fpga.cc * \brief This class implements a tracking Pull-In test for FPGA HW accelerator * implementations based on some input parameters. - * \author Marc Majoral, 2018. majoralmarc(at)cttc.es + * \author Marc Majoral, 2019. majoralmarc(at)cttc.es * Javier Arribas, 2018. jarribas(at)cttc.es * * * ------------------------------------------------------------------------- - * Copyright (C) 2012-2018 (see AUTHORS file for a list of contributors) + * Copyright (C) 2012-2019 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -31,31 +31,15 @@ */ #include "GPS_L1_CA.h" -//<<<<<<< HEAD -//#include "Galileo_E1.h" -//#include "Galileo_E5a.h" -//#include "GPS_L5.h" -//======= #include "acquisition_msg_rx.h" #include "galileo_e5a_noncoherent_iq_acquisition_caf.h" #include "galileo_e5a_pcps_acquisition.h" -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 #include "gnss_block_factory.h" #include "tracking_interface.h" #include "gps_l1_ca_pcps_acquisition_fpga.h" #include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" #include "galileo_e5a_pcps_acquisition_fpga.h" #include "gps_l5i_pcps_acquisition_fpga.h" -//======= -//#include "galileo_e5a_noncoherent_iq_acquisition_caf.h" -//#include "galileo_e5a_pcps_acquisition.h" -//#include "gnss_block_factory.h" -//#include "gnuplot_i.h" -//#include "gps_l1_ca_pcps_acquisition.h" -//#include "gps_l1_ca_pcps_acquisition_fine_doppler.h" -//#include "gps_l2_m_pcps_acquisition.h" -//#include "gps_l5i_pcps_acquisition.h" -//>>>>>>> b6f0c92fd61c2d20888265dac7e4cca64e7a42cb #include "in_memory_configuration.h" #include "signal_generator_flags.h" #include "test_flags.h" @@ -85,22 +69,14 @@ #define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples #define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes #define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define NSAMPLES_TRACKING 1000000000 // number of samples during which we test the tracking module -#define NSAMPLES_FINAL 60000 // number of samples sent after running tracking to unblock the SW if it is waiting for an interrupt of the tracking module -#define NSAMPLES_ACQ_DOPPLER_SWEEP 50000000 // number of samples sent to the acquisition module when running acquisition when the HW controls the doppler loop #define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter -#define DOWNSAMPLING_FILTER_DELAY 48 -#define DOWNSAMPLING_FILTER_OFFSET_SAMPLES 0 +#define DOWNSAMPLING_FILTER_DELAY 48 // delay of the downsampling filter in samples + + // HW related options -bool show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results, 0=> do not show it bool skip_samples_already_used = 0; // if skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops // (exactly in the same way as the SW) -bool doppler_loop_control_in_sw = 0; -//<<<<<<< HEAD - - -// ######## GNURADIO ACQUISITION BLOCK MESSAGE RECEVER ######### class Acquisition_msg_rx_Fpga; typedef boost::shared_ptr Acquisition_msg_rx_Fpga_sptr; @@ -148,9 +124,7 @@ Acquisition_msg_rx_Fpga::Acquisition_msg_rx_Fpga() : gr::block("Acquisition_msg_ } Acquisition_msg_rx_Fpga::~Acquisition_msg_rx_Fpga() {} -//======= -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 -// ######## GNURADIO TRACKING BLOCK MESSAGE RECEVER ######### + class TrackingPullInTestFpga_msg_rx; typedef boost::shared_ptr TrackingPullInTestFpga_msg_rx_sptr; @@ -200,8 +174,6 @@ TrackingPullInTestFpga_msg_rx::~TrackingPullInTestFpga_msg_rx() { } -// ########################################################### - class TrackingPullInTestFpga : public ::testing::Test { public: @@ -323,13 +295,12 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.dump", "true"); config->set_property("Tracking.dump_filename", "./tracking_ch_"); config->set_property("Tracking.implementation", implementation); - //config->set_property("Tracking.item_type", "gr_complex"); config->set_property("Tracking.item_type", "cshort"); config->set_property("Tracking.pll_bw_hz", std::to_string(PLL_wide_bw_hz)); config->set_property("Tracking.dll_bw_hz", std::to_string(DLL_wide_bw_hz)); - //config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); - //config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); - //config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); + config->set_property("Tracking.extend_correlation_symbols", std::to_string(extend_correlation_symbols)); + config->set_property("Tracking.pll_bw_narrow_hz", std::to_string(PLL_narrow_bw_hz)); + config->set_property("Tracking.dll_bw_narrow_hz", std::to_string(DLL_narrow_bw_hz)); gnss_synchro.PRN = FLAGS_test_satellite_PRN; gnss_synchro.Channel_ID = 0; config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(baseband_sampling_freq)); @@ -343,8 +314,6 @@ void TrackingPullInTestFpga::configure_receiver( System_and_Signal = "GPS L1 CA"; signal.copy(gnss_synchro.Signal, 2, 0); config->set_property("Tracking.early_late_space_chips", "0.5"); - //config->set_property("Tracking.early_late_space_narrow_chips", "0.5"); - // added by me config->set_property("Tracking.if", "0"); config->set_property("Tracking.order", "3"); @@ -358,8 +327,6 @@ void TrackingPullInTestFpga::configure_receiver( signal.copy(gnss_synchro.Signal, 2, 0); config->set_property("Tracking.early_late_space_chips", "0.15"); config->set_property("Tracking.very_early_late_space_chips", "0.6"); - //config->set_property("Tracking.early_late_space_narrow_chips", "0.15"); - //config->set_property("Tracking.very_early_late_space_narrow_chips", "0.6"); config->set_property("Tracking.track_pilot", "true"); // added by me @@ -374,10 +341,6 @@ void TrackingPullInTestFpga::configure_receiver( std::string signal = "5X"; System_and_Signal = "Galileo E5a"; signal.copy(gnss_synchro.Signal, 2, 0); - //if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) - // { - // config->supersede_property("Tracking.implementation", std::string("Galileo_E5a_DLL_PLL_Tracking")); - // } config->set_property("Tracking.early_late_space_chips", "0.5"); config->set_property("Tracking.track_pilot", "false"); config->set_property("Tracking.order", "2"); @@ -479,7 +442,6 @@ void *handler_DMA(void *arguments) unsigned int nread_elements; // number of elements effectively read from the input file unsigned int nsamples = 0; // number of complex samples effectively transferred unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA - unsigned int num_bytes_to_transfer; // DMA transfer block size in bytes unsigned int nsamples_transmitted; @@ -500,7 +462,7 @@ void *handler_DMA(void *arguments) // open input file rx_signal_file_id = fopen(file.c_str(), "rb"); - if (rx_signal_file_id < 0) + if (rx_signal_file_id == NULL) { std::cout << "DMA can't open input file" << std::endl; exit(1); @@ -513,7 +475,6 @@ void *handler_DMA(void *arguments) fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); usleep(50000); // wait some time to give time to the main thread to start the acquisition module - unsigned int kk; while (file_completed == false) { @@ -586,21 +547,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { pthread_t thread_DMA; - int baseband_sampling_freq_acquisition; - // step 0 determine the sampling frequency - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - baseband_sampling_freq_acquisition = baseband_sampling_freq/4; // downsampling filter in L1/E1 - } - else - { - baseband_sampling_freq_acquisition = baseband_sampling_freq; - } - // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); @@ -652,8 +598,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - //config->set_property("Acquisition.sampled_ms", "1"); - //config->set_property("Acquisition.select_queue_Fpga", "1"); tmp_gnss_synchro.System = 'E'; std::string signal = "5X"; const char* str = signal.c_str(); // get a C style null terminated string @@ -693,10 +637,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) std::string file = FLAGS_signal_file; - //struct DMA_handler_args args; - - const char* file_name = file.c_str(); - boost::shared_ptr msg_rx; try { @@ -743,527 +683,134 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) setup_fpga_switch(); - unsigned int code_length; unsigned int nsamples_to_transfer; if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq_acquisition) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); } - float nbits = ceilf(log2f((float)code_length*2)); - unsigned int fft_size = pow(2, nbits); - unsigned int nsamples_total = fft_size; - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + + tmp_gnss_synchro.PRN = PRN; + + acquisition->stop_acquisition(); // reset the whole system including the sample counters + acquisition->set_doppler_max(acq_doppler_max); + acquisition->set_doppler_step(acq_doppler_step); + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); + + args.file = file; + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + // send the previous samples to set the downsampling filter in a good condition + send_samples_start = 0; -/* - if (doppler_loop_control_in_sw == 1) - { + args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { - acquisition_GpsL1Ca_Fpga->set_single_doppler_flag(1); + std::cout << "ERROR cannot create DMA Process" << std::endl; } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition_GpsE1_Fpga->set_single_doppler_flag(1); - //printf("eeeeeee just set doppler flag\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->set_single_doppler_flag(1); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start = 0; - acquisition_GpsL5_Fpga->set_single_doppler_flag(1); + args.nsamples_tx = nsamples_to_transfer; + + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; + + } + else + { + args.nsamples_tx = nsamples_to_transfer; + + args.skip_used_samples = 0; + } + + + + + + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + + + acquisition->reset(); // set active + + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; } - int num_doppler_steps = (2*acq_doppler_max)/acq_doppler_step + 1; - - float result_table[MAX_PRN_IDX][num_doppler_steps][3]; - - //uint32_t index_debug[MAX_PRN_IDX]; - //uint32_t samplestamp_debug[MAX_PRN_IDX]; - - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - //for (unsigned int PRN = 0; PRN < 17; PRN++) - { - - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - - - - - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - //printf("doppler_shift = %d\n", doppler_shift); - tmp_gnss_synchro.PRN = PRN; - - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL1Ca_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL1Ca_Fpga->set_doppler_step(0); - - acquisition_GpsL1Ca_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL1Ca_Fpga->init(); - acquisition_GpsL1Ca_Fpga->set_local_code(); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("starting configuring acquisition\n"); - acquisition_GpsE1_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE1_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE1_Fpga->set_doppler_step(0); - - acquisition_GpsE1_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE1_Fpga->init(); - acquisition_GpsE1_Fpga->set_local_code(); - args.freq_band = 0; - //printf("ffffffffffff ending configuring acquisition\n"); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsE5a_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsE5a_Fpga->set_doppler_step(0); - - acquisition_GpsE5a_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsE5a_Fpga->init(); - acquisition_GpsE5a_Fpga->set_local_code(); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset_acquisition(); // reset the whole system including the sample counters - acquisition_GpsL5_Fpga->set_doppler_max(doppler_shift); - acquisition_GpsL5_Fpga->set_doppler_step(0); - - acquisition_GpsL5_Fpga->set_gnss_synchro(&tmp_gnss_synchro); - acquisition_GpsL5_Fpga->init(); - acquisition_GpsL5_Fpga->set_local_code(); - args.freq_band = 1; - } - - args.file = file; - - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("gggggggg \n"); - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - send_samples_start = 0; - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - else - { - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - } - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - //printf("sending pre init %d\n", args.nsamples_tx); - - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start = 0; - //printf("finished sending samples init filter status\n"); - //----------------------------------------------------------------------------------- - - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - else - { - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - } - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - if (skip_samples_already_used == 1) - { - args.skip_used_samples = (PRN -1)*fft_size; - } - else - { - args.skip_used_samples = 0; - } - } - - - - - // create DMA child process - //printf("||||||||1 args freq_band = %d\n", args.freq_band); - //printf("sending samples main DMA %d\n", args.nsamples_tx); - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - printf("ERROR cannot create DMA Process\n"); - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("hhhhhhhhhhhh\n"); - acquisition_GpsE1_Fpga->reset(); // set active - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->reset(); // set active - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->reset(); // set active - } - - // pthread_mutex_lock(&mutex); // it doesn't work if it is done here - // send_samples_start = 1; - // pthread_mutex_unlock(&mutex); - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); - - while (msg_rx->rx_message == 0) - { - usleep(100000); - } - - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL1Ca_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL1Ca_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - //printf("iiiiiiiiiiiiii\n"); - acquisition_GpsE1_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE1_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsE5a_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsE5a_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition_GpsL5_Fpga->read_acquisition_results(&max_index_iteration, &max_magnitude_iteration, &second_magnitude_iteration, &initial_sample_iteration, &doppler_index_iteration, &total_fft_scaling_factor); - //acquisition_GpsL5_Fpga->read_fpga_total_scale_factor(&total_fft_scaling_factor, &fw_fft_scaling_factor); - } - - result_table[PRN][doppler_num][0] = max_magnitude_iteration; - result_table[PRN][doppler_num][1] = second_magnitude_iteration; - result_table[PRN][doppler_num][2] = total_fft_scaling_factor; - doppler_num = doppler_num + 1; - - //printf("max_magnitude_iteration = %f\n", max_magnitude_iteration); - //printf("second_magnitude_iteration = %f\n", second_magnitude_iteration); - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //printf("jjjjjjjjjjjjjjj\n"); - if (max_magnitude_iteration > max_magnitude) - { - int interpolation_factor = 4; - //index_debug[PRN - 1] = max_index_iteration; - max_index = max_index_iteration; // - interpolation_factor*(DOWNSAMPLING_FILTER_DELAY - 1); - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - //samplestamp_debug[PRN - 1] = initial_sample_iteration; - initial_sample = 0; //initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - else - { - - if (max_magnitude_iteration > max_magnitude) - { - max_index = max_index_iteration; - max_magnitude = max_magnitude_iteration; - second_magnitude = second_magnitude_iteration; - initial_sample = initial_sample_iteration; - doppler_index = doppler_index_iteration; - doppler_shift_selected = doppler_shift; - } - } - top_block->stop(); - } - - //power_sum = (power_sum - max_magnitude) / (fft_size - 1); - //float test_statistics = (max_magnitude / power_sum); - float test_statistics = max_magnitude/second_magnitude; - float threshold = config->property("Acquisition.threshold", FLAGS_external_signal_acquisition_threshold); - if (test_statistics > threshold) - { - //printf("XXXXXXXXXXXXXXXXXXXXXXXXXXX max index = %d = %d \n", max_index, max_index % nsamples_total); - std::cout << " " << PRN << " "; - doppler_measurements_map.insert(std::pair(PRN, static_cast(doppler_shift_selected))); - code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index % nsamples_total))); - code_delay_measurements_map.insert(std::pair(PRN, static_cast(max_index))); - acq_samplestamp_map.insert(std::pair(PRN, initial_sample)); // should be 0 (first sample upon which acq starts is always 0 in this case) - } - else - { - std::cout << " . "; - } - - std::cout.flush(); - - } - - uint32_t max_index = 0; - uint32_t total_fft_scaling_factor; - //uint32_t fw_fft_scaling_factor; - float max_magnitude = 0.0; - uint64_t initial_sample = 0; - float second_magnitude = 0; - float peak_to_power = 0; - float test_statistics; - uint32_t doppler_index = 0; - - if (show_results_table == 1) - { - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - std::cout << std::endl << "############################################ Results for satellite " << PRN << std::endl; - int doppler_num = 0; - for (int doppler_shift = -acq_doppler_max;doppler_shift <= acq_doppler_max;doppler_shift = doppler_shift + acq_doppler_step) - { - max_magnitude = result_table[PRN][doppler_num][0]; - second_magnitude = result_table[PRN][doppler_num][1]; - total_fft_scaling_factor = result_table[PRN][doppler_num][2]; - //fw_fft_scaling_factor = result_table[PRN][doppler_num][3]; - doppler_num = doppler_num + 1; - - std::cout << "==================== Doppler shift " << doppler_shift << std::endl; - std::cout << "Max magnitude = " << max_magnitude << std::endl; - std::cout << "Second magnitude = " << second_magnitude << std::endl; - std::cout << "FFT total scaling factor = " << total_fft_scaling_factor << std::endl; - //peak_to_power = max_magnitude/power_sum; - //power_sum = (power_sum - max_magnitude) / (fft_size - 1); - test_statistics = (max_magnitude / second_magnitude); - std::cout << " test_statistics = " << test_statistics << std::endl; - } - int dummy_val; - std::cout << "Enter a value to continue"; - std::cin >> dummy_val; - } - } - } - else // DOPPLER CONTROL IN HW - { -*/ - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { - - uint32_t max_index = 0; - float max_magnitude = 0.0; - float second_magnitude = 0.0; - uint64_t initial_sample = 0; - //float power_sum = 0; - uint32_t doppler_index = 0; - - uint32_t max_index_iteration; - uint32_t total_fft_scaling_factor; - uint32_t fw_fft_scaling_factor; - float max_magnitude_iteration; - float second_magnitude_iteration; - uint64_t initial_sample_iteration; - //float power_sum_iteration; - uint32_t doppler_index_iteration; - int doppler_shift_selected; - int doppler_num = 0; - - tmp_gnss_synchro.PRN = PRN; - - acquisition->stop_acquisition(); // reset the whole system including the sample counters - acquisition->set_doppler_max(acq_doppler_max); - acquisition->set_doppler_step(acq_doppler_step); - acquisition->set_gnss_synchro(&tmp_gnss_synchro); - acquisition->init(); - acquisition->set_local_code(); - - args.file = file; - - - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - //---------------------------------------------------------------------------------- - // send the previous samples to set the downsampling filter in a good condition - send_samples_start = 0; - - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; // set the counter 2000 samples before - - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; //50000; // max size of the FFT - - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start = 0; - //----------------------------------------------------------------------------------- - - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY + DOWNSAMPLING_FILTER_OFFSET_SAMPLES; - - } - else - { - // debug - args.nsamples_tx = nsamples_to_transfer; //fft_size; //50000; // max size of the FFT - - args.skip_used_samples = 0; - } - - - - - - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } - - msg_rx->rx_message = 0; - top_block->start(); - - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - - - acquisition->reset(); // set active - - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); - - // the DMA sends the exact number of samples needed for the acquisition. - // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate - // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra - // sample the DMA might have sent. - do { - usleep(100000); - } while (msg_rx->rx_message == 0); - - if (msg_rx->rx_message == 1) - { - std::cout << " " << PRN << " "; - doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); - code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); - tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation - acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); - } - else - { - std::cout << " . "; - } - - - top_block->stop(); - - std::cout.flush(); - -/* } */ - - - } + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); + + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + // the DMA sends the exact number of samples needed for the acquisition. + // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate + // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra + // sample the DMA might have sent. + do { + usleep(100000); + } while (msg_rx->rx_message == 0); + + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); + code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); + } + else + { + std::cout << " . "; + } + + + top_block->stop(); + + std::cout.flush(); + + } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -1425,7 +972,7 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) { code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); } @@ -1533,11 +1080,9 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) //******************************************************************** - //args.nsamples_tx = NSAMPLES_TRACKING; // number of samples to transfer args.nsamples_tx = baseband_sampling_freq*FLAGS_duration; - //if (pthread_create(&thread_DMA, NULL, handler_DMA_tracking, (void *)&args) < 0) if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) { std::cout << "ERROR cannot create DMA Process" << std::endl; From a03ed571e6a333e11b8c2c46e48885ac8079d815 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 27 Feb 2019 14:37:07 +0100 Subject: [PATCH 38/53] replaced int and unsigned int by int32_t and uint32_t removed some unused variables --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 25 ++++++------ ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 8 ++-- .../galileo_e5a_pcps_acquisition_fpga.cc | 25 ++++++------ .../galileo_e5a_pcps_acquisition_fpga.h | 14 +++---- .../gps_l1_ca_pcps_acquisition_fpga.cc | 30 +++++++------- .../gps_l1_ca_pcps_acquisition_fpga.h | 6 +-- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 25 ++++++------ .../adapters/gps_l5i_pcps_acquisition_fpga.h | 12 +++--- .../adapters/ad9361_fpga_signal_source.cc | 2 +- .../signal_source/libs/fpga_switch.cc | 4 +- .../signal_source/libs/fpga_switch.h | 2 +- .../galileo_e1_dll_pll_veml_tracking_fpga.cc | 38 +++++++++--------- .../galileo_e1_dll_pll_veml_tracking_fpga.h | 10 ++--- .../galileo_e5a_dll_pll_tracking_fpga.cc | 40 +++++++++---------- .../galileo_e5a_dll_pll_tracking_fpga.h | 10 ++--- .../gps_l1_ca_dll_pll_tracking_fpga.cc | 22 +++++----- .../gps_l1_ca_dll_pll_tracking_fpga.h | 8 ++-- .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 36 ++++++++--------- .../adapters/gps_l5_dll_pll_tracking_fpga.h | 10 ++--- .../dll_pll_veml_tracking_fpga.cc | 4 +- .../tracking/libs/fpga_multicorrelator.cc | 4 +- 21 files changed, 165 insertions(+), 170 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 8690c6a1f..94558ef76 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -75,20 +75,19 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 4); + uint32_t sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 4); acq_parameters.sampled_ms = sampled_ms; acquire_pilot_ = configuration_->property(role + ".acquire_pilot", false); //will be true in future versions //--- Find number of samples per spreading code (4 ms) ----------------- - auto code_length = static_cast(std::round(static_cast(fs_in) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + auto code_length = static_cast(std::round(static_cast(fs_in) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length*2)); - unsigned int nsamples_total = pow(2, nbits); - unsigned int vector_length = nsamples_total; - unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); + uint32_t nsamples_total = pow(2, nbits); + uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; @@ -96,7 +95,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( acq_parameters.device_name = device_name; acq_parameters.samples_per_ms = nsamples_total / sampled_ms; acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GALILEO_E1_CODE_CHIP_RATE_HZ)); + acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GALILEO_E1_CODE_CHIP_RATE_HZ)); // compute all the GALILEO E1 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -106,7 +105,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( d_all_fft_codes_ = new lv_16sc_t[nsamples_total * GALILEO_E1_NUMBER_OF_CODES]; // memory containing all the possible fft codes for PRN 0 to 32 float max; // temporary maxima search - for (unsigned int PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) + for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) { bool cboc = false; // cboc is set to 0 when using the FPGA @@ -125,14 +124,14 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( cboc, PRN, fs_in, 0, false); } - for (int s = code_length; s < 2*code_length; s++) + for (uint32_t s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; } // fill in zero padding - for (int s = 2*code_length; s < nsamples_total; s++) + for (uint32_t s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(static_cast(0,0)); } @@ -143,7 +142,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( // normalize the code max = 0; // initialize maximum value - for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima { if (std::abs(fft_codes_padded[i].real()) > max) { @@ -154,10 +153,10 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( max = std::abs(fft_codes_padded[i].imag()); } } - for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 7086c62ac..550c6f159 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -151,10 +151,10 @@ private: bool bit_transition_flag_; bool use_CFAR_algorithm_flag_; bool acquire_pilot_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int max_dwells_; + uint32_t channel_; + uint32_t doppler_max_; + uint32_t doppler_step_; + uint32_t max_dwells_; bool dump_; bool blocking_; std::string dump_filename_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 29ce3778b..15a11df57 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -68,7 +68,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); + uint32_t sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms; acq_pilot_ = configuration_->property(role + ".acquire_pilot", false); @@ -78,14 +78,13 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf acq_pilot_ = false; } - auto code_length = static_cast(std::round(static_cast(fs_in) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); + auto code_length = static_cast(std::round(static_cast(fs_in) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length*2)); - unsigned int nsamples_total = pow(2, nbits); - unsigned int vector_length = nsamples_total; - unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); + uint32_t nsamples_total = pow(2, nbits); + uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); @@ -93,7 +92,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf acq_parameters.samples_per_ms = nsamples_total / sampled_ms; acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(ceil((1.0 / GALILEO_E5A_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters.fs_in))); + acq_parameters.excludelimit = static_cast(ceil((1.0 / GALILEO_E5A_CODE_CHIP_RATE_HZ) * static_cast(acq_parameters.fs_in))); // compute all the GALILEO E5 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -103,7 +102,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf d_all_fft_codes_ = new lv_16sc_t[nsamples_total * GALILEO_E5A_NUMBER_OF_CODES]; // memory containing all the possible fft codes for PRN 0 to 32 float max; // temporary maxima search - for (unsigned int PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) + for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) { char signal_[3]; @@ -123,13 +122,13 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf galileo_e5_a_code_gen_complex_sampled(code, signal_, PRN, fs_in, 0); - for (int s = code_length; s < 2*code_length; s++) + for (uint32_t s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; } // fill in zero padding - for (int s = 2*code_length; s < nsamples_total; s++) + for (uint32_t s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(0.0, 0.0); } @@ -139,7 +138,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values max = 0; // initialize maximum value - for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima { if (std::abs(fft_codes_padded[i].real()) > max) { @@ -150,10 +149,10 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf max = std::abs(fft_codes_padded[i].imag()); } } - for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index abe993526..d53d62076 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -164,13 +164,13 @@ private: bool blocking_; bool acq_iq_; - unsigned int vector_length_; - unsigned int code_length_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int sampled_ms_; - unsigned int max_dwells_; + uint32_t vector_length_; + uint32_t code_length_; + uint32_t channel_; + uint32_t doppler_max_; + uint32_t doppler_step_; + uint32_t sampled_ms_; + uint32_t max_dwells_; unsigned int in_streams_; unsigned int out_streams_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 2b3ec116f..365270199 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -75,53 +75,51 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( doppler_max_ = configuration_->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); + uint32_t sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms; - auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length*2)); - unsigned int nsamples_total = pow(2, nbits); - unsigned int vector_length = nsamples_total; - unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); + uint32_t nsamples_total = pow(2, nbits); + uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); acq_parameters.device_name = device_name; acq_parameters.samples_per_ms = nsamples_total / sampled_ms; acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L1_CA_CODE_RATE_HZ)); + acq_parameters.excludelimit = static_cast(std::round(static_cast(fs_in) / GPS_L1_CA_CODE_RATE_HZ)); // compute all the GPS L1 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) - auto* fft_if = new gr::fft::fft_complex(vector_length, true); // Direct FFT + auto* fft_if = new gr::fft::fft_complex(nsamples_total, true); // Direct FFT // allocate memory to compute all the PRNs and compute all the possible codes auto* code = new std::complex[nsamples_total]; // buffer for the local code auto* fft_codes_padded = static_cast(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_all_fft_codes_ = new lv_16sc_t[nsamples_total * NUM_PRNs]; // memory containing all the possible fft codes for PRN 0 to 32 float max; // temporary maxima search - for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in, 0); // generate PRN code - for (int s = code_length; s < 2*code_length; s++) + for (uint32_t s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; } // fill in zero padding - for (int s = 2*code_length; s < nsamples_total; s++) + for (uint32_t s = 2*code_length; s < nsamples_total; s++) { code[s] = std::complex(0.0, 0.0); } - int offset = 0; - memcpy(fft_if->get_inbuf() + offset, code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values max = 0; // initialize maximum value - for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima { if (std::abs(fft_codes_padded[i].real()) > max) { @@ -132,10 +130,10 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( max = std::abs(fft_codes_padded[i].imag()); } } - for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index 9615338bc..93e2456b9 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -145,9 +145,9 @@ public: private: ConfigurationInterface* configuration_; pcps_acquisition_fpga_sptr acquisition_fpga_; - unsigned int channel_; - unsigned int doppler_max_; - unsigned int doppler_step_; + uint32_t channel_; + uint32_t doppler_max_; + uint32_t doppler_step_; Gnss_Synchro* gnss_synchro_; std::string role_; unsigned int in_streams_; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index cba789547..be7cb07fc 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -72,17 +72,16 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - unsigned int sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); + uint32_t sampled_ms = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms; //--- Find number of samples per spreading code ------------------------- - auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); + auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length*2)); - unsigned int nsamples_total = pow(2, nbits); - unsigned int vector_length = nsamples_total; - unsigned int select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); + uint32_t nsamples_total = pow(2, nbits); + uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); @@ -90,7 +89,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( acq_parameters.samples_per_ms = nsamples_total/sampled_ms; acq_parameters.samples_per_code = nsamples_total; - acq_parameters.excludelimit = static_cast(ceil((1.0 / GPS_L5I_CODE_RATE_HZ) * static_cast(acq_parameters.fs_in))); + acq_parameters.excludelimit = static_cast(ceil((1.0 / GPS_L5I_CODE_RATE_HZ) * static_cast(acq_parameters.fs_in))); // compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time // a channel is assigned) @@ -100,16 +99,16 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( d_all_fft_codes_ = new lv_16sc_t[nsamples_total * NUM_PRNs]; // memory containing all the possible fft codes for PRN 0 to 32 float max; // temporary maxima search - for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l5i_code_gen_complex_sampled(code, PRN, fs_in); - for (int s = code_length; s < 2*code_length; s++) + for (uint32_t s = code_length; s < 2*code_length; s++) { code[s] = code[s - code_length]; } - for (int s = 2*code_length; s < nsamples_total; s++) + for (uint32_t s = 2*code_length; s < nsamples_total; s++) { // fill in zero padding code[s] = std::complex(static_cast(0,0)); @@ -119,7 +118,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values max = 0; // initialize maximum value - for (unsigned int i = 0; i < nsamples_total; i++) // search for maxima + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima { if (std::abs(fft_codes_padded[i].real()) > max) { @@ -130,10 +129,10 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( max = std::abs(fft_codes_padded[i].imag()); } } - for (unsigned int i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index 836d46cee..8c22d8423 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -151,15 +151,15 @@ private: complex_byte_to_float_x2_sptr cbyte_to_float_x2_; size_t item_size_; std::string item_type_; - unsigned int vector_length_; - unsigned int code_length_; + uint32_t vector_length_; + uint32_t code_length_; bool bit_transition_flag_; bool use_CFAR_algorithm_flag_; - unsigned int channel_; + uint32_t channel_; float threshold_; - unsigned int doppler_max_; - unsigned int doppler_step_; - unsigned int max_dwells_; + uint32_t doppler_max_; + uint32_t doppler_step_; + uint32_t max_dwells_; int64_t fs_in_; bool dump_; bool blocking_; diff --git a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc index ba2078719..0a09cc789 100644 --- a/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ad9361_fpga_signal_source.cc @@ -109,7 +109,7 @@ Ad9361FpgaSignalSource::Ad9361FpgaSignalSource(ConfigurationInterface* configura // turn switch to A/D position std::string default_device_name = "/dev/uio1"; std::string device_name = configuration->property(role + ".devicename", default_device_name); - int switch_position = configuration->property(role + ".switch_position", 0); + int32_t switch_position = configuration->property(role + ".switch_position", 0); switch_fpga = std::make_shared(device_name); switch_fpga->set_switch_position(switch_position); if (in_stream_ > 0) diff --git a/src/algorithms/signal_source/libs/fpga_switch.cc b/src/algorithms/signal_source/libs/fpga_switch.cc index 1a93a11a8..5dec90e55 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.cc +++ b/src/algorithms/signal_source/libs/fpga_switch.cc @@ -43,7 +43,7 @@ // constants const size_t PAGE_SIZE = 0x10000; -const unsigned int TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; +const uint32_t TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; Fpga_Switch::Fpga_Switch(const std::string &device_name) { @@ -87,7 +87,7 @@ Fpga_Switch::~Fpga_Switch() } -void Fpga_Switch::set_switch_position(int switch_position) +void Fpga_Switch::set_switch_position(int32_t switch_position) { d_map_base[0] = switch_position; } diff --git a/src/algorithms/signal_source/libs/fpga_switch.h b/src/algorithms/signal_source/libs/fpga_switch.h index 24eb9efba..c6a67c5fc 100644 --- a/src/algorithms/signal_source/libs/fpga_switch.h +++ b/src/algorithms/signal_source/libs/fpga_switch.h @@ -46,7 +46,7 @@ class Fpga_Switch public: Fpga_Switch(const std::string& device_name); ~Fpga_Switch(); - void set_switch_position(int switch_position); + void set_switch_position(int32_t switch_position); private: int d_device_descriptor; // driver descriptor diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index 7836f7a19..1175d35d5 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -58,8 +58,8 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( //################# CONFIGURATION PARAMETERS ######################## std::string default_item_type = "gr_complex"; std::string item_type = configuration->property(role + ".item_type", default_item_type); - int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int32_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int32_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param_fpga.dump = dump; @@ -78,7 +78,7 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( trk_param_fpga.pll_bw_narrow_hz = pll_bw_narrow_hz; float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 0.25); trk_param_fpga.dll_bw_narrow_hz = dll_bw_narrow_hz; - int extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); + int32_t extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.15); trk_param_fpga.early_late_space_chips = early_late_space_chips; float very_early_late_space_chips = configuration->property(role + ".very_early_late_space_chips", 0.6); @@ -105,18 +105,18 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( trk_param_fpga.track_pilot = track_pilot; d_track_pilot = track_pilot; trk_param_fpga.extend_correlation_symbols = extend_correlation_symbols; - int vector_length = std::round(fs_in / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); + int32_t vector_length = std::round(fs_in / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS)); trk_param_fpga.vector_length = vector_length; trk_param_fpga.system = 'E'; char sig_[3] = "1B"; std::memcpy(trk_param_fpga.signal, sig_, 3); - int cn0_samples = configuration->property(role + ".cn0_samples", 20); + int32_t cn0_samples = configuration->property(role + ".cn0_samples", 20); if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; trk_param_fpga.cn0_samples = cn0_samples; - int cn0_min = configuration->property(role + ".cn0_min", 25); + int32_t cn0_min = configuration->property(role + ".cn0_min", 25); if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; trk_param_fpga.cn0_min = cn0_min; - int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + int32_t max_lock_fail = configuration->property(role + ".max_lock_fail", 50); if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; trk_param_fpga.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); @@ -127,29 +127,29 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 15); + uint32_t device_base = configuration->property(role + ".device_base", 15); trk_param_fpga.device_base = device_base; trk_param_fpga.multicorr_type = 1; // 0 -> 3 correlators, 1 -> 5 correlators //################# PRE-COMPUTE ALL THE CODES ################# - unsigned int code_samples_per_chip = 2; - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int), volk_gnsssdr_get_alignment())); + uint32_t code_samples_per_chip = 2; + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); float* ca_codes_f; float* data_codes_f; if (trk_param_fpga.track_pilot) { - d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int), volk_gnsssdr_get_alignment())); + d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); } - ca_codes_f = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); + ca_codes_f = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); if (trk_param_fpga.track_pilot) { - data_codes_f = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); + data_codes_f = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); } - for (unsigned int PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) + for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) { char data_signal[3] = "1B"; if (trk_param_fpga.track_pilot) @@ -158,19 +158,19 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( galileo_e1_code_gen_sinboc11_float(ca_codes_f, pilot_signal, PRN); galileo_e1_code_gen_sinboc11_float(data_codes_f, data_signal, PRN); - for (unsigned int s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) + for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) { - d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); - d_data_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(data_codes_f[s]); + d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); + d_data_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(data_codes_f[s]); } } else { galileo_e1_code_gen_sinboc11_float(ca_codes_f, data_signal, PRN); - for (unsigned int s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) + for (uint32_t s = 0; s < 2 * GALILEO_E1_B_CODE_LENGTH_CHIPS; s++) { - d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); + d_ca_codes[static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * 2 * (PRN - 1) + s] = static_cast(ca_codes_f[s]); } } } diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h index c81fa696f..003aec195 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h @@ -103,12 +103,12 @@ public: private: dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; - unsigned int channel_; + uint32_t channel_; std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; - int* d_ca_codes; - int* d_data_codes; + uint32_t in_streams_; + uint32_t out_streams_; + int32_t* d_ca_codes; + int32_t* d_data_codes; bool d_track_pilot; }; diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index 4d7df5ca0..cb054c87c 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -61,8 +61,8 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( //################# CONFIGURATION PARAMETERS ######################## std::string default_item_type = "gr_complex"; std::string item_type = configuration->property(role + ".item_type", default_item_type); - int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 12000000); - int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int32_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 12000000); + int32_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param_fpga.dump = dump; @@ -83,9 +83,9 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( trk_param_fpga.dll_bw_narrow_hz = dll_bw_narrow_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param_fpga.early_late_space_chips = early_late_space_chips; - int vector_length = std::round(fs_in / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS)); + int32_t vector_length = std::round(fs_in / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS)); trk_param_fpga.vector_length = vector_length; - int extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); + int32_t extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; bool track_pilot = configuration->property(role + ".track_pilot", false); @@ -111,13 +111,13 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( trk_param_fpga.system = 'E'; char sig_[3] = "5X"; std::memcpy(trk_param_fpga.signal, sig_, 3); - int cn0_samples = configuration->property(role + ".cn0_samples", 20); + int32_t cn0_samples = configuration->property(role + ".cn0_samples", 20); if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; trk_param_fpga.cn0_samples = cn0_samples; - int cn0_min = configuration->property(role + ".cn0_min", 25); + int32_t cn0_min = configuration->property(role + ".cn0_min", 25); if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; trk_param_fpga.cn0_min = cn0_min; - int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + int32_t max_lock_fail = configuration->property(role + ".max_lock_fail", 50); if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; trk_param_fpga.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); @@ -128,13 +128,13 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 27); + uint32_t device_base = configuration->property(role + ".device_base", 27); trk_param_fpga.device_base = device_base; trk_param_fpga.multicorr_type = 1; // 0 -> 3 correlators, 1 -> up to 5+1 correlators //################# PRE-COMPUTE ALL THE CODES ################# - unsigned int code_samples_per_chip = 1; - auto code_length_chips = static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS); + uint32_t code_samples_per_chip = 1; + auto code_length_chips = static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS); auto *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * code_length_chips * code_samples_per_chip, volk_gnsssdr_get_alignment())); @@ -147,40 +147,40 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( } tracking_code = static_cast(volk_gnsssdr_malloc(code_samples_per_chip * code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int), volk_gnsssdr_get_alignment())); + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); if (trk_param_fpga.track_pilot) { - d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int), volk_gnsssdr_get_alignment())); + d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); } - for (unsigned int PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) + for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) { galileo_e5_a_code_gen_complex_primary(aux_code, PRN, const_cast(sig_)); if (trk_param_fpga.track_pilot) { - for (unsigned int i = 0; i < code_length_chips; i++) + for (uint32_t i = 0; i < code_length_chips; i++) { tracking_code[i] = aux_code[i].imag(); data_code[i] = aux_code[i].real(); } - for (unsigned int s = 0; s < code_length_chips; s++) + for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); - d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); } } else { - for (unsigned int i = 0; i < code_length_chips; i++) + for (uint32_t i = 0; i < code_length_chips; i++) { tracking_code[i] = aux_code[i].real(); } - for (unsigned int s = 0; s < code_length_chips; s++) + for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); } } } diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h index 3dffd0738..026069a51 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h @@ -100,14 +100,14 @@ public: private: dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; - unsigned int channel_; + uint32_t channel_; std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; + uint32_t in_streams_; + uint32_t out_streams_; - int* d_ca_codes; - int* d_data_codes; + int32_t* d_ca_codes; + int32_t* d_data_codes; bool d_track_pilot; }; diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index 4687269d3..10939dbe8 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -60,8 +60,8 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## - int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); - int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int32_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + int32_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param_fpga.dump = dump; @@ -84,9 +84,9 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( trk_param_fpga.early_late_space_chips = early_late_space_chips; float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.5); trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; - int vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); + int32_t vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); trk_param_fpga.vector_length = vector_length; - int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); + int32_t symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); if (symbols_extended_correlator < 1) { symbols_extended_correlator = 1; @@ -113,13 +113,13 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( trk_param_fpga.system = 'G'; char sig_[3] = "1C"; std::memcpy(trk_param_fpga.signal, sig_, 3); - int cn0_samples = configuration->property(role + ".cn0_samples", 20); + int32_t cn0_samples = configuration->property(role + ".cn0_samples", 20); if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; trk_param_fpga.cn0_samples = cn0_samples; - int cn0_min = configuration->property(role + ".cn0_min", 25); + int32_t cn0_min = configuration->property(role + ".cn0_min", 25); if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; trk_param_fpga.cn0_min = cn0_min; - int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + int32_t max_lock_fail = configuration->property(role + ".max_lock_fail", 50); if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; trk_param_fpga.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); @@ -130,15 +130,15 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 3); + uint32_t device_base = configuration->property(role + ".device_base", 3); trk_param_fpga.device_base = device_base; trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators //################# PRE-COMPUTE ALL THE CODES ################# - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); - for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int32_t), volk_gnsssdr_get_alignment())); + for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { - gps_l1_ca_code_gen_int(&d_ca_codes[(int(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); + gps_l1_ca_code_gen_int(&d_ca_codes[(int32_t(GPS_L1_CA_CODE_LENGTH_CHIPS)) * (PRN - 1)], PRN, 0); } trk_param_fpga.ca_codes = d_ca_codes; trk_param_fpga.code_length_chips = GPS_L1_CA_CODE_LENGTH_CHIPS; diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h index e7da14a75..cd1b8415f 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h @@ -101,11 +101,11 @@ public: private: dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; - unsigned int channel_; + uint32_t channel_; std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; - int* d_ca_codes; + uint32_t in_streams_; + uint32_t out_streams_; + int32_t* d_ca_codes; }; #endif // GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_FPGA_H_ diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc index ba7b52f9f..d51415471 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -59,8 +59,8 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## - int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 12500000); - int fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int32_t fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 12500000); + int32_t fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); trk_param_fpga.fs_in = fs_in; bool dump = configuration->property(role + ".dump", false); trk_param_fpga.dump = dump; @@ -81,9 +81,9 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.dll_bw_narrow_hz = dll_bw_narrow_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param_fpga.early_late_space_chips = early_late_space_chips; - int vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L5I_CODE_RATE_HZ) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS))); + int32_t vector_length = std::round(static_cast(fs_in) / (static_cast(GPS_L5I_CODE_RATE_HZ) / static_cast(GPS_L5I_CODE_LENGTH_CHIPS))); trk_param_fpga.vector_length = vector_length; - int extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); + int32_t extend_correlation_symbols = configuration->property(role + ".extend_correlation_symbols", 1); float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.15); trk_param_fpga.early_late_space_narrow_chips = early_late_space_narrow_chips; bool track_pilot = configuration->property(role + ".track_pilot", false); @@ -109,13 +109,13 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( trk_param_fpga.system = 'G'; char sig_[3] = "L5"; std::memcpy(trk_param_fpga.signal, sig_, 3); - int cn0_samples = configuration->property(role + ".cn0_samples", 20); + int32_t cn0_samples = configuration->property(role + ".cn0_samples", 20); if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; trk_param_fpga.cn0_samples = cn0_samples; - int cn0_min = configuration->property(role + ".cn0_min", 25); + int32_t cn0_min = configuration->property(role + ".cn0_min", 25); if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; trk_param_fpga.cn0_min = cn0_min; - int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); + int32_t max_lock_fail = configuration->property(role + ".max_lock_fail", 50); if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; trk_param_fpga.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.75); @@ -127,12 +127,12 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( std::string default_device_name = "/dev/uio"; std::string device_name = configuration->property(role + ".devicename", default_device_name); trk_param_fpga.device_name = device_name; - unsigned int device_base = configuration->property(role + ".device_base", 27); + uint32_t device_base = configuration->property(role + ".device_base", 27); trk_param_fpga.device_base = device_base; trk_param_fpga.multicorr_type = 0; //multicorr_type : 0 -> 3 correlators, 1 -> 5 correlators //################# PRE-COMPUTE ALL THE CODES ################# - unsigned int code_samples_per_chip = 1; - auto code_length_chips = static_cast(GPS_L5I_CODE_LENGTH_CHIPS); + uint32_t code_samples_per_chip = 1; + auto code_length_chips = static_cast(GPS_L5I_CODE_LENGTH_CHIPS); float *tracking_code; float *data_code; @@ -144,14 +144,14 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( data_code = static_cast(volk_gnsssdr_malloc(code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); } - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips * NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment())); + d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips * NUM_PRNs) * sizeof(int32_t), volk_gnsssdr_get_alignment())); if (trk_param_fpga.track_pilot) { - d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * NUM_PRNs * sizeof(int), volk_gnsssdr_get_alignment())); + d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * NUM_PRNs * sizeof(int32_t), volk_gnsssdr_get_alignment())); } - for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) + for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { if (track_pilot) { @@ -159,19 +159,19 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( gps_l5i_code_gen_float(data_code, PRN); - for (unsigned int s = 0; s < code_length_chips; s++) + for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); - d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); } } else { gps_l5i_code_gen_float(tracking_code, PRN); - for (unsigned int s = 0; s < code_length_chips; s++) + for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); } } } diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h index eeb75b069..08c085d73 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h @@ -98,13 +98,13 @@ public: private: dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; size_t item_size_; - unsigned int channel_; + uint32_t channel_; std::string role_; - unsigned int in_streams_; - unsigned int out_streams_; + uint32_t in_streams_; + uint32_t out_streams_; bool d_track_pilot; - int* d_ca_codes; - int* d_data_codes; + int32_t* d_ca_codes; + int32_t* d_data_codes; }; #endif // GNSS_SDR_GPS_L5_DLL_PLL_TRACKING_FPGA_H_ diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 874ed9929..691990ced 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -756,7 +756,7 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() double tmp_cp1 = 0.0; double tmp_cp2 = 0.0; double tmp_samples = 0.0; - for (unsigned int k = 0; k < trk_parameters.smoother_length; k++) + for (uint32_t k = 0; k < trk_parameters.smoother_length; k++) { tmp_cp1 += d_carr_ph_history.at(k).first; tmp_cp2 += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; @@ -786,7 +786,7 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() double tmp_cp1 = 0.0; double tmp_cp2 = 0.0; double tmp_samples = 0.0; - for (unsigned int k = 0; k < trk_parameters.smoother_length; k++) + for (uint32_t k = 0; k < trk_parameters.smoother_length; k++) { tmp_cp1 += d_code_ph_history.at(k).first; tmp_cp2 += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index dee4667da..b23014af2 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -280,7 +280,7 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { - if (d_ca_codes[((int(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) + if (d_ca_codes[((int32_t(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) { code_chip = 1; } @@ -298,7 +298,7 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { - if (d_data_codes[((int(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) + if (d_data_codes[((int32_t(d_code_length_chips)) * d_code_samples_per_chip * (PRN - 1)) + k] == 1) { code_chip = 1; } From 484b0f4b023de7b69f7b8e358a9e9fd5d14117b7 Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 27 Feb 2019 15:51:01 +0100 Subject: [PATCH 39/53] removed commented-out code --- src/core/receiver/gnss_flowgraph.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 378c135d2..cd270a002 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -277,7 +277,6 @@ void GNSSFlowgraph::connect() #endif #if ENABLE_FPGA -// bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) { @@ -357,8 +356,6 @@ void GNSSFlowgraph::connect() } #endif - //bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); - // Signal conditioner (selected_signal_source) >> channels (i) (dependent of their associated SignalSource_ID) int selected_signal_conditioner_ID = 0; bool use_acq_resampler = configuration_->property("GNSS-SDR.use_acquisition_resampler", false); @@ -673,10 +670,7 @@ void GNSSFlowgraph::connect() LOG(INFO) << "Channel " << i << " assigned to " << channels_.at(i)->get_signal(); if (channels_state_[i] == 1) { -// if (FPGA_enabled == false) -// { - channels_.at(i)->start_acquisition(); -// } + channels_.at(i)->start_acquisition(); LOG(INFO) << "Channel " << i << " connected to observables and ready for acquisition"; } else @@ -708,8 +702,7 @@ void GNSSFlowgraph::disconnect() #ifdef ENABLE_FPGA - bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); - if (FPGA_enabled == false) + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) { for (int i = 0; i < sources_count_; i++) { @@ -821,8 +814,7 @@ void GNSSFlowgraph::disconnect() #endif #ifdef ENABLE_FPGA - //bool FPGA_enabled = configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false); - if (FPGA_enabled == false) + if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) { // disconnect the signal source to sample counter // disconnect the sample counter to Observables From c32e0b427ae6e0c9af63f84844339f414b2e37cf Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Wed, 27 Feb 2019 17:27:31 +0100 Subject: [PATCH 40/53] coding style + removed some unnecessary memory arrays in the FPGA E5A tracking adapter class. --- ...ileo_e1_pcps_ambiguous_acquisition_fpga.cc | 104 +- ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 6 +- .../galileo_e5a_pcps_acquisition_fpga.cc | 25 +- .../galileo_e5a_pcps_acquisition_fpga.h | 1 - .../gps_l1_ca_pcps_acquisition_fpga.cc | 28 +- .../gps_l1_ca_pcps_acquisition_fpga.h | 2 +- .../adapters/gps_l5i_pcps_acquisition_fpga.cc | 79 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 80 +- .../gnuradio_blocks/pcps_acquisition_fpga.h | 4 +- .../acquisition/libs/fpga_acquisition.cc | 120 +- .../acquisition/libs/fpga_acquisition.h | 17 +- .../libs/gnss_sdr_fpga_sample_counter.cc | 6 +- .../libs/gnss_sdr_fpga_sample_counter.h | 6 +- .../galileo_e5a_dll_pll_tracking_fpga.cc | 31 +- .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 2 +- .../dll_pll_veml_tracking_fpga.cc | 117 +- .../dll_pll_veml_tracking_fpga.h | 1 - .../tracking/libs/dll_pll_conf_fpga.cc | 4 +- .../tracking/libs/fpga_multicorrelator.cc | 69 +- .../tracking/libs/fpga_multicorrelator.h | 52 +- src/core/receiver/control_thread.cc | 10 +- src/core/receiver/control_thread.h | 12 +- src/core/receiver/gnss_flowgraph.cc | 339 +++-- .../hybrid_observables_test_fpga.cc | 1117 ++++++++--------- .../tracking/tracking_pull-in_test_fpga.cc | 691 +++++----- 25 files changed, 1388 insertions(+), 1535 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc index 94558ef76..9f2b53e59 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.cc @@ -28,7 +28,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" #include "Galileo_E1.h" @@ -62,13 +62,13 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( // item_type_ = configuration_->property(role + ".item_type", default_item_type); - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); - int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 4000000); + int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); float downsampling_factor = configuration_->property(role + ".downsampling_factor", 4.0); acq_parameters.downsampling_factor = downsampling_factor; - fs_in = fs_in/downsampling_factor; + fs_in = fs_in / downsampling_factor; acq_parameters.fs_in = fs_in; @@ -85,7 +85,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length*2)); + float nbits = ceilf(log2f((float)code_length * 2)); uint32_t nsamples_total = pow(2, nbits); uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); @@ -107,58 +107,56 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) { + bool cboc = false; // cboc is set to 0 when using the FPGA - bool cboc = false; // cboc is set to 0 when using the FPGA + if (acquire_pilot_ == true) + { + //set local signal generator to Galileo E1 pilot component (1C) + char pilot_signal[3] = "1C"; + galileo_e1_code_gen_complex_sampled(code, pilot_signal, + cboc, PRN, fs_in, 0, false); + } + else + { + char data_signal[3] = "1B"; + galileo_e1_code_gen_complex_sampled(code, data_signal, + cboc, PRN, fs_in, 0, false); + } - if (acquire_pilot_ == true) - { - //set local signal generator to Galileo E1 pilot component (1C) - char pilot_signal[3] = "1C"; - galileo_e1_code_gen_complex_sampled(code, pilot_signal, - cboc, PRN, fs_in, 0, false); - } - else - { - char data_signal[3] = "1B"; - galileo_e1_code_gen_complex_sampled(code, data_signal, - cboc, PRN, fs_in, 0, false); - } - - for (uint32_t s = code_length; s < 2*code_length; s++) - { - code[s] = code[s - code_length]; - } + for (uint32_t s = code_length; s < 2 * code_length; s++) + { + code[s] = code[s - code_length]; + } - // fill in zero padding - for (uint32_t s = 2*code_length; s < nsamples_total; s++) - { - code[s] = std::complex(static_cast(0,0)); - } + // fill in zero padding + for (uint32_t s = 2 * code_length; s < nsamples_total; s++) + { + code[s] = std::complex(static_cast(0, 0)); + } - memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer - fft_if->execute(); // Run the FFT of local code - volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values - - // normalize the code - max = 0; // initialize maximum value - for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima - { - if (std::abs(fft_codes_padded[i].real()) > max) - { - max = std::abs(fft_codes_padded[i].real()); - } - if (std::abs(fft_codes_padded[i].imag()) > max) - { - max = std::abs(fft_codes_padded[i].imag()); - } - } - for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs - { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); - } + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + fft_if->execute(); // Run the FFT of local code + volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values + // normalize the code + max = 0; // initialize maximum value + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima + { + if (std::abs(fft_codes_padded[i].real()) > max) + { + max = std::abs(fft_codes_padded[i].real()); + } + if (std::abs(fft_codes_padded[i].imag()) > max) + { + max = std::abs(fft_codes_padded[i].imag()); + } + } + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + { + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + } } acq_parameters.all_fft_codes = d_all_fft_codes_; @@ -188,8 +186,8 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::~GalileoE1PcpsAmbiguousAcquisitionFpga() void GalileoE1PcpsAmbiguousAcquisitionFpga::stop_acquisition() { - // this command causes the SW to reset the HW. - acquisition_fpga_->reset_acquisition(); + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); } diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 550c6f159..428f13210 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -28,7 +28,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #ifndef GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ #define GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ @@ -135,10 +135,10 @@ public: */ void set_state(int state) override; - /*! + /*! * \brief Stop running acquisition */ - void stop_acquisition() override; + void stop_acquisition() override; void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc index 15a11df57..69520f1a9 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.cc @@ -27,7 +27,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "galileo_e5a_pcps_acquisition_fpga.h" #include "Galileo_E5a.h" @@ -55,12 +55,12 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf DLOG(INFO) << "Role " << role; - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); - int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 32000000); + int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); float downsampling_factor = configuration_->property(role + ".downsampling_factor", 1.0); acq_parameters.downsampling_factor = downsampling_factor; - fs_in = fs_in/downsampling_factor; + fs_in = fs_in / downsampling_factor; acq_parameters.fs_in = fs_in; @@ -82,7 +82,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length*2)); + float nbits = ceilf(log2f((float)code_length * 2)); uint32_t nsamples_total = pow(2, nbits); uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); acq_parameters.select_queue_Fpga = select_queue_Fpga; @@ -122,13 +122,13 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf galileo_e5_a_code_gen_complex_sampled(code, signal_, PRN, fs_in, 0); - for (uint32_t s = code_length; s < 2*code_length; s++) + for (uint32_t s = code_length; s < 2 * code_length; s++) { code[s] = code[s - code_length]; } // fill in zero padding - for (uint32_t s = 2*code_length; s < nsamples_total; s++) + for (uint32_t s = 2 * code_length; s < nsamples_total; s++) { code[s] = std::complex(0.0, 0.0); } @@ -137,7 +137,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf fft_if->execute(); // Run the FFT of local code volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values - max = 0; // initialize maximum value + max = 0; // initialize maximum value for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima { if (std::abs(fft_codes_padded[i].real()) > max) @@ -173,7 +173,6 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf delete[] code; delete fft_if; delete[] fft_codes_padded; - } @@ -185,8 +184,8 @@ GalileoE5aPcpsAcquisitionFpga::~GalileoE5aPcpsAcquisitionFpga() void GalileoE5aPcpsAcquisitionFpga::stop_acquisition() { - // this command causes the SW to reset the HW. - acquisition_fpga_->reset_acquisition(); + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); } @@ -255,13 +254,13 @@ void GalileoE5aPcpsAcquisitionFpga::set_state(int state) void GalileoE5aPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { - // nothing to connect + // nothing to connect } void GalileoE5aPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) { - // nothing to connect + // nothing to connect } diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index d53d62076..8e8a08972 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -145,7 +145,6 @@ public: void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{}; private: - ConfigurationInterface* configuration_; pcps_acquisition_fpga_sptr acquisition_fpga_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc index 365270199..dabf94a15 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.cc @@ -32,7 +32,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "gps_l1_ca_pcps_acquisition_fpga.h" #include "GPS_L1_CA.h" @@ -63,13 +63,13 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( DLOG(INFO) << "role " << role; - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); - int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); float downsampling_factor = configuration_->property(role + ".downsampling_factor", 4.0); acq_parameters.downsampling_factor = downsampling_factor; - fs_in = fs_in/downsampling_factor; + fs_in = fs_in / downsampling_factor; acq_parameters.fs_in = fs_in; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); @@ -80,7 +80,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length*2)); + float nbits = ceilf(log2f((float)code_length * 2)); uint32_t nsamples_total = pow(2, nbits); uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 0); acq_parameters.select_queue_Fpga = select_queue_Fpga; @@ -102,23 +102,23 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { gps_l1_ca_code_gen_complex_sampled(code, PRN, fs_in, 0); // generate PRN code - - for (uint32_t s = code_length; s < 2*code_length; s++) + + for (uint32_t s = code_length; s < 2 * code_length; s++) { code[s] = code[s - code_length]; } // fill in zero padding - for (uint32_t s = 2*code_length; s < nsamples_total; s++) + for (uint32_t s = 2 * code_length; s < nsamples_total; s++) { code[s] = std::complex(0.0, 0.0); } - memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values - max = 0; // initialize maximum value + max = 0; // initialize maximum value for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima { if (std::abs(fft_codes_padded[i].real()) > max) @@ -135,7 +135,6 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); } - } //acq_parameters @@ -155,7 +154,6 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( delete[] code; delete fft_if; delete[] fft_codes_padded; - } @@ -167,8 +165,8 @@ GpsL1CaPcpsAcquisitionFpga::~GpsL1CaPcpsAcquisitionFpga() void GpsL1CaPcpsAcquisitionFpga::stop_acquisition() { - // this command causes the SW to reset the HW. - acquisition_fpga_->reset_acquisition(); + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); } @@ -227,7 +225,7 @@ void GpsL1CaPcpsAcquisitionFpga::set_local_code() void GpsL1CaPcpsAcquisitionFpga::reset() { - // this function starts the acquisition process + // this function starts the acquisition process acquisition_fpga_->set_active(true); } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h index 93e2456b9..7d91f04d0 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fpga.h @@ -32,7 +32,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #ifndef GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FPGA_H_ #define GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FPGA_H_ diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc index be7cb07fc..04e30c63c 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.cc @@ -59,13 +59,13 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( LOG(INFO) << "role " << role; - int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); - int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + int64_t fs_in = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); float downsampling_factor = configuration_->property(role + ".downsampling_factor", 1.0); acq_parameters.downsampling_factor = downsampling_factor; - fs_in = fs_in/downsampling_factor; + fs_in = fs_in / downsampling_factor; acq_parameters.fs_in = fs_in; @@ -79,14 +79,14 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( auto code_length = static_cast(std::round(static_cast(fs_in) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. - float nbits = ceilf(log2f((float)code_length*2)); + float nbits = ceilf(log2f((float)code_length * 2)); uint32_t nsamples_total = pow(2, nbits); uint32_t select_queue_Fpga = configuration_->property(role + ".select_queue_Fpga", 1); acq_parameters.select_queue_Fpga = select_queue_Fpga; std::string default_device_name = "/dev/uio0"; std::string device_name = configuration_->property(role + ".devicename", default_device_name); acq_parameters.device_name = device_name; - acq_parameters.samples_per_ms = nsamples_total/sampled_ms; + acq_parameters.samples_per_ms = nsamples_total / sampled_ms; acq_parameters.samples_per_code = nsamples_total; acq_parameters.excludelimit = static_cast(ceil((1.0 / GPS_L5I_CODE_RATE_HZ) * static_cast(acq_parameters.fs_in))); @@ -100,41 +100,41 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( float max; // temporary maxima search for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) - { - gps_l5i_code_gen_complex_sampled(code, PRN, fs_in); + { + gps_l5i_code_gen_complex_sampled(code, PRN, fs_in); - for (uint32_t s = code_length; s < 2*code_length; s++) - { - code[s] = code[s - code_length]; - } + for (uint32_t s = code_length; s < 2 * code_length; s++) + { + code[s] = code[s - code_length]; + } - for (uint32_t s = 2*code_length; s < nsamples_total; s++) - { - // fill in zero padding - code[s] = std::complex(static_cast(0,0)); - } - memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer - fft_if->execute(); // Run the FFT of local code - volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values + for (uint32_t s = 2 * code_length; s < nsamples_total; s++) + { + // fill in zero padding + code[s] = std::complex(static_cast(0, 0)); + } + memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer + fft_if->execute(); // Run the FFT of local code + volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values - max = 0; // initialize maximum value - for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima - { - if (std::abs(fft_codes_padded[i].real()) > max) - { - max = std::abs(fft_codes_padded[i].real()); - } - if (std::abs(fft_codes_padded[i].imag()) > max) - { - max = std::abs(fft_codes_padded[i].imag()); - } - } - for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs - { - d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), - static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); - } - } + max = 0; // initialize maximum value + for (uint32_t i = 0; i < nsamples_total; i++) // search for maxima + { + if (std::abs(fft_codes_padded[i].real()) > max) + { + max = std::abs(fft_codes_padded[i].real()); + } + if (std::abs(fft_codes_padded[i].imag()) > max) + { + max = std::abs(fft_codes_padded[i].imag()); + } + } + for (uint32_t i = 0; i < nsamples_total; i++) // map the FFT to the dynamic range of the fixed point values an copy to buffer containing all FFTs + { + d_all_fft_codes_[i + nsamples_total * (PRN - 1)] = lv_16sc_t(static_cast(floor(fft_codes_padded[i].real() * (pow(2, 9) - 1) / max)), + static_cast(floor(fft_codes_padded[i].imag() * (pow(2, 9) - 1) / max))); + } + } //acq_parameters acq_parameters.all_fft_codes = d_all_fft_codes_; @@ -153,7 +153,6 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( delete[] code; delete fft_if; delete[] fft_codes_padded; - } @@ -166,8 +165,8 @@ GpsL5iPcpsAcquisitionFpga::~GpsL5iPcpsAcquisitionFpga() void GpsL5iPcpsAcquisitionFpga::stop_acquisition() { - // this command causes the SW to reset the HW. - acquisition_fpga_->reset_acquisition(); + // this command causes the SW to reset the HW. + acquisition_fpga_->reset_acquisition(); } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 091092c89..8aed78c5a 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -32,7 +32,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "pcps_acquisition_fpga.h" @@ -77,7 +77,6 @@ pcps_acquisition_fpga::pcps_acquisition_fpga(pcpsconf_fpga_t conf_) : gr::block( acquisition_fpga = std::make_shared(acq_parameters.device_name, acq_parameters.code_length, acq_parameters.doppler_max, d_fft_size, acq_parameters.fs_in, acq_parameters.sampled_ms, acq_parameters.select_queue_Fpga, acq_parameters.all_fft_codes, acq_parameters.excludelimit); - } @@ -105,9 +104,9 @@ void pcps_acquisition_fpga::init() d_mag = 0.0; d_input_power = 0.0; - d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))) + 1; + d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))) + 1; - acquisition_fpga->init(); + acquisition_fpga->init(); } @@ -171,7 +170,6 @@ void pcps_acquisition_fpga::send_negative_acquisition() void pcps_acquisition_fpga::set_active(bool active) { - d_active = active; // initialize acquisition algorithm @@ -203,47 +201,44 @@ void pcps_acquisition_fpga::set_active(bool active) acquisition_fpga->read_acquisition_results(&indext, &firstpeak, &secondpeak, &initial_sample, &d_input_power, &d_doppler_index, &total_block_exp); if (total_block_exp > d_total_block_exp) - { - // if the attenuation factor of the FPGA FFT-IFFT is smaller than the reference attenuation factor then we need to update the reference attenuation factor - std::cout << "changing blk exp..... d_total_block_exp = " << d_total_block_exp << " total_block_exp = " << total_block_exp << " chan = " << d_channel << std::endl; - d_total_block_exp = total_block_exp; + { + // if the attenuation factor of the FPGA FFT-IFFT is smaller than the reference attenuation factor then we need to update the reference attenuation factor + std::cout << "changing blk exp..... d_total_block_exp = " << d_total_block_exp << " total_block_exp = " << total_block_exp << " chan = " << d_channel << std::endl; + d_total_block_exp = total_block_exp; + } - } + doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); - doppler = -static_cast(acq_parameters.doppler_max) + d_doppler_step * (d_doppler_index - 1); - - if (secondpeak > 0) - { - d_test_statistics = firstpeak/secondpeak; - } - else - { - d_test_statistics = 0.0; - } + if (secondpeak > 0) + { + d_test_statistics = firstpeak / secondpeak; + } + else + { + d_test_statistics = 0.0; + } d_gnss_synchro->Acq_doppler_hz = static_cast(doppler); d_sample_counter = initial_sample; if (d_select_queue_Fpga == 0) - { - if (d_downsampling_factor > 1) - { - - d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor*(indext)); - d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor*d_sample_counter - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition - - } - else - { - d_gnss_synchro->Acq_delay_samples = static_cast(indext); - d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition + { + if (d_downsampling_factor > 1) + { + d_gnss_synchro->Acq_delay_samples = static_cast(d_downsampling_factor * (indext)); + d_gnss_synchro->Acq_samplestamp_samples = d_downsampling_factor * d_sample_counter - 44; //33; //41; //+ 81*0.5; // delay due to the downsampling filter in the acquisition + } + else + { + d_gnss_synchro->Acq_delay_samples = static_cast(indext); + d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition + } } - } else - { - d_gnss_synchro->Acq_delay_samples = static_cast(indext); - d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition - } + { + d_gnss_synchro->Acq_delay_samples = static_cast(indext); + d_gnss_synchro->Acq_samplestamp_samples = d_sample_counter; // delay due to the downsampling filter in the acquisition + } if (d_test_statistics > d_threshold) { @@ -270,14 +265,11 @@ int pcps_acquisition_fpga::general_work(int noutput_items __attribute__((unused) void pcps_acquisition_fpga::reset_acquisition(void) { - // this function triggers a HW reset of the FPGA PL. - acquisition_fpga->reset_acquisition(); + // this function triggers a HW reset of the FPGA PL. + acquisition_fpga->reset_acquisition(); } -void pcps_acquisition_fpga::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) +void pcps_acquisition_fpga::read_fpga_total_scale_factor(uint32_t* total_scale_factor, uint32_t* fw_scale_factor) { - acquisition_fpga->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); + acquisition_fpga->read_fpga_total_scale_factor(total_scale_factor, fw_scale_factor); } - - - diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h index a08cd5363..bdb83a257 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.h @@ -39,7 +39,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #ifndef GNSS_SDR_PCPS_ACQUISITION_FPGA_H_ #define GNSS_SDR_PCPS_ACQUISITION_FPGA_H_ @@ -216,7 +216,7 @@ public: /*! * \brief This funciton is only used for the unit tests */ - void read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor); + void read_fpga_total_scale_factor(uint32_t* total_scale_factor, uint32_t* fw_scale_factor); }; #endif /* GNSS_SDR_PCPS_ACQUISITION_FPGA_H_*/ diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 9a14f779a..979fd47ea 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -31,7 +31,7 @@ * along with GNSS-SDR. If not, see . * * ------------------------------------------------------------------------- - */ + */ #include "fpga_acquisition.h" #include "GPS_L1_CA.h" @@ -43,7 +43,6 @@ #include - // FPGA register parameters #define PAGE_SIZE 0x10000 // default page size for the multicorrelator memory map #define MAX_PHASE_STEP_RAD 0.999999999534339 // 1 - pow(2,-31); @@ -58,10 +57,10 @@ #define SELECT_MSB 0XFF00 // value to select the most significant byte #define SELECT_16_BITS 0xFFFF // value to select 16 bits #define SHL_8_BITS 256 // value used to shift a value 8 bits to the left -#define SELECT_LSBits 0x000003FF // Select the 10 LSbits out of a 20-bit word -#define SELECT_MSBbits 0x000FFC00 // Select the 10 MSbits out of a 20-bit word -#define SELECT_ALL_CODE_BITS 0x000FFFFF // Select a 20 bit word -#define SHL_CODE_BITS 1024 // shift left by 10 bits +#define SELECT_LSBits 0x000003FF // Select the 10 LSbits out of a 20-bit word +#define SELECT_MSBbits 0x000FFC00 // Select the 10 MSbits out of a 20-bit word +#define SELECT_ALL_CODE_BITS 0x000FFFFF // Select a 20 bit word +#define SHL_CODE_BITS 1024 // shift left by 10 bits bool fpga_acquisition::init() @@ -73,7 +72,7 @@ bool fpga_acquisition::init() bool fpga_acquisition::set_local_code(uint32_t PRN) { // select the code with the chosen PRN - d_PRN = PRN; + d_PRN = PRN; return true; } @@ -82,7 +81,6 @@ void fpga_acquisition::write_local_code() { fpga_acquisition::fpga_configure_acquisition_local_code( &d_all_fft_codes[d_nsamples_total * (d_PRN - 1)]); - } fpga_acquisition::fpga_acquisition(std::string device_name, @@ -91,7 +89,7 @@ fpga_acquisition::fpga_acquisition(std::string device_name, uint32_t nsamples_total, int64_t fs_in, uint32_t sampled_ms, uint32_t select_queue, lv_16sc_t *all_fft_codes, - uint32_t excludelimit) + uint32_t excludelimit) { uint32_t vector_length = nsamples_total; @@ -116,7 +114,6 @@ fpga_acquisition::fpga_acquisition(std::string device_name, d_PRN = 0; DLOG(INFO) << "Acquisition FPGA class created"; - } void fpga_acquisition::open_device() @@ -135,12 +132,10 @@ void fpga_acquisition::open_device() LOG(WARNING) << "Cannot map the FPGA acquisition module into user memory"; std::cout << "Acq: cannot map deviceio" << d_device_name << std::endl; } - } fpga_acquisition::~fpga_acquisition() { - } @@ -152,7 +147,6 @@ bool fpga_acquisition::free() void fpga_acquisition::fpga_acquisition_test_register() { - // sanity check : check test register uint32_t writeval = TEST_REG_SANITY_CHECK; uint32_t readval; @@ -190,14 +184,12 @@ void fpga_acquisition::fpga_configure_acquisition_local_code(lv_16sc_t fft_local local_code = (tmp & SELECT_LSBits) | ((tmp2 * SHL_CODE_BITS) & SELECT_MSBbits); // put together the real part and the imaginary part fft_data = local_code & SELECT_ALL_CODE_BITS; d_map_base[6] = fft_data; - } } void fpga_acquisition::run_acquisition(void) { - // enable interrupts int32_t reenable = 1; int32_t disable_int = 0; @@ -212,67 +204,63 @@ void fpga_acquisition::run_acquisition(void) nb = read(d_fd, &irq_count, sizeof(irq_count)); if (nb != sizeof(irq_count)) { - std::cout << "acquisition module Read failed to retrieve 4 bytes!" << std::endl; - std::cout << "acquisition module Interrupt number " << irq_count << std::endl; + std::cout << "acquisition module Read failed to retrieve 4 bytes!" << std::endl; + std::cout << "acquisition module Interrupt number " << irq_count << std::endl; } write(d_fd, reinterpret_cast(&disable_int), sizeof(int32_t)); - } void fpga_acquisition::set_block_exp(uint32_t total_block_exp) { - d_map_base[11] = total_block_exp; + d_map_base[11] = total_block_exp; } void fpga_acquisition::set_doppler_sweep(uint32_t num_sweeps) { + float phase_step_rad_real; + float phase_step_rad_int_temp; + int32_t phase_step_rad_int; + int32_t doppler = static_cast(-d_doppler_max); + float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); + // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing + // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) + // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - float phase_step_rad_real; - float phase_step_rad_int_temp; - int32_t phase_step_rad_int; - int32_t doppler = static_cast(-d_doppler_max); - float phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - // The doppler step can never be outside the range -pi to +pi, otherwise there would be aliasing - // The FPGA expects phase_step_rad between -1 (-pi) to +1 (+pi) - // The FPGA also expects the phase to be negative since it produces cos(x) -j*sin(x) - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - - // avoid saturation of the fixed point representation in the fpga - // (only the positive value can saturate due to the 2's complement representation) - if (phase_step_rad_real >= 1.0) - { - phase_step_rad_real = MAX_PHASE_STEP_RAD; - } - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - d_map_base[3] = phase_step_rad_int; - - // repeat the calculation with the doppler step - doppler = static_cast(d_doppler_step); - phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); - phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); - if (phase_step_rad_real >= 1.0) - { - phase_step_rad_real = MAX_PHASE_STEP_RAD; - } - phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 - phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings - d_map_base[4] = phase_step_rad_int; - d_map_base[5] = num_sweeps; + // avoid saturation of the fixed point representation in the fpga + // (only the positive value can saturate due to the 2's complement representation) + if (phase_step_rad_real >= 1.0) + { + phase_step_rad_real = MAX_PHASE_STEP_RAD; + } + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + d_map_base[3] = phase_step_rad_int; + // repeat the calculation with the doppler step + doppler = static_cast(d_doppler_step); + phase_step_rad = GPS_TWO_PI * (doppler) / static_cast(d_fs_in); + phase_step_rad_real = phase_step_rad / (GPS_TWO_PI / 2); + if (phase_step_rad_real >= 1.0) + { + phase_step_rad_real = MAX_PHASE_STEP_RAD; + } + phase_step_rad_int_temp = phase_step_rad_real * POW_2_2; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (POW_2_29)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + d_map_base[4] = phase_step_rad_int; + d_map_base[5] = num_sweeps; } void fpga_acquisition::configure_acquisition() { - fpga_acquisition::open_device(); + fpga_acquisition::open_device(); d_map_base[0] = d_select_queue; d_map_base[1] = d_vector_length; d_map_base[2] = d_nsamples; d_map_base[7] = static_cast(log2(static_cast(d_vector_length))); // log2 FFTlength d_map_base[12] = d_excludelimit; - } @@ -303,7 +291,6 @@ void fpga_acquisition::set_phase_step(uint32_t doppler_index) void fpga_acquisition::read_acquisition_results(uint32_t *max_index, float *firstpeak, float *secondpeak, uint64_t *initial_sample, float *power_sum, uint32_t *doppler_index, uint32_t *total_blk_exp) { - uint64_t initial_sample_tmp = 0; uint32_t readval = 0; uint64_t readval_long = 0; @@ -313,7 +300,7 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, initial_sample_tmp = readval; readval_long = d_map_base[2]; - readval_long_shifted = readval_long << 32; // 2^32 + readval_long_shifted = readval_long << 32; // 2^32 initial_sample_tmp = initial_sample_tmp + readval_long_shifted; // 2^32 *initial_sample = initial_sample_tmp; @@ -335,10 +322,9 @@ void fpga_acquisition::read_acquisition_results(uint32_t *max_index, readval = d_map_base[7]; // read doppler index -- this read releases the interrupt line *doppler_index = readval; - readval = d_map_base[15]; // read dummy + readval = d_map_base[15]; // read dummy fpga_acquisition::close_device(); - } @@ -367,7 +353,7 @@ void fpga_acquisition::close_device() void fpga_acquisition::reset_acquisition(void) { - fpga_acquisition::open_device(); + fpga_acquisition::open_device(); d_map_base[8] = RESET_ACQUISITION; // writing a 2 to d_map_base[8] resets the multicorrelator fpga_acquisition::close_device(); } @@ -376,19 +362,17 @@ void fpga_acquisition::reset_acquisition(void) // this function is only used for the unit tests void fpga_acquisition::read_fpga_total_scale_factor(uint32_t *total_scale_factor, uint32_t *fw_scale_factor) { + uint32_t readval = 0; + readval = d_map_base[8]; + *total_scale_factor = readval; - uint32_t readval = 0; - readval = d_map_base[8]; - *total_scale_factor = readval; - - //readval = d_map_base[8]; - *fw_scale_factor = 0; - + //readval = d_map_base[8]; + *fw_scale_factor = 0; } void fpga_acquisition::read_result_valid(uint32_t *result_valid) { - uint32_t readval = 0; - readval = d_map_base[0]; - *result_valid = readval; + uint32_t readval = 0; + readval = d_map_base[0]; + *result_valid = readval; } diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.h b/src/algorithms/acquisition/libs/fpga_acquisition.h index ff599f4ff..6140e9ade 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.h +++ b/src/algorithms/acquisition/libs/fpga_acquisition.h @@ -54,7 +54,7 @@ public: uint32_t sampled_ms, uint32_t select_queue, lv_16sc_t *all_fft_codes, - uint32_t excludelimit); + uint32_t excludelimit); ~fpga_acquisition(); bool init(); @@ -113,18 +113,17 @@ private: lv_16sc_t *d_all_fft_codes; // memory that contains all the code ffts uint32_t d_vector_length; // number of samples incluing padding and number of ms uint32_t d_excludelimit; - uint32_t d_nsamples_total; // number of samples including padding - uint32_t d_nsamples; // number of samples not including padding - uint32_t d_select_queue; // queue selection - std::string d_device_name; // HW device name - uint32_t d_doppler_max; // max doppler - uint32_t d_doppler_step; // doppler step - uint32_t d_PRN; // PRN + uint32_t d_nsamples_total; // number of samples including padding + uint32_t d_nsamples; // number of samples not including padding + uint32_t d_select_queue; // queue selection + std::string d_device_name; // HW device name + uint32_t d_doppler_max; // max doppler + uint32_t d_doppler_step; // doppler step + uint32_t d_PRN; // PRN // FPGA private functions void fpga_acquisition_test_register(void); void fpga_configure_acquisition_local_code(lv_16sc_t fft_local_code[]); void read_result_valid(uint32_t *result_valid); - }; #endif /* GNSS_SDR_FPGA_ACQUISITION_H_ */ diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc index 9a5427c60..51f3a6547 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc @@ -251,7 +251,7 @@ void gnss_sdr_fpga_sample_counter::close_device() auto *aux = const_cast(map_base); if (munmap(static_cast(aux), PAGE_SIZE) == -1) { - std::cout << "Failed to unmap memory uio" << std::endl; + std::cout << "Failed to unmap memory uio" << std::endl; } close(fd); } @@ -270,8 +270,8 @@ uint32_t gnss_sdr_fpga_sample_counter::wait_for_interrupt_and_read_counter() nb = read(fd, &irq_count, sizeof(irq_count)); if (nb != sizeof(irq_count)) { - std::cout << "fpga sample counter module read failed to retrieve 4 bytes!" << std::endl; - std::cout << "fpga sample counter module interrupt number " << irq_count << std::endl; + std::cout << "fpga sample counter module read failed to retrieve 4 bytes!" << std::endl; + std::cout << "fpga sample counter module interrupt number " << irq_count << std::endl; } // it is a rising edge interrupt, the interrupt does not need to be acknowledged diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h index 3ec323e6a..a11a94be5 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h @@ -66,9 +66,9 @@ private: uint32_t current_days; // Receiver time in days since the beginning of the run int32_t report_interval_ms; bool flag_enable_send_msg; - int32_t fd; // driver descriptor - volatile uint32_t *map_base; // driver memory map - std::string device_name = "/dev/uio2"; // HW device name + int32_t fd; // driver descriptor + volatile uint32_t *map_base; // driver memory map + std::string device_name = "/dev/uio2"; // HW device name public: friend gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms); diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index cb054c87c..f66c967bd 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -55,7 +55,6 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( ConfigurationInterface *configuration, const std::string &role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) { - Dll_Pll_Conf_Fpga trk_param_fpga = Dll_Pll_Conf_Fpga(); DLOG(INFO) << "role " << role; //################# CONFIGURATION PARAMETERS ######################## @@ -138,15 +137,6 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( auto *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * code_length_chips * code_samples_per_chip, volk_gnsssdr_get_alignment())); - float *tracking_code; - float *data_code; - - if (trk_param_fpga.track_pilot) - { - data_code = static_cast(volk_gnsssdr_malloc(code_samples_per_chip * code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); - } - tracking_code = static_cast(volk_gnsssdr_malloc(code_samples_per_chip * code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); - d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); if (trk_param_fpga.track_pilot) @@ -160,37 +150,22 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( galileo_e5_a_code_gen_complex_primary(aux_code, PRN, const_cast(sig_)); if (trk_param_fpga.track_pilot) { - for (uint32_t i = 0; i < code_length_chips; i++) - { - tracking_code[i] = aux_code[i].imag(); - data_code[i] = aux_code[i].real(); - } for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); - d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].imag()); + d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].real()); } } else { - for (uint32_t i = 0; i < code_length_chips; i++) - { - tracking_code[i] = aux_code[i].real(); - } - for (uint32_t s = 0; s < code_length_chips; s++) { - d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); + d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(aux_code[s].real()); } } } volk_gnsssdr_free(aux_code); - volk_gnsssdr_free(tracking_code); - if (trk_param_fpga.track_pilot) - { - volk_gnsssdr_free(data_code); - } trk_param_fpga.ca_codes = d_ca_codes; trk_param_fpga.data_codes = d_data_codes; trk_param_fpga.code_length_chips = code_length_chips; diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc index d51415471..764a69a97 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -153,7 +153,7 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { - if (track_pilot) + if (trk_param_fpga.track_pilot) { gps_l5q_code_gen_float(tracking_code, PRN); gps_l5i_code_gen_float(data_code, PRN); diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 691990ced..fe944d612 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -36,21 +36,21 @@ */ #include "dll_pll_veml_tracking_fpga.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" -#include "control_message_factory.h" -#include "MATH_CONSTANTS.h" -#include "Galileo_E1.h" -#include "galileo_e1_signal_processing.h" -#include "Galileo_E5a.h" -#include "galileo_e5_signal_processing.h" #include "GPS_L1_CA.h" -#include "gps_sdr_signal_processing.h" #include "GPS_L2C.h" -#include "gps_l2c_signal.h" #include "GPS_L5.h" -#include "gps_l5_signal.h" +#include "Galileo_E1.h" +#include "Galileo_E5a.h" +#include "MATH_CONSTANTS.h" +#include "control_message_factory.h" +#include "galileo_e1_signal_processing.h" +#include "galileo_e5_signal_processing.h" #include "gnss_sdr_create_directory.h" +#include "gps_l2c_signal.h" +#include "gps_l5_signal.h" +#include "gps_sdr_signal_processing.h" +#include "lock_detectors.h" +#include "tracking_discriminators.h" #include #include #include @@ -60,8 +60,8 @@ #include #include #include -#include #include +#include using google::LogMessage; @@ -72,7 +72,7 @@ dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Co dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_) : gr::block("dll_pll_veml_tracking_fpga", gr::io_signature::make(0, 0, sizeof(lv_16sc_t)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { trk_parameters = conf_; // Telemetry bit synchronization message port input @@ -326,7 +326,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & trk_parameters.extend_correlation_symbols = 1; } - // --- Initializations --- + // --- Initializations --- // Initial code frequency basis of NCO d_code_freq_chips = d_code_chip_rate; // Residual code phase (in chips) @@ -423,14 +423,11 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & uint32_t multicorr_type = trk_parameters.multicorr_type; multicorrelator_fpga = std::make_shared(d_n_correlator_taps, device_name, device_base, ca_codes, data_codes, d_code_length_chips, trk_parameters.track_pilot, multicorr_type, d_code_samples_per_chip); multicorrelator_fpga->set_output_vectors(d_correlator_outs, d_Prompt_Data); - - } void dll_pll_veml_tracking_fpga::start_tracking() { - // correct the code phase according to the delay between acq and trk d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; @@ -508,7 +505,6 @@ void dll_pll_veml_tracking_fpga::start_tracking() d_cloop = true; d_Prompt_buffer_deque.clear(); d_last_prompt = gr_complex(0.0, 0.0); - } @@ -553,13 +549,11 @@ dll_pll_veml_tracking_fpga::~dll_pll_veml_tracking_fpga() { LOG(WARNING) << "Exception in destructor " << ex.what(); } - } bool dll_pll_veml_tracking_fpga::acquire_secondary() { - // ******* preamble correlation ******** int32_t corr_value = 0; for (uint32_t i = 0; i < d_secondary_code_length; i++) @@ -596,13 +590,11 @@ bool dll_pll_veml_tracking_fpga::acquire_secondary() { return false; } - } bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integration_time_s) { - // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### if (d_cn0_estimation_counter < trk_parameters.cn0_samples) @@ -642,7 +634,6 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra return true; } } - } @@ -654,25 +645,20 @@ bool dll_pll_veml_tracking_fpga::cn0_and_tracking_lock_status(double coh_integra //void dll_pll_veml_tracking_fpga::do_correlation_step(const gr_complex *input_samples) void dll_pll_veml_tracking_fpga::do_correlation_step(void) { + // // ################# CARRIER WIPEOFF AND CORRELATORS ############################## -// // ################# CARRIER WIPEOFF AND CORRELATORS ############################## - - multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( + multicorrelator_fpga->Carrier_wipeoff_multicorrelator_resampler( d_rem_carr_phase_rad, - d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, - static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), - static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), - static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), + d_carrier_phase_step_rad, d_carrier_phase_rate_step_rad, + static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_rate_step_chips) * static_cast(d_code_samples_per_chip), d_current_prn_length_samples); - - - } void dll_pll_veml_tracking_fpga::run_dll_pll() { - // ################## PLL ########################################################## // PLL discriminator if (d_cloop) @@ -707,13 +693,11 @@ void dll_pll_veml_tracking_fpga::run_dll_pll() // New code Doppler frequency estimation d_code_freq_chips = (1.0 + (d_carrier_doppler_hz / d_signal_carrier_freq)) * d_code_chip_rate - d_code_error_filt_chips; - } void dll_pll_veml_tracking_fpga::clear_tracking_vars() { - std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); if (trk_parameters.track_pilot) d_Prompt_Data[0] = gr_complex(0.0, 0.0); d_carr_error_hz = 0.0; @@ -727,13 +711,11 @@ void dll_pll_veml_tracking_fpga::clear_tracking_vars() d_code_phase_rate_step_chips = 0.0; d_carr_ph_history.clear(); d_code_ph_history.clear(); - } void dll_pll_veml_tracking_fpga::update_tracking_vars() { - T_chip_seconds = 1.0 / d_code_freq_chips; T_prn_seconds = T_chip_seconds * static_cast(d_code_length_chips); @@ -800,13 +782,11 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() // remnant code phase [chips] d_rem_code_phase_samples = K_blk_samples - static_cast(d_current_prn_length_samples); // rounding error < 1 sample d_rem_code_phase_chips = d_code_freq_chips * d_rem_code_phase_samples / trk_parameters.fs_in; - } void dll_pll_veml_tracking_fpga::save_correlation_results() { - if (d_secondary) { if (d_secondary_code_string->at(d_current_symbol) == '0') @@ -853,13 +833,11 @@ void dll_pll_veml_tracking_fpga::save_correlation_results() d_cloop = false; else d_cloop = true; - } void dll_pll_veml_tracking_fpga::log_data(bool integrating) { - if (d_dump) { // Dump results to file @@ -980,13 +958,11 @@ void dll_pll_veml_tracking_fpga::log_data(bool integrating) LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } - } int32_t dll_pll_veml_tracking_fpga::save_matfile() { - // READ DUMP FILE std::ifstream::pos_type size; int32_t number_of_double_vars = 1; @@ -1228,13 +1204,11 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() delete[] aux2; delete[] PRN; return 0; - } void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) { - d_channel = channel; multicorrelator_fpga->set_channel(d_channel); LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -1261,7 +1235,6 @@ void dll_pll_veml_tracking_fpga::set_channel(uint32_t channel) } } } - } @@ -1279,8 +1252,6 @@ void dll_pll_veml_tracking_fpga::stop_tracking() int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); @@ -1296,33 +1267,33 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un } case 1: // Pull-in { - int64_t acq_trk_diff_samples; - double acq_trk_diff_seconds; - double delta_trk_to_acq_prn_start_samples; + int64_t acq_trk_diff_samples; + double acq_trk_diff_seconds; + double delta_trk_to_acq_prn_start_samples; multicorrelator_fpga->lock_channel(); uint64_t counter_value = multicorrelator_fpga->read_sample_counter(); uint64_t absolute_samples_offset; if (counter_value > (d_acq_sample_stamp + d_acq_code_phase_samples)) - { - // Signal alignment (skip samples until the incoming signal is aligned with local replica) - acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); - acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; - delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; + { + // Signal alignment (skip samples until the incoming signal is aligned with local replica) + acq_trk_diff_samples = static_cast(counter_value) - static_cast(d_acq_sample_stamp); + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; + delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) - d_acq_code_phase_samples; - uint32_t num_frames = ceil((delta_trk_to_acq_prn_start_samples) / d_correlation_length_samples); - absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); - } + uint32_t num_frames = ceil((delta_trk_to_acq_prn_start_samples) / d_correlation_length_samples); + absolute_samples_offset = static_cast(d_acq_code_phase_samples + d_acq_sample_stamp + num_frames * d_correlation_length_samples); + } else - { - // test mode + { + // test mode - acq_trk_diff_samples = - static_cast(counter_value) + static_cast(d_acq_sample_stamp); - acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; - delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) + d_acq_code_phase_samples; + acq_trk_diff_samples = -static_cast(counter_value) + static_cast(d_acq_sample_stamp); + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / trk_parameters.fs_in; + delta_trk_to_acq_prn_start_samples = static_cast(acq_trk_diff_samples) + d_acq_code_phase_samples; - absolute_samples_offset = static_cast(delta_trk_to_acq_prn_start_samples); - } + absolute_samples_offset = static_cast(delta_trk_to_acq_prn_start_samples); + } multicorrelator_fpga->set_initial_sample(absolute_samples_offset); d_absolute_samples_offset = absolute_samples_offset; d_sample_counter = absolute_samples_offset; @@ -1357,13 +1328,12 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un // don't leave the HW module blocking the signal path before the first sample arrives // start the first tracking process - run_state_2(current_synchro_data); + run_state_2(current_synchro_data); break; - } case 2: // Wide tracking and symbol synchronization { - run_state_2(current_synchro_data); + run_state_2(current_synchro_data); break; } case 3: // coherent integration (correlation time extension) @@ -1497,9 +1467,9 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un if (current_synchro_data.Flag_valid_symbol_output) { current_synchro_data.fs = static_cast(trk_parameters.fs_in); - // two choices for the reporting of the sample counter: - // either the sample counter position that should be (d_sample_counter_next) - //or the sample counter corresponding to the number of samples that the FPGA actually consumed. + // two choices for the reporting of the sample counter: + // either the sample counter position that should be (d_sample_counter_next) + //or the sample counter corresponding to the number of samples that the FPGA actually consumed. current_synchro_data.Tracking_sample_counter = d_sample_counter_next; *out[0] = current_synchro_data; return 1; @@ -1678,7 +1648,6 @@ void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) } } } - } diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index c0411b142..a280c2cad 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -44,7 +44,6 @@ #include #include #include -#include //#include class dll_pll_veml_tracking_fpga; diff --git a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc index 36cdd264b..14ec6ccab 100644 --- a/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc +++ b/src/algorithms/tracking/libs/dll_pll_conf_fpga.cc @@ -37,8 +37,8 @@ Dll_Pll_Conf_Fpga::Dll_Pll_Conf_Fpga() { /* DLL/PLL tracking configuration */ - high_dyn = false; - smoother_length = 10; + high_dyn = false; + smoother_length = 10; fs_in = 0.0; vector_length = 0U; dump = false; diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index b23014af2..a19784fbe 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -35,40 +35,36 @@ */ #include "fpga_multicorrelator.h" -#include -#include -#include -#include -#include -#include +#include #include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include #include // FPGA register access constants -#define PAGE_SIZE 0x10000 -#define MAX_LENGTH_DEVICEIO_NAME 50 -#define CODE_RESAMPLER_NUM_BITS_PRECISION 20 -#define CODE_PHASE_STEP_CHIPS_NUM_NBITS CODE_RESAMPLER_NUM_BITS_PRECISION -#define pwrtwo(x) (1 << (x)) -#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS -#define PHASE_CARR_NBITS 32 -#define PHASE_CARR_NBITS_INT 1 -#define PHASE_CARR_NBITS_FRAC PHASE_CARR_NBITS - PHASE_CARR_NBITS_INT -#define LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT 0x20000000 -#define LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER 0x10000000 -#define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 -#define TEST_REGISTER_TRACK_WRITEVAL 0x55AA - - - +#define PAGE_SIZE 0x10000 +#define MAX_LENGTH_DEVICEIO_NAME 50 +#define CODE_RESAMPLER_NUM_BITS_PRECISION 20 +#define CODE_PHASE_STEP_CHIPS_NUM_NBITS CODE_RESAMPLER_NUM_BITS_PRECISION +#define pwrtwo(x) (1 << (x)) +#define MAX_CODE_RESAMPLER_COUNTER pwrtwo(CODE_PHASE_STEP_CHIPS_NUM_NBITS) // 2^CODE_PHASE_STEP_CHIPS_NUM_NBITS +#define PHASE_CARR_NBITS 32 +#define PHASE_CARR_NBITS_INT 1 +#define PHASE_CARR_NBITS_FRAC PHASE_CARR_NBITS - PHASE_CARR_NBITS_INT +#define LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT 0x20000000 +#define LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER 0x10000000 +#define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 +#define TEST_REGISTER_TRACK_WRITEVAL 0x55AA uint64_t fpga_multicorrelator_8sc::read_sample_counter() @@ -111,9 +107,9 @@ void fpga_multicorrelator_8sc::update_local_code(float rem_code_phase_chips) void fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( float rem_carrier_phase_in_rad, float phase_step_rad, - float carrier_phase_rate_step_rad, + float carrier_phase_rate_step_rad, float rem_code_phase_chips, float code_phase_step_chips, - float code_phase_rate_step_chips, + float code_phase_rate_step_chips, int32_t signal_length_samples) { update_local_code(rem_code_phase_chips); @@ -130,7 +126,7 @@ void fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( if (nb != sizeof(irq_count)) { std::cout << "Tracking_module Read failed to retrieve 4 bytes!" << std::endl; - std::cout << "Tracking_module Interrupt number " << irq_count << std::endl; + std::cout << "Tracking_module Interrupt number " << irq_count << std::endl; } fpga_multicorrelator_8sc::read_tracking_gps_results(); } @@ -294,7 +290,6 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int32_t PR } if (d_track_pilot) { - d_map_base[PROG_MEMS_ADDR] = LOCAL_CODE_FPGA_CLEAR_ADDRESS_COUNTER; for (k = 0; k < d_code_length_chips * d_code_samples_per_chip; k++) { @@ -410,7 +405,6 @@ void fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(void) { d_phase_step_rad_int = -d_phase_step_rad_int; } - } @@ -451,9 +445,9 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) } if (d_track_pilot) { - readval_real = d_map_base[RESULT_REG_REAL_BASE_ADDR + d_n_correlators]; - readval_imag = d_map_base[RESULT_REG_IMAG_BASE_ADDR + d_n_correlators]; - d_Prompt_Data[0] = gr_complex(readval_real, readval_imag); + readval_real = d_map_base[RESULT_REG_REAL_BASE_ADDR + d_n_correlators]; + readval_imag = d_map_base[RESULT_REG_IMAG_BASE_ADDR + d_n_correlators]; + d_Prompt_Data[0] = gr_complex(readval_real, readval_imag); } } @@ -461,8 +455,8 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void) void fpga_multicorrelator_8sc::unlock_channel(void) { // unlock the channel to let the next samples go through - d_map_base[DROP_SAMPLES_REG_ADDR] = 1; // unlock the channel - d_map_base[STOP_TRACKING_REG_ADDR] = 1; // set the tracking module back to idle + d_map_base[DROP_SAMPLES_REG_ADDR] = 1; // unlock the channel + d_map_base[STOP_TRACKING_REG_ADDR] = 1; // set the tracking module back to idle } void fpga_multicorrelator_8sc::close_device() @@ -481,4 +475,3 @@ void fpga_multicorrelator_8sc::lock_channel(void) // lock the channel for processing d_map_base[DROP_SAMPLES_REG_ADDR] = 0; // lock the channel } - diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index 95d5c580a..6229ea0de 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -44,27 +44,26 @@ // FPGA register addresses // write addresses -#define CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR 0 -#define INITIAL_INDEX_REG_BASE_ADDR 1 -#define INITIAL_INTERP_COUNTER_REG_BASE_ADDR 7 -#define NSAMPLES_MINUS_1_REG_ADDR 13 -#define CODE_LENGTH_MINUS_1_REG_ADDR 14 -#define REM_CARR_PHASE_RAD_REG_ADDR 15 -#define PHASE_STEP_RAD_REG_ADDR 16 -#define PROG_MEMS_ADDR 17 -#define DROP_SAMPLES_REG_ADDR 18 -#define INITIAL_COUNTER_VALUE_REG_ADDR_LSW 19 -#define INITIAL_COUNTER_VALUE_REG_ADDR_MSW 20 -#define STOP_TRACKING_REG_ADDR 23 -#define START_FLAG_ADDR 30 +#define CODE_PHASE_STEP_CHIPS_NUM_REG_ADDR 0 +#define INITIAL_INDEX_REG_BASE_ADDR 1 +#define INITIAL_INTERP_COUNTER_REG_BASE_ADDR 7 +#define NSAMPLES_MINUS_1_REG_ADDR 13 +#define CODE_LENGTH_MINUS_1_REG_ADDR 14 +#define REM_CARR_PHASE_RAD_REG_ADDR 15 +#define PHASE_STEP_RAD_REG_ADDR 16 +#define PROG_MEMS_ADDR 17 +#define DROP_SAMPLES_REG_ADDR 18 +#define INITIAL_COUNTER_VALUE_REG_ADDR_LSW 19 +#define INITIAL_COUNTER_VALUE_REG_ADDR_MSW 20 +#define STOP_TRACKING_REG_ADDR 23 +#define START_FLAG_ADDR 30 // read-write addresses -#define TEST_REG_ADDR 31 +#define TEST_REG_ADDR 31 // read addresses -#define RESULT_REG_REAL_BASE_ADDR 1 -#define RESULT_REG_IMAG_BASE_ADDR 7 -#define SAMPLE_COUNTER_REG_ADDR_LSW 13 -#define SAMPLE_COUNTER_REG_ADDR_MSW 14 - +#define RESULT_REG_REAL_BASE_ADDR 1 +#define RESULT_REG_IMAG_BASE_ADDR 7 +#define SAMPLE_COUNTER_REG_ADDR_LSW 13 +#define SAMPLE_COUNTER_REG_ADDR_MSW 14 /*! @@ -74,18 +73,18 @@ class fpga_multicorrelator_8sc { public: fpga_multicorrelator_8sc(int32_t n_correlators, std::string device_name, - uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip); + uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip); ~fpga_multicorrelator_8sc(); void set_output_vectors(gr_complex *corr_out, gr_complex *Prompt_Data); void set_local_code_and_taps( - float *shifts_chips, float *prompt_data_shift, int32_t PRN); + float *shifts_chips, float *prompt_data_shift, int32_t PRN); void update_local_code(float rem_code_phase_chips); void Carrier_wipeoff_multicorrelator_resampler( - float rem_carrier_phase_in_rad, float phase_step_rad, - float carrier_phase_rate_step_rad, - float rem_code_phase_chips, float code_phase_step_chips, - float code_phase_rate_step_chips, - int32_t signal_length_samples); + float rem_carrier_phase_in_rad, float phase_step_rad, + float carrier_phase_rate_step_rad, + float rem_code_phase_chips, float code_phase_step_chips, + float code_phase_rate_step_chips, + int32_t signal_length_samples); bool free(); void set_channel(uint32_t channel); void set_initial_sample(uint64_t samples_offset); @@ -144,7 +143,6 @@ private: void fpga_launch_multicorrelator_fpga(void); void read_tracking_gps_results(void); void close_device(void); - }; #endif /* GNSS_SDR_FPGA_MULTICORRELATOR_H_ */ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index fba66d309..4e66f110d 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -274,9 +274,9 @@ int ControlThread::run() cmd_interface_thread_ = std::thread(&ControlThread::telecommand_listener, this); #ifdef ENABLE_FPGA - // Create a task for the acquisition such that id doesn't block the flow of the control thread - fpga_helper_thread_=boost::thread(&GNSSFlowgraph::start_acquisition_helper, - flowgraph_); + // Create a task for the acquisition such that id doesn't block the flow of the control thread + fpga_helper_thread_ = boost::thread(&GNSSFlowgraph::start_acquisition_helper, + flowgraph_); #endif // Main loop to read and process the control messages while (flowgraph_->running() && !stop_) @@ -299,7 +299,7 @@ int ControlThread::run() // The HW reset causes any HW accelerator module that is waiting for more samples to complete its calculations // to trigger an interrupt and finish its signal processing tasks immediately. In this way all SW threads that // are waiting for interrupts in the HW can exit in a normal way. - flowgraph_->perform_hw_reset(); + flowgraph_->perform_hw_reset(); #endif pthread_t id = keyboard_thread_.native_handle(); @@ -308,7 +308,7 @@ int ControlThread::run() #ifdef ENABLE_FPGA - fpga_helper_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); + fpga_helper_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); #endif diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index c5cb3f647..23ffa877c 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -168,16 +168,16 @@ private: bool delete_configuration_; unsigned int processed_control_messages_; unsigned int applied_actions_; -//<<<<<<< HEAD -// boost::thread keyboard_thread_; -// boost::thread sysv_queue_thread_; -// boost::thread gps_acq_assist_data_collector_thread_; + //<<<<<<< HEAD + // boost::thread keyboard_thread_; + // boost::thread sysv_queue_thread_; + // boost::thread gps_acq_assist_data_collector_thread_; boost::thread fpga_helper_thread_; -//======= + //======= std::thread keyboard_thread_; std::thread sysv_queue_thread_; std::thread gps_acq_assist_data_collector_thread_; -//>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 + //>>>>>>> 4fe976ba016fa9c1c64ece88b26a9a93d93a84f4 void keyboard_listener(); void sysv_queue_listener(); diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index cd270a002..8c01a9afc 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -212,65 +212,65 @@ void GNSSFlowgraph::connect() for (int i = 0; i < sources_count_; i++) { - try - { - //TODO: Remove this array implementation and create generic multistream connector - //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") - { - //Multichannel Array - std::cout << "ARRAY MODE" << std::endl; - for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) - { - std::cout << "connecting ch " << j << std::endl; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); - } - } - else - { - //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - //Include GetRFChannels in the interface to avoid read config parameters here - //read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + try + { + //TODO: Remove this array implementation and create generic multistream connector + //(if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + { + //Multichannel Array + std::cout << "ARRAY MODE" << std::endl; + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + std::cout << "connecting ch " << j << std::endl; + top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + //TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + //Include GetRFChannels in the interface to avoid read config parameters here + //read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); - for (int j = 0; j < RF_Channels; j++) - { - //Connect the multichannel signal source to multiple signal conditioners - // GNURADIO max_streams=-1 means infinite ports! - LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); - LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); + for (int j = 0; j < RF_Channels; j++) + { + //Connect the multichannel signal source to multiple signal conditioners + // GNURADIO max_streams=-1 means infinite ports! + LOG(INFO) << "sig_source_.at(i)->get_right_block()->output_signature()->max_streams()=" << sig_source_.at(i)->get_right_block()->output_signature()->max_streams(); + LOG(INFO) << "sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()=" << sig_conditioner_.at(signal_conditioner_ID)->get_left_block()->input_signature()->max_streams(); - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) - { - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - if (j == 0) - { - // RF_channel 0 backward compatibility with single channel sources - LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; - top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - } - signal_conditioner_ID++; - } - } - } - catch (const std::exception& e) - { - LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; - LOG(ERROR) << e.what(); - top_block_->disconnect_all(); - return; - } + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + LOG(INFO) << "connecting sig_source_ " << i << " stream " << 0 << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + LOG(INFO) << "connecting sig_source_ " << i << " stream " << j << " to conditioner " << j; + top_block_->connect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i; + LOG(ERROR) << e.what(); + top_block_->disconnect_all(); + return; + } } DLOG(INFO) << "Signal source connected to signal conditioner"; @@ -306,7 +306,6 @@ void GNSSFlowgraph::connect() } else { - //create a hardware-defined gnss_synchro pulse for the observables block try { @@ -362,7 +361,6 @@ void GNSSFlowgraph::connect() uint32_t fs = configuration_->property("GNSS-SDR.internal_fs_sps", 0); for (unsigned int i = 0; i < channels_count_; i++) { - #ifndef ENABLE_FPGA if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) { @@ -670,7 +668,7 @@ void GNSSFlowgraph::connect() LOG(INFO) << "Channel " << i << " assigned to " << channels_.at(i)->get_signal(); if (channels_state_[i] == 1) { - channels_.at(i)->start_acquisition(); + channels_.at(i)->start_acquisition(); LOG(INFO) << "Channel " << i << " connected to observables and ready for acquisition"; } else @@ -703,114 +701,114 @@ void GNSSFlowgraph::disconnect() #ifdef ENABLE_FPGA if (configuration_->property(sig_source_.at(0)->role() + ".enable_FPGA", false) == false) - { - for (int i = 0; i < sources_count_; i++) - { - try - { - // TODO: Remove this array implementation and create generic multistream connector - // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") - { - //Multichannel Array - for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) - { - top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); - } - } - else - { - // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - // Include GetRFChannels in the interface to avoid read config parameters here - // read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + { + for (int i = 0; i < sources_count_; i++) + { + try + { + // TODO: Remove this array implementation and create generic multistream connector + // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + { + //Multichannel Array + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); - for (int j = 0; j < RF_Channels; j++) - { - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) - { - top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - if (j == 0) - { - // RF_channel 0 backward compatibility with single channel sources - top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - } - signal_conditioner_ID++; - } - } - } - catch (const std::exception& e) - { - LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); - top_block_->disconnect_all(); - return; - } - } - } + for (int j = 0; j < RF_Channels; j++) + { + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); + top_block_->disconnect_all(); + return; + } + } + } #else - for (int i = 0; i < sources_count_; i++) - { - try - { - // TODO: Remove this array implementation and create generic multistream connector - // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) - if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") - { - //Multichannel Array - for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) - { - top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); - } - } - else - { - // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. - // Include GetRFChannels in the interface to avoid read config parameters here - // read the number of RF channels for each front-end - RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); + for (int i = 0; i < sources_count_; i++) + { + try + { + // TODO: Remove this array implementation and create generic multistream connector + // (if a signal source has more than 1 stream, then connect it to the multistream signal conditioner) + if (sig_source_.at(i)->implementation() == "Raw_Array_Signal_Source") + { + //Multichannel Array + for (int j = 0; j < GNSS_SDR_ARRAY_SIGNAL_CONDITIONER_CHANNELS; j++) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(i)->get_left_block(), j); + } + } + else + { + // TODO: Create a class interface for SignalSources, derived from GNSSBlockInterface. + // Include GetRFChannels in the interface to avoid read config parameters here + // read the number of RF channels for each front-end + RF_Channels = configuration_->property(sig_source_.at(i)->role() + ".RF_channels", 1); - for (int j = 0; j < RF_Channels; j++) - { - if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) - { - top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - if (j == 0) - { - // RF_channel 0 backward compatibility with single channel sources - top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - else - { - // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) - top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); - } - } - signal_conditioner_ID++; - } - } - } - catch (const std::exception& e) - { - LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); - top_block_->disconnect_all(); - return; - } - } + for (int j = 0; j < RF_Channels; j++) + { + if (sig_source_.at(i)->get_right_block()->output_signature()->max_streams() > 1) + { + top_block_->disconnect(sig_source_.at(i)->get_right_block(), j, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + if (j == 0) + { + // RF_channel 0 backward compatibility with single channel sources + top_block_->disconnect(sig_source_.at(i)->get_right_block(), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + else + { + // Multiple channel sources using multiple output blocks of single channel (requires RF_channel selector in call) + top_block_->disconnect(sig_source_.at(i)->get_right_block(j), 0, sig_conditioner_.at(signal_conditioner_ID)->get_left_block(), 0); + } + } + signal_conditioner_ID++; + } + } + } + catch (const std::exception& e) + { + LOG(INFO) << "Can't disconnect signal source " << i << " to signal conditioner " << i << ": " << e.what(); + top_block_->disconnect_all(); + return; + } + } #endif #ifdef ENABLE_FPGA @@ -1133,7 +1131,7 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_[ch_index]->start_acquisition(); #else // create a task for the FPGA such that it doesn't stop the flow - std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[ch_index]); + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[ch_index]); tmp_thread.detach(); #endif } @@ -1210,7 +1208,7 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_[i]->start_acquisition(); #else // create a task for the FPGA such that it doesn't stop the flow - std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[i]); + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[i]); tmp_thread.detach(); #endif } @@ -1231,7 +1229,7 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_[who]->start_acquisition(); #else // create a task for the FPGA such that it doesn't stop the flow - std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[who]); + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[who]); tmp_thread.detach(); #endif } @@ -1366,7 +1364,7 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_[ch_index]->start_acquisition(); #else // create a task for the FPGA such that it doesn't stop the flow - std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[ch_index]); + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[ch_index]); tmp_thread.detach(); #endif } @@ -1400,7 +1398,7 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_[ch_index]->start_acquisition(); #else // create a task for the FPGA such that it doesn't stop the flow - std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[ch_index]); + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[ch_index]); tmp_thread.detach(); #endif } @@ -1435,7 +1433,7 @@ void GNSSFlowgraph::apply_action(unsigned int who, unsigned int what) channels_[ch_index]->start_acquisition(); #else // create a task for the FPGA such that it doesn't stop the flow - std::thread tmp_thread(&ChannelInterface::start_acquisition,channels_[ch_index]); + std::thread tmp_thread(&ChannelInterface::start_acquisition, channels_[ch_index]); tmp_thread.detach(); #endif } @@ -1531,15 +1529,12 @@ void GNSSFlowgraph::start_acquisition_helper() } - void GNSSFlowgraph::perform_hw_reset() { - - // a stop acquisition command causes the SW to reset the HW + // a stop acquisition command causes the SW to reset the HW std::shared_ptr channel_ptr; channel_ptr = std::dynamic_pointer_cast(channels_.at(0)); channel_ptr->acquisition()->stop_acquisition(); - } #endif diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc index 877ca888b..c8024eb2c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test_fpga.cc @@ -30,62 +30,62 @@ * ------------------------------------------------------------------------- */ -#include -#include -#include +#include "GPS_L1_CA.h" +#include "gnss_block_factory.h" +#include "gnss_block_interface.h" +#include "gnss_satellite.h" +#include "gnss_sdr_fpga_sample_counter.h" +#include "gnss_synchro.h" +#include "gnuplot_i.h" +#include "gps_l1_ca_dll_pll_tracking.h" +#include "gps_l1_ca_dll_pll_tracking_fpga.h" +#include "gps_l1_ca_telemetry_decoder.h" +#include "hybrid_observables.h" +#include "in_memory_configuration.h" +#include "observable_tests_flags.h" +#include "observables_dump_reader.h" +#include "signal_generator_flags.h" +#include "telemetry_decoder_interface.h" +#include "test_flags.h" +#include "tlm_dump_reader.h" +#include "tracking_dump_reader.h" +#include "tracking_interface.h" +#include "tracking_tests_flags.h" +#include "tracking_true_obs_reader.h" +#include "true_observables_reader.h" #include -#include #include #include #include -#include -#include +#include #include #include #include #include +#include +#include #include -#include "GPS_L1_CA.h" -#include "gnss_satellite.h" -#include "gnss_block_factory.h" -#include "gnss_block_interface.h" -#include "tracking_interface.h" -#include "telemetry_decoder_interface.h" -#include "in_memory_configuration.h" -#include "gnss_synchro.h" -#include "gps_l1_ca_telemetry_decoder.h" -#include "tracking_true_obs_reader.h" -#include "true_observables_reader.h" -#include "tracking_dump_reader.h" -#include "observables_dump_reader.h" -#include "tlm_dump_reader.h" -#include "gps_l1_ca_dll_pll_tracking.h" -#include "gps_l1_ca_dll_pll_tracking_fpga.h" -#include "hybrid_observables.h" -#include "signal_generator_flags.h" -#include "gnss_sdr_fpga_sample_counter.h" -#include "test_flags.h" -#include "tracking_tests_flags.h" -#include "observable_tests_flags.h" -#include "gnuplot_i.h" +#include +#include +#include // threads -#include // for pthread stuff -#include // for open, O_RDWR, O_SYNC -#include // for cout, endl -#include // for mmap +#include // for open, O_RDWR, O_SYNC +#include // for cout, endl +#include // for pthread stuff +#include // for mmap -#define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples -#define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes -#define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples +#define TEST_OBS_COMPLEX_SAMPLE_SIZE 2 // sample size in bytes +#define TEST_OBS_NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) +#define TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter #define TEST_OBS_DOWNSAMPLING_FILTER_DELAY 48 // HW related options -bool test_observables_show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if test_observables_doppler_control_in_sw = 1), 0=> do not show it -bool test_observables_skip_samples_already_used = 1; // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops - // (exactly in the same way as the SW) +bool test_observables_show_results_table = 0; // 1 => show matrix of (doppler, (max value, power sum)) results (only if test_observables_doppler_control_in_sw = 1), 0=> do not show it +bool test_observables_skip_samples_already_used = 1; // if test_observables_doppler_control_in_sw = 1 and test_observables_skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops + // (exactly in the same way as the SW) class HybridObservablesTest_msg_rx_Fpga; @@ -316,16 +316,17 @@ const unsigned int TEST_OBS_TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; void setup_fpga_switch_obs_test(void) { int switch_device_descriptor; // driver descriptor - volatile unsigned *switch_map_base; // driver memory map + volatile unsigned* switch_map_base; // driver memory map if ((switch_device_descriptor = open("/dev/uio1", O_RDWR | O_SYNC)) == -1) { - LOG(WARNING) << "Cannot open deviceio" << "/dev/uio1"; + LOG(WARNING) << "Cannot open deviceio" + << "/dev/uio1"; } - switch_map_base = reinterpret_cast(mmap(nullptr, TEST_OBS_PAGE_SIZE, + switch_map_base = reinterpret_cast(mmap(nullptr, TEST_OBS_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, switch_device_descriptor, 0)); - if (switch_map_base == reinterpret_cast(-1)) + if (switch_map_base == reinterpret_cast(-1)) { LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory"; std::cout << "Could not map switch memory." << std::endl; @@ -348,7 +349,7 @@ void setup_fpga_switch_obs_test(void) LOG(INFO) << "Test register sanity check success !"; } - switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues + switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues } @@ -356,128 +357,127 @@ static pthread_mutex_t mutex_obs_test = PTHREAD_MUTEX_INITIALIZER; volatile unsigned int send_samples_start_obs_test = 0; -int8_t input_samples_obs_test[TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL*TEST_OBS_COMPLEX_SAMPLE_SIZE]; // re - im -int8_t input_samples_dma_obs_test[TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL*TEST_OBS_COMPLEX_SAMPLE_SIZE*TEST_OBS_NUM_QUEUES]; +int8_t input_samples_obs_test[TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL * TEST_OBS_COMPLEX_SAMPLE_SIZE]; // re - im +int8_t input_samples_dma_obs_test[TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL * TEST_OBS_COMPLEX_SAMPLE_SIZE * TEST_OBS_NUM_QUEUES]; -struct DMA_handler_args_obs_test { +struct DMA_handler_args_obs_test +{ std::string file; unsigned int nsamples_tx; unsigned int skip_used_samples; - unsigned int freq_band; // 0 for GPS L1/ Galileo E1, 1 for GPS L5/Galileo E5 + unsigned int freq_band; // 0 for GPS L1/ Galileo E1, 1 for GPS L5/Galileo E5 }; -void *handler_DMA_obs_test(void *arguments) +void* handler_DMA_obs_test(void* arguments) { + // DMA process that configures the DMA to send the samples to the acquisition engine + int tx_fd; // DMA descriptor + FILE* rx_signal_file_id; // Input file descriptor + bool file_completed = false; // flag to indicate if the file is completed + unsigned int nsamples_block; // number of samples to send in the next DMA block of samples + unsigned int nread_elements; // number of elements effectively read from the input file + unsigned int nsamples = 0; // number of complex samples effectively transferred + unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA - // DMA process that configures the DMA to send the samples to the acquisition engine - int tx_fd; // DMA descriptor - FILE *rx_signal_file_id; // Input file descriptor - bool file_completed = false; // flag to indicate if the file is completed - unsigned int nsamples_block; // number of samples to send in the next DMA block of samples - unsigned int nread_elements; // number of elements effectively read from the input file - unsigned int nsamples = 0; // number of complex samples effectively transferred - unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA + unsigned int nsamples_transmitted; - unsigned int nsamples_transmitted; + struct DMA_handler_args* args = (struct DMA_handler_args*)arguments; - struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; + unsigned int nsamples_tx = args->nsamples_tx; + std::string file = args->file; // input filename + unsigned int skip_used_samples = args->skip_used_samples; - unsigned int nsamples_tx = args->nsamples_tx; - std::string file = args->file; // input filename - unsigned int skip_used_samples = args->skip_used_samples; + // open DMA device + tx_fd = open("/dev/loop_tx", O_WRONLY); + if (tx_fd < 0) + { + std::cout << "DMA can't open loop device" << std::endl; + exit(1); + } + else - // open DMA device - tx_fd = open("/dev/loop_tx", O_WRONLY); - if ( tx_fd < 0 ) - { - std::cout << "DMA can't open loop device" << std::endl; - exit(1); - } - else + // open input file + rx_signal_file_id = fopen(file.c_str(), "rb"); + if (rx_signal_file_id == NULL) + { + std::cout << "DMA can't open input file" << std::endl; + exit(1); + } + while (send_samples_start_obs_test == 0) + ; // wait until acquisition starts + // skip initial samples + int skip_samples = (int)FLAGS_skip_samples; - // open input file - rx_signal_file_id = fopen(file.c_str(), "rb"); - if (rx_signal_file_id == NULL) - { - std::cout << "DMA can't open input file" << std::endl; - exit(1); - } - while(send_samples_start_obs_test == 0); // wait until acquisition starts - // skip initial samples - int skip_samples = (int) FLAGS_skip_samples; + fseek(rx_signal_file_id, (skip_samples + skip_used_samples) * 2, SEEK_SET); - fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); + usleep(50000); // wait some time to give time to the main thread to start the acquisition module - usleep(50000); // wait some time to give time to the main thread to start the acquisition module + while (file_completed == false) + { + if (nsamples_tx - nsamples > TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + { + nsamples_block = TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + } + else + { + nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent + file_completed = true; + } - while (file_completed == false) - { - if (nsamples_tx - nsamples > TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL) - { - nsamples_block = TEST_OBS_MAX_INPUT_COMPLEX_SAMPLES_TOTAL; - } - else - { - nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent - file_completed = true; - } + nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE, rx_signal_file_id); - nread_elements = fread(input_samples_obs_test, sizeof(int8_t), nsamples_block*TEST_OBS_COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + if (nread_elements != nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE) + { + std::cout << "file completed" << std::endl; + file_completed = true; + } - if (nread_elements != nsamples_block * TEST_OBS_COMPLEX_SAMPLE_SIZE) - { - std::cout << "file completed" << std::endl; - file_completed = true; - } + nsamples += (nread_elements / TEST_OBS_COMPLEX_SAMPLE_SIZE); - nsamples+=(nread_elements/TEST_OBS_COMPLEX_SAMPLE_SIZE); - - if (nread_elements > 0) - { - // for the 32-BIT DMA - dma_index = 0; - for (index0 = 0;index0 < (nread_elements);index0+=TEST_OBS_COMPLEX_SAMPLE_SIZE) - { - if (args->freq_band == 0) - { - // channel 1 (queue 1) -> E5/L5 - input_samples_dma_obs_test[dma_index] = 0; - input_samples_dma_obs_test[dma_index+1] = 0; - // channel 0 (queue 0) -> E1/L1 - input_samples_dma_obs_test[dma_index+2] = input_samples_obs_test[index0]; - input_samples_dma_obs_test[dma_index+3] = input_samples_obs_test[index0+1]; - } - else - { - // channel 1 (queue 1) -> E5/L5 - input_samples_dma_obs_test[dma_index] = input_samples_obs_test[index0]; - input_samples_dma_obs_test[dma_index+1] = input_samples_obs_test[index0+1]; - // channel 0 (queue 0) -> E1/L1 - input_samples_dma_obs_test[dma_index+2] = 0; - input_samples_dma_obs_test[dma_index+3] = 0; - } - dma_index += 4; - } - nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements*TEST_OBS_NUM_QUEUES); - if (nsamples_transmitted != nread_elements*TEST_OBS_NUM_QUEUES) - { - std::cout << "Error : DMA could not send all the requested samples" << std::endl; - } - } - } + if (nread_elements > 0) + { + // for the 32-BIT DMA + dma_index = 0; + for (index0 = 0; index0 < (nread_elements); index0 += TEST_OBS_COMPLEX_SAMPLE_SIZE) + { + if (args->freq_band == 0) + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma_obs_test[dma_index] = 0; + input_samples_dma_obs_test[dma_index + 1] = 0; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma_obs_test[dma_index + 2] = input_samples_obs_test[index0]; + input_samples_dma_obs_test[dma_index + 3] = input_samples_obs_test[index0 + 1]; + } + else + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma_obs_test[dma_index] = input_samples_obs_test[index0]; + input_samples_dma_obs_test[dma_index + 1] = input_samples_obs_test[index0 + 1]; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma_obs_test[dma_index + 2] = 0; + input_samples_dma_obs_test[dma_index + 3] = 0; + } + dma_index += 4; + } + nsamples_transmitted = write(tx_fd, &input_samples_dma_obs_test[0], nread_elements * TEST_OBS_NUM_QUEUES); + if (nsamples_transmitted != nread_elements * TEST_OBS_NUM_QUEUES) + { + std::cout << "Error : DMA could not send all the requested samples" << std::endl; + } + } + } - close(tx_fd); - fclose(rx_signal_file_id); - return NULL; - + close(tx_fd); + fclose(rx_signal_file_id); + return NULL; } bool HybridObservablesTestFpga::acquire_signal() { - - pthread_t thread_DMA; + pthread_t thread_DMA; // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; @@ -508,7 +508,6 @@ bool HybridObservablesTestFpga::acquire_signal() args.freq_band = 0; acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { @@ -521,7 +520,6 @@ bool HybridObservablesTestFpga::acquire_signal() args.freq_band = 0; acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) @@ -535,7 +533,6 @@ bool HybridObservablesTestFpga::acquire_signal() args.freq_band = 1; acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { @@ -548,7 +545,6 @@ bool HybridObservablesTestFpga::acquire_signal() args.freq_band = 1; acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - } else { @@ -603,143 +599,135 @@ bool HybridObservablesTestFpga::acquire_signal() setup_fpga_switch_obs_test(); - unsigned int nsamples_to_transfer; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS))); - } - else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) - { - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / GPS_L5I_CODE_LENGTH_CHIPS))); - } + unsigned int nsamples_to_transfer; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E5A_CODE_CHIP_RATE_HZ / GALILEO_E5A_CODE_LENGTH_CHIPS))); + } + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / GPS_L5I_CODE_LENGTH_CHIPS))); + } - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); - int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + tmp_gnss_synchro.PRN = PRN; - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { + acquisition->stop_acquisition(); // reset the whole system including the sample counters + acquisition->set_doppler_max(acq_doppler_max); + acquisition->set_doppler_step(acq_doppler_step); + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); - tmp_gnss_synchro.PRN = PRN; - - acquisition->stop_acquisition(); // reset the whole system including the sample counters - acquisition->set_doppler_max(acq_doppler_max); - acquisition->set_doppler_step(acq_doppler_step); - acquisition->set_gnss_synchro(&tmp_gnss_synchro); - acquisition->init(); - acquisition->set_local_code(); - - args.file = file; + args.file = file; - send_samples_start_obs_test = 0; + send_samples_start_obs_test = 0; - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + args.skip_used_samples = -TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES; - args.skip_used_samples = - TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES; + args.nsamples_tx = TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES + TEST_OBS_DOWNSAMPLING_FILTER_DELAY; - args.nsamples_tx = TEST_OBS_DOWNAMPLING_FILTER_INIT_SAMPLES + TEST_OBS_DOWNSAMPLING_FILTER_DELAY; + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start_obs_test = 0; - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } - pthread_mutex_lock(&mutex); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start_obs_test = 0; + args.nsamples_tx = nsamples_to_transfer; - args.nsamples_tx = nsamples_to_transfer; + args.skip_used_samples = TEST_OBS_DOWNSAMPLING_FILTER_DELAY; + } + else + { + args.nsamples_tx = nsamples_to_transfer; - args.skip_used_samples = TEST_OBS_DOWNSAMPLING_FILTER_DELAY; - - } - else - { - - args.nsamples_tx = nsamples_to_transfer; - - args.skip_used_samples = 0; - } + args.skip_used_samples = 0; + } - // create DMA child process - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } + // create DMA child process + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } - msg_rx->rx_message = 0; - top_block->start(); + msg_rx->rx_message = 0; + top_block->start(); - pthread_mutex_lock(&mutex); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex); + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex); - acquisition->reset(); // set active + acquisition->reset(); // set active - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); - pthread_mutex_lock(&mutex); - send_samples_start_obs_test = 0; - pthread_mutex_unlock(&mutex); + pthread_mutex_lock(&mutex); + send_samples_start_obs_test = 0; + pthread_mutex_unlock(&mutex); - // the DMA sends the exact number of samples needed for the acquisition. - // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate - // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra - // sample the DMA might have sent. - do { - usleep(100000); - } while (msg_rx->rx_message == 0); + // the DMA sends the exact number of samples needed for the acquisition. + // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate + // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra + // sample the DMA might have sent. + do + { + usleep(100000); + } + while (msg_rx->rx_message == 0); - if (msg_rx->rx_message == 1) - { - std::cout << " " << PRN << " "; + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; - tmp_gnss_synchro.Acq_doppler_hz = tmp_gnss_synchro.Acq_doppler_hz; - tmp_gnss_synchro.Acq_delay_samples = tmp_gnss_synchro.Acq_delay_samples; - tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation - tmp_gnss_synchro.Acq_samplestamp_samples = tmp_gnss_synchro.Acq_samplestamp_samples; // delay due to the downsampling filter in the acquisition + tmp_gnss_synchro.Acq_doppler_hz = tmp_gnss_synchro.Acq_doppler_hz; + tmp_gnss_synchro.Acq_delay_samples = tmp_gnss_synchro.Acq_delay_samples; + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + tmp_gnss_synchro.Acq_samplestamp_samples = tmp_gnss_synchro.Acq_samplestamp_samples; // delay due to the downsampling filter in the acquisition - gnss_synchro_vec.push_back(tmp_gnss_synchro); + gnss_synchro_vec.push_back(tmp_gnss_synchro); + } + else + { + std::cout << " . "; + } - } - else - { - std::cout << " . "; - } + top_block->stop(); - top_block->stop(); - - - - - std::cout.flush(); - - } + std::cout.flush(); + } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -826,7 +814,7 @@ void HybridObservablesTestFpga::configure_receiver( config->set_property("TelemetryDecoder.implementation", "Galileo_E1B_Telemetry_Decoder"); } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) { gnss_synchro_master.System = 'E'; std::string signal = "5X"; @@ -1478,11 +1466,10 @@ bool HybridObservablesTestFpga::ReadRinexObs(std::vector* obs_vec, Gn } TEST_F(HybridObservablesTestFpga, ValidationOfResults) { + // pointer to the DMA thread that sends the samples to the acquisition engine + pthread_t thread_DMA; - // pointer to the DMA thread that sends the samples to the acquisition engine - pthread_t thread_DMA; - - struct DMA_handler_args_obs_test args; + struct DMA_handler_args_obs_test args; // Configure the signal generator configure_generator(); @@ -1575,46 +1562,45 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) } - // The HW has been reset after the acquisition phase when the acquisition class was destroyed. - // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the - // GPS L1 / Galileo E1 filter has been cleared. - // During this test all the samples coming from the DMA are consumed so in principle there would be - // no need to reset the HW. However we need to clear the sample counter in each test. Therefore we have - // to reset the HW at the beginning of each test. + // The HW has been reset after the acquisition phase when the acquisition class was destroyed. + // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the + // GPS L1 / Galileo E1 filter has been cleared. + // During this test all the samples coming from the DMA are consumed so in principle there would be + // no need to reset the HW. However we need to clear the sample counter in each test. Therefore we have + // to reset the HW at the beginning of each test. - // instantiate the acquisition modules in order to use them to reset the HW. - // (note that the constructor of the acquisition modules resets the HW too) + // instantiate the acquisition modules in order to use them to reset the HW. + // (note that the constructor of the acquisition modules resets the HW too) - std::shared_ptr acquisition; + std::shared_ptr acquisition; // reset the HW to clear the sample counters: the acquisition constructor generates a reset - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else - { - std::cout << "The test can not run with the selected tracking implementation\n "; - throw(std::exception()); - } + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } std::vector> tracking_ch_vec; @@ -1661,336 +1647,333 @@ TEST_F(HybridObservablesTestFpga, ValidationOfResults) }) << "Failure setting gnss_synchro."; } - top_block = gr::make_top_block("Telemetry_Decoder test"); - boost::shared_ptr dummy_msg_rx_trk = HybridObservablesTest_msg_rx_Fpga_make(); - boost::shared_ptr dummy_tlm_msg_rx = HybridObservablesTest_tlm_msg_rx_Fpga_make(); - //Observables - std::shared_ptr observables(new HybridObservables(config.get(), "Observables", tracking_ch_vec.size() + 1, tracking_ch_vec.size())); + top_block = gr::make_top_block("Telemetry_Decoder test"); + boost::shared_ptr dummy_msg_rx_trk = HybridObservablesTest_msg_rx_Fpga_make(); + boost::shared_ptr dummy_tlm_msg_rx = HybridObservablesTest_tlm_msg_rx_Fpga_make(); + //Observables + std::shared_ptr observables(new HybridObservables(config.get(), "Observables", tracking_ch_vec.size() + 1, tracking_ch_vec.size())); - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - ASSERT_NO_THROW({ - tracking_ch_vec.at(n)->connect(top_block); - }) << "Failure connecting tracking to the top_block."; - } + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + ASSERT_NO_THROW({ + tracking_ch_vec.at(n)->connect(top_block); + }) << "Failure connecting tracking to the top_block."; + } - std::string file; + std::string file; - ASSERT_NO_THROW({ - if (!FLAGS_enable_external_signal_file) - { - file = "./" + filename_raw_data; - } - else - { - file = FLAGS_signal_file; - } - int observable_interval_ms = 20; + ASSERT_NO_THROW({ + if (!FLAGS_enable_external_signal_file) + { + file = "./" + filename_raw_data; + } + else + { + file = FLAGS_signal_file; + } + int observable_interval_ms = 20; - double fs = static_cast(config->property("GNSS-SDR.internal_fs_sps", 0)); + double fs = static_cast(config->property("GNSS-SDR.internal_fs_sps", 0)); - gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter; - ch_out_fpga_sample_counter = gnss_sdr_make_fpga_sample_counter(fs, observable_interval_ms); + gnss_sdr_fpga_sample_counter_sptr ch_out_fpga_sample_counter; + ch_out_fpga_sample_counter = gnss_sdr_make_fpga_sample_counter(fs, observable_interval_ms); - - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - //top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); - top_block->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); - top_block->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); - top_block->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); - top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); - } - //connect sample counter and timmer to the last channel in observables block (extra channel) - //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); - top_block->connect(ch_out_fpga_sample_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //extra port for the sample counter pulse - - }) << "Failure connecting the blocks."; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + //top_block->connect(gr_interleaved_char_to_complex, 0, tracking_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tracking_ch_vec.at(n)->get_right_block(), 0, tlm_ch_vec.at(n)->get_left_block(), 0); + top_block->connect(tlm_ch_vec.at(n)->get_right_block(), 0, observables->get_left_block(), n); + top_block->msg_connect(tracking_ch_vec.at(n)->get_right_block(), pmt::mp("events"), dummy_msg_rx_trk, pmt::mp("events")); + top_block->connect(observables->get_right_block(), n, null_sink_vec.at(n), 0); + } + //connect sample counter and timmer to the last channel in observables block (extra channel) + //top_block->connect(samp_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); + top_block->connect(ch_out_fpga_sample_counter, 0, observables->get_left_block(), tracking_ch_vec.size()); //extra port for the sample counter pulse + }) << "Failure connecting the blocks."; - args.file = file; - args.nsamples_tx = baseband_sampling_freq*FLAGS_duration;; + args.file = file; + args.nsamples_tx = baseband_sampling_freq * FLAGS_duration; + ; - args.skip_used_samples = 0; + args.skip_used_samples = 0; - if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } + if (pthread_create(&thread_DMA, NULL, handler_DMA_obs_test, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - tracking_ch_vec.at(n)->start_tracking(); - } + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + tracking_ch_vec.at(n)->start_tracking(); + } - pthread_mutex_lock(&mutex_obs_test); - send_samples_start_obs_test = 1; - pthread_mutex_unlock(&mutex_obs_test); + pthread_mutex_lock(&mutex_obs_test); + send_samples_start_obs_test = 1; + pthread_mutex_unlock(&mutex_obs_test); - top_block->start(); + top_block->start(); - - EXPECT_NO_THROW({ - start = std::chrono::system_clock::now(); - //top_block->run(); // Start threads and wait - end = std::chrono::system_clock::now(); - elapsed_seconds = end - start; - }) << "Failure running the top_block."; + EXPECT_NO_THROW({ + start = std::chrono::system_clock::now(); + //top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + elapsed_seconds = end - start; + }) << "Failure running the top_block."; - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); - top_block->stop(); + top_block->stop(); // reset the HW AGAIN - acquisition->stop_acquisition(); + acquisition->stop_acquisition(); - // pthread_mutex_lock(&mutex_obs_test); - // send_samples_start_obs_test = 0; - // pthread_mutex_unlock(&mutex_obs_test); + // pthread_mutex_lock(&mutex_obs_test); + // send_samples_start_obs_test = 0; + // pthread_mutex_unlock(&mutex_obs_test); + //check results + // Matrices for storing columnwise true GPS time, Range, Doppler and Carrier phase + std::vector true_obs_vec; - //check results - // Matrices for storing columnwise true GPS time, Range, Doppler and Carrier phase - std::vector true_obs_vec; + if (!FLAGS_enable_external_signal_file) + { + //load the true values + True_Observables_Reader true_observables; + ASSERT_NO_THROW({ + if (true_observables.open_obs_file(std::string("./obs_out.bin")) == false) + { + throw std::exception(); + } + }) << "Failure opening true observables file"; - if (!FLAGS_enable_external_signal_file) - { - //load the true values - True_Observables_Reader true_observables; - ASSERT_NO_THROW({ - if (true_observables.open_obs_file(std::string("./obs_out.bin")) == false) - { - throw std::exception(); - } - }) << "Failure opening true observables file"; + unsigned int nepoch = static_cast(true_observables.num_epochs()); - unsigned int nepoch = static_cast(true_observables.num_epochs()); + std::cout << "True observation epochs = " << nepoch << std::endl; - std::cout << "True observation epochs = " << nepoch << std::endl; + true_observables.restart(); + int64_t epoch_counter = 0; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + true_obs_vec.push_back(arma::zeros(nepoch, 4)); + } - true_observables.restart(); - int64_t epoch_counter = 0; - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - true_obs_vec.push_back(arma::zeros(nepoch, 4)); - } - - ASSERT_NO_THROW({ - while (true_observables.read_binary_obs()) - { - for (unsigned int n = 0; n < true_obs_vec.size(); n++) - { - if (round(true_observables.prn[n]) != gnss_synchro_vec.at(n).PRN) - { - std::cout << "True observables SV PRN does not match measured ones: " - << round(true_observables.prn[n]) << " vs. " << gnss_synchro_vec.at(n).PRN << std::endl; - throw std::exception(); - } - true_obs_vec.at(n)(epoch_counter, 0) = true_observables.gps_time_sec[n]; - true_obs_vec.at(n)(epoch_counter, 1) = true_observables.dist_m[n]; - true_obs_vec.at(n)(epoch_counter, 2) = true_observables.doppler_l1_hz[n]; - true_obs_vec.at(n)(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[n]; - } - epoch_counter++; - } - }); - } - else - { - ASSERT_EQ(ReadRinexObs(&true_obs_vec, gnss_synchro_master), true) - << "Failure reading RINEX file"; - } + ASSERT_NO_THROW({ + while (true_observables.read_binary_obs()) + { + for (unsigned int n = 0; n < true_obs_vec.size(); n++) + { + if (round(true_observables.prn[n]) != gnss_synchro_vec.at(n).PRN) + { + std::cout << "True observables SV PRN does not match measured ones: " + << round(true_observables.prn[n]) << " vs. " << gnss_synchro_vec.at(n).PRN << std::endl; + throw std::exception(); + } + true_obs_vec.at(n)(epoch_counter, 0) = true_observables.gps_time_sec[n]; + true_obs_vec.at(n)(epoch_counter, 1) = true_observables.dist_m[n]; + true_obs_vec.at(n)(epoch_counter, 2) = true_observables.doppler_l1_hz[n]; + true_obs_vec.at(n)(epoch_counter, 3) = true_observables.acc_carrier_phase_l1_cycles[n]; + } + epoch_counter++; + } + }); + } + else + { + ASSERT_EQ(ReadRinexObs(&true_obs_vec, gnss_synchro_master), true) + << "Failure reading RINEX file"; + } - //read measured values - Observables_Dump_Reader estimated_observables(tracking_ch_vec.size()); - ASSERT_NO_THROW({ - if (estimated_observables.open_obs_file(std::string("./observables.dat")) == false) - { - throw std::exception(); - } - }) << "Failure opening dump observables file"; + //read measured values + Observables_Dump_Reader estimated_observables(tracking_ch_vec.size()); + ASSERT_NO_THROW({ + if (estimated_observables.open_obs_file(std::string("./observables.dat")) == false) + { + throw std::exception(); + } + }) << "Failure opening dump observables file"; - unsigned int nepoch = static_cast(estimated_observables.num_epochs()); - std::cout << "Measured observations epochs = " << nepoch << std::endl; + unsigned int nepoch = static_cast(estimated_observables.num_epochs()); + std::cout << "Measured observations epochs = " << nepoch << std::endl; - // Matrices for storing columnwise measured RX_time, TOW, Doppler, Carrier phase and Pseudorange - std::vector measured_obs_vec; - std::vector epoch_counters_vec; - for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) - { - measured_obs_vec.push_back(arma::zeros(nepoch, 5)); - epoch_counters_vec.push_back(0); - } + // Matrices for storing columnwise measured RX_time, TOW, Doppler, Carrier phase and Pseudorange + std::vector measured_obs_vec; + std::vector epoch_counters_vec; + for (unsigned int n = 0; n < tracking_ch_vec.size(); n++) + { + measured_obs_vec.push_back(arma::zeros(nepoch, 5)); + epoch_counters_vec.push_back(0); + } - estimated_observables.restart(); - while (estimated_observables.read_binary_obs()) - { - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - if (static_cast(estimated_observables.valid[n])) - { - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 3) = estimated_observables.Acc_carrier_phase_hz[n]; - measured_obs_vec.at(n)(epoch_counters_vec.at(n), 4) = estimated_observables.Pseudorange_m[n]; - epoch_counters_vec.at(n)++; - } - } - } + estimated_observables.restart(); + while (estimated_observables.read_binary_obs()) + { + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (static_cast(estimated_observables.valid[n])) + { + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 0) = estimated_observables.RX_time[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 1) = estimated_observables.TOW_at_current_symbol_s[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 2) = estimated_observables.Carrier_Doppler_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 3) = estimated_observables.Acc_carrier_phase_hz[n]; + measured_obs_vec.at(n)(epoch_counters_vec.at(n), 4) = estimated_observables.Pseudorange_m[n]; + epoch_counters_vec.at(n)++; + } + } + } - //Cut measurement tail zeros - arma::uvec index; - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - index = arma::find(measured_obs_vec.at(n).col(0) > 0.0, 1, "last"); - if ((index.size() > 0) and index(0) < (nepoch - 1)) - { - measured_obs_vec.at(n).shed_rows(index(0) + 1, nepoch - 1); - } - } + //Cut measurement tail zeros + arma::uvec index; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + index = arma::find(measured_obs_vec.at(n).col(0) > 0.0, 1, "last"); + if ((index.size() > 0) and index(0) < (nepoch - 1)) + { + measured_obs_vec.at(n).shed_rows(index(0) + 1, nepoch - 1); + } + } - //Cut measurement initial transitory of the measurements + //Cut measurement initial transitory of the measurements - double initial_transitory_s = FLAGS_skip_obs_transitory_s; + double initial_transitory_s = FLAGS_skip_obs_transitory_s; - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - index = arma::find(measured_obs_vec.at(n).col(0) >= (measured_obs_vec.at(n)(0, 0) + initial_transitory_s), 1, "first"); - if ((index.size() > 0) and (index(0) > 0)) - { - measured_obs_vec.at(n).shed_rows(0, index(0)); - } + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + index = arma::find(measured_obs_vec.at(n).col(0) >= (measured_obs_vec.at(n)(0, 0) + initial_transitory_s), 1, "first"); + if ((index.size() > 0) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } - index = arma::find(measured_obs_vec.at(n).col(0) >= true_obs_vec.at(n)(0, 0), 1, "first"); - if ((index.size() > 0) and (index(0) > 0)) - { - measured_obs_vec.at(n).shed_rows(0, index(0)); - } - } + index = arma::find(measured_obs_vec.at(n).col(0) >= true_obs_vec.at(n)(0, 0), 1, "first"); + if ((index.size() > 0) and (index(0) > 0)) + { + measured_obs_vec.at(n).shed_rows(0, index(0)); + } + } - //Correct the clock error using true values (it is not possible for a receiver to correct - //the receiver clock offset error at the observables level because it is required the - //decoding of the ephemeris data and solve the PVT equations) + //Correct the clock error using true values (it is not possible for a receiver to correct + //the receiver clock offset error at the observables level because it is required the + //decoding of the ephemeris data and solve the PVT equations) - //Find the reference satellite (the nearest) and compute the receiver time offset at observable level - double min_pr = std::numeric_limits::max(); - unsigned int min_pr_ch_id = 0; - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - if (epoch_counters_vec.at(n) > 10) //discard non-valid channels - { - { - if (measured_obs_vec.at(n)(0, 4) < min_pr) - { - min_pr = measured_obs_vec.at(n)(0, 4); - min_pr_ch_id = n; - } - } - } - else - { - std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; - } - } + //Find the reference satellite (the nearest) and compute the receiver time offset at observable level + double min_pr = std::numeric_limits::max(); + unsigned int min_pr_ch_id = 0; + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + { + if (measured_obs_vec.at(n)(0, 4) < min_pr) + { + min_pr = measured_obs_vec.at(n)(0, 4); + min_pr_ch_id = n; + } + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } - arma::vec receiver_time_offset_ref_channel_s; - //receiver_time_offset_ref_channel_s = true_obs_vec.at(min_pr_ch_id).col(1) / GPS_C_m_s - GPS_STARTOFFSET_ms / 1000.0; - receiver_time_offset_ref_channel_s = (true_obs_vec.at(min_pr_ch_id).col(1)(0) - measured_obs_vec.at(min_pr_ch_id).col(4)(0)) / GPS_C_M_S; - std::cout << "Ref channel initial Receiver time offset " << receiver_time_offset_ref_channel_s(0) * 1e3 << " [ms]" << std::endl; + arma::vec receiver_time_offset_ref_channel_s; + //receiver_time_offset_ref_channel_s = true_obs_vec.at(min_pr_ch_id).col(1) / GPS_C_m_s - GPS_STARTOFFSET_ms / 1000.0; + receiver_time_offset_ref_channel_s = (true_obs_vec.at(min_pr_ch_id).col(1)(0) - measured_obs_vec.at(min_pr_ch_id).col(4)(0)) / GPS_C_M_S; + std::cout << "Ref channel initial Receiver time offset " << receiver_time_offset_ref_channel_s(0) * 1e3 << " [ms]" << std::endl; - for (unsigned int n = 0; n < measured_obs_vec.size(); n++) - { - //debug save to .mat - std::vector tmp_vector_x(true_obs_vec.at(n).col(0).colptr(0), - true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); - std::vector tmp_vector_y(true_obs_vec.at(n).col(1).colptr(0), - true_obs_vec.at(n).col(1).colptr(0) + true_obs_vec.at(n).col(1).n_rows); - save_mat_xy(tmp_vector_x, tmp_vector_y, std::string("true_pr_ch_" + std::to_string(n))); + for (unsigned int n = 0; n < measured_obs_vec.size(); n++) + { + //debug save to .mat + std::vector tmp_vector_x(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y(true_obs_vec.at(n).col(1).colptr(0), + true_obs_vec.at(n).col(1).colptr(0) + true_obs_vec.at(n).col(1).n_rows); + save_mat_xy(tmp_vector_x, tmp_vector_y, std::string("true_pr_ch_" + std::to_string(n))); - std::vector tmp_vector_x2(measured_obs_vec.at(n).col(0).colptr(0), - measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); - std::vector tmp_vector_y2(measured_obs_vec.at(n).col(4).colptr(0), - measured_obs_vec.at(n).col(4).colptr(0) + measured_obs_vec.at(n).col(4).n_rows); - save_mat_xy(tmp_vector_x2, tmp_vector_y2, std::string("measured_pr_ch_" + std::to_string(n))); + std::vector tmp_vector_x2(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y2(measured_obs_vec.at(n).col(4).colptr(0), + measured_obs_vec.at(n).col(4).colptr(0) + measured_obs_vec.at(n).col(4).n_rows); + save_mat_xy(tmp_vector_x2, tmp_vector_y2, std::string("measured_pr_ch_" + std::to_string(n))); - std::vector tmp_vector_x3(true_obs_vec.at(n).col(0).colptr(0), - true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); - std::vector tmp_vector_y3(true_obs_vec.at(n).col(2).colptr(0), - true_obs_vec.at(n).col(2).colptr(0) + true_obs_vec.at(n).col(2).n_rows); - save_mat_xy(tmp_vector_x3, tmp_vector_y3, std::string("true_doppler_ch_" + std::to_string(n))); + std::vector tmp_vector_x3(true_obs_vec.at(n).col(0).colptr(0), + true_obs_vec.at(n).col(0).colptr(0) + true_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y3(true_obs_vec.at(n).col(2).colptr(0), + true_obs_vec.at(n).col(2).colptr(0) + true_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x3, tmp_vector_y3, std::string("true_doppler_ch_" + std::to_string(n))); - std::vector tmp_vector_x4(measured_obs_vec.at(n).col(0).colptr(0), - measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); - std::vector tmp_vector_y4(measured_obs_vec.at(n).col(2).colptr(0), - measured_obs_vec.at(n).col(2).colptr(0) + measured_obs_vec.at(n).col(2).n_rows); - save_mat_xy(tmp_vector_x4, tmp_vector_y4, std::string("measured_doppler_ch_" + std::to_string(n))); + std::vector tmp_vector_x4(measured_obs_vec.at(n).col(0).colptr(0), + measured_obs_vec.at(n).col(0).colptr(0) + measured_obs_vec.at(n).col(0).n_rows); + std::vector tmp_vector_y4(measured_obs_vec.at(n).col(2).colptr(0), + measured_obs_vec.at(n).col(2).colptr(0) + measured_obs_vec.at(n).col(2).n_rows); + save_mat_xy(tmp_vector_x4, tmp_vector_y4, std::string("measured_doppler_ch_" + std::to_string(n))); - if (epoch_counters_vec.at(n) > 10) //discard non-valid channels - { - arma::vec true_TOW_ref_ch_s = true_obs_vec.at(min_pr_ch_id).col(0) - receiver_time_offset_ref_channel_s(0); - arma::vec true_TOW_ch_s = true_obs_vec.at(n).col(0) - receiver_time_offset_ref_channel_s(0); - //Compare measured observables - if (min_pr_ch_id != n) - { - check_results_code_pseudorange(true_obs_vec.at(n), - true_obs_vec.at(min_pr_ch_id), - true_TOW_ch_s, - true_TOW_ref_ch_s, - measured_obs_vec.at(n), - measured_obs_vec.at(min_pr_ch_id), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - check_results_carrier_phase_double_diff(true_obs_vec.at(n), - true_obs_vec.at(min_pr_ch_id), - true_TOW_ch_s, - true_TOW_ref_ch_s, - measured_obs_vec.at(n), - measured_obs_vec.at(min_pr_ch_id), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + if (epoch_counters_vec.at(n) > 10) //discard non-valid channels + { + arma::vec true_TOW_ref_ch_s = true_obs_vec.at(min_pr_ch_id).col(0) - receiver_time_offset_ref_channel_s(0); + arma::vec true_TOW_ch_s = true_obs_vec.at(n).col(0) - receiver_time_offset_ref_channel_s(0); + //Compare measured observables + if (min_pr_ch_id != n) + { + check_results_code_pseudorange(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_phase_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - check_results_carrier_doppler_double_diff(true_obs_vec.at(n), - true_obs_vec.at(min_pr_ch_id), - true_TOW_ch_s, - true_TOW_ref_ch_s, - measured_obs_vec.at(n), - measured_obs_vec.at(min_pr_ch_id), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - } - else - { - std::cout << "[CH " << std::to_string(n) << "] PRN " << std::to_string(gnss_synchro_vec.at(n).PRN) << " is the reference satellite" << std::endl; - } - if (FLAGS_compute_single_diffs) - { - check_results_carrier_phase(true_obs_vec.at(n), - true_TOW_ch_s, - measured_obs_vec.at(n), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - check_results_carrier_doppler(true_obs_vec.at(n), - true_TOW_ch_s, - measured_obs_vec.at(n), - "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); - } - } - else - { - std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; - } - } + check_results_carrier_doppler_double_diff(true_obs_vec.at(n), + true_obs_vec.at(min_pr_ch_id), + true_TOW_ch_s, + true_TOW_ref_ch_s, + measured_obs_vec.at(n), + measured_obs_vec.at(min_pr_ch_id), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + else + { + std::cout << "[CH " << std::to_string(n) << "] PRN " << std::to_string(gnss_synchro_vec.at(n).PRN) << " is the reference satellite" << std::endl; + } + if (FLAGS_compute_single_diffs) + { + check_results_carrier_phase(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + check_results_carrier_doppler(true_obs_vec.at(n), + true_TOW_ch_s, + measured_obs_vec.at(n), + "[CH " + std::to_string(n) + "] PRN " + std::to_string(gnss_synchro_vec.at(n).PRN) + " "); + } + } + else + { + std::cout << "PRN " << gnss_synchro_vec.at(n).PRN << " has NO observations!\n"; + } + } - std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; + std::cout << "Test completed in " << elapsed_seconds.count() << " [s]" << std::endl; } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc index 3675efe5d..9205d0ba6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test_fpga.cc @@ -32,13 +32,12 @@ #include "GPS_L1_CA.h" #include "acquisition_msg_rx.h" +#include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" #include "galileo_e5a_noncoherent_iq_acquisition_caf.h" #include "galileo_e5a_pcps_acquisition.h" -#include "gnss_block_factory.h" -#include "tracking_interface.h" -#include "gps_l1_ca_pcps_acquisition_fpga.h" -#include "galileo_e1_pcps_ambiguous_acquisition_fpga.h" #include "galileo_e5a_pcps_acquisition_fpga.h" +#include "gnss_block_factory.h" +#include "gps_l1_ca_pcps_acquisition_fpga.h" #include "gps_l5i_pcps_acquisition_fpga.h" #include "in_memory_configuration.h" #include "signal_generator_flags.h" @@ -61,21 +60,21 @@ #include // threads -#include // for pthread stuff -#include // for open, O_RDWR, O_SYNC -#include // for cout, endl -#include // for mmap +#include // for open, O_RDWR, O_SYNC +#include // for cout, endl +#include // for pthread stuff +#include // for mmap -#define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples -#define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes -#define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) -#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter -#define DOWNSAMPLING_FILTER_DELAY 48 // delay of the downsampling filter in samples +#define MAX_INPUT_COMPLEX_SAMPLES_TOTAL 8192 // maximum DMA sample block size in complex samples +#define COMPLEX_SAMPLE_SIZE 2 // sample size in bytes +#define NUM_QUEUES 2 // number of queues (1 for GPS L1/Galileo E1, and 1 for GPS L5/Galileo E5) +#define DOWNAMPLING_FILTER_INIT_SAMPLES 100 // some samples to initialize the state of the downsampling filter +#define DOWNSAMPLING_FILTER_DELAY 48 // delay of the downsampling filter in samples // HW related options -bool skip_samples_already_used = 0; // if skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops - // (exactly in the same way as the SW) +bool skip_samples_already_used = 0; // if skip_samples_already_used = 1 => for each PRN loop skip the samples used in the previous PRN loops + // (exactly in the same way as the SW) class Acquisition_msg_rx_Fpga; @@ -316,8 +315,6 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.early_late_space_chips", "0.5"); config->set_property("Tracking.if", "0"); config->set_property("Tracking.order", "3"); - - } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { @@ -335,7 +332,7 @@ void TrackingPullInTestFpga::configure_receiver( config->set_property("Tracking.device_base", "15"); } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) // or implementation.compare("Galileo_E5a_DLL_PLL_Tracking_b") == 0) { gnss_synchro.System = 'E'; std::string signal = "5X"; @@ -381,16 +378,17 @@ const unsigned int TEST_REGISTER_TRACK_WRITEVAL = 0x55AA; void setup_fpga_switch(void) { int switch_device_descriptor; // driver descriptor - volatile unsigned *switch_map_base; // driver memory map + volatile unsigned* switch_map_base; // driver memory map if ((switch_device_descriptor = open("/dev/uio1", O_RDWR | O_SYNC)) == -1) { - LOG(WARNING) << "Cannot open deviceio" << "/dev/uio1"; + LOG(WARNING) << "Cannot open deviceio" + << "/dev/uio1"; } - switch_map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, + switch_map_base = reinterpret_cast(mmap(nullptr, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, switch_device_descriptor, 0)); - if (switch_map_base == reinterpret_cast(-1)) + if (switch_map_base == reinterpret_cast(-1)) { LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory"; std::cout << "Could not map switch memory." << std::endl; @@ -413,7 +411,7 @@ void setup_fpga_switch(void) LOG(INFO) << "Test register sanity check success !"; } - switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues + switch_map_base[0] = 0; //0 -> DMA to queue 0, 1 -> DMA to queue 1, 2 -> A/Ds to queues } @@ -421,133 +419,130 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; volatile unsigned int send_samples_start = 0; -int8_t input_samples[MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE]; // re - im -int8_t input_samples_dma[MAX_INPUT_COMPLEX_SAMPLES_TOTAL*COMPLEX_SAMPLE_SIZE*NUM_QUEUES]; +int8_t input_samples[MAX_INPUT_COMPLEX_SAMPLES_TOTAL * COMPLEX_SAMPLE_SIZE]; // re - im +int8_t input_samples_dma[MAX_INPUT_COMPLEX_SAMPLES_TOTAL * COMPLEX_SAMPLE_SIZE * NUM_QUEUES]; -struct DMA_handler_args { +struct DMA_handler_args +{ std::string file; unsigned int nsamples_tx; unsigned int skip_used_samples; - unsigned int freq_band; // 0 for GPS L1/ Galileo E1, 1 for GPS L5/Galileo E5 + unsigned int freq_band; // 0 for GPS L1/ Galileo E1, 1 for GPS L5/Galileo E5 }; -void *handler_DMA(void *arguments) +void* handler_DMA(void* arguments) { + // DMA process that configures the DMA to send the samples to the acquisition engine + int tx_fd; // DMA descriptor + FILE* rx_signal_file_id; // Input file descriptor + bool file_completed = false; // flag to indicate if the file is completed + unsigned int nsamples_block; // number of samples to send in the next DMA block of samples + unsigned int nread_elements; // number of elements effectively read from the input file + unsigned int nsamples = 0; // number of complex samples effectively transferred + unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA - // DMA process that configures the DMA to send the samples to the acquisition engine - int tx_fd; // DMA descriptor - FILE *rx_signal_file_id; // Input file descriptor - bool file_completed = false; // flag to indicate if the file is completed - unsigned int nsamples_block; // number of samples to send in the next DMA block of samples - unsigned int nread_elements; // number of elements effectively read from the input file - unsigned int nsamples = 0; // number of complex samples effectively transferred - unsigned int index0, dma_index = 0; // counters used for putting the samples in the order expected by the DMA + unsigned int nsamples_transmitted; - unsigned int nsamples_transmitted; + struct DMA_handler_args* args = (struct DMA_handler_args*)arguments; - struct DMA_handler_args *args = (struct DMA_handler_args *) arguments; + unsigned int nsamples_tx = args->nsamples_tx; + std::string file = args->file; // input filename + unsigned int skip_used_samples = args->skip_used_samples; - unsigned int nsamples_tx = args->nsamples_tx; - std::string file = args->file; // input filename - unsigned int skip_used_samples = args->skip_used_samples; + // open DMA device + tx_fd = open("/dev/loop_tx", O_WRONLY); + if (tx_fd < 0) + { + std::cout << "DMA can't open loop device" << std::endl; + exit(1); + } + else - // open DMA device - tx_fd = open("/dev/loop_tx", O_WRONLY); - if ( tx_fd < 0 ) - { - std::cout << "DMA can't open loop device" << std::endl; - exit(1); - } - else + // open input file + rx_signal_file_id = fopen(file.c_str(), "rb"); + if (rx_signal_file_id == NULL) + { + std::cout << "DMA can't open input file" << std::endl; + exit(1); + } + while (send_samples_start == 0) + ; // wait until main thread tells the DMA to start - // open input file - rx_signal_file_id = fopen(file.c_str(), "rb"); - if (rx_signal_file_id == NULL) - { - std::cout << "DMA can't open input file" << std::endl; - exit(1); - } - while(send_samples_start == 0); // wait until main thread tells the DMA to start + // skip initial samples + int skip_samples = (int)FLAGS_skip_samples; - // skip initial samples - int skip_samples = (int) FLAGS_skip_samples; + fseek(rx_signal_file_id, (skip_samples + skip_used_samples) * 2, SEEK_SET); - fseek( rx_signal_file_id, (skip_samples + skip_used_samples)*2, SEEK_SET ); + usleep(50000); // wait some time to give time to the main thread to start the acquisition module - usleep(50000); // wait some time to give time to the main thread to start the acquisition module + while (file_completed == false) + { + if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) + { + nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; + } + else + { + nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent + file_completed = true; + } - while (file_completed == false) - { - if (nsamples_tx - nsamples > MAX_INPUT_COMPLEX_SAMPLES_TOTAL) - { - nsamples_block = MAX_INPUT_COMPLEX_SAMPLES_TOTAL; - } - else - { - nsamples_block = nsamples_tx - nsamples; // remaining samples to be sent - file_completed = true; - } + nread_elements = fread(input_samples, sizeof(int8_t), nsamples_block * COMPLEX_SAMPLE_SIZE, rx_signal_file_id); - nread_elements = fread(input_samples, sizeof(int8_t), nsamples_block*COMPLEX_SAMPLE_SIZE, rx_signal_file_id); + if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) + { + std::cout << "file completed" << std::endl; + file_completed = true; + } - if (nread_elements != nsamples_block * COMPLEX_SAMPLE_SIZE) - { - std::cout << "file completed" << std::endl; - file_completed = true; - } + nsamples += (nread_elements / COMPLEX_SAMPLE_SIZE); - nsamples+=(nread_elements/COMPLEX_SAMPLE_SIZE); - - if (nread_elements > 0) - { - // for the 32-BIT DMA - dma_index = 0; - for (index0 = 0;index0 < (nread_elements);index0+=COMPLEX_SAMPLE_SIZE) - { - if (args->freq_band == 0) - { - // channel 1 (queue 1) -> E5/L5 - input_samples_dma[dma_index] = 0; - input_samples_dma[dma_index+1] = 0; - // channel 0 (queue 0) -> E1/L1 - input_samples_dma[dma_index+2] = input_samples[index0]; - input_samples_dma[dma_index+3] = input_samples[index0+1]; - } - else - { - // channel 1 (queue 1) -> E5/L5 - input_samples_dma[dma_index] = input_samples[index0]; - input_samples_dma[dma_index+1] = input_samples[index0+1]; - // channel 0 (queue 0) -> E1/L1 - input_samples_dma[dma_index+2] = 0; - input_samples_dma[dma_index+3] = 0; - } - dma_index += 4; - } - nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements*NUM_QUEUES); - if (nsamples_transmitted != nread_elements*NUM_QUEUES) - { - std::cout << "Error : DMA could not send all the requested samples" << std::endl; - } - } - } + if (nread_elements > 0) + { + // for the 32-BIT DMA + dma_index = 0; + for (index0 = 0; index0 < (nread_elements); index0 += COMPLEX_SAMPLE_SIZE) + { + if (args->freq_band == 0) + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = 0; + input_samples_dma[dma_index + 1] = 0; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index + 2] = input_samples[index0]; + input_samples_dma[dma_index + 3] = input_samples[index0 + 1]; + } + else + { + // channel 1 (queue 1) -> E5/L5 + input_samples_dma[dma_index] = input_samples[index0]; + input_samples_dma[dma_index + 1] = input_samples[index0 + 1]; + // channel 0 (queue 0) -> E1/L1 + input_samples_dma[dma_index + 2] = 0; + input_samples_dma[dma_index + 3] = 0; + } + dma_index += 4; + } + nsamples_transmitted = write(tx_fd, &input_samples_dma[0], nread_elements * NUM_QUEUES); + if (nsamples_transmitted != nread_elements * NUM_QUEUES) + { + std::cout << "Error : DMA could not send all the requested samples" << std::endl; + } + } + } - close(tx_fd); - fclose(rx_signal_file_id); - return NULL; + close(tx_fd); + fclose(rx_signal_file_id); + return NULL; } - - - - bool TrackingPullInTestFpga::acquire_signal(int SV_ID) { - pthread_t thread_DMA; + pthread_t thread_DMA; - // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) + // 1. Setup GNU Radio flowgraph (file_source -> Acquisition_10m) gr::top_block_sptr top_block; top_block = gr::make_top_block("Acquisition test"); @@ -566,8 +561,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) { - - tmp_gnss_synchro.System = 'G'; + tmp_gnss_synchro.System = 'G'; std::string signal = "1C"; const char* str = signal.c_str(); // get a C style null terminated string std::memcpy(static_cast(tmp_gnss_synchro.Signal), str, 3); // copy string into synchro char array: 2 char + null @@ -576,14 +570,12 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.freq_band = 0; - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); } else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) { - tmp_gnss_synchro.System = 'E'; std::string signal = "1B"; const char* str = signal.c_str(); // get a C style null terminated string @@ -594,7 +586,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.freq_band = 0; acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - } else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) { @@ -608,8 +599,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.freq_band = 1; acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - - } else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) { @@ -622,7 +611,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) args.freq_band = 1; acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - } else { @@ -651,7 +639,7 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) msg_rx->top_block = top_block; - top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); // 5. Run the flowgraph @@ -683,134 +671,130 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) setup_fpga_switch(); - unsigned int nsamples_to_transfer; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } - else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) - { - nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } + unsigned int nsamples_to_transfer; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) + { + nsamples_to_transfer = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } - int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); - int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); + int acq_doppler_max = config->property("Acquisition.doppler_max", FLAGS_external_signal_acquisition_doppler_max_hz); + int acq_doppler_step = config->property("Acquisition.doppler_step", FLAGS_external_signal_acquisition_doppler_step_hz); - for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) - { + for (unsigned int PRN = 1; PRN < MAX_PRN_IDX; PRN++) + { + tmp_gnss_synchro.PRN = PRN; - tmp_gnss_synchro.PRN = PRN; + acquisition->stop_acquisition(); // reset the whole system including the sample counters + acquisition->set_doppler_max(acq_doppler_max); + acquisition->set_doppler_step(acq_doppler_step); + acquisition->set_gnss_synchro(&tmp_gnss_synchro); + acquisition->init(); + acquisition->set_local_code(); - acquisition->stop_acquisition(); // reset the whole system including the sample counters - acquisition->set_doppler_max(acq_doppler_max); - acquisition->set_doppler_step(acq_doppler_step); - acquisition->set_gnss_synchro(&tmp_gnss_synchro); - acquisition->init(); - acquisition->set_local_code(); - - args.file = file; + args.file = file; - if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) - { - // send the previous samples to set the downsampling filter in a good condition - send_samples_start = 0; + if ((implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) or (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0)) + { + // send the previous samples to set the downsampling filter in a good condition + send_samples_start = 0; - args.skip_used_samples = - DOWNAMPLING_FILTER_INIT_SAMPLES; + args.skip_used_samples = -DOWNAMPLING_FILTER_INIT_SAMPLES; - args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY; + args.nsamples_tx = DOWNAMPLING_FILTER_INIT_SAMPLES + DOWNSAMPLING_FILTER_DELAY; - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); - pthread_join(thread_DMA, NULL); - send_samples_start = 0; + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + pthread_join(thread_DMA, NULL); + send_samples_start = 0; - args.nsamples_tx = nsamples_to_transfer; + args.nsamples_tx = nsamples_to_transfer; - args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; + args.skip_used_samples = DOWNSAMPLING_FILTER_DELAY; + } + else + { + args.nsamples_tx = nsamples_to_transfer; - } - else - { - args.nsamples_tx = nsamples_to_transfer; - - args.skip_used_samples = 0; - } + args.skip_used_samples = 0; + } + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } + + msg_rx->rx_message = 0; + top_block->start(); + + pthread_mutex_lock(&mutex); + send_samples_start = 1; + pthread_mutex_unlock(&mutex); + acquisition->reset(); // set active - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } + if (start_msg == true) + { + std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; + std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; + std::cout << "["; + start_msg = false; + } - msg_rx->rx_message = 0; - top_block->start(); + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); - pthread_mutex_lock(&mutex); - send_samples_start = 1; - pthread_mutex_unlock(&mutex); + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); + + // the DMA sends the exact number of samples needed for the acquisition. + // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate + // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra + // sample the DMA might have sent. + do + { + usleep(100000); + } + while (msg_rx->rx_message == 0); + + if (msg_rx->rx_message == 1) + { + std::cout << " " << PRN << " "; + doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); + code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); + tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation + acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); + } + else + { + std::cout << " . "; + } - acquisition->reset(); // set active + top_block->stop(); - if (start_msg == true) - { - std::cout << "Reading external signal file: " << FLAGS_signal_file << std::endl; - std::cout << "Searching for " << System_and_Signal << " Satellites..." << std::endl; - std::cout << "["; - start_msg = false; - } - - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); - - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); - - // the DMA sends the exact number of samples needed for the acquisition. - // however because of the LPF in the GPS L1/Gal E1 acquisition, this calculation is approximate - // and some extra samples might be sent. Wait at least once to give time the HW to consume any extra - // sample the DMA might have sent. - do { - usleep(100000); - } while (msg_rx->rx_message == 0); - - if (msg_rx->rx_message == 1) - { - std::cout << " " << PRN << " "; - doppler_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_doppler_hz)); - code_delay_measurements_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_delay_samples)); - tmp_gnss_synchro.Acq_samplestamp_samples = 0; // do not take into account the filter internal state initialisation - acq_samplestamp_map.insert(std::pair(PRN, tmp_gnss_synchro.Acq_samplestamp_samples)); - } - else - { - std::cout << " . "; - } - - - top_block->stop(); - - std::cout.flush(); - - } + std::cout.flush(); + } std::cout << "]" << std::endl; std::cout << "-------------------------------------------\n"; @@ -821,7 +805,6 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) } - // report the elapsed time end = std::chrono::system_clock::now(); elapsed_seconds = end - start; @@ -833,13 +816,11 @@ bool TrackingPullInTestFpga::acquire_signal(int SV_ID) TEST_F(TrackingPullInTestFpga, ValidationOfResults) { + // pointer to the DMA thread that sends the samples to the acquisition engine + pthread_t thread_DMA; - // pointer to the DMA thread that sends the samples to the acquisition engine - pthread_t thread_DMA; - - - struct DMA_handler_args args; + struct DMA_handler_args args; //************************************************* @@ -886,7 +867,6 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } - // use generator or use an external capture file if (FLAGS_enable_external_signal_file) { @@ -953,71 +933,69 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) std::cout << "Estimated Initial Doppler " << true_acq_doppler_hz << " [Hz], estimated Initial code delay " << true_acq_delay_samples << " [Samples]" << " Acquisition SampleStamp is " << acq_samplestamp_samples << std::endl; - } std::vector> pull_in_results_v_v; - unsigned int code_length; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); + unsigned int code_length; + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GALILEO_E1_CODE_CHIP_RATE_HZ / GALILEO_E1_B_CODE_LENGTH_CHIPS))); + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast(GALILEO_E5A_CODE_LENGTH_CHIPS))); + } + else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) + { + code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); + } - } - else // (if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0)) - { - code_length = static_cast(std::round(static_cast(baseband_sampling_freq) / (GPS_L5I_CODE_RATE_HZ / static_cast(GPS_L5I_CODE_LENGTH_CHIPS)))); - } + float nbits = ceilf(log2f((float)code_length)); + unsigned int fft_size = pow(2, nbits); - float nbits = ceilf(log2f((float)code_length)); - unsigned int fft_size = pow(2, nbits); + // The HW has been reset after the acquisition phase when the acquisition class was destroyed. + // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the + // GPS L1 / Galileo E1 filter has been cleared. + // During this test all the samples coming from the DMA are consumed so in principle there would be + // no need to reset the HW. However we need to clear the sample counter in each test. Therefore we have + // to reset the HW at the beginning of each test. - // The HW has been reset after the acquisition phase when the acquisition class was destroyed. - // No more samples remained in the DMA. Therefore any intermediate state in the LPF of the - // GPS L1 / Galileo E1 filter has been cleared. - // During this test all the samples coming from the DMA are consumed so in principle there would be - // no need to reset the HW. However we need to clear the sample counter in each test. Therefore we have - // to reset the HW at the beginning of each test. + // instantiate the acquisition modules in order to use them to reset the HW. + // (note that the constructor of the acquisition modules resets the HW too) - // instantiate the acquisition modules in order to use them to reset the HW. - // (note that the constructor of the acquisition modules resets the HW too) - - std::shared_ptr acquisition; + std::shared_ptr acquisition; - if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) - { - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 0; - } - else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } - else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) - { - acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); - args.freq_band = 1; - } + if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E1_DLL_PLL_VEML_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 0; + } + else if (implementation.compare("Galileo_E5a_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } + else if (implementation.compare("GPS_L5_DLL_PLL_Tracking_Fpga") == 0) + { + acquisition = std::make_shared(config.get(), "Acquisition", 0, 0); + args.freq_band = 1; + } else - { - std::cout << "The test can not run with the selected tracking implementation\n "; - throw(std::exception()); - } + { + std::cout << "The test can not run with the selected tracking implementation\n "; + throw(std::exception()); + } for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values.size(); current_cn0_idx++) { @@ -1026,11 +1004,10 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) { for (unsigned int current_acq_code_error_idx = 0; current_acq_code_error_idx < acq_delay_error_chips_values.at(current_acq_doppler_error_idx).size(); current_acq_code_error_idx++) { + // reset the HW to clear the sample counters + acquisition->stop_acquisition(); - // reset the HW to clear the sample counters - acquisition->stop_acquisition(); - - gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; + gnss_synchro.Acq_samplestamp_samples = acq_samplestamp_samples; //simulate a Doppler error in acquisition gnss_synchro.Acq_doppler_hz = true_acq_doppler_hz + acq_doppler_error_hz_values.at(current_acq_doppler_error_idx); //simulate Code Delay error in acquisition @@ -1065,13 +1042,13 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) args.file = file; - if (skip_samples_already_used == 1) + if (skip_samples_already_used == 1) { - args.skip_used_samples = (gnss_synchro.PRN - 1)*fft_size; + args.skip_used_samples = (gnss_synchro.PRN - 1) * fft_size; } - else + else { - args.skip_used_samples = 0; + args.skip_used_samples = 0; } @@ -1080,13 +1057,13 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) //******************************************************************** - args.nsamples_tx = baseband_sampling_freq*FLAGS_duration; + args.nsamples_tx = baseband_sampling_freq * FLAGS_duration; - if (pthread_create(&thread_DMA, NULL, handler_DMA, (void *)&args) < 0) - { - std::cout << "ERROR cannot create DMA Process" << std::endl; - } + if (pthread_create(&thread_DMA, NULL, handler_DMA, (void*)&args) < 0) + { + std::cout << "ERROR cannot create DMA Process" << std::endl; + } std::cout << "--- START TRACKING WITH PULL-IN ERROR: " << acq_doppler_error_hz_values.at(current_acq_doppler_error_idx) << " [Hz] and " << acq_delay_error_chips_values.at(current_acq_doppler_error_idx).at(current_acq_code_error_idx) << " [Chips] ---" << std::endl; @@ -1098,17 +1075,17 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) top_block->start(); - // wait for the child DMA process to finish - pthread_join(thread_DMA, NULL); + // wait for the child DMA process to finish + pthread_join(thread_DMA, NULL); - top_block->stop(); + top_block->stop(); - // reset the HW to launch the pending interrupts - acquisition->stop_acquisition(); + // reset the HW to launch the pending interrupts + acquisition->stop_acquisition(); - pthread_mutex_lock(&mutex); - send_samples_start = 0; - pthread_mutex_unlock(&mutex); + pthread_mutex_lock(&mutex); + send_samples_start = 0; + pthread_mutex_unlock(&mutex); pull_in_results_v.push_back(msg_rx->rx_message != 3); //save last asynchronous tracking message in order to detect a loss of lock @@ -1280,9 +1257,9 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) } //end acquisition Delay errors loop - usleep(100000); // give time to the HW to consume all the remaining samples + usleep(100000); // give time to the HW to consume all the remaining samples - } //end acquisition Doppler errors loop + } //end acquisition Doppler errors loop pull_in_results_v_v.push_back(pull_in_results_v); @@ -1308,44 +1285,40 @@ TEST_F(TrackingPullInTestFpga, ValidationOfResults) if (FLAGS_show_plots) { - Gnuplot g4("points palette pointsize 2 pointtype 7"); - g4.showonscreen(); // window output - g4.cmd("set palette defined ( 0 \"black\", 1 \"green\" )"); - g4.cmd("set key off"); - g4.cmd("set view map"); - std::string title; - if (!FLAGS_enable_external_signal_file) - { - title = std::string("Tracking Pull-in result grid at CN0:" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + " [dB-Hz], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz]."); - } - else - { - title = std::string("Tracking Pull-in result grid, PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); - } - - g4.set_title(title); - g4.set_grid(); - g4.set_xlabel("Acquisition Doppler error [Hz]"); - g4.set_ylabel("Acquisition Code Delay error [Chips]"); - g4.cmd("set cbrange[0:1]"); - g4.plot_xyz(doppler_error_mesh, - code_delay_error_mesh, - pull_in_result_mesh); - g4.set_legend(); - if (!FLAGS_enable_external_signal_file) - { - g4.savetops("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx))))); - g4.savetopdf("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))), 12); - } - else - { - g4.savetops("trk_pull_in_grid_external_file"); - g4.savetopdf("trk_pull_in_grid_external_file", 12); - } + Gnuplot g4("points palette pointsize 2 pointtype 7"); + g4.showonscreen(); // window output + g4.cmd("set palette defined ( 0 \"black\", 1 \"green\" )"); + g4.cmd("set key off"); + g4.cmd("set view map"); + std::string title; + if (!FLAGS_enable_external_signal_file) + { + title = std::string("Tracking Pull-in result grid at CN0:" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))) + " [dB-Hz], PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz]."); + } + else + { + title = std::string("Tracking Pull-in result grid, PLL/DLL BW: " + std::to_string(FLAGS_PLL_bw_hz_start) + "," + std::to_string(FLAGS_DLL_bw_hz_start) + " [Hz], GPS L1 C/A (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")"); + } + g4.set_title(title); + g4.set_grid(); + g4.set_xlabel("Acquisition Doppler error [Hz]"); + g4.set_ylabel("Acquisition Code Delay error [Chips]"); + g4.cmd("set cbrange[0:1]"); + g4.plot_xyz(doppler_error_mesh, + code_delay_error_mesh, + pull_in_result_mesh); + g4.set_legend(); + if (!FLAGS_enable_external_signal_file) + { + g4.savetops("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx))))); + g4.savetopdf("trk_pull_in_grid_" + std::to_string(static_cast(round(generator_CN0_values.at(current_cn0_idx)))), 12); + } + else + { + g4.savetops("trk_pull_in_grid_external_file"); + g4.savetopdf("trk_pull_in_grid_external_file", 12); + } } - } - - } From fd64cdd8c29df7b41c7d7e1073dc1605c5f992e8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 Feb 2019 09:33:47 +0100 Subject: [PATCH 41/53] Fix program termination with some configurations This is not a robust solution but fixes termination when URSP is being used. To be improved --- src/core/receiver/control_thread.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 16c180990..67dc239c1 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -294,6 +294,7 @@ int ControlThread::run() stop_ = true; flowgraph_->disconnect(); + std::this_thread::sleep_for(std::chrono::milliseconds(500)); // Terminate keyboard thread pthread_t id = keyboard_thread_.native_handle(); keyboard_thread_.detach(); From ccc9222ebe2db7a17adfe3a95cf2caa386f0fdd9 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 Feb 2019 13:40:09 +0100 Subject: [PATCH 42/53] Replace deque by faster boost::circular_buffer --- .../gnuradio_blocks/CMakeLists.txt | 6 +- .../beidou_b1i_telemetry_decoder_cc.cc | 12 +--- .../beidou_b1i_telemetry_decoder_cc.h | 3 +- .../galileo_telemetry_decoder_cc.cc | 62 +++++++++---------- .../galileo_telemetry_decoder_cc.h | 4 +- .../glonass_l1_ca_telemetry_decoder_cc.cc | 22 +++---- .../glonass_l1_ca_telemetry_decoder_cc.h | 3 +- .../glonass_l2_ca_telemetry_decoder_cc.cc | 22 +++---- .../glonass_l2_ca_telemetry_decoder_cc.h | 3 +- .../gps_l2c_telemetry_decoder_cc.h | 4 +- .../gps_l5_telemetry_decoder_cc.cc | 9 +-- .../gps_l5_telemetry_decoder_cc.h | 8 +-- 12 files changed, 71 insertions(+), 87 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt index 8e71b0681..e56549c50 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt @@ -50,13 +50,13 @@ add_library(telemetry_decoder_gr_blocks target_link_libraries(telemetry_decoder_gr_blocks PUBLIC - Gnuradio::runtime - Volkgnsssdr::volkgnsssdr telemetry_decoder_libswiftcnav telemetry_decoder_libs core_system_parameters - PRIVATE + Gnuradio::runtime + Volkgnsssdr::volkgnsssdr Boost::boost + PRIVATE Gflags::gflags Glog::glog ) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc index 7a39e31ec..6f50fd1c5 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.cc @@ -117,6 +117,7 @@ beidou_b1i_telemetry_decoder_cc::beidou_b1i_telemetry_decoder_cc( d_subframe_symbols = static_cast(volk_gnsssdr_malloc(BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * sizeof(double), volk_gnsssdr_get_alignment())); d_required_symbols = BEIDOU_DNAV_SUBFRAME_SYMBOLS * d_samples_per_symbol + d_samples_per_preamble; + d_symbol_history.set_capacity(d_required_symbols + 1); // Generic settings d_sample_counter = 0; d_stat = 0; @@ -316,12 +317,8 @@ void beidou_b1i_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satell volk_gnsssdr_free(d_secondary_code_symbols); volk_gnsssdr_free(d_subframe_symbols); - d_samples_per_symbol = (BEIDOU_B1I_CODE_RATE_HZ / BEIDOU_B1I_CODE_LENGTH_CHIPS) / BEIDOU_D2NAV_SYMBOL_RATE_SPS; - d_symbols_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS; - d_samples_per_preamble = BEIDOU_DNAV_PREAMBLE_LENGTH_SYMBOLS * d_samples_per_symbol; d_secondary_code_symbols = nullptr; d_preamble_samples = static_cast(volk_gnsssdr_malloc(d_samples_per_preamble * sizeof(int32_t), volk_gnsssdr_get_alignment())); - d_preamble_period_samples = BEIDOU_DNAV_PREAMBLE_PERIOD_SYMBOLS * d_samples_per_symbol; // Setting samples of preamble code int32_t n = 0; @@ -401,7 +398,7 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ //******* preamble correlation ******** for (int32_t i = 0; i < d_samples_per_preamble; i++) { - if (d_symbol_history.at(i) < 0) // symbols clipping + if (d_symbol_history[i] < 0) // symbols clipping { corr_value -= d_preamble_samples[i]; } @@ -579,11 +576,6 @@ int beidou_b1i_telemetry_decoder_cc::general_work(int noutput_items __attribute_ } } - // remove used symbols from history - if (d_symbol_history.size() > d_required_symbols) - { - d_symbol_history.pop_front(); - } // 3. Make the output (copy the object contents to the GNURadio reserved memory) *out[0] = current_symbol; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h index e1b0b02ec..ed768795e 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b1i_telemetry_decoder_cc.h @@ -42,6 +42,7 @@ #include "beidou_dnav_utc_model.h" #include "gnss_satellite.h" #include "gnss_synchro.h" +#include #include #include #include @@ -94,7 +95,7 @@ private: uint32_t d_required_symbols; // Storage for incoming data - std::deque d_symbol_history; + boost::circular_buffer d_symbol_history; // Variables for internal functionality uint64_t d_sample_counter; // Sample counter as an index (1,2,3,..etc) indicating number of samples processed diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc index f2b4a3896..835e93f12 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc @@ -52,25 +52,6 @@ galileo_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, int frame_typ } -void galileo_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits) -{ - Viterbi(page_part_bits, out0, state0, out1, state1, - page_part_symbols, KK, nn, DataLength); -} - - -void galileo_telemetry_decoder_cc::deinterleaver(int32_t rows, int32_t cols, const double *in, double *out) -{ - for (int32_t r = 0; r < rows; r++) - { - for (int32_t c = 0; c < cols; c++) - { - out[c * rows + r] = in[r * cols + c]; - } - } -} - - galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc( const Gnss_Satellite &satellite, int frame_type, bool dump) : gr::block("galileo_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), @@ -216,6 +197,8 @@ galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc( d_channel = 0; flag_TOW_set = false; + d_symbol_history.set_capacity(d_required_symbols + 1); + // vars for Viterbi decoder int32_t max_states = 1 << mm; // 2^mm g_encoder[0] = 121; // Polynomial G1 @@ -256,6 +239,25 @@ galileo_telemetry_decoder_cc::~galileo_telemetry_decoder_cc() } +void galileo_telemetry_decoder_cc::viterbi_decoder(double *page_part_symbols, int32_t *page_part_bits) +{ + Viterbi(page_part_bits, out0, state0, out1, state1, + page_part_symbols, KK, nn, DataLength); +} + + +void galileo_telemetry_decoder_cc::deinterleaver(int32_t rows, int32_t cols, const double *in, double *out) +{ + for (int32_t r = 0; r < rows; r++) + { + for (int32_t c = 0; c < cols; c++) + { + out[c * rows + r] = in[r * cols + c]; + } + } +} + + void galileo_telemetry_decoder_cc::decode_INAV_word(double *page_part_symbols, int32_t frame_length) { // 1. De-interleave @@ -473,11 +475,10 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( if (d_symbol_history.size() > d_required_symbols) { - // TODO Optimize me! // ******* preamble correlation ******** for (int32_t i = 0; i < d_samples_per_preamble; i++) { - if (d_symbol_history.at(i) < 0.0) // symbols clipping + if (d_symbol_history[i] < 0.0) // symbols clipping { corr_value -= d_preamble_samples[i]; } @@ -524,7 +525,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( } break; } - case 2: //preamble acquired + case 2: // preamble acquired { if (d_sample_counter == d_preamble_index + static_cast(d_preamble_period_symbols)) { @@ -534,14 +535,14 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( case 1: // INAV // NEW Galileo page part is received // 0. fetch the symbols into an array - if (corr_value > 0) //normal PLL lock + if (corr_value > 0) // normal PLL lock { for (uint32_t i = 0; i < d_frame_length_symbols; i++) { d_page_part_symbols[i] = d_symbol_history.at(i + d_samples_per_preamble); // because last symbol of the preamble is just received now! } } - else //180 deg. inverted carrier phase PLL lock + else // 180 deg. inverted carrier phase PLL lock { for (uint32_t i = 0; i < d_frame_length_symbols; i++) { @@ -553,7 +554,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( case 2: // FNAV // NEW Galileo page part is received // 0. fetch the symbols into an array - if (corr_value > 0) //normal PLL lock + if (corr_value > 0) // normal PLL lock { int k = 0; for (uint32_t i = 0; i < d_frame_length_symbols; i++) @@ -567,13 +568,13 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( } } } - else //180 deg. inverted carrier phase PLL lock + else // 180 deg. inverted carrier phase PLL lock { int k = 0; for (uint32_t i = 0; i < d_frame_length_symbols; i++) { d_page_part_symbols[i] = 0; - for (uint32_t m = 0; m < d_samples_per_symbol; m++) //integrate samples into symbols + for (uint32_t m = 0; m < d_samples_per_symbol; m++) // integrate samples into symbols { d_page_part_symbols[i] -= static_cast(d_secondary_code_samples[k]) * d_symbol_history.at(i * d_samples_per_symbol + d_samples_per_preamble + m); // because last symbol of the preamble is just received now! k++; @@ -717,13 +718,6 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( } } - // remove used symbols from history - // todo: Use circular buffer here - if (d_symbol_history.size() > d_required_symbols) - { - d_symbol_history.pop_front(); - } - switch (d_frame_type) { case 1: // INAV diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h index 91aecd117..e678d1d44 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h @@ -43,11 +43,11 @@ #include "galileo_utc_model.h" #include "gnss_satellite.h" #include "gnss_synchro.h" +#include #include #include #include - class galileo_telemetry_decoder_cc; using galileo_telemetry_decoder_cc_sptr = boost::shared_ptr; @@ -95,7 +95,7 @@ private: uint32_t d_frame_length_symbols; double *d_page_part_symbols; - std::deque d_symbol_history; + boost::circular_buffer d_symbol_history; uint64_t d_sample_counter; uint64_t d_preamble_index; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index 7ead9f53b..cf9a92f06 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -89,6 +89,8 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( n++; } } + + d_symbol_history.set_capacity(GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS); d_sample_counter = 0ULL; d_stat = 0; d_preamble_index = 0ULL; @@ -276,14 +278,14 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu consume_each(1); d_flag_preamble = false; - uint32_t required_symbols = GLONASS_GNAV_STRING_SYMBOLS; - if (d_symbol_history.size() > required_symbols) + if (d_symbol_history.size() == d_symbols_per_preamble) { // ******* preamble correlation ******** - for (int32_t i = 0; i < d_symbols_per_preamble; i++) + int i = 0; + for (const auto &iter : d_symbol_history) { - if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping + if (iter.Prompt_I < 0.0) // symbols clipping { corr_value -= d_preambles_symbols[i]; } @@ -291,6 +293,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu { corr_value += d_preambles_symbols[i]; } + i++; } } @@ -304,7 +307,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu LOG(INFO) << "Preamble detection for GLONASS L1 C/A SAT " << this->d_satellite; // Enter into frame pre-detection status d_stat = 1; - d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the preamble sample stamp + d_preamble_time_samples = d_symbol_history[0].Tracking_sample_counter; // record the preamble sample stamp } } else if (d_stat == 1) // possible preamble lock @@ -314,7 +317,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu // check preamble separation preamble_diff = static_cast(d_sample_counter - d_preamble_index); // Record the PRN start sample index associated to the preamble - d_preamble_time_samples = static_cast(d_symbol_history.at(0).Tracking_sample_counter); + d_preamble_time_samples = static_cast(d_symbol_history[0].Tracking_sample_counter); if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0) { // try to decode frame @@ -366,7 +369,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu { d_flag_frame_sync = true; DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " - << d_symbol_history.at(0).Tracking_sample_counter << " [samples]"; + << d_symbol_history[0].Tracking_sample_counter << " [samples]"; } } else @@ -437,11 +440,6 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } } - // remove used symbols from history - if (d_symbol_history.size() > required_symbols) - { - d_symbol_history.pop_front(); - } // 3. Make the output (copy the object contents to the GNURadio reserved memory) *out[0] = current_symbol; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h index 01b8dcd5a..52583ac94 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h @@ -41,6 +41,7 @@ #include "glonass_gnav_utc_model.h" #include "gnss_satellite.h" #include "gnss_synchro.h" +#include #include #include #include @@ -88,7 +89,7 @@ private: int32_t d_symbols_per_preamble; //!< Storage for incoming data - std::deque d_symbol_history; + boost::circular_buffer d_symbol_history; //!< Variables for internal functionality uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc index b250fb912..a58a61785 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc @@ -89,6 +89,8 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc( n++; } } + + d_symbol_history.set_capacity(GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS); d_sample_counter = 0ULL; d_stat = 0; d_preamble_index = 0ULL; @@ -276,14 +278,14 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu consume_each(1); d_flag_preamble = false; - uint32_t required_symbols = GLONASS_GNAV_STRING_SYMBOLS; - if (d_symbol_history.size() > required_symbols) + if (d_symbol_history.size() == GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) { // ******* preamble correlation ******** - for (int32_t i = 0; i < d_symbols_per_preamble; i++) + int i = 0; + for (const auto &iter : d_symbol_history) { - if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping + if (iter.Prompt_I < 0.0) // symbols clipping { corr_value -= d_preambles_symbols[i]; } @@ -291,6 +293,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu { corr_value += d_preambles_symbols[i]; } + i++; } } @@ -304,7 +307,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu LOG(INFO) << "Preamble detection for GLONASS L2 C/A SAT " << this->d_satellite; // Enter into frame pre-detection status d_stat = 1; - d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the preamble sample stamp + d_preamble_time_samples = d_symbol_history[0].Tracking_sample_counter; // record the preamble sample stamp } } else if (d_stat == 1) // possible preamble lock @@ -314,7 +317,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu // check preamble separation preamble_diff = static_cast(d_sample_counter - d_preamble_index); // Record the PRN start sample index associated to the preamble - d_preamble_time_samples = static_cast(d_symbol_history.at(0).Tracking_sample_counter); + d_preamble_time_samples = static_cast(d_symbol_history[0].Tracking_sample_counter); if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0) { // try to decode frame @@ -366,7 +369,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu { d_flag_frame_sync = true; DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " - << d_symbol_history.at(0).Tracking_sample_counter << " [samples]"; + << d_symbol_history[0].Tracking_sample_counter << " [samples]"; } } else @@ -437,11 +440,6 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu } } - // remove used symbols from history - if (d_symbol_history.size() > required_symbols) - { - d_symbol_history.pop_front(); - } // 3. Make the output (copy the object contents to the GNURadio reserved memory) *out[0] = current_symbol; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h index 0ee799a34..566f5c855 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h @@ -40,6 +40,7 @@ #include "glonass_gnav_utc_model.h" #include "gnss_satellite.h" #include "gnss_synchro.h" +#include #include #include #include @@ -86,7 +87,7 @@ private: int32_t d_symbols_per_preamble; //!< Storage for incoming data - std::deque d_symbol_history; + boost::circular_buffer d_symbol_history; //!< Variables for internal functionality uint64_t d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h index 3c7747f1b..b545679fe 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h @@ -32,6 +32,7 @@ #define GNSS_SDR_GPS_L2C_TELEMETRY_DECODER_CC_H +#include "GPS_L2C.h" #include "gnss_satellite.h" #include "gps_cnav_ephemeris.h" #include "gps_cnav_iono.h" @@ -39,13 +40,11 @@ #include #include // for copy #include -#include #include #include #include // for pair #include - extern "C" { #include "bits.h" @@ -53,7 +52,6 @@ extern "C" #include "edc.h" } -#include "GPS_L2C.h" class gps_l2c_telemetry_decoder_cc; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index a0b54b74d..91037b661 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -66,6 +66,8 @@ gps_l5_telemetry_decoder_cc::gps_l5_telemetry_decoder_cc( d_flag_valid_word = false; d_TOW_at_current_symbol_ms = 0U; d_TOW_at_Preamble_ms = 0U; + sym_hist.set_capacity(GPS_L5I_NH_CODE_LENGTH); + // initialize the CNAV frame decoder (libswiftcnav) cnav_msg_decoder_init(&d_cnav_decoder); for (int32_t aux = 0; aux < GPS_L5I_NH_CODE_LENGTH; aux++) @@ -145,10 +147,10 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u const auto *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer // UPDATE GNSS SYNCHRO DATA - Gnss_Synchro current_synchro_data{}; //structure to save the synchronization information and send the output object to the next block + 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]; - consume_each(1); //one by one + consume_each(1); // one by one sym_hist.push_back(in[0].Prompt_I); int32_t corr_NH = 0; int32_t symbol_value = 0; @@ -158,7 +160,7 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u { for (int32_t i = 0; i < GPS_L5I_NH_CODE_LENGTH; i++) { - if ((bits_NH[i] * sym_hist.at(i)) > 0.0) + if ((bits_NH[i] * sym_hist[i]) > 0.0) { corr_NH += 1; } @@ -183,7 +185,6 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u } else { - sym_hist.pop_front(); sync_NH = false; new_sym = false; } diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h index d28e8b58f..39471b350 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h @@ -31,12 +31,13 @@ #define GNSS_SDR_GPS_L5_TELEMETRY_DECODER_CC_H +#include "GPS_L5.h" #include "gnss_satellite.h" #include "gps_cnav_navigation_message.h" +#include #include #include #include -#include #include #include #include @@ -49,7 +50,6 @@ extern "C" #include "edc.h" } -#include "GPS_L5.h" class gps_l5_telemetry_decoder_cc; @@ -90,8 +90,8 @@ private: bool d_flag_valid_word; Gps_CNAV_Navigation_Message d_CNAV_Message; - double bits_NH[GPS_L5I_NH_CODE_LENGTH]{}; - std::deque sym_hist; + float bits_NH[GPS_L5I_NH_CODE_LENGTH]{}; + boost::circular_buffer sym_hist; bool sync_NH; bool new_sym; }; From e6d2776f1b4bcce6f9f008babe802ee235822aab Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 Feb 2019 14:10:44 +0100 Subject: [PATCH 43/53] Replace std::deque by faster boost::circular_buffer --- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 48 +++++++++---------- .../gnuradio_blocks/dll_pll_veml_tracking.h | 10 ++-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index 033e49493..9fea05e98 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -153,8 +153,8 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl n++; } } - d_symbol_history.resize(GPS_CA_PREAMBLE_LENGTH_SYMBOLS); // Change fixed buffer size - d_symbol_history.clear(); // Clear all the elements in the buffer + d_symbol_history.set_capacity(GPS_CA_PREAMBLE_LENGTH_SYMBOLS); // Change fixed buffer size + d_symbol_history.clear(); // Clear all the elements in the buffer } else if (signal_type == "2S") { @@ -405,6 +405,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl } // --- Initializations --- + d_Prompt_circular_buffer.set_capacity(d_secondary_code_length); multicorrelator_cpu.set_high_dynamics_resampler(trk_parameters.high_dyn); // Initial code frequency basis of NCO d_code_freq_chips = d_code_chip_rate; @@ -446,13 +447,13 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl clear_tracking_vars(); if (trk_parameters.smoother_length > 0) { - d_carr_ph_history.resize(trk_parameters.smoother_length * 2); - d_code_ph_history.resize(trk_parameters.smoother_length * 2); + d_carr_ph_history.set_capacity(trk_parameters.smoother_length * 2); + d_code_ph_history.set_capacity(trk_parameters.smoother_length * 2); } else { - d_carr_ph_history.resize(1); - d_code_ph_history.resize(1); + d_carr_ph_history.set_capacity(1); + d_code_ph_history.set_capacity(1); } d_dump = trk_parameters.dump; @@ -607,7 +608,7 @@ void dll_pll_veml_tracking::start_tracking() n++; } } - d_symbol_history.resize(22); // Change fixed buffer size + d_symbol_history.set_capacity(22); // Change fixed buffer size d_symbol_history.clear(); } } @@ -649,7 +650,7 @@ void dll_pll_veml_tracking::start_tracking() // enable tracking pull-in d_state = 1; d_cloop = true; - d_Prompt_buffer_deque.clear(); + d_Prompt_circular_buffer.clear(); d_last_prompt = gr_complex(0.0, 0.0); } @@ -710,7 +711,7 @@ bool dll_pll_veml_tracking::acquire_secondary() int32_t corr_value = 0; for (uint32_t i = 0; i < d_secondary_code_length; i++) { - if (d_Prompt_buffer_deque.at(i).real() < 0.0) // symbols clipping + if (d_Prompt_circular_buffer[i].real() < 0.0) // symbols clipping { if (d_secondary_code_string->at(i) == '0') { @@ -866,7 +867,7 @@ void dll_pll_veml_tracking::clear_tracking_vars() d_code_error_chips = 0.0; d_code_error_filt_chips = 0.0; d_current_symbol = 0; - d_Prompt_buffer_deque.clear(); + d_Prompt_circular_buffer.clear(); d_last_prompt = gr_complex(0.0, 0.0); d_carrier_phase_rate_step_rad = 0.0; d_code_phase_rate_step_chips = 0.0; @@ -902,9 +903,9 @@ void dll_pll_veml_tracking::update_tracking_vars() double tmp_samples = 0.0; for (unsigned int k = 0; k < trk_parameters.smoother_length; k++) { - tmp_cp1 += d_carr_ph_history.at(k).first; - tmp_cp2 += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; - tmp_samples += d_carr_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).second; + tmp_cp1 += d_carr_ph_history[k].first; + tmp_cp2 += d_carr_ph_history[trk_parameters.smoother_length * 2 - k - 1].first; + tmp_samples += d_carr_ph_history[trk_parameters.smoother_length * 2 - k - 1].second; } tmp_cp1 /= static_cast(trk_parameters.smoother_length); tmp_cp2 /= static_cast(trk_parameters.smoother_length); @@ -916,7 +917,6 @@ void dll_pll_veml_tracking::update_tracking_vars() d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, PI_2); - // carrier phase accumulator //double a = d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); //double b = 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples); @@ -936,9 +936,9 @@ void dll_pll_veml_tracking::update_tracking_vars() double tmp_samples = 0.0; for (unsigned int k = 0; k < trk_parameters.smoother_length; k++) { - tmp_cp1 += d_code_ph_history.at(k).first; - tmp_cp2 += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).first; - tmp_samples += d_code_ph_history.at(trk_parameters.smoother_length * 2 - k - 1).second; + tmp_cp1 += d_code_ph_history[k].first; + tmp_cp2 += d_code_ph_history[trk_parameters.smoother_length * 2 - k - 1].first; + tmp_samples += d_code_ph_history[trk_parameters.smoother_length * 2 - k - 1].second; } tmp_cp1 /= static_cast(trk_parameters.smoother_length); tmp_cp2 /= static_cast(trk_parameters.smoother_length); @@ -1503,8 +1503,8 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) if (d_secondary) { // ####### SECONDARY CODE LOCK ##### - d_Prompt_buffer_deque.push_back(*d_Prompt); - if (d_Prompt_buffer_deque.size() == d_secondary_code_length) + d_Prompt_circular_buffer.push_back(*d_Prompt); + if (d_Prompt_circular_buffer.size() == d_secondary_code_length) { next_state = acquire_secondary(); if (next_state) @@ -1514,8 +1514,6 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) std::cout << systemName << " " << signal_pretty_name << " secondary code locked in channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; } - - d_Prompt_buffer_deque.pop_front(); } } else if (d_symbols_per_bit > 1) //Signal does not have secondary code. Search a bit transition by sign change @@ -1528,9 +1526,10 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) int32_t corr_value = 0; if ((static_cast(d_symbol_history.size()) == d_preamble_length_symbols)) // and (d_make_correlation or !d_flag_frame_sync)) { - for (int32_t i = 0; i < d_preamble_length_symbols; i++) + int i = 0; + for (const auto &iter : d_symbol_history) { - if (d_symbol_history.at(i) < 0) // symbols clipping + if (iter < 0.0) // symbols clipping { corr_value -= d_preambles_symbols[i]; } @@ -1538,6 +1537,7 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) { corr_value += d_preambles_symbols[i]; } + i++; } } if (corr_value == d_preamble_length_symbols) @@ -1606,7 +1606,7 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) d_L_accu = gr_complex(0.0, 0.0); d_VL_accu = gr_complex(0.0, 0.0); d_last_prompt = gr_complex(0.0, 0.0); - d_Prompt_buffer_deque.clear(); + d_Prompt_circular_buffer.clear(); d_current_symbol = 0; if (d_enable_extended_integration) diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h index 477880b03..bcf605eb5 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h @@ -92,7 +92,7 @@ private: uint32_t d_channel; Gnss_Synchro *d_acquisition_gnss_synchro; - //Signal parameters + // Signal parameters bool d_secondary; bool interchange_iq; double d_signal_carrier_freq; @@ -111,9 +111,10 @@ private: int32_t d_preamble_length_symbols; boost::circular_buffer d_symbol_history; - //tracking state machine + // tracking state machine int32_t d_state; - //Integration period in samples + + // Integration period in samples int32_t d_correlation_length_ms; int32_t d_n_correlator_taps; @@ -188,11 +189,10 @@ private: // CN0 estimation and lock detector int32_t d_cn0_estimation_counter; int32_t d_carrier_lock_fail_counter; - std::deque d_carrier_lock_detector_queue; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - std::deque d_Prompt_buffer_deque; + boost::circular_buffer d_Prompt_circular_buffer; gr_complex *d_Prompt_buffer; // file dump From 92d20d0842b966f080061dbdfa02096d07c0fe3a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 Feb 2019 16:39:21 +0100 Subject: [PATCH 44/53] Fix comparison --- .../gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 4d3b9f315..c0fcf733b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -343,7 +343,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ { if (iter.Flag_valid_symbol_output == true) { - if (iter.Prompt_I < 0) // symbols clipping + if (iter.Prompt_I < 0.0) // symbols clipping { corr_value -= d_preambles_symbols[i]; } From b1c6e1d91f0e96984b4f3f3804128bc32c1a0086 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 Feb 2019 18:20:33 +0100 Subject: [PATCH 45/53] Make Galileo E1 message decoding less verbose in terminal --- .../galileo_navigation_message.cc | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc index ea3e7889b..aec3cdd0d 100644 --- a/src/core/system_parameters/galileo_navigation_message.cc +++ b/src/core/system_parameters/galileo_navigation_message.cc @@ -343,18 +343,11 @@ bool Galileo_Navigation_Message::read_navigation_bool(std::bitset TLM_word_for_CRC_bits(TLM_word_for_CRC); std::bitset<24> checksum(CRC_data); - //if (Tail_odd.compare(correct_tail) != 0) - // std::cout << "Tail odd is not correct!" << std::endl; - //else std::cout<<"Tail odd is correct!"< Date: Thu, 28 Feb 2019 18:27:30 +0100 Subject: [PATCH 46/53] Provide more info to the user if something fails --- src/main/main.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/main.cc b/src/main/main.cc index 67e0881f5..905a2670a 100644 --- a/src/main/main.cc +++ b/src/main/main.cc @@ -123,7 +123,7 @@ int main(int argc, char** argv) boost::system::error_code ec; if (!boost::filesystem::create_directory(p, ec)) { - std::cout << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended." << std::endl; + std::cerr << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended." << std::endl; google::ShutDownCommandLineFlags(); return 1; } @@ -144,8 +144,9 @@ int main(int argc, char** argv) } catch (const boost::thread_resource_error& e) { - std::cout << "Failed to create boost thread." << std::endl; + std::cerr << "Failed to create boost thread." << std::endl; google::ShutDownCommandLineFlags(); + std::cout << "GNSS-SDR program ended." << std::endl; return 1; } catch (const boost::exception& e) @@ -153,12 +154,14 @@ int main(int argc, char** argv) if (GOOGLE_STRIP_LOG == 0) { LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e); + std::cerr << boost::diagnostic_information(e) << std::endl; } else { std::cerr << "Boost exception: " << boost::diagnostic_information(e) << std::endl; } google::ShutDownCommandLineFlags(); + std::cout << "GNSS-SDR program ended." << std::endl; return 1; } catch (const std::exception& ex) @@ -166,12 +169,14 @@ int main(int argc, char** argv) if (GOOGLE_STRIP_LOG == 0) { LOG(WARNING) << "C++ Standard Library exception: " << ex.what(); + std::cerr << ex.what() << std::endl; } else { std::cerr << "C++ Standard Library exception: " << ex.what() << std::endl; } google::ShutDownCommandLineFlags(); + std::cout << "GNSS-SDR program ended." << std::endl; return 1; } catch (...) @@ -179,12 +184,14 @@ int main(int argc, char** argv) if (GOOGLE_STRIP_LOG == 0) { LOG(WARNING) << "Unexpected catch. This should not happen."; + std::cerr << "Unexpected error." << std::endl; } else { std::cerr << "Unexpected catch. This should not happen." << std::endl; } google::ShutDownCommandLineFlags(); + std::cout << "GNSS-SDR program ended." << std::endl; return 1; } From 7ffec280af16d0d26a1f55f105eeff1291c511ea Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 Feb 2019 22:04:24 +0100 Subject: [PATCH 47/53] Update changelog --- docs/changelog | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 312543bc6..a76665271 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,28 +2,46 @@ ### Improvements in Efficiency +- Improved preamble detection implementation in the decoding of navigation messages (acceleration by x1.6 on average). - Applied clang-tidy checks and fixes related to performance. + ### Improvements in Interoperability: - Added the BeiDou B1I receiver chain. - Fix bug in GLONASS dual frequency receiver. + ### Improvements in Maintainability: - Usage of clang-tidy integrated into CMake scripts. New option -DENABLE_CLANG_TIDY=ON executes clang-tidy along with compilation. Requires clang compiler. - Applied clang-tidy checks and fixes related to readability. + ### Improvements in Portability: +- Added interfaces for FPGA off-loading. - CMake scripts now follow a modern approach (targets and properties) but still work in 2.8.12 -## Improvements in Reliability +### Improvements in Reliability - Applied clang-tidy checks and fixes related to High Integrity C++. +### Improvements in Usability + +- The receiver now admits FPGA off-loading, allowing for real time operation at high sampling rates and higher number of signals and channels. +- Fixed program termination (avoiding hangs and segfaults in some platforms/configurations). +- Improved information provided to the user in case of failure. + + + +See the definitions of concepts and metrics at https://gnss-sdr.org/design-forces/ + + + + ## [0.0.10](https://github.com/gnss-sdr/gnss-sdr/releases/tag/v0.0.10) This release has several improvements in different dimensions, addition of new features and bug fixes: From 5b87bbbeb6d3644a7bba2403d654c114c42f34e8 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Thu, 28 Feb 2019 22:11:26 +0100 Subject: [PATCH 48/53] Update changelog --- docs/changelog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/changelog b/docs/changelog index a76665271..b1c6e6397 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,5 +1,10 @@ ## [Unreleased](https://github.com/gnss-sdr/gnss-sdr/tree/next) +### Improvements in Availability + +- Fixed bug that caused a random deadlock in the Observables block, preventing the computation of PVT fixes. + + ### Improvements in Efficiency - Improved preamble detection implementation in the decoding of navigation messages (acceleration by x1.6 on average). From df0a77ee0d002c6906a119ff34752f97f2389e9b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Mar 2019 10:11:36 +0100 Subject: [PATCH 49/53] Fix warnings more protection on read/write failures and some code cleaning --- .../gps_l2_m_pcps_acquisition_fpga.cc | 168 ++---------------- .../gnuradio_blocks/pcps_acquisition.cc | 7 +- .../gnuradio_blocks/pcps_acquisition_fpga.cc | 3 +- .../acquisition/libs/fpga_acquisition.cc | 18 +- .../libs/gnss_sdr_fpga_sample_counter.cc | 6 +- .../glonass_l1_ca_telemetry_decoder_cc.cc | 2 +- .../galileo_e1_dll_pll_veml_tracking_fpga.cc | 18 +- .../galileo_e1_dll_pll_veml_tracking_fpga.h | 1 - .../galileo_e5a_dll_pll_tracking_fpga.cc | 10 +- .../galileo_e5a_dll_pll_tracking_fpga.h | 10 +- .../gps_l1_ca_dll_pll_tracking_fpga.cc | 2 - .../gps_l1_ca_dll_pll_tracking_fpga.h | 2 - .../gps_l2_m_dll_pll_tracking_fpga.cc | 6 +- .../adapters/gps_l2_m_dll_pll_tracking_fpga.h | 7 +- .../adapters/gps_l5_dll_pll_tracking_fpga.cc | 24 +-- .../adapters/gps_l5_dll_pll_tracking_fpga.h | 4 +- .../dll_pll_veml_tracking_fpga.cc | 30 ++-- .../dll_pll_veml_tracking_fpga.h | 3 +- .../tracking/libs/fpga_multicorrelator.cc | 151 ++++++++-------- .../tracking/libs/fpga_multicorrelator.h | 8 +- .../gps_l1_ca_pcps_acquisition_test_fpga.cc | 12 +- .../gps_l1_ca_dll_pll_tracking_test_fpga.cc | 13 +- 22 files changed, 191 insertions(+), 314 deletions(-) diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc index c3cd96275..49a5cd0e3 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -52,7 +52,6 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( in_streams_(in_streams), out_streams_(out_streams) { - //pcpsconf_t acq_parameters; pcpsconf_fpga_t acq_parameters; configuration_ = configuration; std::string default_item_type = "gr_complex"; @@ -61,33 +60,17 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( LOG(INFO) << "role " << role; item_type_ = configuration_->property(role + ".item_type", default_item_type); - //float pfa = configuration_->property(role + ".pfa", 0.0); int64_t fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); acq_parameters.fs_in = fs_in_; - //if_ = configuration_->property(role + ".if", 0); - //acq_parameters.freq = if_; - //dump_ = configuration_->property(role + ".dump", false); - //acq_parameters.dump = dump_; - //blocking_ = configuration_->property(role + ".blocking", true); - //acq_parameters.blocking = blocking_; + doppler_max_ = configuration->property(role + ".doppler_max", 5000); if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; acq_parameters.doppler_max = doppler_max_; - //bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); - //acq_parameters.bit_transition_flag = bit_transition_flag_; - //use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions - //acq_parameters.use_CFAR_algorithm_flag = use_CFAR_algorithm_flag_; - //max_dwells_ = configuration_->property(role + ".max_dwells", 1); - //acq_parameters.max_dwells = max_dwells_; - //dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); - //acq_parameters.dump_filename = dump_filename_; - //--- Find number of samples per spreading code ------------------------- - //code_length_ = std::round(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); acq_parameters.sampled_ms = 20; - unsigned code_length = std::round(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); + unsigned int code_length = std::round(static_cast(fs_in_) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS))); acq_parameters.code_length = code_length; // The FPGA can only use FFT lengths that are a power of two. float nbits = ceilf(log2f((float)code_length)); @@ -114,10 +97,9 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( { gps_l2c_m_code_gen_complex_sampled(code, PRN, fs_in_); // fill in zero padding - for (int s = code_length; s < nsamples_total; s++) + for (unsigned int s = code_length; s < nsamples_total; s++) { code[s] = std::complex(0.0, 0.0); - //code[s] = 0; } memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer fft_if->execute(); // Run the FFT of local code @@ -156,47 +138,9 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( doppler_step_ = 0; gnss_synchro_ = nullptr; - - // vector_length_ = code_length_; - // - // if (bit_transition_flag_) - // { - // vector_length_ *= 2; - // } - - // code_ = new gr_complex[vector_length_]; - // - // if (item_type_.compare("cshort") == 0) - // { - // item_size_ = sizeof(lv_16sc_t); - // } - // else - // { - // item_size_ = sizeof(gr_complex); - // } - //acq_parameters.samples_per_ms = static_cast(std::round(static_cast(fs_in_) * 0.001)); - //acq_parameters.samples_per_code = code_length_; - //acq_parameters.it_size = item_size_; - //acq_parameters.sampled_ms = 20; - //acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); - //acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); - //acq_parameters.make_2_steps = configuration_->property(role + ".make_two_steps", true); - //acquisition_ = pcps_make_acquisition(acq_parameters); DLOG(INFO) << "acquisition(" << acquisition_fpga_->unique_id() << ")"; - // stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); - // DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; - // - // if (item_type_.compare("cbyte") == 0) - // { - // cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); - // float_to_complex_ = gr::blocks::float_to_complex::make(); - // } - - // channel_ = 0; threshold_ = 0.0; - // doppler_step_ = 0; - // gnss_synchro_ = 0; } @@ -221,23 +165,8 @@ void GpsL2MPcpsAcquisitionFpga::set_channel(unsigned int channel) void GpsL2MPcpsAcquisitionFpga::set_threshold(float threshold) { - // float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - // - // if (pfa == 0.0) - // { - // pfa = configuration_->property(role_ + ".pfa", 0.0); - // } - // if (pfa == 0.0) - // { - // threshold_ = threshold; - // } - // else - // { - // threshold_ = calculate_threshold(pfa); - // } - + threshold_ = threshold; DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; - acquisition_fpga_->set_threshold(threshold_); } @@ -301,99 +230,26 @@ void GpsL2MPcpsAcquisitionFpga::set_state(int state) } -//float GpsL2MPcpsAcquisitionFpga::calculate_threshold(float pfa) -//{ -// //Calculate the threshold -// unsigned int frequency_bins = 0; -// for (int doppler = static_cast(-doppler_max_); doppler <= static_cast(doppler_max_); doppler += doppler_step_) -// { -// frequency_bins++; -// } -// DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; -// unsigned int ncells = vector_length_ * frequency_bins; -// double exponent = 1.0 / static_cast(ncells); -// double val = pow(1.0 - pfa, exponent); -// double lambda = double(vector_length_); -// boost::math::exponential_distribution mydist(lambda); -// float threshold = static_cast(quantile(mydist, val)); -// -// return threshold; -//} - - void GpsL2MPcpsAcquisitionFpga::connect(gr::top_block_sptr top_block) { - // if (item_type_.compare("gr_complex") == 0) - // { - // top_block->connect(stream_to_vector_, 0, acquisition_, 0); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // top_block->connect(stream_to_vector_, 0, acquisition_, 0); - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); - // top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - // top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); - // top_block->connect(stream_to_vector_, 0, acquisition_, 0); - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } - - // nothing to connect + if (top_block) + { /* top_block is not null */ + }; + // Nothing to connect } void GpsL2MPcpsAcquisitionFpga::disconnect(gr::top_block_sptr top_block) { - // if (item_type_.compare("gr_complex") == 0) - // { - // top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); - // } - // else if (item_type_.compare("cshort") == 0) - // { - // top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // // Since a byte-based acq implementation is not available, - // // we just convert cshorts to gr_complex - // top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); - // top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); - // top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); - // top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // } - - // nothing to disconnect + if (top_block) + { /* top_block is not null */ + }; + // Nothing to diconnect } gr::basic_block_sptr GpsL2MPcpsAcquisitionFpga::get_left_block() { - // if (item_type_.compare("gr_complex") == 0) - // { - // return stream_to_vector_; - // } - // else if (item_type_.compare("cshort") == 0) - // { - // return stream_to_vector_; - // } - // else if (item_type_.compare("cbyte") == 0) - // { - // return cbyte_to_float_x2_; - // } - // else - // { - // LOG(WARNING) << item_type_ << " unknown acquisition item type"; - // return nullptr; - // } return nullptr; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 8a806c80f..c43e9d453 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -187,6 +187,7 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu } } + pcps_acquisition::~pcps_acquisition() { if (d_num_doppler_bins > 0) @@ -227,6 +228,7 @@ void pcps_acquisition::set_resampler_latency(uint32_t latency_samples) acq_parameters.resampler_latency_samples = latency_samples; } + void pcps_acquisition::set_local_code(std::complex* code) { // reset the intermediate frequency @@ -912,6 +914,7 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) } } + // Called by gnuradio to enable drivers, etc for i/o devices. bool pcps_acquisition::start() { @@ -919,8 +922,10 @@ bool pcps_acquisition::start() return true; } + int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), - gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, + gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, gr_vector_void_star& output_items __attribute__((unused))) { /* diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc index 4c870542d..83b5362c9 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fpga.cc @@ -253,7 +253,8 @@ void pcps_acquisition_fpga::set_active(bool active) int pcps_acquisition_fpga::general_work(int noutput_items __attribute__((unused)), - gr_vector_int& ninput_items, gr_vector_const_void_star& input_items, + gr_vector_int& ninput_items __attribute__((unused)), + gr_vector_const_void_star& input_items __attribute__((unused)), gr_vector_void_star& output_items __attribute__((unused))) { // the general work is not used with the acquisition that uses the FPGA diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 3b5419771..6125ee313 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -87,8 +87,10 @@ void Fpga_Acquisition::write_local_code() Fpga_Acquisition::Fpga_Acquisition(std::string device_name, uint32_t nsamples, uint32_t doppler_max, - uint32_t nsamples_total, int64_t fs_in, - uint32_t sampled_ms, uint32_t select_queue, + uint32_t nsamples_total, + int64_t fs_in, + uint32_t sampled_ms __attribute__((unused)), + uint32_t select_queue, lv_16sc_t *all_fft_codes, uint32_t excludelimit) { @@ -193,7 +195,11 @@ void Fpga_Acquisition::run_acquisition(void) // enable interrupts int32_t reenable = 1; int32_t disable_int = 0; - write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t)); + ssize_t nbytes = TEMP_FAILURE_RETRY(write(d_fd, reinterpret_cast(&reenable), sizeof(int32_t))); + if (nbytes != sizeof(int32_t)) + { + std::cerr << "Error enabling run in the FPGA." << std::endl; + } // launch the acquisition process d_map_base[8] = LAUNCH_ACQUISITION; // writing a 1 to reg 8 launches the acquisition process @@ -208,7 +214,11 @@ void Fpga_Acquisition::run_acquisition(void) std::cout << "acquisition module Interrupt number " << irq_count << std::endl; } - write(d_fd, reinterpret_cast(&disable_int), sizeof(int32_t)); + nbytes = TEMP_FAILURE_RETRY(write(d_fd, reinterpret_cast(&disable_int), sizeof(int32_t))); + if (nbytes != sizeof(int32_t)) + { + std::cerr << "Error disabling interruptions in the FPGA." << std::endl; + } } diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc index dfe5d3e21..a9feedaed 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc @@ -269,7 +269,11 @@ uint32_t gnss_sdr_fpga_sample_counter::wait_for_interrupt_and_read_counter() // enable interrupts int32_t reenable = 1; - write(fd, reinterpret_cast(&reenable), sizeof(int32_t)); + ssize_t nbytes = TEMP_FAILURE_RETRY(write(fd, reinterpret_cast(&reenable), sizeof(int32_t))); + if (nbytes != sizeof(int32_t)) + { + std::cerr << "Error enabling interruptions in the FPGA." << std::endl; + } // wait for interrupt nb = read(fd, &irq_count, sizeof(irq_count)); diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index cf9a92f06..4a7b04cd2 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -279,7 +279,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu d_flag_preamble = false; - if (d_symbol_history.size() == d_symbols_per_preamble) + if (static_cast(d_symbol_history.size()) == d_symbols_per_preamble) { // ******* preamble correlation ******** int i = 0; diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index 1175d35d5..bf2ecffbe 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -135,16 +135,15 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( uint32_t code_samples_per_chip = 2; d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); float* ca_codes_f; - float* data_codes_f; + float* data_codes_f = nullptr; - - if (trk_param_fpga.track_pilot) + if (d_track_pilot) { d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); } ca_codes_f = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); - if (trk_param_fpga.track_pilot) + if (d_track_pilot) { data_codes_f = static_cast(volk_gnsssdr_malloc((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * code_samples_per_chip * sizeof(float), volk_gnsssdr_get_alignment())); } @@ -152,7 +151,7 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) { char data_signal[3] = "1B"; - if (trk_param_fpga.track_pilot) + if (d_track_pilot) { char pilot_signal[3] = "1C"; galileo_e1_code_gen_sinboc11_float(ca_codes_f, pilot_signal, PRN); @@ -176,9 +175,9 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( } delete[] ca_codes_f; - if (trk_param_fpga.track_pilot) + if (d_track_pilot) { - delete[] data_codes_f; + volk_gnsssdr_free(data_codes_f); } trk_param_fpga.ca_codes = d_ca_codes; trk_param_fpga.data_codes = d_data_codes; @@ -200,6 +199,7 @@ GalileoE1DllPllVemlTrackingFpga::~GalileoE1DllPllVemlTrackingFpga() } } + void GalileoE1DllPllVemlTrackingFpga::start_tracking() { tracking_fpga_sc->start_tracking(); @@ -227,7 +227,7 @@ void GalileoE1DllPllVemlTrackingFpga::connect(gr::top_block_sptr top_block) if (top_block) { /* top_block is not null */ }; - //nothing to connect, now the tracking uses gr_sync_decimator + // nothing to connect, now the tracking uses gr_sync_decimator } @@ -236,7 +236,7 @@ void GalileoE1DllPllVemlTrackingFpga::disconnect(gr::top_block_sptr top_block) if (top_block) { /* top_block is not null */ }; - //nothing to disconnect, now the tracking uses gr_sync_decimator + // nothing to disconnect, now the tracking uses gr_sync_decimator } diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h index 003aec195..729bbe5b4 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h @@ -3,7 +3,6 @@ * \brief Adapts a DLL+PLL VEML (Very Early Minus Late) tracking loop block * to a TrackingInterface for Galileo E1 signals for the FPGA * \author Marc Majoral, 2019. mmajoral(at)cttc.cat - * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index f66c967bd..ba621e619 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -2,15 +2,7 @@ * \file galileo_e5a_dll_pll_tracking_fpga.cc * \brief Adapts a code DLL + carrier PLL * tracking block to a TrackingInterface for Galileo E5a signals for the FPGA - * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * Galileo E5a data and pilot Signals for the FPGA - * \author Marc Sales, 2014. marcsales92(at)gmail.com - * \based on work from: - *
            - *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat - *
          • Javier Arribas, 2011. jarribas(at)cttc.es - *
          • Luis Esteve, 2012. luis(at)epsilon-formacion.com - *
          + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * * ------------------------------------------------------------------------- * diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h index 026069a51..b50f67207 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.h @@ -2,15 +2,7 @@ * \file galileo_e5a_dll_pll_tracking_fpga.h * \brief Adapts a code DLL + carrier PLL * tracking block to a TrackingInterface for Galileo E5a signals for the FPGA - * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for - * Galileo E5a data and pilot Signals for the FPGA - * \author Marc Sales, 2014. marcsales92(at)gmail.com - * \based on work from: - *
            - *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat - *
          • Javier Arribas, 2011. jarribas(at)cttc.es - *
          • Luis Esteve, 2012. luis(at)epsilon-formacion.com - *
          + * \author Marc Majoral, 2019. mmajoral(at)cttc.cat * * ------------------------------------------------------------------------- * diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc index 10939dbe8..57427275a 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.cc @@ -3,8 +3,6 @@ * \brief Implementation of an adapter of a DLL+PLL tracking loop block * for GPS L1 C/A to a TrackingInterface for the FPGA * \author Marc Majoral, 2019, mmajoral(at)cttc.es - * Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * Javier Arribas, 2011. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h index cd1b8415f..f0117fdaa 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h @@ -3,8 +3,6 @@ * \brief Interface of an adapter of a DLL+PLL tracking loop block * for GPS L1 C/A to a TrackingInterface for the FPGA * \author Marc Majoral, 2019, mmajoral(at)cttc.es - * Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * Javier Arribas, 2011. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc index c133b1ea1..6db3a0cd6 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.cc @@ -1,8 +1,8 @@ /*! - * \file gps_l2_m_dll_pll_tracking.cc + * \file gps_l2_m_dll_pll_tracking_fpga.cc * \brief Implementation of an adapter of a DLL+PLL tracking loop block - * for GPS L1 C/A to a TrackingInterface - * \author Javier Arribas, 2015. jarribas(at)cttc.es + * for GPS L2C to a TrackingInterface + * \author Javier Arribas, 2019. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h index e1a606f1f..e734dea58 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking_fpga.h @@ -1,9 +1,8 @@ /*! - * \file gps_l2_m_dll_pll_tracking.h + * \file gps_l2_m_dll_pll_tracking_fpga.h * \brief Interface of an adapter of a DLL+PLL tracking loop block - * for GPS L1 C/A to a TrackingInterface - * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * Javier Arribas, 2011. jarribas(at)cttc.es + * for GPS L2C to a TrackingInterface + * \author Marc Majoral, 2019, mmajoral(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc index 764a69a97..19099270a 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.cc @@ -1,9 +1,9 @@ /*! - * \file gps_l5_dll_pll_tracking.cc + * \file gps_l5_dll_pll_tracking_fpga.cc * \brief Interface of an adapter of a DLL+PLL tracking loop block * for GPS L5 to a TrackingInterface * \author Marc Majoral, 2019. mmajoral(at)cttc.cat - * \author Javier Arribas, 2017. jarribas(at)cttc.es + * Javier Arribas, 2019. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, @@ -135,37 +135,39 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( auto code_length_chips = static_cast(GPS_L5I_CODE_LENGTH_CHIPS); float *tracking_code; - float *data_code; + float *data_code = nullptr; tracking_code = static_cast(volk_gnsssdr_malloc(code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); - if (trk_param_fpga.track_pilot) + if (track_pilot) { data_code = static_cast(volk_gnsssdr_malloc(code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); + for (uint32_t i = 0; i < code_length_chips; i++) + { + data_code[i] = 0.0; + } } d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(code_length_chips * NUM_PRNs) * sizeof(int32_t), volk_gnsssdr_get_alignment())); - if (trk_param_fpga.track_pilot) + if (track_pilot) { d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * NUM_PRNs * sizeof(int32_t), volk_gnsssdr_get_alignment())); } for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) { - if (trk_param_fpga.track_pilot) + if (track_pilot) { gps_l5q_code_gen_float(tracking_code, PRN); gps_l5i_code_gen_float(data_code, PRN); - for (uint32_t s = 0; s < code_length_chips; s++) { d_ca_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(tracking_code[s]); d_data_codes[static_cast(code_length_chips) * (PRN - 1) + s] = static_cast(data_code[s]); } } - else { gps_l5i_code_gen_float(tracking_code, PRN); @@ -176,10 +178,10 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga( } } - delete[] tracking_code; - if (trk_param_fpga.track_pilot) + volk_gnsssdr_free(tracking_code); + if (track_pilot) { - delete[] data_code; + volk_gnsssdr_free(data_code); } trk_param_fpga.ca_codes = d_ca_codes; trk_param_fpga.data_codes = d_data_codes; diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h index 08c085d73..c61e1e81a 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h @@ -1,9 +1,9 @@ /*! - * \file gps_l5_dll_pll_tracking.h + * \file gps_l5_dll_pll_tracking_fpga.h * \brief Interface of an adapter of a DLL+PLL tracking loop block * for GPS L5 to a TrackingInterface * \author Marc Majoral, 2019. mmajoral(at)cttc.cat - * \author Javier Arribas, 2017. jarribas(at)cttc.es + * Javier Arribas, 2019. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index f470913e7..4c7f05109 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -2,8 +2,7 @@ * \file dll_pll_veml_tracking_fpga.cc * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA * \author Marc Majoral, 2019. marc.majoral(at)cttc.es - * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com - * \author Javier Arribas, 2018. jarribas(at)cttc.es + * \author Javier Arribas, 2019. jarribas(at)cttc.es * * Code DLL + carrier PLL according to the algorithms described in: * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, @@ -315,7 +314,6 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_prompt_data_shift = &d_local_code_shift_chips[1]; } - if (trk_parameters.extend_correlation_symbols > 1) { d_enable_extended_integration = true; @@ -498,7 +496,6 @@ void dll_pll_veml_tracking_fpga::start_tracking() std::cout << "Tracking of " << systemName << " " << signal_pretty_name << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; DLOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; - multicorrelator_fpga->set_local_code_and_taps(d_local_code_shift_chips, d_prompt_data_shift, d_acquisition_gnss_synchro->PRN); // enable tracking pull-in d_state = 1; @@ -677,7 +674,6 @@ void dll_pll_veml_tracking_fpga::run_dll_pll() // New carrier Doppler frequency estimation d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_carr_error_filt_hz; - // ################## DLL ########################################################## // DLL discriminator if (d_veml) @@ -753,7 +749,6 @@ void dll_pll_veml_tracking_fpga::update_tracking_vars() d_rem_carr_phase_rad += static_cast(d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, PI_2); - // carrier phase accumulator d_acc_carrier_phase_rad -= (d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples) + 0.5 * d_carrier_phase_rate_step_rad * static_cast(d_current_prn_length_samples) * static_cast(d_current_prn_length_samples)); @@ -1021,7 +1016,6 @@ int32_t dll_pll_veml_tracking_fpga::save_matfile() auto *aux2 = new double[num_epoch]; auto *PRN = new uint32_t[num_epoch]; - try { if (dump_file.is_open()) @@ -1249,15 +1243,23 @@ void dll_pll_veml_tracking_fpga::stop_tracking() d_state = 0; } -int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) + +void dll_pll_veml_tracking_fpga::reset(void) +{ + multicorrelator_fpga->unlock_channel(); +} + + +int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((unused)), + gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items __attribute__((unused)), + gr_vector_void_star &output_items) { auto **out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); d_current_prn_length_samples = d_next_prn_length_samples; - switch (d_state) { case 0: // Standby - Consume samples at full throttle, do nothing @@ -1300,7 +1302,6 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un current_synchro_data.Tracking_sample_counter = absolute_samples_offset; d_sample_counter_next = d_sample_counter; - // Signal alignment (skip samples until the incoming signal is aligned with local replica) // Doppler effect Fd = (C / (C + Vr)) * F @@ -1477,6 +1478,7 @@ int dll_pll_veml_tracking_fpga::general_work(int noutput_items __attribute__((un return 0; } + void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) { d_sample_counter = d_sample_counter_next; @@ -1649,9 +1651,3 @@ void dll_pll_veml_tracking_fpga::run_state_2(Gnss_Synchro ¤t_synchro_data) } } } - - -void dll_pll_veml_tracking_fpga::reset(void) -{ - multicorrelator_fpga->unlock_channel(); -} diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h index 64e705aad..9fe6cbbbc 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.h @@ -2,8 +2,7 @@ * \file dll_pll_veml_tracking_fpga.h * \brief Implementation of a code DLL + carrier PLL tracking block using an FPGA. * \author Marc Majoral, 2019. marc.majoral(at)cttc.es - * \author Javier Arribas, 2018. jarribas(at)cttc.es - * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com + * \author Javier Arribas, 2019. jarribas(at)cttc.es * * ------------------------------------------------------------------------- * diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index c574bab69..adcfac599 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -1,12 +1,12 @@ /*! - * \file fpga_multicorrelator_8sc.cc - * \brief High optimized FPGA vector correlator class + * \file fpga_multicorrelator.cc + * \brief FPGA vector correlator class * \authors
            *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat - *
          • Javier Arribas, 2015. jarribas(at)cttc.es + *
          • Javier Arribas, 2019. jarribas(at)cttc.es *
          * - * Class that controls and executes a high optimized vector correlator + * Class that controls and executes a highly optimized vector correlator * class in the FPGA * * ------------------------------------------------------------------------- @@ -67,70 +67,6 @@ #define TEST_REGISTER_TRACK_WRITEVAL 0x55AA -uint64_t Fpga_Multicorrelator_8sc::read_sample_counter() -{ - uint64_t sample_counter_tmp, sample_counter_msw_tmp; - sample_counter_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_LSW]; - sample_counter_msw_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_MSW]; - sample_counter_msw_tmp = sample_counter_msw_tmp << 32; - sample_counter_tmp = sample_counter_tmp + sample_counter_msw_tmp; // 2^32 - return sample_counter_tmp; -} - -void Fpga_Multicorrelator_8sc::set_initial_sample(uint64_t samples_offset) -{ - d_initial_sample_counter = samples_offset; - d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_LSW] = (d_initial_sample_counter & 0xFFFFFFFF); - d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_MSW] = (d_initial_sample_counter >> 32) & 0xFFFFFFFF; -} - -void Fpga_Multicorrelator_8sc::set_local_code_and_taps(float *shifts_chips, float *prompt_data_shift, int32_t PRN) -{ - d_shifts_chips = shifts_chips; - d_prompt_data_shift = prompt_data_shift; - Fpga_Multicorrelator_8sc::fpga_configure_tracking_gps_local_code(PRN); -} - -void Fpga_Multicorrelator_8sc::set_output_vectors(gr_complex *corr_out, gr_complex *Prompt_Data) -{ - d_corr_out = corr_out; - d_Prompt_Data = Prompt_Data; -} - -void Fpga_Multicorrelator_8sc::update_local_code(float rem_code_phase_chips) -{ - d_rem_code_phase_chips = rem_code_phase_chips; - Fpga_Multicorrelator_8sc::fpga_compute_code_shift_parameters(); - Fpga_Multicorrelator_8sc::fpga_configure_code_parameters_in_fpga(); -} - - -void Fpga_Multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( - float rem_carrier_phase_in_rad, float phase_step_rad, - float carrier_phase_rate_step_rad, - float rem_code_phase_chips, float code_phase_step_chips, - float code_phase_rate_step_chips, - int32_t signal_length_samples) -{ - update_local_code(rem_code_phase_chips); - d_rem_carrier_phase_in_rad = rem_carrier_phase_in_rad; - d_code_phase_step_chips = code_phase_step_chips; - d_phase_step_rad = phase_step_rad; - d_correlator_length_samples = signal_length_samples; - Fpga_Multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(); - Fpga_Multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(); - Fpga_Multicorrelator_8sc::fpga_launch_multicorrelator_fpga(); - int32_t irq_count; - ssize_t nb; - nb = read(d_device_descriptor, &irq_count, sizeof(irq_count)); - if (nb != sizeof(irq_count)) - { - std::cout << "Tracking_module Read failed to retrieve 4 bytes!" << std::endl; - std::cout << "Tracking_module Interrupt number " << irq_count << std::endl; - } - Fpga_Multicorrelator_8sc::read_tracking_gps_results(); -} - Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators, std::string device_name, uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, uint32_t multicorr_type, uint32_t code_samples_per_chip) @@ -186,6 +122,77 @@ Fpga_Multicorrelator_8sc::~Fpga_Multicorrelator_8sc() } +uint64_t Fpga_Multicorrelator_8sc::read_sample_counter() +{ + uint64_t sample_counter_tmp, sample_counter_msw_tmp; + sample_counter_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_LSW]; + sample_counter_msw_tmp = d_map_base[SAMPLE_COUNTER_REG_ADDR_MSW]; + sample_counter_msw_tmp = sample_counter_msw_tmp << 32; + sample_counter_tmp = sample_counter_tmp + sample_counter_msw_tmp; // 2^32 + return sample_counter_tmp; +} + + +void Fpga_Multicorrelator_8sc::set_initial_sample(uint64_t samples_offset) +{ + d_initial_sample_counter = samples_offset; + d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_LSW] = (d_initial_sample_counter & 0xFFFFFFFF); + d_map_base[INITIAL_COUNTER_VALUE_REG_ADDR_MSW] = (d_initial_sample_counter >> 32) & 0xFFFFFFFF; +} + + +void Fpga_Multicorrelator_8sc::set_local_code_and_taps(float *shifts_chips, float *prompt_data_shift, int32_t PRN) +{ + d_shifts_chips = shifts_chips; + d_prompt_data_shift = prompt_data_shift; + Fpga_Multicorrelator_8sc::fpga_configure_tracking_gps_local_code(PRN); +} + + +void Fpga_Multicorrelator_8sc::set_output_vectors(gr_complex *corr_out, gr_complex *Prompt_Data) +{ + d_corr_out = corr_out; + d_Prompt_Data = Prompt_Data; +} + + +void Fpga_Multicorrelator_8sc::update_local_code(float rem_code_phase_chips) +{ + d_rem_code_phase_chips = rem_code_phase_chips; + Fpga_Multicorrelator_8sc::fpga_compute_code_shift_parameters(); + Fpga_Multicorrelator_8sc::fpga_configure_code_parameters_in_fpga(); +} + + +void Fpga_Multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( + float rem_carrier_phase_in_rad, + float phase_step_rad, + float carrier_phase_rate_step_rad __attribute__((unused)), + float rem_code_phase_chips, + float code_phase_step_chips __attribute__((unused)), + float code_phase_rate_step_chips __attribute__((unused)), + int32_t signal_length_samples) +{ + update_local_code(rem_code_phase_chips); + d_rem_carrier_phase_in_rad = rem_carrier_phase_in_rad; + d_code_phase_step_chips = code_phase_step_chips; + d_phase_step_rad = phase_step_rad; + d_correlator_length_samples = signal_length_samples; + Fpga_Multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(); + Fpga_Multicorrelator_8sc::fpga_configure_signal_parameters_in_fpga(); + Fpga_Multicorrelator_8sc::fpga_launch_multicorrelator_fpga(); + int32_t irq_count; + ssize_t nb; + nb = read(d_device_descriptor, &irq_count, sizeof(irq_count)); + if (nb != sizeof(irq_count)) + { + std::cout << "Tracking_module Read failed to retrieve 4 bytes!" << std::endl; + std::cout << "Tracking_module Interrupt number " << irq_count << std::endl; + } + Fpga_Multicorrelator_8sc::read_tracking_gps_results(); +} + + bool Fpga_Multicorrelator_8sc::free() { // unlock the channel @@ -424,8 +431,11 @@ void Fpga_Multicorrelator_8sc::fpga_launch_multicorrelator_fpga(void) { // enable interrupts int32_t reenable = 1; - write(d_device_descriptor, reinterpret_cast(&reenable), sizeof(int32_t)); - + ssize_t nbytes = TEMP_FAILURE_RETRY(write(d_device_descriptor, reinterpret_cast(&reenable), sizeof(int32_t))); + if (nbytes != sizeof(int32_t)) + { + std::cerr << "Error launching the FPGA multicorrelator" << std::endl; + } // writing 1 to reg 14 launches the tracking d_map_base[START_FLAG_ADDR] = 1; } @@ -459,6 +469,7 @@ void Fpga_Multicorrelator_8sc::unlock_channel(void) d_map_base[STOP_TRACKING_REG_ADDR] = 1; // set the tracking module back to idle } + void Fpga_Multicorrelator_8sc::close_device() { auto *aux = const_cast(d_map_base); diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index ddf1930c1..155503002 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -1,12 +1,12 @@ /*! - * \file fpga_multicorrelator_8sc.h - * \brief High optimized FPGA vector correlator class + * \file fpga_multicorrelator.h + * \brief FPGA vector correlator class * \authors
            *
          • Marc Majoral, 2019. mmajoral(at)cttc.cat - *
          • Javier Arribas, 2016. jarribas(at)cttc.es + *
          • Javier Arribas, 2019. jarribas(at)cttc.es *
          * - * Class that controls and executes a high optimized vector correlator + * Class that controls and executes a highly optimized vector correlator * class in the FPGA * * ------------------------------------------------------------------------- diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc index 458f53f3f..d43aef640 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc @@ -102,7 +102,11 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block, pointer_float = (float *)&buffer_float[0]; for (int k = 0; k < file_length; k = k + FLOAT_SIZE) { - fread(buffer_float, FLOAT_SIZE, 1, rx_signal_file); + size_t result = fread(buffer_float, FLOAT_SIZE, 1, rx_signal_file); + if (result != FLOAT_SIZE) + { + std::cerr << "Error reading buffer" << std::endl; + } if (fabs(pointer_float[0]) > max) { @@ -152,7 +156,11 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block, for (int t = 0; t < transfer_size; t++) { - fread(buffer_float, FLOAT_SIZE, 1, rx_signal_file); + size_t result = fread(buffer_float, FLOAT_SIZE, 1, rx_signal_file); + if (result != FLOAT_SIZE) + { + std::cerr << "Error reading buffer" << std::endl; + } // specify (float) (int) for a quantization maximizing the dynamic range buffer_DMA[t] = static_cast((pointer_float[0] * (RX_SIGNAL_MAX_VALUE - 1) / max)); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc index 78303a1cf..b492e7d21 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc @@ -102,7 +102,11 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file, } if (num_remaining_samples > DMA_TRACK_TRANSFER_SIZE) { - fread(buffer_DMA, DMA_TRACK_TRANSFER_SIZE, 1, rx_signal_file); + size_t result = fread(buffer_DMA, DMA_TRACK_TRANSFER_SIZE, 1, rx_signal_file); + if (result != DMA_TRACK_TRANSFER_SIZE) + { + std::cerr << "Error reading from DMA" << std::endl; + } assert(DMA_TRACK_TRANSFER_SIZE == write(dma_descr, &buffer_DMA[0], DMA_TRACK_TRANSFER_SIZE)); num_remaining_samples = num_remaining_samples - DMA_TRACK_TRANSFER_SIZE; @@ -110,8 +114,11 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file, } else { - fread(buffer_DMA, num_remaining_samples, 1, rx_signal_file); - + size_t result = fread(buffer_DMA, num_remaining_samples, 1, rx_signal_file); + if (static_cast(result) != num_remaining_samples) + { + std::cerr << "Error reading from DMA" << std::endl; + } assert(num_remaining_samples == write(dma_descr, &buffer_DMA[0], num_remaining_samples)); num_samples_transferred = num_samples_transferred + num_remaining_samples; num_remaining_samples = 0; From e43b8f5284c134bffc4813fd26f0c831e05ce162 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Mar 2019 15:29:43 +0100 Subject: [PATCH 50/53] Fix defects detected by Coverity Scan --- ...lileo_e1_pcps_ambiguous_acquisition_fpga.h | 5 - .../galileo_e5a_pcps_acquisition_fpga.h | 18 +- .../gps_l2_m_pcps_acquisition_fpga.cc | 4 - .../adapters/gps_l2_m_pcps_acquisition_fpga.h | 12 +- .../adapters/gps_l5i_pcps_acquisition_fpga.h | 13 +- .../acquisition/libs/fpga_acquisition.cc | 12 + .../libs/gnss_sdr_fpga_sample_counter.cc | 210 ++++++++++-------- .../libs/gnss_sdr_fpga_sample_counter.h | 2 + .../galileo_e1_dll_pll_veml_tracking_fpga.cc | 11 +- .../galileo_e1_dll_pll_veml_tracking_fpga.h | 3 +- .../galileo_e5a_dll_pll_tracking_fpga.cc | 2 +- .../gps_l1_ca_dll_pll_tracking_fpga.h | 3 +- .../adapters/gps_l5_dll_pll_tracking_fpga.h | 3 +- .../tracking/libs/fpga_multicorrelator.cc | 24 +- .../tracking/libs/fpga_multicorrelator.h | 3 +- 15 files changed, 168 insertions(+), 157 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h index 2baf58e45..7f71790ac 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition_fpga.h @@ -147,15 +147,10 @@ private: gr::blocks::stream_to_vector::sptr stream_to_vector_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; - bool bit_transition_flag_; - bool use_CFAR_algorithm_flag_; bool acquire_pilot_; uint32_t channel_; uint32_t doppler_max_; uint32_t doppler_step_; - uint32_t max_dwells_; - bool dump_; - bool blocking_; std::string dump_filename_; Gnss_Synchro* gnss_synchro_; std::string role_; diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h index e2871e06f..462235a43 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition_fpga.h @@ -67,7 +67,7 @@ public: inline size_t item_size() override { - return item_size_; + return sizeof(int); } void connect(gr::top_block_sptr top_block) override; @@ -150,35 +150,19 @@ private: pcps_acquisition_fpga_sptr acquisition_fpga_; gr::blocks::stream_to_vector::sptr stream_to_vector_; - size_t item_size_; - std::string item_type_; std::string dump_filename_; std::string role_; - bool bit_transition_flag_; - bool dump_; bool acq_pilot_; - bool use_CFAR_; - bool blocking_; bool acq_iq_; - uint32_t vector_length_; - uint32_t code_length_; uint32_t channel_; uint32_t doppler_max_; uint32_t doppler_step_; - uint32_t sampled_ms_; - uint32_t max_dwells_; unsigned int in_streams_; unsigned int out_streams_; - int64_t fs_in_; - - float threshold_; - - gr_complex* code_; - Gnss_Synchro* gnss_synchro_; lv_16sc_t* d_all_fft_codes_; // memory that contains all the code ffts diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc index 49a5cd0e3..8595b24ec 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.cc @@ -146,7 +146,6 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( GpsL2MPcpsAcquisitionFpga::~GpsL2MPcpsAcquisitionFpga() { - //delete[] code_; delete[] d_all_fft_codes_; } @@ -212,9 +211,6 @@ void GpsL2MPcpsAcquisitionFpga::init() void GpsL2MPcpsAcquisitionFpga::set_local_code() { - //gps_l2c_m_code_gen_complex_sampled(code_, gnss_synchro_->PRN, fs_in_); - - //acquisition_fpga_->set_local_code(code_); acquisition_fpga_->set_local_code(); } diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h index 102911d3d..743fb6062 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition_fpga.h @@ -75,7 +75,7 @@ public: inline size_t item_size() override { - return item_size_; + return sizeof(int); } void connect(gr::top_block_sptr top_block) override; @@ -149,23 +149,13 @@ private: gr::blocks::stream_to_vector::sptr stream_to_vector_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; - size_t item_size_; std::string item_type_; - unsigned int vector_length_; - unsigned int code_length_; - bool bit_transition_flag_; - bool use_CFAR_algorithm_flag_; unsigned int channel_; float threshold_; unsigned int doppler_max_; unsigned int doppler_step_; - unsigned int max_dwells_; int64_t fs_in_; - //long if_; - bool dump_; - bool blocking_; std::string dump_filename_; - std::complex* code_; Gnss_Synchro* gnss_synchro_; std::string role_; unsigned int in_streams_; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h index 8063edd62..8a9a9e748 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition_fpga.h @@ -76,7 +76,7 @@ public: inline size_t item_size() override { - return item_size_; + return sizeof(int); } void connect(gr::top_block_sptr top_block) override; @@ -149,22 +149,11 @@ private: gr::blocks::stream_to_vector::sptr stream_to_vector_; gr::blocks::float_to_complex::sptr float_to_complex_; complex_byte_to_float_x2_sptr cbyte_to_float_x2_; - size_t item_size_; std::string item_type_; - uint32_t vector_length_; - uint32_t code_length_; - bool bit_transition_flag_; - bool use_CFAR_algorithm_flag_; uint32_t channel_; - float threshold_; uint32_t doppler_max_; uint32_t doppler_step_; - uint32_t max_dwells_; - int64_t fs_in_; - bool dump_; - bool blocking_; std::string dump_filename_; - std::complex* code_; Gnss_Synchro* gnss_synchro_; std::string role_; unsigned int in_streams_; diff --git a/src/algorithms/acquisition/libs/fpga_acquisition.cc b/src/algorithms/acquisition/libs/fpga_acquisition.cc index 6125ee313..e429e8c8e 100644 --- a/src/algorithms/acquisition/libs/fpga_acquisition.cc +++ b/src/algorithms/acquisition/libs/fpga_acquisition.cc @@ -62,6 +62,18 @@ #define SELECT_ALL_CODE_BITS 0x000FFFFF // Select a 20 bit word #define SHL_CODE_BITS 1024 // shift left by 10 bits +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(exp) \ + ({ \ + decltype(exp) _rc; \ + do \ + { \ + _rc = (exp); \ + } \ + while (_rc == -1 && errno == EINTR); \ + _rc; \ + }) +#endif bool Fpga_Acquisition::init() { diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc index a9feedaed..e8e147e6a 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc @@ -40,8 +40,23 @@ #include #include // libraries used by the GIPO +using google::LogMessage; + #define PAGE_SIZE 0x10000 // default page size for the multicorrelator memory map #define TEST_REG_SANITY_CHECK 0x55AA // value to check the presence of the test register (to detect the hw) +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(exp) \ + ({ \ + decltype(exp) _rc; \ + do \ + { \ + _rc = (exp); \ + } \ + while (_rc == -1 && errno == EINTR); \ + _rc; \ + }) +#endif + gnss_sdr_fpga_sample_counter::gnss_sdr_fpga_sample_counter( double _fs, @@ -59,7 +74,7 @@ gnss_sdr_fpga_sample_counter::gnss_sdr_fpga_sample_counter( //The hardware timer must keep always interrupting the PS. It must not wait for the interrupt to //be served. open_device(); - + is_open = true; sample_counter = 0ULL; current_T_rx_ms = 0; current_s = 0; @@ -81,6 +96,15 @@ gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, } +gnss_sdr_fpga_sample_counter::~gnss_sdr_fpga_sample_counter() +{ + if (is_open) + { + close_device(); + } +} + + // Called by gnuradio to enable drivers, etc for i/o devices. bool gnss_sdr_fpga_sample_counter::start() { @@ -100,102 +124,11 @@ bool gnss_sdr_fpga_sample_counter::stop() //todo: place here the routines to stop the associated hardware (if needed).This function will be called by GNURadio at every stop of the flowgraph. // return true if everything is ok. close_device(); - + is_open = false; return true; } -int gnss_sdr_fpga_sample_counter::general_work(int noutput_items __attribute__((unused)), - __attribute__((unused)) gr_vector_int &ninput_items, - __attribute__((unused)) gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - //todo: Call here a function that waits for an interrupt. Do not open a thread, - //it must be a simple call to a BLOCKING function. - // The function will return the actual absolute sample count of the internal counter of the timmer. - // store the sample count in class member sample_counter - // Possible problem: what happen if the PS is overloaded and gnuradio does not call this function - // with the sufficient rate to catch all the interrupts in the counter. To be evaluated later. - - uint32_t counter = wait_for_interrupt_and_read_counter(); - uint64_t samples_passed = 2 * static_cast(samples_per_output) - static_cast(counter); // ellapsed samples - // Note: at this moment the sample counter is implemented as a sample counter that decreases to zero and then it is automatically - // reloaded again and keeps counter. It is done in this way to minimize the logic in the FPGA and maximize the FPGA clock performance - // (it takes less resources and latency in the FPGA to compare a number against a fixed value like zero than to compare it to a programmable - // variable number). - - sample_counter = sample_counter + samples_passed; //samples_per_output; - auto *out = reinterpret_cast(output_items[0]); - out[0] = Gnss_Synchro(); - out[0].Flag_valid_symbol_output = false; - out[0].Flag_valid_word = false; - out[0].Channel_ID = -1; - out[0].fs = fs; - if ((current_T_rx_ms % report_interval_ms) == 0) - { - current_s++; - if ((current_s % 60) == 0) - { - current_s = 0; - current_m++; - flag_m = true; - if ((current_m % 60) == 0) - { - current_m = 0; - current_h++; - flag_h = true; - if ((current_h % 24) == 0) - { - current_h = 0; - current_days++; - flag_days = true; - } - } - } - - if (flag_days) - { - std::string day; - if (current_days == 1) - { - day = " day "; - } - else - { - day = " days "; - } - std::cout << "Current receiver time: " << current_days << day << current_h << " h " << current_m << " min " << current_s << " s" << std::endl; - } - else - { - if (flag_h) - { - std::cout << "Current receiver time: " << current_h << " h " << current_m << " min " << current_s << " s" << std::endl; - } - else - { - if (flag_m) - { - std::cout << "Current receiver time: " << current_m << " min " << current_s << " s" << std::endl; - } - else - { - std::cout << "Current receiver time: " << current_s << " s" << std::endl; - } - } - } - if (flag_enable_send_msg) - { - message_port_pub(pmt::mp("receiver_time"), pmt::from_double(static_cast(current_T_rx_ms) / 1000.0)); - } - } - out[0].Tracking_sample_counter = sample_counter; - //current_T_rx_ms = (sample_counter * 1000) / samples_per_output; - current_T_rx_ms = interval_ms * (sample_counter) / samples_per_output; - return 1; -} - - uint32_t gnss_sdr_fpga_sample_counter::test_register(uint32_t writeval) { uint32_t readval; @@ -290,3 +223,94 @@ uint32_t gnss_sdr_fpga_sample_counter::wait_for_interrupt_and_read_counter() counter = samples_per_output; //map_base[0]; return counter; } + + +int gnss_sdr_fpga_sample_counter::general_work(int noutput_items __attribute__((unused)), + __attribute__((unused)) gr_vector_int &ninput_items, + __attribute__((unused)) gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + //todo: Call here a function that waits for an interrupt. Do not open a thread, + //it must be a simple call to a BLOCKING function. + // The function will return the actual absolute sample count of the internal counter of the timmer. + // store the sample count in class member sample_counter + // Possible problem: what happen if the PS is overloaded and gnuradio does not call this function + // with the sufficient rate to catch all the interrupts in the counter. To be evaluated later. + + uint32_t counter = wait_for_interrupt_and_read_counter(); + uint64_t samples_passed = 2 * static_cast(samples_per_output) - static_cast(counter); // ellapsed samples + // Note: at this moment the sample counter is implemented as a sample counter that decreases to zero and then it is automatically + // reloaded again and keeps counter. It is done in this way to minimize the logic in the FPGA and maximize the FPGA clock performance + // (it takes less resources and latency in the FPGA to compare a number against a fixed value like zero than to compare it to a programmable + // variable number). + + sample_counter = sample_counter + samples_passed; //samples_per_output; + auto *out = reinterpret_cast(output_items[0]); + out[0] = Gnss_Synchro(); + out[0].Flag_valid_symbol_output = false; + out[0].Flag_valid_word = false; + out[0].Channel_ID = -1; + out[0].fs = fs; + if ((current_T_rx_ms % report_interval_ms) == 0) + { + current_s++; + if ((current_s % 60) == 0) + { + current_s = 0; + current_m++; + flag_m = true; + if ((current_m % 60) == 0) + { + current_m = 0; + current_h++; + flag_h = true; + if ((current_h % 24) == 0) + { + current_h = 0; + current_days++; + flag_days = true; + } + } + } + + if (flag_days) + { + std::string day; + if (current_days == 1) + { + day = " day "; + } + else + { + day = " days "; + } + std::cout << "Current receiver time: " << current_days << day << current_h << " h " << current_m << " min " << current_s << " s" << std::endl; + } + else + { + if (flag_h) + { + std::cout << "Current receiver time: " << current_h << " h " << current_m << " min " << current_s << " s" << std::endl; + } + else + { + if (flag_m) + { + std::cout << "Current receiver time: " << current_m << " min " << current_s << " s" << std::endl; + } + else + { + std::cout << "Current receiver time: " << current_s << " s" << std::endl; + } + } + } + if (flag_enable_send_msg) + { + message_port_pub(pmt::mp("receiver_time"), pmt::from_double(static_cast(current_T_rx_ms) / 1000.0)); + } + } + out[0].Tracking_sample_counter = sample_counter; + //current_T_rx_ms = (sample_counter * 1000) / samples_per_output; + current_T_rx_ms = interval_ms * (sample_counter) / samples_per_output; + return 1; +} diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h index d19fc6dba..dd508c33d 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.h @@ -72,9 +72,11 @@ private: int32_t fd; // driver descriptor volatile uint32_t *map_base; // driver memory map std::string device_name = "/dev/uio2"; // HW device name + bool is_open; public: friend gnss_sdr_fpga_sample_counter_sptr gnss_sdr_make_fpga_sample_counter(double _fs, int32_t _interval_ms); + ~gnss_sdr_fpga_sample_counter(); int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc index bf2ecffbe..3d692c5db 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.cc @@ -3,7 +3,6 @@ * \brief Adapts a DLL+PLL VEML (Very Early Minus Late) tracking loop block * to a TrackingInterface for Galileo E1 signals for the FPGA * \author Marc Majoral, 2019. mmajoral(at)cttc.cat - * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, @@ -45,10 +44,6 @@ using google::LogMessage; -void GalileoE1DllPllVemlTrackingFpga::stop_tracking() -{ -} - GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) @@ -136,6 +131,7 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga( d_ca_codes = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * code_samples_per_chip * GALILEO_E1_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); float* ca_codes_f; float* data_codes_f = nullptr; + d_data_codes = nullptr; if (d_track_pilot) { @@ -200,6 +196,11 @@ GalileoE1DllPllVemlTrackingFpga::~GalileoE1DllPllVemlTrackingFpga() } +void GalileoE1DllPllVemlTrackingFpga::stop_tracking() +{ +} + + void GalileoE1DllPllVemlTrackingFpga::start_tracking() { tracking_fpga_sc->start_tracking(); diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h index 729bbe5b4..79cf7b6a4 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking_fpga.h @@ -71,7 +71,7 @@ public: inline size_t item_size() override { - return item_size_; + return sizeof(int); } void connect(gr::top_block_sptr top_block) override; @@ -101,7 +101,6 @@ public: private: dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; - size_t item_size_; uint32_t channel_; std::string role_; uint32_t in_streams_; diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc index ba621e619..e158d493f 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking_fpga.cc @@ -114,6 +114,7 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; trk_param_fpga.carrier_lock_th = carrier_lock_th; + d_data_codes = nullptr; // FPGA configuration parameters std::string default_device_name = "/dev/uio"; @@ -136,7 +137,6 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga( d_data_codes = static_cast(volk_gnsssdr_malloc((static_cast(code_length_chips)) * code_samples_per_chip * GALILEO_E5A_NUMBER_OF_CODES * sizeof(int32_t), volk_gnsssdr_get_alignment())); } - for (uint32_t PRN = 1; PRN <= GALILEO_E5A_NUMBER_OF_CODES; PRN++) { galileo_e5_a_code_gen_complex_primary(aux_code, PRN, const_cast(sig_)); diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h index f0117fdaa..5be1e7104 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h @@ -70,7 +70,7 @@ public: inline size_t item_size() override { - return item_size_; + return sizeof(int) } void connect(gr::top_block_sptr top_block) override; @@ -98,7 +98,6 @@ public: private: dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; - size_t item_size_; uint32_t channel_; std::string role_; uint32_t in_streams_; diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h index c61e1e81a..1d6060f2f 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking_fpga.h @@ -70,7 +70,7 @@ public: inline size_t item_size() override { - return item_size_; + return sizeof(int); } void connect(gr::top_block_sptr top_block) override; @@ -97,7 +97,6 @@ public: private: dll_pll_veml_tracking_fpga_sptr tracking_fpga_sc; - size_t item_size_; uint32_t channel_; std::string role_; uint32_t in_streams_; diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.cc b/src/algorithms/tracking/libs/fpga_multicorrelator.cc index adcfac599..741705303 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.cc @@ -66,6 +66,18 @@ #define LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY 0x0C000000 #define TEST_REGISTER_TRACK_WRITEVAL 0x55AA +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(exp) \ + ({ \ + decltype(exp) _rc; \ + do \ + { \ + _rc = (exp); \ + } \ + while (_rc == -1 && errno == EINTR); \ + _rc; \ + }) +#endif Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators, std::string device_name, uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, @@ -95,6 +107,7 @@ Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators, } d_shifts_chips = nullptr; d_prompt_data_shift = nullptr; + d_Prompt_Data = nullptr; d_corr_out = nullptr; d_code_length_chips = 0; d_rem_code_phase_chips = 0; @@ -105,7 +118,8 @@ Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators, d_phase_step_rad_int = 0; d_initial_sample_counter = 0; d_channel = 0; - d_correlator_length_samples = 0, + d_correlator_length_samples = 0; + d_code_phase_step_chips_num = 0; d_code_length_chips = code_length_chips; d_ca_codes = ca_codes; d_data_codes = data_codes; @@ -119,6 +133,14 @@ Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators, Fpga_Multicorrelator_8sc::~Fpga_Multicorrelator_8sc() { close_device(); + if (d_initial_index != nullptr) + { + volk_gnsssdr_free(d_initial_index); + } + if (d_initial_interp_counter != nullptr) + { + volk_gnsssdr_free(d_initial_interp_counter); + } } diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator.h b/src/algorithms/tracking/libs/fpga_multicorrelator.h index 155503002..1a44de781 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator.h +++ b/src/algorithms/tracking/libs/fpga_multicorrelator.h @@ -98,7 +98,7 @@ private: float *d_shifts_chips; float *d_prompt_data_shift; int32_t d_code_length_chips; - int32_t d_n_correlators; + int32_t d_n_correlators; // number of correlators // data related to the hardware module and the driver int32_t d_device_descriptor; // driver descriptor @@ -106,7 +106,6 @@ private: // configuration data received from the interface uint32_t d_channel; // channel number - uint32_t d_ncorrelators; // number of correlators uint32_t d_correlator_length_samples; float d_rem_code_phase_chips; float d_code_phase_step_chips; From 3b9f04407403b074181fcf8d7a12d90e79bce131 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 1 Mar 2019 16:48:10 +0100 Subject: [PATCH 51/53] Moving LOG(INFO) to DLOG(INFO) for some telemetry decoder messages --- .../galileo_telemetry_decoder_cc.cc | 18 +++++++++--------- .../gps_l5_telemetry_decoder_cc.cc | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc index 835e93f12..fd86b993c 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc @@ -63,7 +63,7 @@ galileo_telemetry_decoder_cc::galileo_telemetry_decoder_cc( d_dump = dump; d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); d_frame_type = frame_type; - LOG(INFO) << "Initializing GALILEO UNIFIED TELEMETRY DECODER"; + DLOG(INFO) << "Initializing GALILEO UNIFIED TELEMETRY DECODER"; switch (d_frame_type) { @@ -299,11 +299,11 @@ void galileo_telemetry_decoder_cc::decode_INAV_word(double *page_part_symbols, i d_inav_nav.split_page(page_String, flag_even_word_arrived); if (d_inav_nav.flag_CRC_test == true) { - LOG(INFO) << "Galileo E1 CRC correct in channel " << d_channel << " from satellite " << d_satellite; + DLOG(INFO) << "Galileo E1 CRC correct in channel " << d_channel << " from satellite " << d_satellite; } else { - LOG(INFO) << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite; + DLOG(INFO) << "Galileo E1 CRC error in channel " << d_channel << " from satellite " << d_satellite; } flag_even_word_arrived = 0; } @@ -391,11 +391,11 @@ void galileo_telemetry_decoder_cc::decode_FNAV_word(double *page_symbols, int32_ d_fnav_nav.split_page(page_String); if (d_fnav_nav.flag_CRC_test == true) { - LOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite; + DLOG(INFO) << "Galileo E5a CRC correct in channel " << d_channel << " from satellite " << d_satellite; } else { - LOG(INFO) << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite; + DLOG(INFO) << "Galileo E5a CRC error in channel " << d_channel << " from satellite " << d_satellite; } // 4. Push the new navigation data to the queues @@ -431,7 +431,7 @@ void galileo_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite void galileo_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; - LOG(INFO) << "Navigation channel set to " << channel; + DLOG(INFO) << "Navigation channel set to " << channel; // ############# ENABLE DATA FILE LOG ################# if (d_dump == true) { @@ -497,7 +497,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( if (abs(corr_value) >= d_samples_per_preamble) { d_preamble_index = d_sample_counter; // record the preamble sample stamp - LOG(INFO) << "Preamble detection for Galileo satellite " << this->d_satellite; + DLOG(INFO) << "Preamble detection for Galileo satellite " << this->d_satellite; d_stat = 1; // enter into frame pre-detection status } break; @@ -511,7 +511,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( if (abs(preamble_diff - d_preamble_period_symbols) == 0) { // try to decode frame - LOG(INFO) << "Starting page decoder for Galileo satellite " << this->d_satellite; + DLOG(INFO) << "Starting page decoder for Galileo satellite " << this->d_satellite; d_preamble_index = d_sample_counter; // record the preamble sample stamp d_stat = 2; } @@ -606,7 +606,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( d_preamble_index = d_sample_counter; // record the preamble sample stamp if (d_CRC_error_counter > CRC_ERROR_LIMIT) { - LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; + DLOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; d_flag_frame_sync = false; d_stat = 0; d_TOW_at_current_symbol_ms = 0; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index 91037b661..48ff89668 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -105,7 +105,7 @@ gps_l5_telemetry_decoder_cc::~gps_l5_telemetry_decoder_cc() void gps_l5_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) { d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); - LOG(INFO) << "GPS L5 CNAV telemetry decoder in channel " << this->d_channel << " set to satellite " << d_satellite; + DLOG(INFO) << "GPS L5 CNAV telemetry decoder in channel " << this->d_channel << " set to satellite " << d_satellite; d_CNAV_Message.reset(); } @@ -114,7 +114,7 @@ void gps_l5_telemetry_decoder_cc::set_channel(int32_t channel) { d_channel = channel; d_CNAV_Message.reset(); - LOG(INFO) << "GPS L5 CNAV channel set to " << channel; + DLOG(INFO) << "GPS L5 CNAV channel set to " << channel; // ############# ENABLE DATA FILE LOG ################# if (d_dump == true) { From 2543b2aae21fa1d2f28b1e336ef7f8f280430276 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 1 Mar 2019 16:59:29 +0100 Subject: [PATCH 52/53] Fix error --- .../tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h index 5be1e7104..b083495a5 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking_fpga.h @@ -70,7 +70,7 @@ public: inline size_t item_size() override { - return sizeof(int) + return sizeof(int); } void connect(gr::top_block_sptr top_block) override; From d6bf84b222bed893f1ef3e3f78f13f86573e2c11 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 1 Mar 2019 18:31:15 +0100 Subject: [PATCH 53/53] Moving LOG(INFO) to DLOG(INFO) in galileo navigation message parser --- src/core/system_parameters/galileo_navigation_message.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc index aec3cdd0d..263294057 100644 --- a/src/core/system_parameters/galileo_navigation_message.cc +++ b/src/core/system_parameters/galileo_navigation_message.cc @@ -627,7 +627,7 @@ int32_t Galileo_Navigation_Message::page_jk_decoder(const char* data_jk) std::bitset data_jk_bits(data_jk_string); page_number = static_cast(read_navigation_unsigned(data_jk_bits, PAGE_TYPE_BIT)); - LOG(INFO) << "Page number = " << page_number; + DLOG(INFO) << "Page number = " << page_number; switch (page_number) {