From f7050766bcc98edff7958beb5f831aab2bd48c3a Mon Sep 17 00:00:00 2001 From: Marc Majoral Date: Fri, 16 Nov 2018 18:28:02 +0100 Subject: [PATCH] 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();