1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-01-07 07:50:32 +00:00

Replace memcpy by copy_n. Avoid pointer arithmetics

This commit is contained in:
Carles Fernandez 2019-06-29 11:58:08 +02:00
parent c79b360fa7
commit dd53f81b1a
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
21 changed files with 75 additions and 65 deletions

View File

@ -39,6 +39,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition(
@ -208,10 +209,10 @@ void BeidouB1iPcpsAcquisition::set_local_code()
beidou_b1i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); beidou_b1i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0);
for (uint32_t i = 0; i < sampled_ms_; i++) gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -37,7 +37,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
using google::LogMessage; using google::LogMessage;
@ -206,10 +206,10 @@ void BeidouB3iPcpsAcquisition::set_local_code()
beidou_b3i_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); 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_);
for (unsigned int i = 0; i < sampled_ms_; i++) for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -36,6 +36,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition(
@ -223,10 +224,10 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_local_code()
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, code_length_), Signal_,
cboc, gnss_synchro_->PRN, fs_in_, 0, false); cboc, gnss_synchro_->PRN, fs_in_, 0, false);
gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < sampled_ms_ / 4; i++) for (unsigned int i = 0; i < sampled_ms_ / 4; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_cc_->set_local_code(code_); acquisition_cc_->set_local_code(code_);

View File

@ -37,6 +37,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition(
@ -275,10 +276,10 @@ void GalileoE1PcpsAmbiguousAcquisition::set_local_code()
} }
} }
gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < sampled_ms_ / 4; i++) for (unsigned int i = 0; i < sampled_ms_ / 4; i++)
{ {
memcpy(&(code_[i * code_length_]), code, sizeof(gr_complex) * code_length_); std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -40,9 +40,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex #include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc #include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h> #include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor #include <cmath> // for abs, pow, floor
#include <complex> // for complex #include <complex> // for complex
#include <cstring> // for memcpy
// the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA
// expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking.
@ -144,7 +144,7 @@ GalileoE1PcpsAmbiguousAcquisitionFpga::GalileoE1PcpsAmbiguousAcquisitionFpga(
code[s] = std::complex<float>(0.0, 0.0); code[s] = std::complex<float>(0.0, 0.0);
} }
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer std::copy_n(code, nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values

View File

@ -36,6 +36,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcquisition( GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcquisition(
@ -257,14 +258,12 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_local_code()
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, code_length_), Signal_,
cboc, gnss_synchro_->PRN, fs_in_, 0, false); cboc, gnss_synchro_->PRN, fs_in_, 0, false);
gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < (sampled_ms_ / (folding_factor_ * 4)); i++) for (unsigned int i = 0; i < (sampled_ms_ / (folding_factor_ * 4)); i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
// memcpy(code_, code,sizeof(gr_complex)*code_length_);
acquisition_cc_->set_local_code(code_); acquisition_cc_->set_local_code(code_);
delete[] code; delete[] code;

View File

@ -36,6 +36,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition(
@ -226,10 +227,10 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_local_code()
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, code_length_), Signal_,
cboc, gnss_synchro_->PRN, fs_in_, 0, false); cboc, gnss_synchro_->PRN, fs_in_, 0, false);
gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < sampled_ms_ / 4; i++) for (unsigned int i = 0; i < sampled_ms_ / 4; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_cc_->set_local_code(code_); acquisition_cc_->set_local_code(code_);

View File

@ -42,6 +42,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf(
@ -244,28 +245,26 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_local_code()
} }
// WARNING: 3ms are coherently integrated. Secondary sequence (1,1,1) // WARNING: 3ms are coherently integrated. Secondary sequence (1,1,1)
// is generated, and modulated in the 'block'. // 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_);
if (Zero_padding == 0) // if no zero_padding if (Zero_padding == 0) // if no zero_padding
{ {
for (unsigned int i = 0; i < sampled_ms_; i++) for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(codeI_[i * code_length_]), codeI, std::copy_n(codeI, code_length_, codeI_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X') if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X')
{ {
memcpy(&(codeQ_[i * code_length_]), codeQ, std::copy_n(codeQ, code_length_, codeQ_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
} }
} }
else else
{ {
// 1ms code + 1ms zero padding // 1ms code + 1ms zero padding
memcpy(&(codeI_[0]), codeI, std::copy_n(codeI, code_length_, codeI_);
sizeof(gr_complex) * code_length_);
if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X') if (gnss_synchro_->Signal[0] == '5' && gnss_synchro_->Signal[1] == 'X')
{ {
memcpy(&(codeQ_[0]), codeQ, std::copy_n(codeQ, code_length_, codeQ_);
sizeof(gr_complex) * code_length_);
} }
} }

View File

@ -37,6 +37,7 @@
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <volk_gnsssdr/volk_gnsssdr_complex.h> #include <volk_gnsssdr/volk_gnsssdr_complex.h>
#include <algorithm>
GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* configuration, GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* configuration,
@ -261,10 +262,10 @@ void GalileoE5aPcpsAcquisition::set_local_code()
{ {
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, code_length_), signal_, gnss_synchro_->PRN, fs_in_, 0);
} }
gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++) for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(code_ + (i * code_length_), code, sizeof(gr_complex) * code_length_); std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -40,9 +40,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex #include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc #include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h> #include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor #include <cmath> // for abs, pow, floor
#include <complex> // for complex #include <complex> // for complex
#include <cstring> // for strcpy, memcpy
// the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA // the following flags are FPGA-specific and they are using arrange the values of the fft of the local code in the way the FPGA
// expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking. // expects. This arrangement is done in the initialisation to avoid consuming unnecessary clock cycles during tracking.
@ -149,7 +149,7 @@ GalileoE5aPcpsAcquisitionFpga::GalileoE5aPcpsAcquisitionFpga(ConfigurationInterf
code[s] = std::complex<float>(0.0, 0.0); code[s] = std::complex<float>(0.0, 0.0);
} }
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer std::copy_n(code, nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values

View File

@ -39,6 +39,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition(
@ -210,10 +211,10 @@ void GlonassL1CaPcpsAcquisition::set_local_code()
glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), /* gnss_synchro_->PRN,*/ fs_in_, 0); 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_);
for (unsigned int i = 0; i < sampled_ms_; i++) for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -38,6 +38,7 @@
#include "gnss_sdr_flags.h" #include "gnss_sdr_flags.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition(
@ -210,10 +211,10 @@ void GlonassL2CaPcpsAcquisition::set_local_code()
glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), /* gnss_synchro_->PRN,*/ fs_in_, 0); 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_);
for (unsigned int i = 0; i < sampled_ms_; i++) for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -41,6 +41,7 @@
#include "gps_sdr_signal_processing.h" #include "gps_sdr_signal_processing.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
#include <gsl/gsl> #include <gsl/gsl>
@ -237,10 +238,10 @@ 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); 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_);
for (unsigned int i = 0; i < sampled_ms_; i++) for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -43,9 +43,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex #include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc #include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h> #include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor #include <cmath> // for abs, pow, floor
#include <complex> // for complex #include <complex> // for complex
#include <cstring> // for memcpy
#define NUM_PRNs 32 #define NUM_PRNs 32
@ -126,7 +126,7 @@ GpsL1CaPcpsAcquisitionFpga::GpsL1CaPcpsAcquisitionFpga(
code[s] = std::complex<float>(0.0, 0.0); code[s] = std::complex<float>(0.0, 0.0);
} }
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer std::copy_n(code, nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values

View File

@ -36,6 +36,7 @@
#include "gps_sdr_signal_processing.h" #include "gps_sdr_signal_processing.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition( GpsL1CaPcpsOpenClAcquisition::GpsL1CaPcpsOpenClAcquisition(
@ -211,10 +212,10 @@ void GpsL1CaPcpsOpenClAcquisition::set_local_code()
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); 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_);
for (unsigned int i = 0; i < sampled_ms_; i++) for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_cc_->set_local_code(code_); acquisition_cc_->set_local_code(code_);

