From 90ac5938dcb2fc9bb550d6938985d16e48c71aeb Mon Sep 17 00:00:00 2001 From: mmajoral Date: Wed, 24 May 2017 10:03:58 +0200 Subject: [PATCH] all the class elements are initialized in the constructor --- .../libs/gps_fpga_acquisition_8sc.cc | 1 + .../tracking/libs/fpga_multicorrelator_8sc.cc | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc index 1b0453288..fcc6c1c43 100644 --- a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc +++ b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc @@ -102,6 +102,7 @@ gps_fpga_acquisition_8sc::gps_fpga_acquisition_8sc(std::string device_name, unsi d_nsamples = nsamples; // number of samples not including padding d_select_queue = select_queue; + d_doppler_max = 0; d_doppler_step = 0; d_fd = 0; // driver descriptor d_map_base = nullptr; // driver memory map diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc b/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc index bcc77d0e6..0b9dde66d 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc @@ -154,6 +154,8 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators, std::strin d_n_correlators = n_correlators; d_device_name = device_name; d_device_base = device_base; + d_fd = 0; + d_map_base = nullptr; // instantiate variable length vectors d_initial_index = static_cast(volk_gnsssdr_malloc(n_correlators * sizeof(unsigned), volk_gnsssdr_get_alignment())); @@ -163,9 +165,18 @@ fpga_multicorrelator_8sc::fpga_multicorrelator_8sc(int n_correlators, std::strin d_shifts_chips = nullptr; d_corr_out = nullptr; d_code_length_chips = 0; + d_rem_code_phase_chips = 0; + d_code_phase_step_chips = 0; + d_rem_carrier_phase_in_rad = 0; + d_phase_step_rad = 0; + d_rem_carr_phase_rad_int = 0; + d_phase_step_rad_int = 0; + d_initial_sample_counter = 0; d_ena_write_signals = new unsigned[d_n_correlators]; + d_channel = 0; + d_correlator_length_samples = 0; } @@ -201,6 +212,8 @@ bool fpga_multicorrelator_8sc::free() void fpga_multicorrelator_8sc::set_channel(unsigned int channel) { + char device_io_name[MAX_LENGTH_DEVICEIO_NAME]; // driver io name + d_channel = channel; // open the device corresponding to the assigned channel @@ -210,11 +223,11 @@ void fpga_multicorrelator_8sc::set_channel(unsigned int channel) int numdevice = d_device_base + d_channel; devicebasetemp << numdevice; mergedname = d_device_name + devicebasetemp.str(); - strcpy(d_device_io_name, mergedname.c_str()); - printf("Opening Device Name : %s\n", d_device_io_name); - if ((d_fd = open(d_device_io_name, O_RDWR | O_SYNC )) == -1) + strcpy(device_io_name, mergedname.c_str()); + printf("Opening Device Name : %s\n", device_io_name); + if ((d_fd = open(device_io_name, O_RDWR | O_SYNC )) == -1) { - LOG(WARNING) << "Cannot open deviceio" << d_device_io_name; + LOG(WARNING) << "Cannot open deviceio" << device_io_name; } d_map_base = (volatile unsigned *)mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, d_fd,0);