mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-06-25 22:52:52 +00:00
Fix coverity scan defects
This commit is contained in:
parent
642c7effee
commit
fb1fd2584d
@ -81,13 +81,15 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block,
|
||||
buffer_float = (char *)malloc(FLOAT_SIZE); // allocate space for the temporary buffer
|
||||
if (!buffer_float)
|
||||
{
|
||||
fprintf(stderr, "Memory error!");
|
||||
std::cerr << "Memory error!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
rx_signal_file = fopen(file_name, "rb"); // file containing the received signal
|
||||
if (!rx_signal_file)
|
||||
{
|
||||
printf("Unable to open file!");
|
||||
std::cerr << "Unable to open file!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// determine the length of the file that contains the received signal
|
||||
@ -96,7 +98,6 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block,
|
||||
fseek(rx_signal_file, 0, SEEK_SET);
|
||||
|
||||
// first step: check for the maximum value of the received signal
|
||||
|
||||
float max = 0;
|
||||
float *pointer_float;
|
||||
pointer_float = (float *)&buffer_float[0];
|
||||
@ -118,23 +119,21 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block,
|
||||
fseek(rx_signal_file, 0, SEEK_SET);
|
||||
|
||||
// allocate memory for the samples to be transferred to the DMA
|
||||
|
||||
buffer_DMA = (signed char *)malloc(DMA_ACQ_TRANSFER_SIZE);
|
||||
if (!buffer_DMA)
|
||||
{
|
||||
fprintf(stderr, "Memory error!");
|
||||
std::cerr << "Memory error!" << std::endl;
|
||||
}
|
||||
|
||||
// open the DMA descriptor
|
||||
dma_descr = open("/dev/loop_tx", O_WRONLY);
|
||||
if (dma_descr < 0)
|
||||
{
|
||||
printf("can't open loop device\n");
|
||||
exit(1);
|
||||
std::cerr << "Can't open loop device\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// cycle through the file containing the received samples
|
||||
|
||||
for (int k = 0; k < NTIMES_CYCLE_THROUGH_RX_SAMPLES_FILE; k++)
|
||||
{
|
||||
fseek(rx_signal_file, 0, SEEK_SET);
|
||||
@ -176,7 +175,6 @@ void thread_acquisition_send_rx_samples(gr::top_block_sptr top_block,
|
||||
close(dma_descr);
|
||||
|
||||
// when all the samples are sent stop the top block
|
||||
|
||||
top_block->stop();
|
||||
}
|
||||
|
||||
|
@ -424,10 +424,8 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
//*************************************************
|
||||
//***** STEP 2: Prepare the parameters sweep ******
|
||||
//*************************************************
|
||||
|
||||
std::vector<double> generator_CN0_values;
|
||||
|
||||
|
||||
//data containers for config param sweep
|
||||
std::vector<std::vector<double>> mean_doppler_error_sweep; //swep config param and cn0 sweep
|
||||
std::vector<std::vector<double>> std_dev_doppler_error_sweep; //swep config param and cn0 sweep
|
||||
@ -449,16 +447,13 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
double acq_doppler_hz = 0.0;
|
||||
Tracking_True_Obs_Reader true_obs_data;
|
||||
|
||||
|
||||
// CONFIG PARAM SWEEP LOOP
|
||||
std::vector<double> PLL_wide_bw_values;
|
||||
std::vector<double> DLL_wide_bw_values;
|
||||
|
||||
|
||||
//***********************************************************
|
||||
//***** STEP 2: Tracking configuration parameters sweep *****
|
||||
//***********************************************************
|
||||
|
||||
if (FLAGS_PLL_bw_hz_start == FLAGS_PLL_bw_hz_stop)
|
||||
{
|
||||
if (FLAGS_DLL_bw_hz_start == FLAGS_DLL_bw_hz_stop)
|
||||
@ -490,8 +485,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
//*********************************************
|
||||
//***** STEP 3: Generate the input signal *****
|
||||
//*********************************************
|
||||
|
||||
|
||||
std::vector<double> cno_vector;
|
||||
if (FLAGS_CN0_dBHz_start == FLAGS_CN0_dBHz_stop)
|
||||
{
|
||||
@ -587,7 +580,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
true_obs_data.restart();
|
||||
}
|
||||
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||
|
||||
top_block = gr::make_top_block("Tracking test");
|
||||
@ -625,7 +617,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
top_block->msg_connect(tracking->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
|
||||
}) << "Failure connecting the blocks of tracking test.";
|
||||
|
||||
|
||||
//********************************************************************
|
||||
//***** STEP 5: Perform the signal tracking and read the results *****
|
||||
//********************************************************************
|
||||
@ -736,7 +727,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
trk_Doppler_Hz = trk_Doppler_Hz.subvec(initial_meas_point(0), trk_Doppler_Hz.size() - 1);
|
||||
trk_prn_delay_chips = trk_prn_delay_chips.subvec(initial_meas_point(0), trk_prn_delay_chips.size() - 1);
|
||||
|
||||
|
||||
double mean_error;
|
||||
double std_dev_error;
|
||||
double rmse;
|
||||
@ -781,7 +771,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
std::cout << "Tracking output could not be used, possible loss of lock " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
} //CN0 LOOP
|
||||
|
||||
if (!FLAGS_enable_external_signal_file)
|
||||
@ -917,7 +906,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
g5.set_xlabel("Time [s]");
|
||||
g5.set_ylabel("Code delay error [Chips]");
|
||||
|
||||
|
||||
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++)
|
||||
{
|
||||
try
|
||||
@ -952,7 +940,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
g5b.set_xlabel("Time [s]");
|
||||
g5b.set_ylabel("Code delay error [meters]");
|
||||
|
||||
|
||||
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++)
|
||||
{
|
||||
try
|
||||
@ -973,7 +960,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
g5b.savetops("Code_error_meters");
|
||||
g5b.savetopdf("Code_error_meters", 18);
|
||||
|
||||
|
||||
Gnuplot g6("points");
|
||||
if (FLAGS_show_plots)
|
||||
{
|
||||
@ -988,7 +974,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
g6.set_xlabel("Time [s]");
|
||||
g6.set_ylabel("Accumulated carrier phase error [Cycles]");
|
||||
|
||||
|
||||
for (unsigned int current_cn0_idx = 0; current_cn0_idx < generator_CN0_values_sweep_copy.at(config_idx).size(); current_cn0_idx++)
|
||||
{
|
||||
try
|
||||
@ -1064,7 +1049,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
if (generator_CN0_values.size() > 1)
|
||||
{
|
||||
//plot metrics
|
||||
|
||||
Gnuplot g7("linespoints");
|
||||
if (FLAGS_show_plots)
|
||||
{
|
||||
@ -1098,7 +1082,6 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
g7.savetops("Doppler_error_metrics");
|
||||
g7.savetopdf("Doppler_error_metrics", 18);
|
||||
|
||||
|
||||
Gnuplot g8("linespoints");
|
||||
g8.set_title("Accumulated carrier phase error metrics (PRN #" + std::to_string(FLAGS_test_satellite_PRN) + ")");
|
||||
g8.set_grid();
|
||||
@ -1155,6 +1138,7 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GpsL1CADllPllTrackingTest::save_mat_xy(std::vector<double>& x, std::vector<double>& y, std::string filename)
|
||||
{
|
||||
try
|
||||
|
@ -79,14 +79,15 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file,
|
||||
dma_descr = open("/dev/loop_tx", O_WRONLY);
|
||||
if (dma_descr < 0)
|
||||
{
|
||||
printf("can't open loop device\n");
|
||||
exit(1);
|
||||
std::cerr << "Can't open loop device\n";
|
||||
return;
|
||||
}
|
||||
|
||||
buffer_DMA = (char *)malloc(DMA_TRACK_TRANSFER_SIZE);
|
||||
if (!buffer_DMA)
|
||||
{
|
||||
fprintf(stderr, "Memory error!");
|
||||
std::cerr << "Memory error!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
while (num_remaining_samples > 0)
|
||||
@ -140,7 +141,8 @@ void sending_thread(gr::top_block_sptr top_block, const char *file_name)
|
||||
rx_signal_file = fopen(file_name, "rb");
|
||||
if (!rx_signal_file)
|
||||
{
|
||||
printf("Unable to open file!");
|
||||
std::cerr << "Unable to open file!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
fseek(rx_signal_file, 0, SEEK_END);
|
||||
@ -347,7 +349,6 @@ void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec &true_time_s
|
||||
|
||||
// 2. RMSE
|
||||
arma::vec err;
|
||||
|
||||
err = meas_value - true_value_interp;
|
||||
arma::vec err2 = arma::square(err);
|
||||
double rmse = sqrt(arma::mean(err2));
|
||||
@ -356,7 +357,7 @@ void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec &true_time_s
|
||||
double error_mean = arma::mean(err);
|
||||
double error_var = arma::var(err);
|
||||
|
||||
// 5. Peaks
|
||||
// 4. Peaks
|
||||
double max_error = arma::max(err);
|
||||
double min_error = arma::min(err);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user