View File

@ -37,6 +37,7 @@
#include "gps_sdr_signal_processing.h" #include "gps_sdr_signal_processing.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition(
@ -240,13 +241,12 @@ void GpsL1CaPcpsQuickSyncAcquisition::set_local_code()
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0);
for (unsigned int i = 0; i < (sampled_ms_ / folding_factor_); i++) gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
//memcpy(code_, code,sizeof(gr_complex)*code_length_);
acquisition_cc_->set_local_code(code_); acquisition_cc_->set_local_code(code_);
delete[] code; delete[] code;

View File

@ -36,6 +36,7 @@
#include "gps_sdr_signal_processing.h" #include "gps_sdr_signal_processing.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition(
@ -201,10 +202,10 @@ void GpsL1CaPcpsTongAcquisition::set_local_code()
gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), gnss_synchro_->PRN, fs_in_, 0); 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_);
for (unsigned int i = 0; i < sampled_ms_; i++) for (unsigned int i = 0; i < sampled_ms_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_cc_->set_local_code(code_); acquisition_cc_->set_local_code(code_);

View File

@ -39,6 +39,7 @@
#include "gps_l2c_signal.h" #include "gps_l2c_signal.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition(
@ -250,10 +251,10 @@ void GpsL2MPcpsAcquisition::set_local_code()
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, code_length_), gnss_synchro_->PRN, fs_in_);
} }
gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < num_codes_; i++) for (unsigned int i = 0; i < num_codes_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -42,9 +42,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex #include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc #include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h> #include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor #include <cmath> // for abs, pow, floor
#include <complex> // for complex #include <complex> // for complex
#include <cstring> // for memcpy
#define NUM_PRNs 32 #define NUM_PRNs 32
#define QUANT_BITS_LOCAL_CODE 16 #define QUANT_BITS_LOCAL_CODE 16
@ -119,7 +119,7 @@ GpsL2MPcpsAcquisitionFpga::GpsL2MPcpsAcquisitionFpga(
{ {
code[s] = std::complex<float>(0.0, 0.0); code[s] = std::complex<float>(0.0, 0.0);
} }
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer std::copy_n(code, nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values
max = 0; // initialize maximum value max = 0; // initialize maximum value

View File

@ -39,6 +39,7 @@
#include "gps_l5_signal.h" #include "gps_l5_signal.h"
#include <boost/math/distributions/exponential.hpp> #include <boost/math/distributions/exponential.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm>
GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition(
@ -230,11 +231,11 @@ void GpsL5iPcpsAcquisition::init()
acquisition_->init(); acquisition_->init();
} }
void GpsL5iPcpsAcquisition::set_local_code() void GpsL5iPcpsAcquisition::set_local_code()
{ {
auto* code = new std::complex<float>[code_length_]; auto* code = new std::complex<float>[code_length_];
if (acq_parameters_.use_automatic_resampler) 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, code_length_), gnss_synchro_->PRN, acq_parameters_.resampled_fs);
@ -244,10 +245,10 @@ void GpsL5iPcpsAcquisition::set_local_code()
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, code_length_), gnss_synchro_->PRN, fs_in_);
} }
gsl::span<gr_complex> code_span(code_, vector_length_);
for (unsigned int i = 0; i < num_codes_; i++) for (unsigned int i = 0; i < num_codes_; i++)
{ {
memcpy(&(code_[i * code_length_]), code, std::copy_n(code, code_length_, code_span.subspan(i * code_length_, code_length_).data());
sizeof(gr_complex) * code_length_);
} }
acquisition_->set_local_code(code_); acquisition_->set_local_code(code_);

