1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-06-20 07:24:08 +00:00

Apply code formatting

This commit is contained in:
Carles Fernandez 2018-04-30 19:53:20 +02:00
parent 21a6d8ac61
commit bd81330201
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
7 changed files with 281 additions and 295 deletions

View File

@ -78,4 +78,3 @@ add_library(signal_source_lib ${SIGNAL_SOURCE_LIB_SOURCES} ${SIGNAL_SOURCE_LIB_H
source_group(Headers FILES ${SIGNAL_SOURCE_LIB_HEADERS})
target_link_libraries(signal_source_lib ${OPT_LIBRARIES})

View File

@ -35,7 +35,6 @@
*/
#include "fpga_switch.h"
#include <cmath>
// FPGA stuff
@ -78,7 +77,7 @@ fpga_switch::fpga_switch(std::string device_name)
d_map_base = reinterpret_cast<volatile unsigned *>(mmap(NULL, PAGE_SIZE,
PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0));
if (d_map_base == reinterpret_cast<void*>(-1))
if (d_map_base == reinterpret_cast<void *>(-1))
{
LOG(WARNING) << "Cannot map the FPGA switch module into tracking memory";
printf("could not map switch memory\n");
@ -100,16 +99,19 @@ fpga_switch::fpga_switch(std::string device_name)
DLOG(INFO) << "Switch FPGA class created";
}
fpga_switch::~fpga_switch()
{
close_device();
}
void fpga_switch::set_switch_position(int switch_position)
{
d_map_base[0] = switch_position;
}
unsigned fpga_switch::fpga_switch_test_register(
unsigned writeval)
{
@ -122,15 +124,14 @@ unsigned fpga_switch::fpga_switch_test_register(
return readval;
}
void fpga_switch::close_device()
{
unsigned * aux = const_cast<unsigned*>(d_map_base);
if (munmap(static_cast<void*>(aux), PAGE_SIZE) == -1)
unsigned *aux = const_cast<unsigned *>(d_map_base);
if (munmap(static_cast<void *>(aux), PAGE_SIZE) == -1)
{
printf("Failed to unmap memory uio\n");
}
close(d_device_descriptor);
}

View File

@ -55,7 +55,6 @@ private:
// private functions
unsigned fpga_switch_test_register(unsigned writeval);
void close_device(void);
};
#endif /* GNSS_SDR_FPGA_SWITCH_H_ */

View File

@ -35,9 +35,7 @@
*/
#include "fpga_multicorrelator_8sc.h"
#include <cmath>
// FPGA stuff
#include <new>
@ -98,13 +96,12 @@ void fpga_multicorrelator_8sc::set_initial_sample(int samples_offset)
void fpga_multicorrelator_8sc::set_local_code_and_taps(int code_length_chips,
float *shifts_chips, int PRN)
{
d_shifts_chips = shifts_chips;
d_code_length_chips = code_length_chips;
fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(PRN);
}
void fpga_multicorrelator_8sc::set_output_vectors(gr_complex* corr_out)
void fpga_multicorrelator_8sc::set_output_vectors(gr_complex *corr_out)
{
d_corr_out = corr_out;
}
@ -116,14 +113,11 @@ void fpga_multicorrelator_8sc::update_local_code(float rem_code_phase_chips)
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 rem_code_phase_chips, float code_phase_step_chips,
int 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;
@ -143,6 +137,7 @@ void fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler(
fpga_multicorrelator_8sc::read_tracking_gps_results();
}
fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators,
std::string device_name, unsigned int device_base)
{
@ -153,9 +148,9 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators,
d_map_base = nullptr;
// instantiate variable length vectors
d_initial_index = static_cast<unsigned*>(volk_gnsssdr_malloc(
d_initial_index = static_cast<unsigned *>(volk_gnsssdr_malloc(
n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment()));
d_initial_interp_counter = static_cast<unsigned*>(volk_gnsssdr_malloc(
d_initial_interp_counter = static_cast<unsigned *>(volk_gnsssdr_malloc(
n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment()));
//d_local_code_in = nullptr;
@ -173,13 +168,12 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators,
d_correlator_length_samples = 0;
// pre-compute all the codes
d_ca_codes = static_cast<int*>(volk_gnsssdr_malloc(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS*NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment()));
d_ca_codes = static_cast<int *>(volk_gnsssdr_malloc(static_cast<int>(GPS_L1_CA_CODE_LENGTH_CHIPS * NUM_PRNs) * sizeof(int), volk_gnsssdr_get_alignment()));
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);
}
DLOG(INFO) << "TRACKING FPGA CLASS CREATED";
}
@ -231,7 +225,7 @@ void fpga_multicorrelator_8sc::set_channel(unsigned int channel)
d_map_base = reinterpret_cast<volatile unsigned *>(mmap(NULL, PAGE_SIZE,
PROT_READ | PROT_WRITE, MAP_SHARED, d_device_descriptor, 0));
if (d_map_base == reinterpret_cast<void*>(-1))
if (d_map_base == reinterpret_cast<void *>(-1))
{
LOG(WARNING) << "Cannot map the FPGA tracking module "
<< d_channel << "into user memory";
@ -287,11 +281,9 @@ void fpga_multicorrelator_8sc::fpga_configure_tracking_gps_local_code(int PRN)
code_chip = 0;
}
// copy the local code to the FPGA memory one by one
d_map_base[11] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY
| code_chip | select_fpga_correlator;
d_map_base[11] = LOCAL_CODE_FPGA_ENABLE_WRITE_MEMORY | code_chip | select_fpga_correlator;
}
select_fpga_correlator = select_fpga_correlator
+ LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT;
select_fpga_correlator = select_fpga_correlator + LOCAL_CODE_FPGA_CORRELATOR_SELECT_COUNT;
}
}
@ -310,14 +302,14 @@ void fpga_multicorrelator_8sc::fpga_compute_code_shift_parameters(void)
{
temp_calculation = temp_calculation + d_code_length_chips; // % operator does not work as in Matlab with negative numbers
}
d_initial_index[i] = static_cast<unsigned>( (static_cast<int>(temp_calculation)) % d_code_length_chips);
d_initial_index[i] = static_cast<unsigned>((static_cast<int>(temp_calculation)) % d_code_length_chips);
temp_calculation = fmod(d_shifts_chips[i] - d_rem_code_phase_chips,
1.0);
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<unsigned>( floor( MAX_CODE_RESAMPLER_COUNTER * temp_calculation));
d_initial_interp_counter[i] = static_cast<unsigned>(floor(MAX_CODE_RESAMPLER_COUNTER * temp_calculation));
}
}
@ -338,29 +330,26 @@ void fpga_multicorrelator_8sc::fpga_compute_signal_parameters_in_fpga(void)
{
float d_rem_carrier_phase_in_rad_temp;
d_code_phase_step_chips_num = static_cast<unsigned>( roundf(MAX_CODE_RESAMPLER_COUNTER * d_code_phase_step_chips));
d_code_phase_step_chips_num = static_cast<unsigned>(roundf(MAX_CODE_RESAMPLER_COUNTER * d_code_phase_step_chips));
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;
d_rem_carrier_phase_in_rad_temp = -2 * M_PI + d_rem_carrier_phase_in_rad;
}
else 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;
d_rem_carrier_phase_in_rad_temp = 2 * M_PI + d_rem_carrier_phase_in_rad;
}
else
{
d_rem_carrier_phase_in_rad_temp = d_rem_carrier_phase_in_rad;
}
d_rem_carr_phase_rad_int = static_cast<int>( roundf(
(fabs(d_rem_carrier_phase_in_rad_temp) / M_PI)
* pow(2, PHASE_CARR_NBITS_FRAC)));
d_rem_carr_phase_rad_int = static_cast<int>(roundf(
(fabs(d_rem_carrier_phase_in_rad_temp) / M_PI) * pow(2, PHASE_CARR_NBITS_FRAC)));
if (d_rem_carrier_phase_in_rad_temp < 0)
{
d_rem_carr_phase_rad_int = -d_rem_carr_phase_rad_int;
}
d_phase_step_rad_int = static_cast<int>( roundf(
d_phase_step_rad_int = static_cast<int>(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
if (d_phase_step_rad < 0)
@ -383,7 +372,7 @@ void fpga_multicorrelator_8sc::fpga_launch_multicorrelator_fpga(void)
{
// enable interrupts
int reenable = 1;
write(d_device_descriptor, reinterpret_cast<void*>(&reenable), sizeof(int));
write(d_device_descriptor, reinterpret_cast<void *>(&reenable), sizeof(int));
// writing 1 to reg 14 launches the tracking
d_map_base[14] = 1;
@ -409,7 +398,7 @@ void fpga_multicorrelator_8sc::read_tracking_gps_results(void)
{
readval_imag = -2097152 + readval_imag;
}
d_corr_out[k] = gr_complex(readval_real,readval_imag);
d_corr_out[k] = gr_complex(readval_real, readval_imag);
}
}
@ -420,14 +409,15 @@ void fpga_multicorrelator_8sc::unlock_channel(void)
d_map_base[12] = 1; // unlock the channel
}
void fpga_multicorrelator_8sc::close_device()
{
unsigned * aux = const_cast<unsigned*>(d_map_base);
if (munmap(static_cast<void*>(aux), PAGE_SIZE) == -1)
unsigned *aux = const_cast<unsigned *>(d_map_base);
if (munmap(static_cast<void *>(aux), PAGE_SIZE) == -1)
{
printf("Failed to unmap memory uio\n");
}
/* else
/* else
{
printf("memory uio unmapped\n");
} */
@ -441,15 +431,16 @@ void fpga_multicorrelator_8sc::lock_channel(void)
d_map_base[12] = 0; // lock the channel
}
void fpga_multicorrelator_8sc::read_sample_counters(int *sample_counter, int *secondary_sample_counter, int *counter_corr_0_in, int *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

View File

@ -52,10 +52,10 @@ public:
unsigned int device_base);
~fpga_multicorrelator_8sc();
//bool set_output_vectors(gr_complex* corr_out);
void set_output_vectors(gr_complex* corr_out);
// bool set_local_code_and_taps(
// int code_length_chips, const int* local_code_in,
// float *shifts_chips, int PRN);
void set_output_vectors(gr_complex *corr_out);
// bool set_local_code_and_taps(
// int code_length_chips, const int* local_code_in,
// float *shifts_chips, int PRN);
//bool set_local_code_and_taps(
void set_local_code_and_taps(
int code_length_chips,
@ -66,7 +66,8 @@ public:
void Carrier_wipeoff_multicorrelator_resampler(
float rem_carrier_phase_in_rad, float phase_step_rad,
float rem_code_phase_chips, float code_phase_step_chips,
int signal_length_samples);bool free();
int signal_length_samples);
bool free();
void set_channel(unsigned int channel);
void set_initial_sample(int samples_offset);
int read_sample_counter();
@ -74,10 +75,9 @@ public:
void unlock_channel(void);
void read_sample_counters(int *sample_counter, int *secondary_sample_counter, int *counter_corr_0_in, int *counter_corr_0_out); // debug
private:
//const int *d_local_code_in;
gr_complex * d_corr_out;
gr_complex *d_corr_out;
float *d_shifts_chips;
int d_code_length_chips;
int d_n_correlators;
@ -107,8 +107,7 @@ private:
std::string d_device_name;
unsigned int d_device_base;
int* d_ca_codes;
int *d_ca_codes;
// private functions
unsigned fpga_acquisition_test_register(unsigned writeval);
@ -121,9 +120,6 @@ private:
void read_tracking_gps_results(void);
void reset_multicorrelator(void);
void close_device(void);
// debug
//unsigned int first_time = 1;
};
#endif /* GNSS_SDR_FPGA_MULTICORRELATOR_H_ */

