mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Avoid pointer arithmetics
This commit is contained in:
parent
dd53f81b1a
commit
d6714e35a1
@ -53,7 +53,7 @@ void galileo_e1_code_gen_int(gsl::span<int> _dest, std::array<char, 3> _Signal,
|
||||
{
|
||||
for (char i : GALILEO_E1_B_PRIMARY_CODE[prn])
|
||||
{
|
||||
hex_to_binary_converter(&_dest[index], i);
|
||||
hex_to_binary_converter(_dest.subspan(index, 4), i);
|
||||
index += 4;
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ void galileo_e1_code_gen_int(gsl::span<int> _dest, std::array<char, 3> _Signal,
|
||||
{
|
||||
for (char i : GALILEO_E1_C_PRIMARY_CODE[prn])
|
||||
{
|
||||
hex_to_binary_converter(&_dest[index], i);
|
||||
hex_to_binary_converter(_dest.subspan(index, 4), i);
|
||||
index += 4;
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, std::array<char,
|
||||
|
||||
_codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS;
|
||||
_signal_E1 = new float[_codeLength];
|
||||
|
||||
gsl::span<float> _signal_E1_span(_signal_E1, _codeLength);
|
||||
if (_cboc == true)
|
||||
{
|
||||
galileo_e1_gen_float(gsl::span<float>(_signal_E1, _codeLength), gsl::span<int>(primary_code_E1_chips, static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)), _Signal); // generate cboc 12 samples per chip
|
||||
@ -183,11 +183,12 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, std::array<char,
|
||||
else
|
||||
{
|
||||
auto* _signal_E1_int = static_cast<int32_t*>(volk_gnsssdr_malloc(_codeLength * sizeof(int32_t), volk_gnsssdr_get_alignment()));
|
||||
gsl::span<int32_t> _signal_E1_int_span(_signal_E1_int, _codeLength);
|
||||
galileo_e1_sinboc_11_gen_int(gsl::span<int32_t>(_signal_E1_int, _codeLength), gsl::span<int>(primary_code_E1_chips, static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS))); // generate sinboc(1,1) 2 samples per chip
|
||||
|
||||
for (uint32_t ii = 0; ii < _codeLength; ++ii)
|
||||
{
|
||||
_signal_E1[ii] = static_cast<float>(_signal_E1_int[ii]);
|
||||
_signal_E1_span[ii] = static_cast<float>(_signal_E1_int_span[ii]);
|
||||
}
|
||||
volk_gnsssdr_free(_signal_E1_int);
|
||||
}
|
||||
@ -205,24 +206,24 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, std::array<char,
|
||||
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];
|
||||
|
||||
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++)
|
||||
{
|
||||
for (unsigned k = 0; k < _samplesPerCode; k++)
|
||||
{
|
||||
_signal_E1C_secondary[i * _samplesPerCode + k] = _signal_E1[k] * (GALILEO_E1_C_SECONDARY_CODE.at(i) == '0' ? 1.0f : -1.0f);
|
||||
_signal_E1C_secondary_span[i * _samplesPerCode + k] = _signal_E1_span[k] * (GALILEO_E1_C_SECONDARY_CODE.at(i) == '0' ? 1.0f : -1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
_samplesPerCode *= static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH);
|
||||
|
||||
delete[] _signal_E1;
|
||||
_signal_E1 = _signal_E1C_secondary;
|
||||
_signal_E1 = _signal_E1C_secondary_span.data();
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < _samplesPerCode; i++)
|
||||
{
|
||||
_dest[(i + delay) % _samplesPerCode] = _signal_E1[i];
|
||||
_dest[(i + delay) % _samplesPerCode] = _signal_E1_span[i];
|
||||
}
|
||||
|
||||
delete[] _signal_E1;
|
||||
@ -245,12 +246,12 @@ void galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, s
|
||||
}
|
||||
|
||||
auto* real_code = static_cast<float*>(volk_gnsssdr_malloc(_samplesPerCode * sizeof(float), volk_gnsssdr_get_alignment()));
|
||||
|
||||
galileo_e1_code_gen_float_sampled(gsl::span<float>(real_code, _samplesPerCode), _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag);
|
||||
gsl::span<float> real_code_span(real_code, _samplesPerCode);
|
||||
galileo_e1_code_gen_float_sampled(real_code_span, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag);
|
||||
|
||||
for (uint32_t ii = 0; ii < _samplesPerCode; ++ii)
|
||||
{
|
||||
_dest[ii] = std::complex<float>(real_code[ii], 0.0f);
|
||||
_dest[ii] = std::complex<float>(real_code_span[ii], 0.0f);
|
||||
}
|
||||
volk_gnsssdr_free(real_code);
|
||||
}
|
||||
|
@ -109,8 +109,8 @@ void galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest,
|
||||
const int32_t _codeFreqBasis = GALILEO_E5A_CODE_CHIP_RATE_HZ;
|
||||
|
||||
auto* _code = new std::complex<float>[_codeLength]();
|
||||
|
||||
galileo_e5_a_code_gen_complex_primary(gsl::span<std::complex<float>>(_code, _codeLength), _prn, _Signal);
|
||||
gsl::span<std::complex<float>> _code_span(_code, _codeLength);
|
||||
galileo_e5_a_code_gen_complex_primary(_code_span, _prn, _Signal);
|
||||
|
||||
_samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
|
||||
|
||||
@ -122,14 +122,14 @@ void galileo_e5_a_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest,
|
||||
if (posix_memalign(reinterpret_cast<void**>(&_resampled_signal), 16, _samplesPerCode * sizeof(gr_complex)) == 0)
|
||||
{
|
||||
};
|
||||
resampler(gsl::span<std::complex<float>>(_code, _codeLength), gsl::span<std::complex<float>>(_resampled_signal, _samplesPerCode), _codeFreqBasis, _fs); // resamples code to fs
|
||||
resampler(_code_span, gsl::span<std::complex<float>>(_resampled_signal, _samplesPerCode), _codeFreqBasis, _fs); // resamples code to fs
|
||||
delete[] _code;
|
||||
_code = _resampled_signal;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < _samplesPerCode; i++)
|
||||
{
|
||||
_dest[(i + delay) % _samplesPerCode] = _code[i];
|
||||
_dest[(i + delay) % _samplesPerCode] = _code_span[i];
|
||||
}
|
||||
if (_fs != _codeFreqBasis)
|
||||
{
|
||||
|
@ -54,105 +54,105 @@ void complex_exp_gen_conj(gsl::span<std::complex<float>> _dest, double _f, doubl
|
||||
}
|
||||
|
||||
|
||||
void hex_to_binary_converter(int32_t* _dest, char _from)
|
||||
void hex_to_binary_converter(gsl::span<int32_t> _dest, char _from)
|
||||
{
|
||||
switch (_from)
|
||||
{
|
||||
case '0':
|
||||
*(_dest) = 1;
|
||||
*(_dest + 1) = 1;
|
||||
*(_dest + 2) = 1;
|
||||
*(_dest + 3) = 1;
|
||||
_dest[0] = 1;
|
||||
_dest[1] = 1;
|
||||
_dest[2] = 1;
|
||||
_dest[3] = 1;
|
||||
break;
|
||||
case '1':
|
||||
*(_dest) = 1;
|
||||
*(_dest + 1) = 1;
|
||||
*(_dest + 2) = 1;
|
||||
*(_dest + 3) = -1;
|
||||
_dest[0] = 1;
|
||||
_dest[1] = 1;
|
||||
_dest[2] = 1;
|
||||
_dest[3] = -1;
|
||||
break;
|
||||
case '2':
|
||||
*(_dest) = 1;
|
||||
*(_dest + 1) = 1;
|
||||
*(_dest + 2) = -1;
|
||||
*(_dest + 3) = 1;
|
||||
_dest[0] = 1;
|
||||
_dest[1] = 1;
|
||||
_dest[2] = -1;
|
||||
_dest[3] = 1;
|
||||
break;
|
||||
case '3':
|
||||
*(_dest) = 1;
|
||||
*(_dest + 1) = 1;
|
||||
*(_dest + 2) = -1;
|
||||
*(_dest + 3) = -1;
|
||||
_dest[0] = 1;
|
||||
_dest[1] = 1;
|
||||
_dest[2] = -1;
|
||||
_dest[3] = -1;
|
||||
break;
|
||||
case '4':
|
||||
*(_dest) = 1;
|
||||
*(_dest + 1) = -1;
|
||||
*(_dest + 2) = 1;
|
||||
*(_dest + 3) = 1;
|
||||
_dest[0] = 1;
|
||||
_dest[1] = -1;
|
||||
_dest[2] = 1;
|
||||
_dest[3] = 1;
|
||||
break;
|
||||
case '5':
|
||||
*(_dest) = 1;
|
||||
*(_dest + 1) = -1;
|
||||
*(_dest + 2) = 1;
|
||||
*(_dest + 3) = -1;
|
||||
_dest[0] = 1;
|
||||
_dest[1] = -1;
|
||||
_dest[2] = 1;
|
||||
_dest[3] = -1;
|
||||
break;
|
||||
case '6':
|
||||
*(_dest) = 1;
|
||||
*(_dest + 1) = -1;
|
||||
*(_dest + 2) = -1;
|
||||
*(_dest + 3) = 1;
|
||||
_dest[0] = 1;
|
||||
_dest[1] = -1;
|
||||
_dest[2] = -1;
|
||||
_dest[3] = 1;
|
||||
break;
|
||||
case '7':
|
||||
*(_dest) = 1;
|
||||
*(_dest + 1) = -1;
|
||||
*(_dest + 2) = -1;
|
||||
*(_dest + 3) = -1;
|
||||
_dest[0] = 1;
|
||||
_dest[1] = -1;
|
||||
_dest[2] = -1;
|
||||
_dest[3] = -1;
|
||||
break;
|
||||
case '8':
|
||||
*(_dest) = -1;
|
||||
*(_dest + 1) = 1;
|
||||
*(_dest + 2) = 1;
|
||||
*(_dest + 3) = 1;
|
||||
_dest[0] = -1;
|
||||
_dest[1] = 1;
|
||||
_dest[2] = 1;
|
||||
_dest[3] = 1;
|
||||
break;
|
||||
case '9':
|
||||
*(_dest) = -1;
|
||||
*(_dest + 1) = 1;
|
||||
*(_dest + 2) = 1;
|
||||
*(_dest + 3) = -1;
|
||||
_dest[0] = -1;
|
||||
_dest[1] = 1;
|
||||
_dest[2] = 1;
|
||||
_dest[3] = -1;
|
||||
break;
|
||||
case 'A':
|
||||
*(_dest) = -1;
|
||||
*(_dest + 1) = 1;
|
||||
*(_dest + 2) = -1;
|
||||
*(_dest + 3) = 1;
|
||||
_dest[0] = -1;
|
||||
_dest[1] = 1;
|
||||
_dest[2] = -1;
|
||||
_dest[3] = 1;
|
||||
break;
|
||||
case 'B':
|
||||
*(_dest) = -1;
|
||||
*(_dest + 1) = 1;
|
||||
*(_dest + 2) = -1;
|
||||
*(_dest + 3) = -1;
|
||||
_dest[0] = -1;
|
||||
_dest[1] = 1;
|
||||
_dest[2] = -1;
|
||||
_dest[3] = -1;
|
||||
break;
|
||||
case 'C':
|
||||
*(_dest) = -1;
|
||||
*(_dest + 1) = -1;
|
||||
*(_dest + 2) = 1;
|
||||
*(_dest + 3) = 1;
|
||||
_dest[0] = -1;
|
||||
_dest[1] = -1;
|
||||
_dest[2] = 1;
|
||||
_dest[3] = 1;
|
||||
break;
|
||||
case 'D':
|
||||
*(_dest) = -1;
|
||||
*(_dest + 1) = -1;
|
||||
*(_dest + 2) = 1;
|
||||
*(_dest + 3) = -1;
|
||||
_dest[0] = -1;
|
||||
_dest[1] = -1;
|
||||
_dest[2] = 1;
|
||||
_dest[3] = -1;
|
||||
break;
|
||||
case 'E':
|
||||
*(_dest) = -1;
|
||||
*(_dest + 1) = -1;
|
||||
*(_dest + 2) = -1;
|
||||
*(_dest + 3) = 1;
|
||||
_dest[0] = -1;
|
||||
_dest[1] = -1;
|
||||
_dest[2] = -1;
|
||||
_dest[3] = 1;
|
||||
break;
|
||||
case 'F':
|
||||
*(_dest) = -1;
|
||||
*(_dest + 1) = -1;
|
||||
*(_dest + 2) = -1;
|
||||
*(_dest + 3) = -1;
|
||||
_dest[0] = -1;
|
||||
_dest[1] = -1;
|
||||
_dest[2] = -1;
|
||||
_dest[3] = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ void complex_exp_gen_conj(gsl::span<std::complex<float>> _dest, double _f, doubl
|
||||
* to binary (the output are 4 ints with +1 or -1 values).
|
||||
*
|
||||
*/
|
||||
void hex_to_binary_converter(int32_t* _dest, char _from);
|
||||
void hex_to_binary_converter(gsl::span<int32_t> _dest, char _from);
|
||||
|
||||
/*!
|
||||
* \brief This function resamples a sequence of float values.
|
||||
|
@ -56,15 +56,15 @@ 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];
|
||||
|
||||
gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS);
|
||||
if (_prn > 0 and _prn < 51)
|
||||
{
|
||||
gps_l2c_m_code(gsl::span<int32_t>(_code, GPS_L2_M_CODE_LENGTH_CHIPS), _prn);
|
||||
gps_l2c_m_code(_code_span, _prn);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++)
|
||||
{
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[i], 0.0);
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0);
|
||||
}
|
||||
|
||||
delete[] _code;
|
||||
@ -74,15 +74,15 @@ void gps_l2c_m_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _
|
||||
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];
|
||||
|
||||
gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS);
|
||||
if (_prn > 0 and _prn < 51)
|
||||
{
|
||||
gps_l2c_m_code(gsl::span<int32_t>(_code, GPS_L2_M_CODE_LENGTH_CHIPS), _prn);
|
||||
gps_l2c_m_code(_code_span, _prn);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++)
|
||||
{
|
||||
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]);
|
||||
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]);
|
||||
}
|
||||
|
||||
delete[] _code;
|
||||
@ -95,9 +95,10 @@ 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];
|
||||
gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS);
|
||||
if (_prn > 0 and _prn < 51)
|
||||
{
|
||||
gps_l2c_m_code(gsl::span<int32_t>(_code, GPS_L2_M_CODE_LENGTH_CHIPS), _prn);
|
||||
gps_l2c_m_code(_code_span, _prn);
|
||||
}
|
||||
|
||||
int32_t _samplesPerCode, _codeValueIndex;
|
||||
@ -112,26 +113,22 @@ void gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, ui
|
||||
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec
|
||||
_tc = 1.0 / static_cast<float>(GPS_L2_M_CODE_RATE_HZ); // C/A chip period in sec
|
||||
|
||||
//float aux;
|
||||
for (int32_t i = 0; i < _samplesPerCode; i++)
|
||||
{
|
||||
//=== Digitizing =======================================================
|
||||
|
||||
//--- Make index array to read L2C code values -------------------------
|
||||
//TODO: Check this formula! Seems to start with an extra sample
|
||||
_codeValueIndex = std::ceil((_ts * (static_cast<float>(i) + 1)) / _tc) - 1;
|
||||
//aux = (_ts * (i + 1)) / _tc;
|
||||
//_codeValueIndex = static_cast<int32_t>(static_cast<long>(aux)) - 1;
|
||||
|
||||
//--- Make the digitized version of the L2C code -----------------------
|
||||
if (i == _samplesPerCode - 1)
|
||||
{
|
||||
//--- Correct the last index (due to number rounding issues) -----------
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0);
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0); //repeat the chip -> upsample
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0); //repeat the chip -> upsample
|
||||
}
|
||||
}
|
||||
delete[] _code;
|
||||
|
@ -174,15 +174,15 @@ 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];
|
||||
|
||||
gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS);
|
||||
if (_prn > 0 and _prn < 51)
|
||||
{
|
||||
make_l5i(gsl::span<int32_t>(_code, GPS_L5I_CODE_LENGTH_CHIPS), _prn - 1);
|
||||
make_l5i(_code_span, _prn - 1);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++)
|
||||
{
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[i], 0.0);
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0);
|
||||
}
|
||||
|
||||
delete[] _code;
|
||||
@ -192,15 +192,15 @@ void gps_l5i_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _pr
|
||||
void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn)
|
||||
{
|
||||
auto* _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)
|
||||
{
|
||||
make_l5i(gsl::span<int32_t>(_code, GPS_L5I_CODE_LENGTH_CHIPS), _prn - 1);
|
||||
make_l5i(_code_span, _prn - 1);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++)
|
||||
{
|
||||
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]);
|
||||
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]);
|
||||
}
|
||||
|
||||
delete[] _code;
|
||||
@ -213,9 +213,10 @@ 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];
|
||||
gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS);
|
||||
if (_prn > 0 and _prn < 51)
|
||||
{
|
||||
make_l5i(gsl::span<int32_t>(_code, GPS_L5I_CODE_LENGTH_CHIPS), _prn - 1);
|
||||
make_l5i(_code_span, _prn - 1);
|
||||
}
|
||||
|
||||
int32_t _samplesPerCode, _codeValueIndex;
|
||||
@ -241,11 +242,11 @@ void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint
|
||||
if (i == _samplesPerCode - 1)
|
||||
{
|
||||
//--- Correct the last index (due to number rounding issues) -----------
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0.0);
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0.0); // repeat the chip -> upsample
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0.0); // repeat the chip -> upsample
|
||||
}
|
||||
}
|
||||
delete[] _code;
|
||||
@ -255,15 +256,15 @@ void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint
|
||||
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];
|
||||
|
||||
gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS);
|
||||
if (_prn > 0 and _prn < 51)
|
||||
{
|
||||
make_l5q(gsl::span<int32_t>(_code, GPS_L5Q_CODE_LENGTH_CHIPS), _prn - 1);
|
||||
make_l5q(_code_span, _prn - 1);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++)
|
||||
{
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[i], 0.0);
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0);
|
||||
}
|
||||
|
||||
delete[] _code;
|
||||
@ -273,15 +274,15 @@ void gps_l5q_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _pr
|
||||
void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn)
|
||||
{
|
||||
auto* _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)
|
||||
{
|
||||
make_l5q(gsl::span<int32_t>(_code, GPS_L5Q_CODE_LENGTH_CHIPS), _prn - 1);
|
||||
make_l5q(_code_span, _prn - 1);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++)
|
||||
{
|
||||
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]);
|
||||
_dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]);
|
||||
}
|
||||
|
||||
delete[] _code;
|
||||
@ -294,9 +295,10 @@ 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];
|
||||
gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS);
|
||||
if (_prn > 0 and _prn < 51)
|
||||
{
|
||||
make_l5q(gsl::span<int32_t>(_code, GPS_L5Q_CODE_LENGTH_CHIPS), _prn - 1);
|
||||
make_l5q(_code_span, _prn - 1);
|
||||
}
|
||||
|
||||
int32_t _samplesPerCode, _codeValueIndex;
|
||||
@ -323,11 +325,11 @@ void gps_l5q_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint
|
||||
if (i == _samplesPerCode - 1)
|
||||
{
|
||||
//--- Correct the last index (due to number rounding issues) -----------
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0);
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0); // repeat the chip -> upsample
|
||||
_dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0); // repeat the chip -> upsample
|
||||
}
|
||||
}
|
||||
delete[] _code;
|
||||
|
Loading…
Reference in New Issue
Block a user