1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-30 19:04:51 +00:00

Avoid null dereference

This commit is contained in:
Carles Fernandez 2018-05-19 20:50:48 +02:00
parent 2b7ccc11b9
commit ba6968bfe0
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -281,7 +281,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_correlator_outs = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_local_code_shift_chips = static_cast<float *>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); d_local_code_shift_chips = static_cast<float *>(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)); clear_tracking_vars();
// map memory pointers of correlator outputs // map memory pointers of correlator outputs
if (d_veml) if (d_veml)
@ -328,7 +328,6 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
{ {
// Extra correlator for the data component // Extra correlator for the data component
correlator_data_cpu.init(2 * trk_parameters.vector_length, 1); correlator_data_cpu.init(2 * trk_parameters.vector_length, 1);
d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_Prompt_Data[0] = gr_complex(0.0, 0.0); d_Prompt_Data[0] = gr_complex(0.0, 0.0);
d_data_code = static_cast<float *>(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); d_data_code = static_cast<float *>(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment()));
} }
@ -338,7 +337,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
d_data_code = nullptr; d_data_code = nullptr;
} }
//--- Initializations ---// // --- Initializations ---
// Initial code frequency basis of NCO // Initial code frequency basis of NCO
d_code_freq_chips = d_code_chip_rate; d_code_freq_chips = d_code_chip_rate;
// Residual code phase (in chips) // Residual code phase (in chips)
@ -360,8 +359,6 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
d_carrier_lock_fail_counter = 0; d_carrier_lock_fail_counter = 0;
d_carrier_lock_threshold = trk_parameters.carrier_lock_th; d_carrier_lock_threshold = trk_parameters.carrier_lock_th;
clear_tracking_vars();
d_acquisition_gnss_synchro = nullptr; d_acquisition_gnss_synchro = nullptr;
d_channel = 0; d_channel = 0;
d_acq_code_phase_samples = 0.0; d_acq_code_phase_samples = 0.0;
@ -383,9 +380,8 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(dllpllconf_t conf_) : gr::block("dl
void dll_pll_veml_tracking::start_tracking() void dll_pll_veml_tracking::start_tracking()
{ {
gr::thread::scoped_lock l(d_setlock); gr::thread::scoped_lock l(d_setlock);
/*
* correct the code phase according to the delay between acq and trk // 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_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples;
d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz;
d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples;
@ -396,7 +392,7 @@ void dll_pll_veml_tracking::start_tracking()
DLOG(INFO) << "Number of seconds between Acquisition and Tracking = " << acq_trk_diff_seconds; DLOG(INFO) << "Number of seconds between Acquisition and Tracking = " << acq_trk_diff_seconds;
// Doppler effect Fd = (C / (C + Vr)) * F // Doppler effect Fd = (C / (C + Vr)) * F
double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; 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 // new chip and PRN sequence periods based on acq Doppler
d_code_freq_chips = radial_velocity * d_code_chip_rate; 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_step_chips = d_code_freq_chips / trk_parameters.fs_in;
double T_chip_mod_seconds = 1.0 / d_code_freq_chips; double T_chip_mod_seconds = 1.0 / d_code_freq_chips;
@ -566,7 +562,6 @@ dll_pll_veml_tracking::~dll_pll_veml_tracking()
volk_gnsssdr_free(d_tracking_code); volk_gnsssdr_free(d_tracking_code);
if (trk_parameters.track_pilot) if (trk_parameters.track_pilot)
{ {
volk_gnsssdr_free(d_Prompt_Data);
volk_gnsssdr_free(d_data_code); volk_gnsssdr_free(d_data_code);
correlator_data_cpu.free(); correlator_data_cpu.free();
} }
@ -735,7 +730,7 @@ void dll_pll_veml_tracking::run_dll_pll()
void dll_pll_veml_tracking::clear_tracking_vars() void dll_pll_veml_tracking::clear_tracking_vars()
{ {
std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); 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_hz = 0.0;
d_carr_error_filt_hz = 0.0; d_carr_error_filt_hz = 0.0;
d_code_error_chips = 0.0; d_code_error_chips = 0.0;