View File

@ -36,8 +36,8 @@
#include <iostream>
#include <unistd.h>
#include <armadillo>
#include <boost/thread.hpp>// to test the FPGA we have to create a simultaneous task to send the samples using the DMA and stop the test
#include <stdio.h>// FPGA read input file
#include <boost/thread.hpp> // to test the FPGA we have to create a simultaneous task to send the samples using the DMA and stop the test
#include <stdio.h> // FPGA read input file
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/analog/sig_source_waveform.h>
@ -79,7 +79,7 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file,
exit(1);
}
buffer_DMA = (char *) malloc(DMA_TRACK_TRANSFER_SIZE);
buffer_DMA = (char *)malloc(DMA_TRACK_TRANSFER_SIZE);
if (!buffer_DMA)
{
fprintf(stderr, "Memory error!");
@ -98,8 +98,7 @@ 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);
fread(buffer_DMA, DMA_TRACK_TRANSFER_SIZE, 1, rx_signal_file);
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;
@ -121,7 +120,7 @@ void send_tracking_gps_input_samples(FILE *rx_signal_file,
// thread that sends the samples to the FPGA
void thread(gr::top_block_sptr top_block, const char * file_name)
void thread(gr::top_block_sptr top_block, const char *file_name)
{
// file descriptor
FILE *rx_signal_file; // file descriptor
@ -181,7 +180,7 @@ void GpsL1CADllPllTrackingTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg)
long int message = pmt::to_long(msg);
rx_message = message;
}
catch (boost::bad_any_cast& e)
catch (boost::bad_any_cast &e)
{
LOG(WARNING) << "msg_handler_telemetry Bad any cast!";
rx_message = 0;
@ -189,8 +188,7 @@ void GpsL1CADllPllTrackingTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg)
}
GpsL1CADllPllTrackingTestFpga_msg_rx::GpsL1CADllPllTrackingTestFpga_msg_rx() :
gr::block("GpsL1CADllPllTrackingTestFpga_msg_rx",
GpsL1CADllPllTrackingTestFpga_msg_rx::GpsL1CADllPllTrackingTestFpga_msg_rx() : gr::block("GpsL1CADllPllTrackingTestFpga_msg_rx",
gr::io_signature::make(0, 0, 0),
gr::io_signature::make(0, 0, 0))
{
@ -204,7 +202,8 @@ GpsL1CADllPllTrackingTestFpga_msg_rx::GpsL1CADllPllTrackingTestFpga_msg_rx() :
GpsL1CADllPllTrackingTestFpga_msg_rx::~GpsL1CADllPllTrackingTestFpga_msg_rx()
{}
{
}
// ###########################################################
@ -226,12 +225,12 @@ public:
int configure_generator();
int generate_signal();
void check_results_doppler(arma::vec & true_time_s, arma::vec & true_value,
arma::vec & meas_time_s, arma::vec & meas_value);
void check_results_acc_carrier_phase(arma::vec & true_time_s,
arma::vec & true_value, arma::vec & meas_time_s, arma::vec & meas_value);
void check_results_codephase(arma::vec & true_time_s, arma::vec & true_value,
arma::vec & meas_time_s, arma::vec & meas_value);
void check_results_doppler(arma::vec &true_time_s, arma::vec &true_value,
arma::vec &meas_time_s, arma::vec &meas_value);
void check_results_acc_carrier_phase(arma::vec &true_time_s,
arma::vec &true_value, arma::vec &meas_time_s, arma::vec &meas_value);
void check_results_codephase(arma::vec &true_time_s, arma::vec &true_value,
arma::vec &meas_time_s, arma::vec &meas_value);
GpsL1CADllPllTrackingTestFpga()
{
@ -263,8 +262,7 @@ int GpsL1CADllPllTrackingTestFpga::configure_generator()
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);
p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(FLAGS_duration * 10);
}
else
{
@ -281,8 +279,8 @@ int GpsL1CADllPllTrackingTestFpga::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 };
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)
@ -328,8 +326,8 @@ void GpsL1CADllPllTrackingTestFpga::configure_receiver()
}
void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec & true_time_s,
arma::vec & true_value, arma::vec & meas_time_s, arma::vec & meas_value)
void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec &true_time_s,
arma::vec &true_value, arma::vec &meas_time_s, arma::vec &meas_value)
{
//1. True value interpolation to match the measurement times
arma::vec true_value_interp;
@ -362,13 +360,13 @@ void GpsL1CADllPllTrackingTestFpga::check_results_doppler(arma::vec & true_time_
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Hz]"
<< std::endl;
std::cout.precision (ss);
std::cout.precision(ss);
}
void GpsL1CADllPllTrackingTestFpga::check_results_acc_carrier_phase(
arma::vec & true_time_s, arma::vec & true_value, arma::vec & meas_time_s,
arma::vec & meas_value)
arma::vec &true_time_s, arma::vec &true_value, arma::vec &meas_time_s,
arma::vec &meas_value)
{
//1. True value interpolation to match the measurement times
arma::vec true_value_interp;
@ -401,13 +399,13 @@ void GpsL1CADllPllTrackingTestFpga::check_results_acc_carrier_phase(
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Hz]"
<< std::endl;
std::cout.precision (ss);
std::cout.precision(ss);
}
void GpsL1CADllPllTrackingTestFpga::check_results_codephase(
arma::vec & true_time_s, arma::vec & true_value, arma::vec & meas_time_s,
arma::vec & meas_value)
arma::vec &true_time_s, arma::vec &true_value, arma::vec &meas_time_s,
arma::vec &meas_value)
{
//1. True value interpolation to match the measurement times
arma::vec true_value_interp;
@ -439,7 +437,7 @@ void GpsL1CADllPllTrackingTestFpga::check_results_codephase(
<< ", mean=" << error_mean << ", stdev=" << sqrt(error_var)
<< " (max,min)=" << max_error << "," << min_error << " [Chips]"
<< std::endl;
std::cout.precision (ss);
std::cout.precision(ss);
}
@ -468,11 +466,12 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
{
throw std::exception();
};
}) << "Failure opening true observables file";
})
<< "Failure opening true observables file";
top_block = gr::make_top_block("Tracking test");
//std::shared_ptr<GpsL1CaDllPllCAidTrackingFpga> tracking = std::make_shared<GpsL1CaDllPllCAidTrackingFpga> (config.get(), "Tracking_1C", 1, 1);
std::shared_ptr<GpsL1CaDllPllTrackingFpga> tracking = std::make_shared<GpsL1CaDllPllTrackingFpga> (config.get(), "Tracking_1C", 1, 1);
std::shared_ptr<GpsL1CaDllPllTrackingFpga> tracking = std::make_shared<GpsL1CaDllPllTrackingFpga>(config.get(), "Tracking_1C", 1, 1);
boost::shared_ptr<GpsL1CADllPllTrackingTestFpga_msg_rx> msg_rx = GpsL1CADllPllTrackingTestFpga_msg_rx_make();
@ -483,7 +482,8 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
{
throw std::exception();
};
}) << "Failure reading true observables file";
})
<< "Failure reading true observables file";
//restart the epoch counter
true_obs_data.restart();
@ -492,52 +492,54 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
<< " Initial code delay [Chips]=" << true_obs_data.prn_delay_chips
<< std::endl;
gnss_synchro.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS
- true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS)
* baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD;
gnss_synchro.Acq_delay_samples = (GPS_L1_CA_CODE_LENGTH_CHIPS - true_obs_data.prn_delay_chips / GPS_L1_CA_CODE_LENGTH_CHIPS) * baseband_sampling_freq * GPS_L1_CA_CODE_PERIOD;
gnss_synchro.Acq_doppler_hz = true_obs_data.doppler_l1_hz;
gnss_synchro.Acq_samplestamp_samples = 0;
ASSERT_NO_THROW(
{
tracking->set_channel(gnss_synchro.Channel_ID);
}) << "Failure setting channel.";
})
<< "Failure setting channel.";
ASSERT_NO_THROW(
{
tracking->set_gnss_synchro(&gnss_synchro);
}) << "Failure setting gnss_synchro.";
})
<< "Failure setting gnss_synchro.";
ASSERT_NO_THROW(
{
tracking->connect(top_block);
}) << "Failure connecting tracking to the top_block.";
})
<< "Failure connecting tracking to the top_block.";
ASSERT_NO_THROW(
{
gr::blocks::null_sink::sptr sink = gr::blocks::null_sink::make(sizeof(Gnss_Synchro));
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"));
}) << "Failure connecting the blocks of tracking test.";
})
<< "Failure connecting the blocks of tracking test.";
tracking->start_tracking();
// assemble again the file name in a null terminated string (not available by default in the main program flow)
std::string file = "./" + filename_raw_data;
const char * file_name = file.c_str();
const char *file_name = file.c_str();
// start thread that sends the DMA samples to the FPGA
boost::thread t
{ thread, top_block, file_name };
boost::thread t{thread, top_block, file_name};
EXPECT_NO_THROW(
{
start = std::chrono::system_clock::now();
top_block->run(); // Start threads and wait
tracking->reset();// unlock the channel
tracking->reset(); // unlock the channel
end = std::chrono::system_clock::now();
elapsed_seconds = end - start;
}) << "Failure running the top_block.";
})
<< "Failure running the top_block.";
// wait until child thread terminates
t.join();
@ -572,7 +574,8 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
{
throw std::exception();
};
}) << "Failure opening tracking dump file";
})
<< "Failure opening tracking dump file";
nepoch = trk_dump.num_epochs();
std::cout << "Measured observation epochs=" << nepoch << std::endl;
@ -585,14 +588,11 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
epoch_counter = 0;
while (trk_dump.read_binary_obs())
{
trk_timestamp_s(epoch_counter) = static_cast<double>(trk_dump.PRN_start_sample_count)
/ static_cast<double>(baseband_sampling_freq);
trk_timestamp_s(epoch_counter) = static_cast<double>(trk_dump.PRN_start_sample_count) / static_cast<double>(baseband_sampling_freq);
trk_acc_carrier_phase_cycles(epoch_counter) = trk_dump.acc_carrier_phase_rad / GPS_TWO_PI;
trk_Doppler_Hz(epoch_counter) = trk_dump.carrier_doppler_hz;
double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS
* (fmod( (static_cast<double>(trk_dump.PRN_start_sample_count) + trk_dump.aux1)
/ static_cast<double>(baseband_sampling_freq), 1.0e-3) / 1.0e-3);
double delay_chips = GPS_L1_CA_CODE_LENGTH_CHIPS - GPS_L1_CA_CODE_LENGTH_CHIPS * (fmod((static_cast<double>(trk_dump.PRN_start_sample_count) + trk_dump.aux1) / static_cast<double>(baseband_sampling_freq), 1.0e-3) / 1.0e-3);
trk_prn_delay_chips(epoch_counter) = delay_chips;
epoch_counter++;
@ -600,7 +600,7 @@ TEST_F(GpsL1CADllPllTrackingTestFpga, ValidationOfResultsFpga)
//Align initial measurements and cut the tracking pull-in transitory
double pull_in_offset_s = 1.0;
arma::uvec initial_meas_point = arma::find( trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first");
arma::uvec initial_meas_point = arma::find(trk_timestamp_s >= (true_timestamp_s(0) + pull_in_offset_s), 1, "first");
trk_timestamp_s = trk_timestamp_s.subvec(initial_meas_point(0), trk_timestamp_s.size() - 1);
trk_acc_carrier_phase_cycles = trk_acc_carrier_phase_cycles.subvec(initial_meas_point(0), trk_acc_carrier_phase_cycles.size() - 1);