View File

@ -43,9 +43,9 @@
#include <gnuradio/gr_complex.h> // for gr_complex #include <gnuradio/gr_complex.h> // for gr_complex
#include <volk/volk.h> // for volk_32fc_conjugate_32fc #include <volk/volk.h> // for volk_32fc_conjugate_32fc
#include <volk_gnsssdr/volk_gnsssdr.h> #include <volk_gnsssdr/volk_gnsssdr.h>
#include <algorithm> // for copy_n
#include <cmath> // for abs, pow, floor #include <cmath> // for abs, pow, floor
#include <complex> // for complex #include <complex> // for complex
#include <cstring> // for memcpy
#define NUM_PRNs 32 #define NUM_PRNs 32
@ -130,7 +130,7 @@ GpsL5iPcpsAcquisitionFpga::GpsL5iPcpsAcquisitionFpga(
// fill in zero padding // fill in zero padding
code[s] = std::complex<float>(0.0, 0.0); code[s] = std::complex<float>(0.0, 0.0);
} }
memcpy(fft_if->get_inbuf(), code, sizeof(gr_complex) * nsamples_total); // copy to FFT buffer std::copy_n(code, nsamples_total, fft_if->get_inbuf()); // copy to FFT buffer
fft_if->execute(); // Run the FFT of local code fft_if->execute(); // Run the FFT of local code
volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values volk_32fc_conjugate_32fc(fft_codes_padded, fft_if->get_outbuf(), nsamples_total); // conjugate values