mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 07:13:03 +00:00 
			
		
		
		
	Do not use deletes. Improve memory management
This commit is contained in:
		| @@ -40,6 +40,7 @@ | ||||
| #include <boost/math/distributions/exponential.hpp> | ||||
| #include <glog/logging.h> | ||||
| #include <algorithm> | ||||
| #include <memory> | ||||
|  | ||||
|  | ||||
| BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( | ||||
| @@ -91,7 +92,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( | ||||
|             vector_length_ *= 2; | ||||
|         } | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "cshort") | ||||
|         { | ||||
| @@ -136,10 +137,7 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| BeidouB1iPcpsAcquisition::~BeidouB1iPcpsAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| BeidouB1iPcpsAcquisition::~BeidouB1iPcpsAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void BeidouB1iPcpsAcquisition::stop_acquisition() | ||||
| @@ -205,18 +203,17 @@ void BeidouB1iPcpsAcquisition::init() | ||||
|  | ||||
| void BeidouB1iPcpsAcquisition::set_local_code() | ||||
| { | ||||
|     auto* code = new std::complex<float>[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|     beidou_b1i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|  | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -42,7 +42,9 @@ | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <cstdint> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
|  | ||||
| class ConfigurationInterface; | ||||
| @@ -100,15 +102,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -159,7 +160,6 @@ public: | ||||
|      */ | ||||
|     void set_resampler_latency(uint32_t latency_samples) override; | ||||
|  | ||||
|  | ||||
| private: | ||||
|     ConfigurationInterface* configuration_; | ||||
|     pcps_acquisition_sptr acquisition_; | ||||
| @@ -183,12 +183,11 @@ private: | ||||
|     bool dump_; | ||||
|     bool blocking_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     uint32_t in_streams_; | ||||
|     uint32_t out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -91,7 +91,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( | ||||
|             vector_length_ *= 2; | ||||
|         } | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "cshort") | ||||
|         { | ||||
| @@ -136,10 +136,7 @@ BeidouB3iPcpsAcquisition::BeidouB3iPcpsAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| BeidouB3iPcpsAcquisition::~BeidouB3iPcpsAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| BeidouB3iPcpsAcquisition::~BeidouB3iPcpsAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void BeidouB3iPcpsAcquisition::stop_acquisition() | ||||
| @@ -205,18 +202,17 @@ void BeidouB3iPcpsAcquisition::init() | ||||
|  | ||||
| void BeidouB3iPcpsAcquisition::set_local_code() | ||||
| { | ||||
|     auto* code = new std::complex<float>[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|     beidou_b3i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|  | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -41,7 +41,9 @@ | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <cstdint> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
|  | ||||
| class ConfigurationInterface; | ||||
| @@ -99,15 +101,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -158,7 +159,6 @@ public: | ||||
|      */ | ||||
|     void set_resampler_latency(uint32_t latency_samples) override; | ||||
|  | ||||
|  | ||||
| private: | ||||
|     ConfigurationInterface* configuration_; | ||||
|     pcps_acquisition_sptr acquisition_; | ||||
| @@ -182,12 +182,11 @@ private: | ||||
|     bool dump_; | ||||
|     bool blocking_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -87,7 +87,7 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( | ||||
|  | ||||
|     int samples_per_ms = code_length_ / 4; | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
| @@ -123,10 +123,7 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE1Pcps8msAmbiguousAcquisition::~GalileoE1Pcps8msAmbiguousAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GalileoE1Pcps8msAmbiguousAcquisition::~GalileoE1Pcps8msAmbiguousAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE1Pcps8msAmbiguousAcquisition::stop_acquisition() | ||||
| @@ -217,22 +214,20 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_local_code() | ||||
|             bool cboc = configuration_->property( | ||||
|                 "Acquisition" + std::to_string(channel_) + ".cboc", false); | ||||
|  | ||||
|             auto* code = new std::complex<float>[code_length_]; | ||||
|             std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|             std::array<char, 3> Signal_; | ||||
|             std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3); | ||||
|  | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), Signal_, | ||||
|                 cboc, gnss_synchro_->PRN, fs_in_, 0, false); | ||||
|  | ||||
|             gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|             gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|             for (unsigned int i = 0; i < sampled_ms_ / 4; i++) | ||||
|                 { | ||||
|                     std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                     std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                 } | ||||
|  | ||||
|             acquisition_cc_->set_local_code(code_); | ||||
|  | ||||
|             delete[] code; | ||||
|             acquisition_cc_->set_local_code(code_.data()); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -245,6 +240,7 @@ void GalileoE1Pcps8msAmbiguousAcquisition::reset() | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| float GalileoE1Pcps8msAmbiguousAcquisition::calculate_threshold(float pfa) | ||||
| { | ||||
|     unsigned int frequency_bins = 0; | ||||
|   | ||||
| @@ -36,7 +36,9 @@ | ||||
| #include "galileo_pcps_8ms_acquisition_cc.h" | ||||
| #include "gnss_synchro.h" | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -165,7 +167,7 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|   | ||||
| @@ -127,7 +127,7 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( | ||||
|             vector_length_ *= 2; | ||||
|         } | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "cshort") | ||||
|         { | ||||
| @@ -167,16 +167,14 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE1PcpsAmbiguousAcquisition::~GalileoE1PcpsAmbiguousAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GalileoE1PcpsAmbiguousAcquisition::~GalileoE1PcpsAmbiguousAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsAmbiguousAcquisition::stop_acquisition() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsAmbiguousAcquisition::set_threshold(float threshold) | ||||
| { | ||||
|     float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); | ||||
| @@ -243,7 +241,8 @@ void GalileoE1PcpsAmbiguousAcquisition::set_local_code() | ||||
|     bool cboc = configuration_->property( | ||||
|         "Acquisition" + std::to_string(channel_) + ".cboc", false); | ||||
|  | ||||
|     auto* code = new std::complex<float>[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|     gsl::span<std::complex<float>> code_span(code.get(), code_length_); | ||||
|  | ||||
|     if (acquire_pilot_ == true) | ||||
|         { | ||||
| @@ -251,12 +250,12 @@ void GalileoE1PcpsAmbiguousAcquisition::set_local_code() | ||||
|             std::array<char, 3> pilot_signal = {{'1', 'C', '\0'}}; | ||||
|             if (acq_parameters_.use_automatic_resampler) | ||||
|                 { | ||||
|                     galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), pilot_signal, | ||||
|                     galileo_e1_code_gen_complex_sampled(code_span, pilot_signal, | ||||
|                         cboc, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0, false); | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), pilot_signal, | ||||
|                     galileo_e1_code_gen_complex_sampled(code_span, pilot_signal, | ||||
|                         cboc, gnss_synchro_->PRN, fs_in_, 0, false); | ||||
|                 } | ||||
|         } | ||||
| @@ -266,24 +265,23 @@ void GalileoE1PcpsAmbiguousAcquisition::set_local_code() | ||||
|             std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3); | ||||
|             if (acq_parameters_.use_automatic_resampler) | ||||
|                 { | ||||
|                     galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), Signal_, | ||||
|                     galileo_e1_code_gen_complex_sampled(code_span, Signal_, | ||||
|                         cboc, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0, false); | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), Signal_, | ||||
|                     galileo_e1_code_gen_complex_sampled(code_span, Signal_, | ||||
|                         cboc, gnss_synchro_->PRN, fs_in_, 0, false); | ||||
|                 } | ||||
|         } | ||||
|  | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code__span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < sampled_ms_ / 4; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code__span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -39,7 +39,9 @@ | ||||
| #include "pcps_acquisition.h" | ||||
| #include <gnuradio/blocks/float_to_complex.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
|  | ||||
| class ConfigurationInterface; | ||||
| @@ -98,13 +100,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -153,10 +156,8 @@ public: | ||||
|     /*! | ||||
|      * \brief Sets the resampler latency to account it in the acquisition code delay estimation | ||||
|      */ | ||||
|  | ||||
|     void set_resampler_latency(uint32_t latency_samples) override; | ||||
|  | ||||
|  | ||||
| private: | ||||
|     ConfigurationInterface* configuration_; | ||||
|     Acq_Conf acq_parameters_; | ||||
| @@ -181,7 +182,7 @@ private: | ||||
|     bool dump_; | ||||
|     bool blocking_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|   | ||||
| @@ -109,10 +109,11 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( | ||||
|     // compute all the GALILEO E1 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time | ||||
|     // a channel is assigned) | ||||
|     auto* fft_if = new gr::fft::fft_complex(nsamples_total, true);  // Direct FFT | ||||
|     auto* code = new std::complex<float>[nsamples_total];           // buffer for the local code | ||||
|     //auto code = std::make_shared<std::complex<float>>(nsamples_total);  // buffer for the local code | ||||
|     std::vector<std::complex<float>> code(nsamples_total); | ||||
|     auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); | ||||
|     d_all_fft_codes_ = new uint32_t[(nsamples_total * GALILEO_E1_NUMBER_OF_CODES)];  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     float max;                                                                       // temporary maxima search | ||||
|     d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * GALILEO_E1_NUMBER_OF_CODES);  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     float max;                                                                              // temporary maxima search | ||||
|     int32_t tmp, tmp2, local_code, fft_data; | ||||
|  | ||||
|     for (uint32_t PRN = 1; PRN <= GALILEO_E1_NUMBER_OF_CODES; PRN++) | ||||
| @@ -123,13 +124,13 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( | ||||
|                 { | ||||
|                     //set local signal generator to Galileo E1 pilot component (1C) | ||||
|                     std::array<char, 3> pilot_signal = {{'1', 'C', '\0'}}; | ||||
|                     galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, nsamples_total), pilot_signal, | ||||
|                     galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), pilot_signal, | ||||
|                         cboc, PRN, fs_in, 0, false); | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     std::array<char, 3> data_signal = {{'1', 'B', '\0'}}; | ||||
|                     galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, nsamples_total), data_signal, | ||||
|                     galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), data_signal, | ||||
|                         cboc, PRN, fs_in, 0, false); | ||||
|                 } | ||||
|  | ||||
| @@ -144,7 +145,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( | ||||
|                     code[s] = std::complex<float>(0.0, 0.0); | ||||
|                 } | ||||
|  | ||||
|             std::copy_n(code, nsamples_total, fft_if->get_inbuf());                            // copy to FFT buffer | ||||
|             std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf());                     // copy to FFT buffer | ||||
|             fft_if->execute();                                                                 // Run the FFT of local code | ||||
|             volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total);  // conjugate values | ||||
|  | ||||
| @@ -173,7 +174,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( | ||||
|                 } | ||||
|         } | ||||
|  | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_; | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_.data(); | ||||
|  | ||||
|     acq_parameters.num_doppler_bins_step2 = configuration_->property(role + ".second_nbins", 4); | ||||
|     acq_parameters.doppler_step2 = configuration_->property(role + ".second_doppler_step", 125.0); | ||||
| @@ -189,16 +190,12 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga( | ||||
|     gnss_synchro_ = nullptr; | ||||
|  | ||||
|     // temporary buffers that we can delete | ||||
|     delete[] code; | ||||
|     delete fft_if; | ||||
|     delete[] fft_codes_padded; | ||||
|     volk_gnsssdr_free(fft_codes_padded); | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE1PcpsAmbiguousAcquisitionFpga::~GalileoE1PcpsAmbiguousAcquisitionFpga() | ||||
| { | ||||
|     delete[] d_all_fft_codes_; | ||||
| } | ||||
| GalileoE1PcpsAmbiguousAcquisitionFpga::~GalileoE1PcpsAmbiguousAcquisitionFpga() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsAmbiguousAcquisitionFpga::stop_acquisition() | ||||
|   | ||||
| @@ -37,7 +37,9 @@ | ||||
| #include <gnuradio/runtime_types.h>  // for basic_block_sptr, top_block_sptr | ||||
| #include <volk/volk_complex.h>       // for lv_16sc_t | ||||
| #include <cstddef>                   // for size_t | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class Gnss_Synchro; | ||||
| class ConfigurationInterface; | ||||
| @@ -97,8 +99,8 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
| @@ -165,8 +167,7 @@ private: | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     uint32_t* d_all_fft_codes_;  // memory that contains all the code ffts | ||||
|     std::vector<uint32_t> d_all_fft_codes_;  // memory that contains all the code ffts | ||||
| }; | ||||
|  | ||||
| #endif /* GNSS_SDR_GALILEO_E1_PCPS_AMBIGUOUS_ACQUISITION_FPGA_H_ */ | ||||
|   | ||||
| @@ -86,8 +86,8 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition | ||||
|  | ||||
|     int samples_per_ms = code_length_ / 4; | ||||
|  | ||||
|     code_data_ = new gr_complex[vector_length_]; | ||||
|     code_pilot_ = new gr_complex[vector_length_]; | ||||
|     code_data_ = std::vector<std::complex<float>>(vector_length_); | ||||
|     code_pilot_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
| @@ -123,11 +123,7 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE1PcpsCccwsrAmbiguousAcquisition::~GalileoE1PcpsCccwsrAmbiguousAcquisition() | ||||
| { | ||||
|     delete[] code_data_; | ||||
|     delete[] code_pilot_; | ||||
| } | ||||
| GalileoE1PcpsCccwsrAmbiguousAcquisition::~GalileoE1PcpsCccwsrAmbiguousAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsCccwsrAmbiguousAcquisition::stop_acquisition() | ||||
| @@ -168,6 +164,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_doppler_step(unsigned int dopp | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_gnss_synchro( | ||||
|     Gnss_Synchro* gnss_synchro) | ||||
| { | ||||
| @@ -205,15 +202,15 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_local_code() | ||||
|  | ||||
|             std::array<char, 3> signal = {{'1', 'B', '\0'}}; | ||||
|  | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(code_data_, vector_length_), signal, | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(code_data_.data(), vector_length_), signal, | ||||
|                 cboc, gnss_synchro_->PRN, fs_in_, 0, false); | ||||
|  | ||||
|             std::array<char, 3> signal_C = {{'1', 'C', '\0'}}; | ||||
|  | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(code_pilot_, vector_length_), signal_C, | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<gr_complex>(code_pilot_.data(), vector_length_), signal_C, | ||||
|                 cboc, gnss_synchro_->PRN, fs_in_, 0, false); | ||||
|  | ||||
|             acquisition_cc_->set_local_code(code_data_, code_pilot_); | ||||
|             acquisition_cc_->set_local_code(code_data_.data(), code_pilot_.data()); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -226,6 +223,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisition::reset() | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsCccwsrAmbiguousAcquisition::set_state(int state) | ||||
| { | ||||
|     acquisition_cc_->set_state(state); | ||||
|   | ||||
| @@ -36,7 +36,9 @@ | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_cccwsr_acquisition_cc.h" | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -94,13 +96,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_cc_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of CCCWSR algorithm | ||||
|      */ | ||||
| @@ -153,7 +156,6 @@ private: | ||||
|     std::string item_type_; | ||||
|     unsigned int vector_length_; | ||||
|     unsigned int code_length_; | ||||
|     //unsigned int satellite_; | ||||
|     unsigned int channel_; | ||||
|     std::weak_ptr<ChannelFsm> channel_fsm_; | ||||
|     float threshold_; | ||||
| @@ -164,8 +166,8 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_data_; | ||||
|     std::complex<float>* code_pilot_; | ||||
|     std::vector<std::complex<float>> code_data_; | ||||
|     std::vector<std::complex<float>> code_pilot_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|   | ||||
| @@ -115,7 +115,7 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui | ||||
|     dump_filename_ = configuration_->property(role + ".dump_filename", | ||||
|         default_dump_filename); | ||||
|  | ||||
|     code_ = new gr_complex[code_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(code_length_); | ||||
|     LOG(INFO) << "Vector Length: " << vector_length_ | ||||
|               << ", Samples per ms: " << samples_per_ms | ||||
|               << ", Folding factor: " << folding_factor_ | ||||
| @@ -157,10 +157,7 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE1PcpsQuickSyncAmbiguousAcquisition::~GalileoE1PcpsQuickSyncAmbiguousAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GalileoE1PcpsQuickSyncAmbiguousAcquisition::~GalileoE1PcpsQuickSyncAmbiguousAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsQuickSyncAmbiguousAcquisition::stop_acquisition() | ||||
| @@ -251,23 +248,20 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_local_code() | ||||
|             bool cboc = configuration_->property( | ||||
|                 "Acquisition" + std::to_string(channel_) + ".cboc", false); | ||||
|  | ||||
|             auto* code = new std::complex<float>[code_length_]; | ||||
|             std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|             std::array<char, 3> Signal_; | ||||
|             std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3); | ||||
|  | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), Signal_, | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), Signal_, | ||||
|                 cboc, gnss_synchro_->PRN, fs_in_, 0, false); | ||||
|  | ||||
|             gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|             gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|             for (unsigned int i = 0; i < (sampled_ms_ / (folding_factor_ * 4)); i++) | ||||
|                 { | ||||
|                     std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                     std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                 } | ||||
|  | ||||
|             acquisition_cc_->set_local_code(code_); | ||||
|  | ||||
|             delete[] code; | ||||
|             code = nullptr; | ||||
|             acquisition_cc_->set_local_code(code_.data()); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -280,6 +274,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::reset() | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_state(int state) | ||||
| { | ||||
|     if (item_type_ == "gr_complex") | ||||
|   | ||||
| @@ -36,7 +36,9 @@ | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_quicksync_acquisition_cc.h" | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
|  | ||||
| class ConfigurationInterface; | ||||
| @@ -169,7 +171,7 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|   | ||||
| @@ -90,7 +90,7 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( | ||||
|  | ||||
|     int samples_per_ms = code_length_ / 4; | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
| @@ -127,10 +127,7 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE1PcpsTongAmbiguousAcquisition::~GalileoE1PcpsTongAmbiguousAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GalileoE1PcpsTongAmbiguousAcquisition::~GalileoE1PcpsTongAmbiguousAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsTongAmbiguousAcquisition::stop_acquisition() | ||||
| @@ -221,21 +218,19 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_local_code() | ||||
|             bool cboc = configuration_->property( | ||||
|                 "Acquisition" + std::to_string(channel_) + ".cboc", false); | ||||
|  | ||||
|             auto* code = new std::complex<float>[code_length_]; | ||||
|             std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|             std::array<char, 3> Signal_; | ||||
|             std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3); | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), Signal_, | ||||
|             galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), Signal_, | ||||
|                 cboc, gnss_synchro_->PRN, fs_in_, 0, false); | ||||
|  | ||||
|             gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|             gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|             for (unsigned int i = 0; i < sampled_ms_ / 4; i++) | ||||
|                 { | ||||
|                     std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                     std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                 } | ||||
|  | ||||
|             acquisition_cc_->set_local_code(code_); | ||||
|  | ||||
|             delete[] code; | ||||
|             acquisition_cc_->set_local_code(code_.data()); | ||||
|         } | ||||
| } | ||||
|  | ||||
| @@ -248,6 +243,7 @@ void GalileoE1PcpsTongAmbiguousAcquisition::reset() | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
| void GalileoE1PcpsTongAmbiguousAcquisition::set_state(int state) | ||||
| { | ||||
|     acquisition_cc_->set_state(state); | ||||
|   | ||||
| @@ -36,7 +36,9 @@ | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_tong_acquisition_cc.h" | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -168,7 +170,7 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|   | ||||
| @@ -94,8 +94,8 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( | ||||
|  | ||||
|     vector_length_ = code_length_ * sampled_ms_; | ||||
|  | ||||
|     codeI_ = new gr_complex[vector_length_]; | ||||
|     codeQ_ = new gr_complex[vector_length_]; | ||||
|     codeI_ = std::vector<std::complex<float>>(vector_length_); | ||||
|     codeQ_ = std::vector<std::complex<float>>(vector_length_); | ||||
|     both_signal_components = false; | ||||
|  | ||||
|     std::string sig_ = configuration_->property("Channel.signal", std::string("5X")); | ||||
| @@ -132,11 +132,7 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE5aNoncoherentIQAcquisitionCaf::~GalileoE5aNoncoherentIQAcquisitionCaf() | ||||
| { | ||||
|     delete[] codeI_; | ||||
|     delete[] codeQ_; | ||||
| } | ||||
| GalileoE5aNoncoherentIQAcquisitionCaf::~GalileoE5aNoncoherentIQAcquisitionCaf() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE5aNoncoherentIQAcquisitionCaf::stop_acquisition() | ||||
| @@ -224,53 +220,51 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_local_code() | ||||
| { | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
|             auto* codeI = new std::complex<float>[code_length_]; | ||||
|             auto* codeQ = new std::complex<float>[code_length_]; | ||||
|             std::vector<std::complex<float>> codeI(code_length_); | ||||
|             std::vector<std::complex<float>> codeQ(code_length_); | ||||
|  | ||||
|             if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X') | ||||
|                 { | ||||
|                     std::array<char, 3> a = {{'5', 'I', '\0'}}; | ||||
|                     galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeI, code_length_), a, | ||||
|                     galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeI.data(), code_length_), a, | ||||
|                         gnss_synchro_->PRN, fs_in_, 0); | ||||
|  | ||||
|                     std::array<char, 3> b = {{'5', 'Q', '\0'}}; | ||||
|                     galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeQ, code_length_), b, | ||||
|                     galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeQ.data(), code_length_), b, | ||||
|                         gnss_synchro_->PRN, fs_in_, 0); | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     std::array<char, 3> signal_type_ = {{'5', 'X', '\0'}}; | ||||
|                     galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeI, code_length_), signal_type_, | ||||
|                     galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(codeI.data(), code_length_), signal_type_, | ||||
|                         gnss_synchro_->PRN, fs_in_, 0); | ||||
|                 } | ||||
|             // WARNING: 3ms are coherently integrated. Secondary sequence (1,1,1) | ||||
|             // is generated, and modulated in the 'block'. | ||||
|             gsl::span<gr_complex> codeQ_span(codeQ_, vector_length_); | ||||
|             gsl::span<gr_complex> codeI_span(codeI_, vector_length_); | ||||
|             gsl::span<gr_complex> codeQ_span(codeQ_.data(), vector_length_); | ||||
|             gsl::span<gr_complex> codeI_span(codeI_.data(), vector_length_); | ||||
|             if (Zero_padding == 0)  // if no zero_padding | ||||
|                 { | ||||
|                     for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|                         { | ||||
|                             std::copy_n(codeI, code_length_, codeI_span.subspan(i * code_length_, code_length_).data()); | ||||
|                             std::copy_n(codeI.data(), code_length_, codeI_span.subspan(i * code_length_, code_length_).data()); | ||||
|                             if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X') | ||||
|                                 { | ||||
|                                     std::copy_n(codeQ, code_length_, codeQ_span.subspan(i * code_length_, code_length_).data()); | ||||
|                                     std::copy_n(codeQ.data(), code_length_, codeQ_span.subspan(i * code_length_, code_length_).data()); | ||||
|                                 } | ||||
|                         } | ||||
|                 } | ||||
|             else | ||||
|                 { | ||||
|                     // 1ms code + 1ms zero padding | ||||
|                     std::copy_n(codeI, code_length_, codeI_); | ||||
|                     std::copy_n(codeI.data(), code_length_, codeI_.data()); | ||||
|                     if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X') | ||||
|                         { | ||||
|                             std::copy_n(codeQ, code_length_, codeQ_); | ||||
|                             std::copy_n(codeQ.data(), code_length_, codeQ_.data()); | ||||
|                         } | ||||
|                 } | ||||
|  | ||||
|             acquisition_cc_->set_local_code(codeI_, codeQ_); | ||||
|             delete[] codeI; | ||||
|             delete[] codeQ; | ||||
|             acquisition_cc_->set_local_code(codeI_.data(), codeQ_.data()); | ||||
|         } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -41,7 +41,9 @@ | ||||
| #include "channel_fsm.h" | ||||
| #include "galileo_e5a_noncoherent_iq_acquisition_caf_cc.h" | ||||
| #include "gnss_synchro.h" | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -95,13 +97,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_cc_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -171,8 +174,8 @@ private: | ||||
|     std::string dump_filename_; | ||||
|     int Zero_padding; | ||||
|     int CAF_window_hz_; | ||||
|     std::complex<float>* codeI_; | ||||
|     std::complex<float>* codeQ_; | ||||
|     std::vector<std::complex<float>> codeI_; | ||||
|     std::vector<std::complex<float>> codeQ_; | ||||
|     bool both_signal_components; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|   | ||||
| @@ -124,7 +124,7 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con | ||||
|     code_length_ = static_cast<unsigned int>(std::round(static_cast<double>(fs_in_) / GALILEO_E5A_CODE_CHIP_RATE_HZ * static_cast<double>(GALILEO_E5A_CODE_LENGTH_CHIPS))); | ||||
|     vector_length_ = code_length_ * sampled_ms_; | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
| @@ -165,10 +165,7 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE5aPcpsAcquisition::~GalileoE5aPcpsAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GalileoE5aPcpsAcquisition::~GalileoE5aPcpsAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE5aPcpsAcquisition::stop_acquisition() | ||||
| @@ -236,7 +233,7 @@ void GalileoE5aPcpsAcquisition::init() | ||||
|  | ||||
| void GalileoE5aPcpsAcquisition::set_local_code() | ||||
| { | ||||
|     auto* code = new gr_complex[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|     std::array<char, 3> signal_; | ||||
|     signal_[0] = '5'; | ||||
|     signal_[2] = '\0'; | ||||
| @@ -256,20 +253,19 @@ void GalileoE5aPcpsAcquisition::set_local_code() | ||||
|  | ||||
|     if (acq_parameters_.use_automatic_resampler) | ||||
|         { | ||||
|             galileo_e5_a_code_gen_complex_sampled(gsl::span<gr_complex>(code, code_length_), signal_, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0); | ||||
|             galileo_e5_a_code_gen_complex_sampled(gsl::span<gr_complex>(code.get(), code_length_), signal_, gnss_synchro_->PRN, acq_parameters_.resampled_fs, 0); | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             galileo_e5_a_code_gen_complex_sampled(gsl::span<gr_complex>(code, code_length_), signal_, gnss_synchro_->PRN, fs_in_, 0); | ||||
|             galileo_e5_a_code_gen_complex_sampled(gsl::span<gr_complex>(code.get(), code_length_), signal_, gnss_synchro_->PRN, fs_in_, 0); | ||||
|         } | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -35,7 +35,9 @@ | ||||
| #include "channel_fsm.h" | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_acquisition.h" | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -86,13 +88,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -143,29 +146,23 @@ public: | ||||
|     /*! | ||||
|      * \brief Sets the resampler latency to account it in the acquisition code delay estimation | ||||
|      */ | ||||
|  | ||||
|     void set_resampler_latency(uint32_t latency_samples) override; | ||||
|  | ||||
| private: | ||||
|     float calculate_threshold(float pfa); | ||||
|  | ||||
|     ConfigurationInterface* configuration_; | ||||
|  | ||||
|     pcps_acquisition_sptr acquisition_; | ||||
|     Acq_Conf acq_parameters_; | ||||
|     size_t item_size_; | ||||
|  | ||||
|     std::string item_type_; | ||||
|     std::string dump_filename_; | ||||
|     std::string role_; | ||||
|  | ||||
|     bool bit_transition_flag_; | ||||
|     bool dump_; | ||||
|     bool acq_pilot_; | ||||
|     bool use_CFAR_; | ||||
|     bool blocking_; | ||||
|     bool acq_iq_; | ||||
|  | ||||
|     unsigned int vector_length_; | ||||
|     unsigned int code_length_; | ||||
|     unsigned int channel_; | ||||
| @@ -176,18 +173,10 @@ private: | ||||
|     unsigned int max_dwells_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     int64_t fs_in_; | ||||
|  | ||||
|     float threshold_; | ||||
|  | ||||
|     /* | ||||
|     std::complex<float>* codeI_; | ||||
|     std::complex<float>* codeQ_; | ||||
|     */ | ||||
|  | ||||
|     gr_complex* code_; | ||||
|  | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
| }; | ||||
|  | ||||
| #endif /* GALILEO_E5A_PCPS_ACQUISITION_H_ */ | ||||
|   | ||||
| @@ -110,9 +110,9 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf | ||||
|     // compute all the GALILEO E5 PRN Codes (this is done only once in the class constructor in order to avoid re-computing the PRN codes every time | ||||
|     // a channel is assigned) | ||||
|     auto* fft_if = new gr::fft::fft_complex(nsamples_total, true);  // Direct FFT | ||||
|     auto* code = new std::complex<float>[nsamples_total];           // buffer for the local code | ||||
|     std::vector<std::complex<float>> code(nsamples_total);          // buffer for the local code | ||||
|     auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); | ||||
|     d_all_fft_codes_ = new uint32_t[(nsamples_total * GALILEO_E5A_NUMBER_OF_CODES)];  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * GALILEO_E5A_NUMBER_OF_CODES);  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|  | ||||
|     float max;  // temporary maxima search | ||||
|     int32_t tmp, tmp2, local_code, fft_data; | ||||
| @@ -136,7 +136,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf | ||||
|                     signal_[1] = 'I'; | ||||
|                 } | ||||
|  | ||||
|             galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, nsamples_total), signal_, PRN, fs_in, 0); | ||||
|             galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), signal_, PRN, fs_in, 0); | ||||
|  | ||||
|             for (uint32_t s = code_length; s < 2 * code_length; s++) | ||||
|                 { | ||||
| @@ -149,7 +149,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf | ||||
|                     code[s] = std::complex<float>(0.0, 0.0); | ||||
|                 } | ||||
|  | ||||
|             std::copy_n(code, nsamples_total, fft_if->get_inbuf());                            // copy to FFT buffer | ||||
|             std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf());                     // copy to FFT buffer | ||||
|             fft_if->execute();                                                                 // Run the FFT of local code | ||||
|             volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total);  // conjugate values | ||||
|  | ||||
| @@ -177,7 +177,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf | ||||
|                 } | ||||
|         } | ||||
|  | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_; | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_.data(); | ||||
|  | ||||
|     // reference for the FPGA FFT-IFFT attenuation factor | ||||
|     acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 13); | ||||
| @@ -193,16 +193,12 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf | ||||
|     gnss_synchro_ = nullptr; | ||||
|  | ||||
|     // temporary buffers that we can delete | ||||
|     delete[] code; | ||||
|     delete fft_if; | ||||
|     delete[] fft_codes_padded; | ||||
|     volk_gnsssdr_free(fft_codes_padded); | ||||
| } | ||||
|  | ||||
|  | ||||
| GalileoE5aPcpsAcquisitionFpga::~GalileoE5aPcpsAcquisitionFpga() | ||||
| { | ||||
|     delete[] d_all_fft_codes_; | ||||
| } | ||||
| GalileoE5aPcpsAcquisitionFpga::~GalileoE5aPcpsAcquisitionFpga() = default; | ||||
|  | ||||
|  | ||||
| void GalileoE5aPcpsAcquisitionFpga::stop_acquisition() | ||||
|   | ||||
| @@ -39,7 +39,9 @@ | ||||
| #include <volk/volk_complex.h>       // for lv_16sc_t | ||||
| #include <cstddef>                   // for size_t | ||||
| #include <cstdint> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class Gnss_Synchro; | ||||
| class ConfigurationInterface; | ||||
| @@ -99,8 +101,8 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
| @@ -167,24 +169,19 @@ public: | ||||
| private: | ||||
|     ConfigurationInterface* configuration_; | ||||
|     pcps_acquisition_fpga_sptr acquisition_fpga_; | ||||
|  | ||||
|     std::string item_type_; | ||||
|     std::string dump_filename_; | ||||
|     std::string role_; | ||||
|  | ||||
|     bool acq_pilot_; | ||||
|     bool acq_iq_; | ||||
|  | ||||
|     uint32_t channel_; | ||||
|     std::weak_ptr<ChannelFsm> channel_fsm_; | ||||
|     uint32_t doppler_max_; | ||||
|     uint32_t doppler_step_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|  | ||||
|     uint32_t* d_all_fft_codes_;  // memory that contains all the code ffts | ||||
|     std::vector<uint32_t> d_all_fft_codes_;  // memory that contains all the code ffts | ||||
| }; | ||||
|  | ||||
| #endif /* GNSS_SDR_GALILEO_E5A_PCPS_ACQUISITION_FPGA_H_ */ | ||||
|   | ||||
| @@ -94,7 +94,7 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( | ||||
|             vector_length_ *= 2; | ||||
|         } | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "cshort") | ||||
|         { | ||||
| @@ -138,16 +138,14 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GlonassL1CaPcpsAcquisition::~GlonassL1CaPcpsAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GlonassL1CaPcpsAcquisition::~GlonassL1CaPcpsAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GlonassL1CaPcpsAcquisition::stop_acquisition() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void GlonassL1CaPcpsAcquisition::set_threshold(float threshold) | ||||
| { | ||||
|     float pfa = configuration_->property(role_ + ".pfa", 0.0); | ||||
| @@ -207,18 +205,17 @@ void GlonassL1CaPcpsAcquisition::init() | ||||
|  | ||||
| void GlonassL1CaPcpsAcquisition::set_local_code() | ||||
| { | ||||
|     auto* code = new std::complex<float>[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|     glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), /* gnss_synchro_->PRN,*/ fs_in_, 0); | ||||
|  | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -39,7 +39,9 @@ | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_acquisition.h" | ||||
| #include <gnuradio/blocks/float_to_complex.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -86,6 +88,7 @@ public: | ||||
|      *  tracking blocks | ||||
|      */ | ||||
|     void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set acquisition channel unique ID | ||||
|      */ | ||||
| @@ -96,13 +99,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -172,12 +176,11 @@ private: | ||||
|     bool dump_; | ||||
|     bool blocking_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -93,7 +93,7 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( | ||||
|             vector_length_ *= 2; | ||||
|         } | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "cshort") | ||||
|         { | ||||
| @@ -137,10 +137,7 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GlonassL2CaPcpsAcquisition::~GlonassL2CaPcpsAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GlonassL2CaPcpsAcquisition::~GlonassL2CaPcpsAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GlonassL2CaPcpsAcquisition::stop_acquisition() | ||||
| @@ -207,18 +204,17 @@ void GlonassL2CaPcpsAcquisition::init() | ||||
|  | ||||
| void GlonassL2CaPcpsAcquisition::set_local_code() | ||||
| { | ||||
|     auto* code = new std::complex<float>[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|     glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), /* gnss_synchro_->PRN,*/ fs_in_, 0); | ||||
|  | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -38,7 +38,9 @@ | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_acquisition.h" | ||||
| #include <gnuradio/blocks/float_to_complex.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -96,13 +98,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -172,12 +175,11 @@ private: | ||||
|     bool dump_; | ||||
|     bool blocking_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -123,7 +123,7 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( | ||||
|  | ||||
|     acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast<float>(GPS_L1_CA_CODE_PERIOD * 1000.0); | ||||
|     vector_length_ = std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2 : 1); | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "cshort") | ||||
|         { | ||||
| @@ -161,16 +161,14 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL1CaPcpsAcquisition::~GpsL1CaPcpsAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GpsL1CaPcpsAcquisition::~GpsL1CaPcpsAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsAcquisition::stop_acquisition() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsAcquisition::set_threshold(float threshold) | ||||
| { | ||||
|     float pfa = configuration_->property(role_ + ".pfa", 0.0); | ||||
| @@ -228,7 +226,7 @@ void GpsL1CaPcpsAcquisition::init() | ||||
|  | ||||
| void GpsL1CaPcpsAcquisition::set_local_code() | ||||
| { | ||||
|     auto* code = new std::complex<float>[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|     if (acq_parameters_.use_automatic_resampler) | ||||
|         { | ||||
| @@ -238,14 +236,13 @@ void GpsL1CaPcpsAcquisition::set_local_code() | ||||
|         { | ||||
|             gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|         } | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -43,7 +43,9 @@ | ||||
| #include "pcps_acquisition.h" | ||||
| #include <gnuradio/blocks/float_to_complex.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
|  | ||||
| class ConfigurationInterface; | ||||
| @@ -102,13 +104,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -157,10 +160,8 @@ public: | ||||
|     /*! | ||||
|      * \brief Sets the resampler latency to account it in the acquisition code delay estimation | ||||
|      */ | ||||
|  | ||||
|     void set_resampler_latency(uint32_t latency_samples) override; | ||||
|  | ||||
|  | ||||
| private: | ||||
|     ConfigurationInterface* configuration_; | ||||
|     pcps_acquisition_sptr acquisition_; | ||||
| @@ -184,12 +185,11 @@ private: | ||||
|     bool dump_; | ||||
|     bool blocking_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -80,7 +80,7 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler( | ||||
|     //--- Find number of samples per spreading code ------------------------- | ||||
|     vector_length_ = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); | ||||
|     acq_parameters.samples_per_ms = vector_length_; | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
| @@ -109,10 +109,7 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler( | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL1CaPcpsAcquisitionFineDoppler::~GpsL1CaPcpsAcquisitionFineDoppler() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GpsL1CaPcpsAcquisitionFineDoppler::~GpsL1CaPcpsAcquisitionFineDoppler() = default; | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsAcquisitionFineDoppler::stop_acquisition() | ||||
| @@ -163,8 +160,8 @@ void GpsL1CaPcpsAcquisitionFineDoppler::init() | ||||
|  | ||||
| void GpsL1CaPcpsAcquisitionFineDoppler::set_local_code() | ||||
| { | ||||
|     gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code_, vector_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|     acquisition_cc_->set_local_code(code_); | ||||
|     gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code_.data(), vector_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|     acquisition_cc_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -37,7 +37,9 @@ | ||||
| #include "channel_fsm.h" | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_acquisition_fine_doppler_cc.h" | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -95,13 +97,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_cc_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -161,7 +164,7 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|   | ||||
| @@ -105,15 +105,15 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( | ||||
|     // a channel is assigned) | ||||
|     auto* fft_if = new gr::fft::fft_complex(nsamples_total, true);  // Direct FFT | ||||
|     // allocate memory to compute all the PRNs and compute all the possible codes | ||||
|     auto* code = new std::complex<float>[nsamples_total];  // buffer for the local code | ||||
|     std::vector<std::complex<float>> code(nsamples_total);  // buffer for the local code | ||||
|     auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); | ||||
|     d_all_fft_codes_ = new uint32_t[(nsamples_total * NUM_PRNs)];  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs);  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     float max; | ||||
|     int32_t tmp, tmp2, local_code, fft_data; | ||||
|     // temporary maxima search | ||||
|     for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) | ||||
|         { | ||||
|             gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, nsamples_total), PRN, fs_in, 0);  // generate PRN code | ||||
|             gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), PRN, fs_in, 0);  // generate PRN code | ||||
|  | ||||
|             for (uint32_t s = code_length; s < 2 * code_length; s++) | ||||
|                 { | ||||
| @@ -126,7 +126,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( | ||||
|                     code[s] = std::complex<float>(0.0, 0.0); | ||||
|                 } | ||||
|  | ||||
|             std::copy_n(code, nsamples_total, fft_if->get_inbuf());                            // copy to FFT buffer | ||||
|             std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf());                     // copy to FFT buffer | ||||
|             fft_if->execute();                                                                 // Run the FFT of local code | ||||
|             volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total);  // conjugate values | ||||
|  | ||||
| @@ -155,7 +155,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( | ||||
|         } | ||||
|  | ||||
|     //acq_parameters | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_; | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_.data(); | ||||
|  | ||||
|     // reference for the FPGA FFT-IFFT attenuation factor | ||||
|     acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 10); | ||||
| @@ -171,16 +171,12 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga( | ||||
|     gnss_synchro_ = nullptr; | ||||
|  | ||||
|     // temporary buffers that we can delete | ||||
|     delete[] code; | ||||
|     delete fft_if; | ||||
|     delete[] fft_codes_padded; | ||||
|     volk_gnsssdr_free(fft_codes_padded); | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL1CaPcpsAcquisitionFpga::~GpsL1CaPcpsAcquisitionFpga() | ||||
| { | ||||
|     delete[] d_all_fft_codes_; | ||||
| } | ||||
| GpsL1CaPcpsAcquisitionFpga::~GpsL1CaPcpsAcquisitionFpga() = default; | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsAcquisitionFpga::stop_acquisition() | ||||
|   | ||||
| @@ -41,7 +41,9 @@ | ||||
| #include <gnuradio/runtime_types.h>  // for basic_block_sptr, top_block_sptr | ||||
| #include <volk/volk_complex.h>       // for lv_16sc_t | ||||
| #include <cstddef>                   // for size_t | ||||
| #include <string>                    // for string | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class Gnss_Synchro; | ||||
| class ConfigurationInterface; | ||||
| @@ -167,7 +169,7 @@ private: | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|     uint32_t* d_all_fft_codes_;  // memory that contains all the code ffts | ||||
|     std::vector<uint32_t> d_all_fft_codes_;  // memory that contains all the code ffts | ||||
| }; | ||||
|  | ||||
| #endif /* GNSS_SDR_GPS_L1_CA_PCPS_ACQUISITION_FPGA_H_ */ | ||||
|   | ||||
| @@ -70,7 +70,7 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( | ||||
|     //--- Find number of samples per spreading code ------------------------- | ||||
|     vector_length_ = round(fs_in_ / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::make_shared<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
| @@ -101,10 +101,7 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL1CaPcpsAssistedAcquisition::~GpsL1CaPcpsAssistedAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GpsL1CaPcpsAssistedAcquisition::~GpsL1CaPcpsAssistedAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsAssistedAcquisition::stop_acquisition() | ||||
| @@ -154,8 +151,8 @@ void GpsL1CaPcpsAssistedAcquisition::init() | ||||
|  | ||||
| void GpsL1CaPcpsAssistedAcquisition::set_local_code() | ||||
| { | ||||
|     gps_l1_ca_code_gen_complex_sampled(gsl::span<gr_complex>(code_, vector_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|     acquisition_cc_->set_local_code(code_); | ||||
|     gps_l1_ca_code_gen_complex_sampled(gsl::span<gr_complex>(code_.get(), vector_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|     acquisition_cc_->set_local_code(code_.get()); | ||||
| } | ||||
|  | ||||
| void GpsL1CaPcpsAssistedAcquisition::reset() | ||||
|   | ||||
| @@ -37,7 +37,9 @@ | ||||
| #include "channel_fsm.h" | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_assisted_acquisition_cc.h" | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -95,13 +97,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_cc_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -147,7 +150,6 @@ private: | ||||
|     size_t item_size_; | ||||
|     std::string item_type_; | ||||
|     unsigned int vector_length_; | ||||
|     //unsigned int satellite_; | ||||
|     unsigned int channel_; | ||||
|     std::weak_ptr<ChannelFsm> channel_fsm_; | ||||
|     float threshold_; | ||||
| @@ -159,7 +161,7 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::shared_ptr<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|   | ||||
| @@ -85,7 +85,7 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition( | ||||
|  | ||||
|     vector_length_ = code_length_ * sampled_ms_; | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
| @@ -121,16 +121,14 @@ GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL1CaPcpsOpenClAcquisition::~GpsL1CaPcpsOpenClAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GpsL1CaPcpsOpenClAcquisition::~GpsL1CaPcpsOpenClAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsOpenClAcquisition::stop_acquisition() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsOpenClAcquisition::set_threshold(float threshold) | ||||
| { | ||||
|     float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); | ||||
| @@ -211,19 +209,17 @@ void GpsL1CaPcpsOpenClAcquisition::set_local_code() | ||||
| { | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
|             auto* code = new std::complex<float>[code_length_]; | ||||
|             std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|             gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|  | ||||
|             gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|             gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|             for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|                 { | ||||
|                     std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                     std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                 } | ||||
|  | ||||
|             acquisition_cc_->set_local_code(code_); | ||||
|  | ||||
|             delete[] code; | ||||
|             acquisition_cc_->set_local_code(code_.data()); | ||||
|         } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -36,7 +36,9 @@ | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_opencl_acquisition_cc.h" | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -94,13 +96,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_cc_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -169,12 +172,11 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -105,7 +105,7 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( | ||||
|     dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); | ||||
|  | ||||
|     int samples_per_ms = round(code_length_); | ||||
|     code_ = new gr_complex[code_length_](); | ||||
|     code_ = std::vector<std::complex<float>>(code_length_); | ||||
|     /*Object relevant information for debugging*/ | ||||
|     LOG(INFO) << "Implementation: " << this->implementation() | ||||
|               << ", Vector Length: " << vector_length_ | ||||
| @@ -150,16 +150,14 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL1CaPcpsQuickSyncAcquisition::~GpsL1CaPcpsQuickSyncAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GpsL1CaPcpsQuickSyncAcquisition::~GpsL1CaPcpsQuickSyncAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsQuickSyncAcquisition::stop_acquisition() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsQuickSyncAcquisition::set_threshold(float threshold) | ||||
| { | ||||
|     float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); | ||||
| @@ -237,19 +235,17 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_local_code() | ||||
| { | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
|             auto* code = new std::complex<float>[code_length_](); | ||||
|             std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|             gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|  | ||||
|             gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|             gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|             for (unsigned int i = 0; i < (sampled_ms_ / folding_factor_); i++) | ||||
|                 { | ||||
|                     std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                     std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                 } | ||||
|  | ||||
|             acquisition_cc_->set_local_code(code_); | ||||
|  | ||||
|             delete[] code; | ||||
|             acquisition_cc_->set_local_code(code_.data()); | ||||
|         } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -38,7 +38,9 @@ | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_quicksync_acquisition_cc.h" | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -96,13 +98,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_cc_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -170,12 +173,11 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -76,7 +76,7 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( | ||||
|  | ||||
|     vector_length_ = code_length_ * sampled_ms_; | ||||
|  | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
| @@ -112,16 +112,14 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL1CaPcpsTongAcquisition::~GpsL1CaPcpsTongAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GpsL1CaPcpsTongAcquisition::~GpsL1CaPcpsTongAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsTongAcquisition::stop_acquisition() | ||||
| { | ||||
| } | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsTongAcquisition::set_threshold(float threshold) | ||||
| { | ||||
|     float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); | ||||
| @@ -194,23 +192,22 @@ void GpsL1CaPcpsTongAcquisition::init() | ||||
|     //set_local_code(); | ||||
| } | ||||
|  | ||||
|  | ||||
| void GpsL1CaPcpsTongAcquisition::set_local_code() | ||||
| { | ||||
|     if (item_type_ == "gr_complex") | ||||
|         { | ||||
|             auto* code = new std::complex<float>[code_length_]; | ||||
|             std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|             gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); | ||||
|  | ||||
|             gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|             gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|             for (unsigned int i = 0; i < sampled_ms_; i++) | ||||
|                 { | ||||
|                     std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                     std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|                 } | ||||
|  | ||||
|             acquisition_cc_->set_local_code(code_); | ||||
|  | ||||
|             delete[] code; | ||||
|             acquisition_cc_->set_local_code(code_.data()); | ||||
|         } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -37,7 +37,9 @@ | ||||
| #include "gnss_synchro.h" | ||||
| #include "pcps_tong_acquisition_cc.h" | ||||
| #include <gnuradio/blocks/stream_to_vector.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class ConfigurationInterface; | ||||
|  | ||||
| @@ -95,13 +97,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_cc_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of TONG algorithm | ||||
|      */ | ||||
| @@ -169,12 +172,11 @@ private: | ||||
|     int64_t fs_in_; | ||||
|     bool dump_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -127,7 +127,7 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( | ||||
|  | ||||
|     acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast<float>(GPS_L2_M_PERIOD * 1000.0); | ||||
|     vector_length_ = acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms * (acq_parameters_.bit_transition_flag ? 2 : 1); | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|  | ||||
|     if (item_type_ == "cshort") | ||||
|         { | ||||
| @@ -165,10 +165,7 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL2MPcpsAcquisition::~GpsL2MPcpsAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GpsL2MPcpsAcquisition::~GpsL2MPcpsAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GpsL2MPcpsAcquisition::stop_acquisition() | ||||
| @@ -240,25 +237,24 @@ void GpsL2MPcpsAcquisition::init() | ||||
|  | ||||
| void GpsL2MPcpsAcquisition::set_local_code() | ||||
| { | ||||
|     auto* code = new std::complex<float>[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|     if (acq_parameters_.use_automatic_resampler) | ||||
|         { | ||||
|             gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, acq_parameters_.resampled_fs); | ||||
|             gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), gnss_synchro_->PRN, acq_parameters_.resampled_fs); | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_); | ||||
|             gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), gnss_synchro_->PRN, fs_in_); | ||||
|         } | ||||
|  | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < num_codes_; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -40,7 +40,9 @@ | ||||
| #include "pcps_acquisition.h" | ||||
| #include <gnuradio/blocks/float_to_complex.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
|  | ||||
| class ConfigurationInterface; | ||||
| @@ -99,13 +101,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -154,10 +157,8 @@ public: | ||||
|     /*! | ||||
|      * \brief Sets the resampler latency to account it in the acquisition code delay estimation | ||||
|      */ | ||||
|  | ||||
|     void set_resampler_latency(uint32_t latency_samples) override; | ||||
|  | ||||
|  | ||||
| private: | ||||
|     ConfigurationInterface* configuration_; | ||||
|     pcps_acquisition_sptr acquisition_; | ||||
| @@ -180,13 +181,12 @@ private: | ||||
|     bool dump_; | ||||
|     bool blocking_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|     unsigned int num_codes_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -104,22 +104,21 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( | ||||
|     // a channel is assigned) | ||||
|     auto* fft_if = new gr::fft::fft_complex(vector_length, true);  // Direct FFT | ||||
|     // allocate memory to compute all the PRNs and compute all the possible codes | ||||
|     auto* code = new std::complex<float>[nsamples_total];  // buffer for the local code | ||||
|     std::vector<std::complex<float>> code(nsamples_total);  // buffer for the local code | ||||
|     auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); | ||||
|     //d_all_fft_codes_ = new lv_16sc_t[nsamples_total * NUM_PRNs];  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     d_all_fft_codes_ = new uint32_t[(nsamples_total * NUM_PRNs)];  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     float max;                                                     // temporary maxima search | ||||
|     d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs);  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     float max;                                                            // temporary maxima search | ||||
|     int32_t tmp, tmp2, local_code, fft_data; | ||||
|  | ||||
|     for (unsigned int PRN = 1; PRN <= NUM_PRNs; PRN++) | ||||
|         { | ||||
|             gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, nsamples_total), PRN, fs_in_); | ||||
|             gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.data(), nsamples_total), PRN, fs_in_); | ||||
|             // fill in zero padding | ||||
|             for (unsigned int s = code_length; s < nsamples_total; s++) | ||||
|                 { | ||||
|                     code[s] = std::complex<float>(0.0, 0.0); | ||||
|                 } | ||||
|             std::copy_n(code, nsamples_total, fft_if->get_inbuf());                            // copy to FFT buffer | ||||
|             std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf());                     // copy to FFT buffer | ||||
|             fft_if->execute();                                                                 // Run the FFT of local code | ||||
|             volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total);  // conjugate values | ||||
|             max = 0;                                                                           // initialize maximum value | ||||
| @@ -149,12 +148,11 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( | ||||
|                 } | ||||
|         } | ||||
|  | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_; | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_.data(); | ||||
|  | ||||
|     // temporary buffers that we can delete | ||||
|     delete[] code; | ||||
|     delete fft_if; | ||||
|     delete[] fft_codes_padded; | ||||
|     volk_gnsssdr_free(fft_codes_padded); | ||||
|  | ||||
|     acquisition_fpga_ = pcps_make_acquisition_fpga(acq_parameters); | ||||
|  | ||||
| @@ -162,15 +160,11 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga( | ||||
|     doppler_step_ = 0; | ||||
|     gnss_synchro_ = nullptr; | ||||
|  | ||||
|  | ||||
|     threshold_ = 0.0; | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL2MPcpsAcquisitionFpga::~GpsL2MPcpsAcquisitionFpga() | ||||
| { | ||||
|     delete[] d_all_fft_codes_; | ||||
| } | ||||
| GpsL2MPcpsAcquisitionFpga::~GpsL2MPcpsAcquisitionFpga() = default; | ||||
|  | ||||
|  | ||||
| void GpsL2MPcpsAcquisitionFpga::stop_acquisition() | ||||
|   | ||||
| @@ -39,7 +39,9 @@ | ||||
| #include <gnuradio/runtime_types.h>  // for basic_block_sptr, top_block_sptr | ||||
| #include <volk/volk_complex.h>       // for lv_16sc_t | ||||
| #include <cstddef>                   // for size_t | ||||
| #include <memory>                    // for weak_ptr | ||||
| #include <string>                    // for string | ||||
| #include <vector> | ||||
|  | ||||
| class Gnss_Synchro; | ||||
| class ConfigurationInterface; | ||||
| @@ -98,8 +100,8 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
| @@ -168,10 +170,7 @@ private: | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     uint32_t* d_all_fft_codes_;  // memory that contains all the code ffts | ||||
|  | ||||
|     //float calculate_threshold(float pfa); | ||||
|     std::vector<uint32_t> d_all_fft_codes_;  // memory that contains all the code ffts | ||||
| }; | ||||
|  | ||||
| #endif /* GNSS_SDR_GPS_L2_M_PCPS_ACQUISITION_FPGA_H_ */ | ||||
|   | ||||
| @@ -134,7 +134,7 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( | ||||
|  | ||||
|     acq_parameters_.samples_per_code = acq_parameters_.samples_per_ms * static_cast<float>(GPS_L5I_PERIOD * 1000.0); | ||||
|     vector_length_ = std::floor(acq_parameters_.sampled_ms * acq_parameters_.samples_per_ms) * (acq_parameters_.bit_transition_flag ? 2 : 1); | ||||
|     code_ = new gr_complex[vector_length_]; | ||||
|     code_ = std::vector<std::complex<float>>(vector_length_); | ||||
|     acquisition_ = pcps_make_acquisition(acq_parameters_); | ||||
|     DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; | ||||
|  | ||||
| @@ -160,10 +160,7 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL5iPcpsAcquisition::~GpsL5iPcpsAcquisition() | ||||
| { | ||||
|     delete[] code_; | ||||
| } | ||||
| GpsL5iPcpsAcquisition::~GpsL5iPcpsAcquisition() = default; | ||||
|  | ||||
|  | ||||
| void GpsL5iPcpsAcquisition::stop_acquisition() | ||||
| @@ -234,25 +231,24 @@ void GpsL5iPcpsAcquisition::init() | ||||
|  | ||||
| void GpsL5iPcpsAcquisition::set_local_code() | ||||
| { | ||||
|     auto* code = new std::complex<float>[code_length_]; | ||||
|     std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]}; | ||||
|  | ||||
|     if (acq_parameters_.use_automatic_resampler) | ||||
|         { | ||||
|             gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, acq_parameters_.resampled_fs); | ||||
|             gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), gnss_synchro_->PRN, acq_parameters_.resampled_fs); | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_); | ||||
|             gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), gnss_synchro_->PRN, fs_in_); | ||||
|         } | ||||
|  | ||||
|     gsl::span<gr_complex> code_span(code_, vector_length_); | ||||
|     gsl::span<gr_complex> code_span(code_.data(), vector_length_); | ||||
|     for (unsigned int i = 0; i < num_codes_; i++) | ||||
|         { | ||||
|             std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|             std::copy_n(code.get(), code_length_, code_span.subspan(i * code_length_, code_length_).data()); | ||||
|         } | ||||
|  | ||||
|     acquisition_->set_local_code(code_); | ||||
|     delete[] code; | ||||
|     acquisition_->set_local_code(code_.data()); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -261,6 +257,7 @@ void GpsL5iPcpsAcquisition::reset() | ||||
|     acquisition_->set_active(true); | ||||
| } | ||||
|  | ||||
|  | ||||
| void GpsL5iPcpsAcquisition::set_state(int state) | ||||
| { | ||||
|     acquisition_->set_state(state); | ||||
| @@ -360,6 +357,7 @@ gr::basic_block_sptr GpsL5iPcpsAcquisition::get_right_block() | ||||
|     return acquisition_; | ||||
| } | ||||
|  | ||||
|  | ||||
| void GpsL5iPcpsAcquisition::set_resampler_latency(uint32_t latency_samples) | ||||
| { | ||||
|     acquisition_->set_resampler_latency(latency_samples); | ||||
|   | ||||
| @@ -31,8 +31,8 @@ | ||||
|  * ------------------------------------------------------------------------- | ||||
|  */ | ||||
|  | ||||
| #ifndef GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_H_ | ||||
| #define GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_H_ | ||||
| #ifndef GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_H_ | ||||
| #define GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_H_ | ||||
|  | ||||
| #include "channel_fsm.h" | ||||
| #include "complex_byte_to_float_x2.h" | ||||
| @@ -40,7 +40,9 @@ | ||||
| #include "pcps_acquisition.h" | ||||
| #include <gnuradio/blocks/float_to_complex.h> | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
|  | ||||
| class ConfigurationInterface; | ||||
| @@ -99,13 +101,14 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
|         acquisition_->set_channel_fsm(channel_fsm); | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|      * \brief Set statistics threshold of PCPS algorithm | ||||
|      */ | ||||
| @@ -154,7 +157,6 @@ public: | ||||
|     /*! | ||||
|      * \brief Sets the resampler latency to account it in the acquisition code delay estimation | ||||
|      */ | ||||
|  | ||||
|     void set_resampler_latency(uint32_t latency_samples) override; | ||||
|  | ||||
| private: | ||||
| @@ -179,14 +181,13 @@ private: | ||||
|     bool dump_; | ||||
|     bool blocking_; | ||||
|     std::string dump_filename_; | ||||
|     std::complex<float>* code_; | ||||
|     std::vector<std::complex<float>> code_; | ||||
|     Gnss_Synchro* gnss_synchro_; | ||||
|     std::string role_; | ||||
|     unsigned int num_codes_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
| #endif /* GNSS_SDR_GPS_L5i_PCPS_ACQUISITION_H_ */ | ||||
| #endif /* GNSS_SDR_GPS_L5I_PCPS_ACQUISITION_H_ */ | ||||
|   | ||||
| @@ -109,16 +109,16 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( | ||||
|     // compute all the GPS L5 PRN Codes (this is done only once upon the class constructor in order to avoid re-computing the PRN codes every time | ||||
|     // a channel is assigned) | ||||
|     auto* fft_if = new gr::fft::fft_complex(nsamples_total, true);  // Direct FFT | ||||
|     auto* code = new gr_complex[nsamples_total]; | ||||
|     std::vector<std::complex<float>> code(nsamples_total); | ||||
|     auto* fft_codes_padded = static_cast<gr_complex*>(volk_gnsssdr_malloc(nsamples_total * sizeof(gr_complex), volk_gnsssdr_get_alignment())); | ||||
|     d_all_fft_codes_ = new uint32_t[(nsamples_total * NUM_PRNs)];  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|     d_all_fft_codes_ = std::vector<uint32_t>(nsamples_total * NUM_PRNs);  // memory containing all the possible fft codes for PRN 0 to 32 | ||||
|  | ||||
|     float max;  // temporary maxima search | ||||
|     int32_t tmp, tmp2, local_code, fft_data; | ||||
|  | ||||
|     for (uint32_t PRN = 1; PRN <= NUM_PRNs; PRN++) | ||||
|         { | ||||
|             gps_l5i_code_gen_complex_sampled(gsl::span<gr_complex>(code, nsamples_total), PRN, fs_in); | ||||
|             gps_l5i_code_gen_complex_sampled(gsl::span<gr_complex>(code.data(), nsamples_total), PRN, fs_in); | ||||
|  | ||||
|             for (uint32_t s = code_length; s < 2 * code_length; s++) | ||||
|                 { | ||||
| @@ -130,7 +130,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( | ||||
|                     // fill in zero padding | ||||
|                     code[s] = std::complex<float>(0.0, 0.0); | ||||
|                 } | ||||
|             std::copy_n(code, nsamples_total, fft_if->get_inbuf());                            // copy to FFT buffer | ||||
|             std::copy_n(code.data(), nsamples_total, fft_if->get_inbuf());                     // copy to FFT buffer | ||||
|             fft_if->execute();                                                                 // Run the FFT of local code | ||||
|             volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total);  // conjugate values | ||||
|  | ||||
| @@ -158,7 +158,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( | ||||
|                 } | ||||
|         } | ||||
|  | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_; | ||||
|     acq_parameters.all_fft_codes = d_all_fft_codes_.data(); | ||||
|  | ||||
|     // reference for the FPGA FFT-IFFT attenuation factor | ||||
|     acq_parameters.total_block_exp = configuration_->property(role + ".total_block_exp", 13); | ||||
| @@ -174,17 +174,12 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga( | ||||
|     gnss_synchro_ = nullptr; | ||||
|  | ||||
|     // temporary buffers that we can delete | ||||
|     delete[] code; | ||||
|     delete fft_if; | ||||
|     delete[] fft_codes_padded; | ||||
|     volk_gnsssdr_free(fft_codes_padded); | ||||
| } | ||||
|  | ||||
|  | ||||
| GpsL5iPcpsAcquisitionFpga::~GpsL5iPcpsAcquisitionFpga() | ||||
| { | ||||
|     //delete[] code_; | ||||
|     delete[] d_all_fft_codes_; | ||||
| } | ||||
| GpsL5iPcpsAcquisitionFpga::~GpsL5iPcpsAcquisitionFpga() = default; | ||||
|  | ||||
|  | ||||
| void GpsL5iPcpsAcquisitionFpga::stop_acquisition() | ||||
|   | ||||
| @@ -40,7 +40,9 @@ | ||||
| #include <gnuradio/runtime_types.h>  // for basic_block_sptr, top_block_sptr | ||||
| #include <volk/volk_complex.h>       // for lv_16sc_t | ||||
| #include <cstddef>                   // for size_t | ||||
| #include <memory> | ||||
| #include <string> | ||||
| #include <vector> | ||||
|  | ||||
| class Gnss_Synchro; | ||||
| class ConfigurationInterface; | ||||
| @@ -99,8 +101,8 @@ public: | ||||
|     } | ||||
|  | ||||
|     /*! | ||||
|       * \brief Set channel fsm associated to this acquisition instance | ||||
|       */ | ||||
|      * \brief Set channel fsm associated to this acquisition instance | ||||
|      */ | ||||
|     inline void set_channel_fsm(std::weak_ptr<ChannelFsm> channel_fsm) override | ||||
|     { | ||||
|         channel_fsm_ = channel_fsm; | ||||
| @@ -167,9 +169,7 @@ private: | ||||
|     std::string role_; | ||||
|     unsigned int in_streams_; | ||||
|     unsigned int out_streams_; | ||||
|  | ||||
|     uint32_t* d_all_fft_codes_;  // memory that contains all the code ffts | ||||
|  | ||||
|     std::vector<uint32_t> d_all_fft_codes_;  // memory that contains all the code ffts | ||||
|     float calculate_threshold(float pfa); | ||||
| }; | ||||
|  | ||||
|   | ||||
| @@ -34,6 +34,7 @@ | ||||
| #include "Galileo_E1.h" | ||||
| #include "gnss_signal_processing.h" | ||||
| #include <volk_gnsssdr/volk_gnsssdr.h> | ||||
| #include <memory> | ||||
| #include <string> | ||||
|  | ||||
|  | ||||
| @@ -171,10 +172,8 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array< | ||||
|  | ||||
|     galileo_e1_code_gen_int(gsl::span<int32_t>(primary_code_E1_chips, static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)), _Signal, _prn);  // generate Galileo E1 code, 1 sample per chip | ||||
|  | ||||
|     float* _signal_E1; | ||||
|  | ||||
|     _codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS; | ||||
|     _signal_E1 = new float[_codeLength]; | ||||
|     std::unique_ptr<float> _signal_E1{new float[_codeLength]}; | ||||
|     gsl::span<float> _signal_E1_span(_signal_E1, _codeLength); | ||||
|  | ||||
|     if (_cboc == true) | ||||
| @@ -196,12 +195,11 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array< | ||||
|  | ||||
|     if (_fs != _samplesPerChip * _codeFreqBasis) | ||||
|         { | ||||
|             auto* _resampled_signal = new float[_samplesPerCode]; | ||||
|             std::unique_ptr<float> _resampled_signal{new float[_samplesPerCode]}; | ||||
|  | ||||
|             resampler(gsl::span<float>(_signal_E1, _codeLength), gsl::span<float>(_resampled_signal, _samplesPerCode), _samplesPerChip * _codeFreqBasis, _fs);  // resamples code to fs | ||||
|  | ||||
|             delete[] _signal_E1; | ||||
|             _signal_E1 = _resampled_signal; | ||||
|             _signal_E1 = std::move(_resampled_signal); | ||||
|         } | ||||
|     uint32_t size_signal_E1 = _codeLength; | ||||
|     if (_fs != _samplesPerChip * _codeFreqBasis) | ||||
| @@ -211,7 +209,7 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array< | ||||
|     gsl::span<float> _signal_E1_span_aux(_signal_E1, size_signal_E1); | ||||
|     if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) | ||||
|         { | ||||
|             auto* _signal_E1C_secondary = new float[static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode]; | ||||
|             std::unique_ptr<float> _signal_E1C_secondary{new float[static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode]}; | ||||
|             gsl::span<float> _signal_E1C_secondary_span(_signal_E1C_secondary, static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode); | ||||
|             for (uint32_t i = 0; i < static_cast<uint32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH); i++) | ||||
|                 { | ||||
| @@ -223,8 +221,7 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array< | ||||
|  | ||||
|             _samplesPerCode *= static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH); | ||||
|  | ||||
|             delete[] _signal_E1; | ||||
|             _signal_E1 = _signal_E1C_secondary_span.data(); | ||||
|             _signal_E1 = std::move(_signal_E1C_secondary); | ||||
|         } | ||||
|     if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) | ||||
|         { | ||||
| @@ -236,7 +233,6 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array< | ||||
|             _dest[(i + delay) % _samplesPerCode] = _signal_E1_span_aux2[i]; | ||||
|         } | ||||
|  | ||||
|     delete[] _signal_E1; | ||||
|     volk_gnsssdr_free(primary_code_E1_chips); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -35,6 +35,7 @@ | ||||
| #include "Galileo_E5a.h" | ||||
| #include "gnss_signal_processing.h" | ||||
| #include <gnuradio/gr_complex.h> | ||||
| #include <memory> | ||||
|  | ||||
|  | ||||
| void galileo_e5_a_code_gen_complex_primary(gsl::span<std::complex<float>> _dest, int32_t _prn, const std::array<char, 3>& _Signal) | ||||
| @@ -108,7 +109,7 @@ void galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, | ||||
|     const uint32_t _codeLength = GALILEO_E5A_CODE_LENGTH_CHIPS; | ||||
|     const int32_t _codeFreqBasis = GALILEO_E5A_CODE_CHIP_RATE_HZ; | ||||
|  | ||||
|     auto* _code = new std::complex<float>[_codeLength](); | ||||
|     std::unique_ptr<std::complex<float>> _code{new std::complex<float>[_codeLength]}; | ||||
|     gsl::span<std::complex<float>> _code_span(_code, _codeLength); | ||||
|     galileo_e5_a_code_gen_complex_primary(_code_span, _prn, _Signal); | ||||
|  | ||||
| @@ -118,13 +119,9 @@ void galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, | ||||
|  | ||||
|     if (_fs != _codeFreqBasis) | ||||
|         { | ||||
|             std::complex<float>* _resampled_signal; | ||||
|             if (posix_memalign(reinterpret_cast<void**>(&_resampled_signal), 16, _samplesPerCode * sizeof(gr_complex)) == 0) | ||||
|                 { | ||||
|                 }; | ||||
|             std::unique_ptr<std::complex<float>> _resampled_signal{new std::complex<float>[_samplesPerCode]}; | ||||
|             resampler(_code_span, gsl::span<std::complex<float>>(_resampled_signal, _samplesPerCode), _codeFreqBasis, _fs);  // resamples code to fs | ||||
|             delete[] _code; | ||||
|             _code = _resampled_signal; | ||||
|             _code = std::move(_resampled_signal); | ||||
|         } | ||||
|     uint32_t size_code = _codeLength; | ||||
|     if (_fs != _codeFreqBasis) | ||||
| @@ -136,12 +133,4 @@ void galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, | ||||
|         { | ||||
|             _dest[(i + delay) % _samplesPerCode] = _code_span_aux[i]; | ||||
|         } | ||||
|     if (_fs != _codeFreqBasis) | ||||
|         { | ||||
|             free(_code); | ||||
|         } | ||||
|     else | ||||
|         { | ||||
|             delete[] _code; | ||||
|         } | ||||
| } | ||||
|   | ||||
| @@ -33,6 +33,7 @@ | ||||
| #include "gps_l2c_signal.h" | ||||
| #include "GPS_L2C.h" | ||||
| #include <cmath> | ||||
| #include <memory> | ||||
|  | ||||
|  | ||||
| int32_t gps_l2c_m_shift(int32_t x) | ||||
| @@ -55,7 +56,7 @@ void gps_l2c_m_code(gsl::span<int32_t> _dest, uint32_t _prn) | ||||
|  | ||||
| void gps_l2c_m_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -66,14 +67,12 @@ void gps_l2c_m_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _ | ||||
|         { | ||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0); | ||||
|         } | ||||
|  | ||||
|     delete[] _code; | ||||
| } | ||||
|  | ||||
|  | ||||
| void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -84,8 +83,6 @@ void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|         { | ||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]); | ||||
|         } | ||||
|  | ||||
|     delete[] _code; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -94,7 +91,7 @@ void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|  */ | ||||
| void gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -131,5 +128,4 @@ void gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, ui | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0);  //repeat the chip -> upsample | ||||
|                 } | ||||
|         } | ||||
|     delete[] _code; | ||||
| } | ||||
|   | ||||
| @@ -173,7 +173,7 @@ void make_l5q(gsl::span<int32_t> _dest, int32_t prn) | ||||
|  | ||||
| void gps_l5i_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -184,14 +184,12 @@ void gps_l5i_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _pr | ||||
|         { | ||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0); | ||||
|         } | ||||
|  | ||||
|     delete[] _code; | ||||
| } | ||||
|  | ||||
|  | ||||
| void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -202,8 +200,6 @@ void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|         { | ||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]); | ||||
|         } | ||||
|  | ||||
|     delete[] _code; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -212,7 +208,7 @@ void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|  */ | ||||
| void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -249,13 +245,12 @@ void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0.0);  // repeat the chip -> upsample | ||||
|                 } | ||||
|         } | ||||
|     delete[] _code; | ||||
| } | ||||
|  | ||||
|  | ||||
| void gps_l5q_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -266,14 +261,12 @@ void gps_l5q_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _pr | ||||
|         { | ||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0); | ||||
|         } | ||||
|  | ||||
|     delete[] _code; | ||||
| } | ||||
|  | ||||
|  | ||||
| void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -284,8 +277,6 @@ void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|         { | ||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]); | ||||
|         } | ||||
|  | ||||
|     delete[] _code; | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -294,7 +285,7 @@ void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||
|  */ | ||||
| void gps_l5q_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||
| { | ||||
|     auto* _code = new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]; | ||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; | ||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); | ||||
|     if (_prn > 0 and _prn < 51) | ||||
|         { | ||||
| @@ -332,5 +323,4 @@ void gps_l5q_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint | ||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0);  // repeat the chip -> upsample | ||||
|                 } | ||||
|         } | ||||
|     delete[] _code; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez