diff --git a/CMakeLists.txt b/CMakeLists.txt index d3c95eea4..9e4865db9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,11 +397,11 @@ set(GNSSSDR_PROTOBUF_MIN_VERSION "3.0.0") ################################################################################ set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") -set(GNSSSDR_ARMADILLO_LOCAL_VERSION "9.500.x") +set(GNSSSDR_ARMADILLO_LOCAL_VERSION "9.600.x") set(GNSSSDR_GTEST_LOCAL_VERSION "1.8.1") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10.6") -set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.16") +set(GNSSSDR_MATIO_LOCAL_VERSION "1.5.17") set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.9") set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "3.9.0") diff --git a/README.md b/README.md index 7240ccbca..fcbcd7223 100644 --- a/README.md +++ b/README.md @@ -220,9 +220,9 @@ $ sudo apt-get install libblas-dev liblapack-dev # For Debian/Ubuntu/Linux $ sudo yum install lapack-devel blas-devel # For Fedora/CentOS/RHEL $ sudo zypper install lapack-devel blas-devel # For OpenSUSE $ sudo pacman -S blas lapack # For Arch Linux -$ wget http://sourceforge.net/projects/arma/files/armadillo-9.400.4.tar.xz -$ tar xvfz armadillo-9.400.4.tar.xz -$ cd armadillo-9.400.4 +$ wget http://sourceforge.net/projects/arma/files/armadillo-9.600.4.tar.xz +$ tar xvfz armadillo-9.600.4.tar.xz +$ cd armadillo-9.600.4 $ cmake . $ make $ sudo make install diff --git a/src/algorithms/libs/beidou_b1i_signal_processing.cc b/src/algorithms/libs/beidou_b1i_signal_processing.cc index 504d7ee0d..3a4d310bf 100644 --- a/src/algorithms/libs/beidou_b1i_signal_processing.cc +++ b/src/algorithms/libs/beidou_b1i_signal_processing.cc @@ -71,7 +71,7 @@ void beidou_b1i_code_gen_int(gsl::span _dest, int32_t _prn, uint32_t _c for (lcv = 0; lcv < _code_length; lcv++) { G1[lcv] = G1_register[0]; - G2[lcv] = G2_register[-(phase1[prn_idx] - 11)] ^ G2_register[-(phase2[prn_idx] - 11)]; + G2[lcv] = G2_register[-(phase1[prn_idx] - 11)] xor G2_register[-(phase2[prn_idx] - 11)]; feedback1 = G1_register[0] xor G1_register[1] xor G1_register[2] xor G1_register[3] xor G1_register[4] xor G1_register[10]; feedback2 = G2_register[0] xor G2_register[2] xor G2_register[3] xor G2_register[6] xor G2_register[7] xor G2_register[8] xor G2_register[9] xor G2_register[10]; @@ -94,7 +94,7 @@ void beidou_b1i_code_gen_int(gsl::span _dest, int32_t _prn, uint32_t _c // Generate PRN from G1 and G2 Registers for (lcv = 0; lcv < _code_length; lcv++) { - aux = G1[(lcv + _chip_shift) % _code_length] ^ G2[delay]; + aux = G1[(lcv + _chip_shift) % _code_length] xor G2[delay]; if (aux == true) { _dest[lcv] = 1; diff --git a/src/algorithms/libs/beidou_b3i_signal_processing.cc b/src/algorithms/libs/beidou_b3i_signal_processing.cc index e47771d6f..a08cdd7b4 100644 --- a/src/algorithms/libs/beidou_b3i_signal_processing.cc +++ b/src/algorithms/libs/beidou_b3i_signal_processing.cc @@ -42,9 +42,9 @@ void beidou_b3i_code_gen_int(gsl::span _dest, signed int _prn, unsigned int const unsigned int _code_length = 10230; std::bitset<_code_length> G1{}; std::bitset<_code_length> G2{}; - auto G1_register = std::move(std::bitset<13>{}.set()); // All true - auto G2_register = std::move(std::bitset<13>{}.set()); // All true - auto G1_register_reset = std::move(std::bitset<13>{}.set()); + auto G1_register = std::bitset<13>{}.set(); // All true + auto G2_register = std::bitset<13>{}.set(); // All true + auto G1_register_reset = std::bitset<13>{}.set(); G1_register_reset.reset(0); G1_register_reset.reset(1); // {false, false, true, true, true, true, true, true, true, true, true, true, true}; @@ -148,7 +148,7 @@ void beidou_b3i_code_gen_int(gsl::span _dest, signed int _prn, unsigned int // Reset G1 register if sequence found if (G1_register == G1_register_reset) { - G1_register = std::move(std::bitset<13>{}.set()); // All true + G1_register = std::bitset<13>{}.set(); // All true } } diff --git a/src/algorithms/libs/galileo_e1_signal_processing.cc b/src/algorithms/libs/galileo_e1_signal_processing.cc index 63c2ca743..59f0cfb1c 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.cc +++ b/src/algorithms/libs/galileo_e1_signal_processing.cc @@ -33,10 +33,10 @@ #include "galileo_e1_signal_processing.h" #include "Galileo_E1.h" #include "gnss_signal_processing.h" -#include #include #include #include +#include void galileo_e1_code_gen_int(gsl::span _dest, const std::array& _Signal, int32_t _prn) @@ -111,8 +111,8 @@ void galileo_e1_code_gen_sinboc11_float(gsl::span _dest, const std::array { std::string _galileo_signal = _Signal.data(); const auto _codeLength = static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS); - std::array primary_code_E1_chips{}; // _codeLength not accepted by Clang - galileo_e1_code_gen_int(gsl::span(primary_code_E1_chips.data(), 4092), _Signal, _prn); //generate Galileo E1 code, 1 sample per chip + std::array primary_code_E1_chips{}; + galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); // generate Galileo E1 code, 1 sample per chip for (uint32_t i = 0; i < _codeLength; i++) { _dest[2 * i] = static_cast(primary_code_E1_chips[i]); @@ -163,35 +163,31 @@ void galileo_e1_code_gen_float_sampled(gsl::span _dest, const std::array< std::string _galileo_signal = _Signal.data(); uint32_t _samplesPerCode; const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ; // Hz - auto _codeLength = static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS); - auto* primary_code_E1_chips = static_cast(volk_gnsssdr_malloc(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) * sizeof(int32_t), volk_gnsssdr_get_alignment())); - - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); + std::vector primary_code_E1_chips(static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS)); const int32_t _samplesPerChip = (_cboc == true) ? 12 : 2; const uint32_t delay = ((static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / GALILEO_E1_B_CODE_LENGTH_CHIPS; - galileo_e1_code_gen_int(gsl::span(primary_code_E1_chips, static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)), _Signal, _prn); // generate Galileo E1 code, 1 sample per chip + galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); // generate Galileo E1 code, 1 sample per chip - _codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS; + const uint32_t _codeLength = _samplesPerChip * GALILEO_E1_B_CODE_LENGTH_CHIPS; std::unique_ptr _signal_E1{new float[_codeLength]}; gsl::span _signal_E1_span(_signal_E1, _codeLength); if (_cboc == true) { - galileo_e1_gen_float(_signal_E1_span, gsl::span(primary_code_E1_chips, static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS)), _Signal); // generate cboc 12 samples per chip + galileo_e1_gen_float(_signal_E1_span, primary_code_E1_chips, _Signal); // generate cboc 12 samples per chip } else { - auto* _signal_E1_int = static_cast(volk_gnsssdr_malloc(_codeLength * sizeof(int32_t), volk_gnsssdr_get_alignment())); - gsl::span _signal_E1_int_span(_signal_E1_int, _codeLength); - galileo_e1_sinboc_11_gen_int(_signal_E1_int_span, gsl::span(primary_code_E1_chips, static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS))); // generate sinboc(1,1) 2 samples per chip + std::vector _signal_E1_int(static_cast(_codeLength)); + galileo_e1_sinboc_11_gen_int(_signal_E1_int, primary_code_E1_chips); // generate sinboc(1,1) 2 samples per chip for (uint32_t ii = 0; ii < _codeLength; ++ii) { - _signal_E1_span[ii] = static_cast(_signal_E1_int_span[ii]); + _signal_E1_span[ii] = static_cast(_signal_E1_int[ii]); } - volk_gnsssdr_free(_signal_E1_int); } if (_fs != _samplesPerChip * _codeFreqBasis) @@ -233,8 +229,6 @@ void galileo_e1_code_gen_float_sampled(gsl::span _dest, const std::array< { _dest[(i + delay) % _samplesPerCode] = _signal_E1_span_aux2[i]; } - - volk_gnsssdr_free(primary_code_E1_chips); } @@ -245,22 +239,20 @@ void galileo_e1_code_gen_complex_sampled(gsl::span> _dest, c std::string _galileo_signal = _Signal.data(); const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ; // Hz auto _samplesPerCode = static_cast(static_cast(_fs) / - (static_cast(_codeFreqBasis) / static_cast(GALILEO_E1_B_CODE_LENGTH_CHIPS))); + (static_cast(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS)); if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) { _samplesPerCode *= static_cast(GALILEO_E1_C_SECONDARY_CODE_LENGTH); } - auto* real_code = static_cast(volk_gnsssdr_malloc(_samplesPerCode * sizeof(float), volk_gnsssdr_get_alignment())); - gsl::span real_code_span(real_code, _samplesPerCode); - galileo_e1_code_gen_float_sampled(real_code_span, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag); + std::vector real_code(_samplesPerCode); + galileo_e1_code_gen_float_sampled(real_code, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag); for (uint32_t ii = 0; ii < _samplesPerCode; ++ii) { - _dest[ii] = std::complex(real_code_span[ii], 0.0F); + _dest[ii] = std::complex(real_code[ii], 0.0F); } - volk_gnsssdr_free(real_code); } diff --git a/src/algorithms/libs/glonass_l1_signal_processing.cc b/src/algorithms/libs/glonass_l1_signal_processing.cc index da1cc34ce..ee07164bf 100644 --- a/src/algorithms/libs/glonass_l1_signal_processing.cc +++ b/src/algorithms/libs/glonass_l1_signal_processing.cc @@ -32,30 +32,26 @@ #include "glonass_l1_signal_processing.h" #include +#include auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; void glonass_l1_ca_code_gen_complex(gsl::span> _dest, /* int32_t _prn,*/ uint32_t _chip_shift) { const uint32_t _code_length = 511; - std::array G1{}; - std::array G1_register{}; + std::bitset<_code_length> G1{}; + auto G1_register = std::bitset<9>{}.set(); // All true bool feedback1; bool aux; uint32_t delay; uint32_t lcv, lcv2; - for (lcv = 0; lcv < 9; lcv++) - { - G1_register[lcv] = true; - } - /* Generate G1 Register */ for (lcv = 0; lcv < _code_length; lcv++) { G1[lcv] = G1_register[2]; - feedback1 = G1_register[4] ^ G1_register[0]; + feedback1 = G1_register[4] xor G1_register[0]; for (lcv2 = 0; lcv2 < 8; lcv2++) { @@ -123,7 +119,7 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span> _dest _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec - glonass_l1_ca_code_gen_complex(gsl::span>(_code.data(), 511), _chip_shift); // generate C/A code 1 sample per chip + glonass_l1_ca_code_gen_complex(_code, _chip_shift); // generate C/A code 1 sample per chip for (int32_t i = 0; i < _samplesPerCode; i++) { @@ -134,7 +130,6 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span> _dest // number of samples per millisecond (because one C/A code period is one // millisecond). - // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; aux = (_ts * (i + 1)) / _tc; _codeValueIndex = auxCeil(aux) - 1; @@ -148,7 +143,7 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span> _dest } else { - _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + _dest[i] = _code[_codeValueIndex]; // repeat the chip -> upsample } } } diff --git a/src/algorithms/libs/glonass_l2_signal_processing.cc b/src/algorithms/libs/glonass_l2_signal_processing.cc index d92b785c9..f2223fa94 100644 --- a/src/algorithms/libs/glonass_l2_signal_processing.cc +++ b/src/algorithms/libs/glonass_l2_signal_processing.cc @@ -32,30 +32,26 @@ #include "glonass_l2_signal_processing.h" #include +#include auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; void glonass_l2_ca_code_gen_complex(gsl::span> _dest, /* int32_t _prn,*/ uint32_t _chip_shift) { const uint32_t _code_length = 511; - std::array G1{}; - std::array G1_register{}; + std::bitset<_code_length> G1{}; + auto G1_register = std::bitset<9>{}.set(); // All true bool feedback1; bool aux; uint32_t delay; uint32_t lcv, lcv2; - for (lcv = 0; lcv < 9; lcv++) - { - G1_register[lcv] = true; - } - /* Generate G1 Register */ for (lcv = 0; lcv < _code_length; lcv++) { G1[lcv] = G1_register[2]; - feedback1 = G1_register[4] ^ G1_register[0]; + feedback1 = G1_register[4] xor G1_register[0]; for (lcv2 = 0; lcv2 < 8; lcv2++) { @@ -123,7 +119,7 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span> _dest _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec - glonass_l2_ca_code_gen_complex(gsl::span>(_code.data(), 511), _chip_shift); // generate C/A code 1 sample per chip + glonass_l2_ca_code_gen_complex(_code, _chip_shift); // generate C/A code 1 sample per chip for (int32_t i = 0; i < _samplesPerCode; i++) { @@ -134,7 +130,6 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span> _dest // number of samples per millisecond (because one C/A code period is one // millisecond). - // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; aux = (_ts * (i + 1)) / _tc; _codeValueIndex = auxCeil(aux) - 1; @@ -148,7 +143,7 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span> _dest } else { - _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + _dest[i] = _code[_codeValueIndex]; // repeat the chip -> upsample } } } diff --git a/src/algorithms/libs/gnss_signal_processing.cc b/src/algorithms/libs/gnss_signal_processing.cc index 71e61e159..38f606d93 100644 --- a/src/algorithms/libs/gnss_signal_processing.cc +++ b/src/algorithms/libs/gnss_signal_processing.cc @@ -154,6 +154,8 @@ void hex_to_binary_converter(gsl::span _dest, char _from) _dest[2] = -1; _dest[3] = -1; break; + default: + break; } } @@ -168,13 +170,12 @@ void resampler(const gsl::span _from, gsl::span _dest, float _fs_i const float _t_out = 1 / _fs_out; // Out sampling period in sec for (uint32_t i = 0; i < _dest.size() - 1; i++) { - //=== Digitizing ======================================================= - //--- compute index array to read sampled values ------------------------- - //_codeValueIndex = ceil((_t_out * ((float)i + 1)) / _t_in) - 1; + //=== Digitizing =================================================== + //--- compute index array to read sampled values ------------------- aux = (_t_out * (i + 1)) / _t_in; _codeValueIndex = auxCeil2(aux) - 1; - //if repeat the chip -> upsample by nearest neighborhood interpolation + // if repeat the chip -> upsample by nearest neighborhood interpolation _dest[i] = _from[_codeValueIndex]; } //--- Correct the last index (due to number rounding issues) ----------- @@ -192,13 +193,12 @@ void resampler(gsl::span> _from, gsl::span upsample by nearest neighborhood interpolation + // if repeat the chip -> upsample by nearest neighborhood interpolation _dest[i] = _from[_codeValueIndex]; } //--- Correct the last index (due to number rounding issues) ----------- diff --git a/src/algorithms/libs/gps_l2c_signal.cc b/src/algorithms/libs/gps_l2c_signal.cc index 364c5ee66..73d9e5b7a 100644 --- a/src/algorithms/libs/gps_l2c_signal.cc +++ b/src/algorithms/libs/gps_l2c_signal.cc @@ -32,13 +32,14 @@ #include "gps_l2c_signal.h" #include "GPS_L2C.h" +#include #include #include uint32_t gps_l2c_m_shift(uint32_t x) { - return static_cast((x >> 1U) ^ ((x & 1U) * 0445112474U)); + return static_cast((x >> 1U) xor ((x & 1U) * 0445112474U)); } @@ -56,32 +57,30 @@ void gps_l2c_m_code(gsl::span _dest, uint32_t _prn) void gps_l2c_m_code_gen_complex(gsl::span> _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - gps_l2c_m_code(_code_span, _prn); + gps_l2c_m_code(_code, _prn); } for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[i], 0.0); + _dest[i] = std::complex(1.0 - 2.0 * _code[i], 0.0); } } void gps_l2c_m_code_gen_float(gsl::span _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - gps_l2c_m_code(_code_span, _prn); + gps_l2c_m_code(_code, _prn); } for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) { - _dest[i] = 1.0 - 2.0 * static_cast(_code_span[i]); + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } } @@ -91,11 +90,10 @@ void gps_l2c_m_code_gen_float(gsl::span _dest, uint32_t _prn) */ void gps_l2c_m_code_gen_complex_sampled(gsl::span> _dest, uint32_t _prn, int32_t _fs) { - std::unique_ptr _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - gps_l2c_m_code(_code_span, _prn); + gps_l2c_m_code(_code, _prn); } int32_t _samplesPerCode, _codeValueIndex; @@ -121,11 +119,11 @@ void gps_l2c_m_code_gen_complex_sampled(gsl::span> _dest, ui if (i == _samplesPerCode - 1) { //--- Correct the last index (due to number rounding issues) ----------- - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeLength - 1], 0); + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeLength - 1], 0); } else { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeValueIndex], 0); //repeat the chip -> upsample + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeValueIndex], 0); //repeat the chip -> upsample } } } diff --git a/src/algorithms/libs/gps_l5_signal.cc b/src/algorithms/libs/gps_l5_signal.cc index 8fa132b63..8c301ee6e 100644 --- a/src/algorithms/libs/gps_l5_signal.cc +++ b/src/algorithms/libs/gps_l5_signal.cc @@ -32,9 +32,9 @@ #include "gps_l5_signal.h" #include "GPS_L5.h" +#include #include - std::deque l5i_xa_shift(std::deque xa) // GPS-IS-705E Figure 3-4 pp. 15 { if (xa == std::deque{true, true, true, true, true, true, true, true, true, true, true, false, true}) @@ -173,32 +173,30 @@ void make_l5q(gsl::span _dest, int32_t prn) void gps_l5i_code_gen_complex(gsl::span> _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5i(_code_span, _prn - 1); + make_l5i(_code, _prn - 1); } for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[i], 0.0); + _dest[i] = std::complex(1.0 - 2.0 * static_cast(_code[i]), 0.0); } } void gps_l5i_code_gen_float(gsl::span _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5i(_code_span, _prn - 1); + make_l5i(_code, _prn - 1); } for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) { - _dest[i] = 1.0 - 2.0 * static_cast(_code_span[i]); + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } } @@ -208,11 +206,10 @@ void gps_l5i_code_gen_float(gsl::span _dest, uint32_t _prn) */ void gps_l5i_code_gen_complex_sampled(gsl::span> _dest, uint32_t _prn, int32_t _fs) { - std::unique_ptr _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5i(_code_span, _prn - 1); + make_l5i(_code, _prn - 1); } int32_t _samplesPerCode, _codeValueIndex; @@ -238,11 +235,11 @@ void gps_l5i_code_gen_complex_sampled(gsl::span> _dest, uint if (i == _samplesPerCode - 1) { //--- Correct the last index (due to number rounding issues) ----------- - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeLength - 1], 0.0); + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeLength - 1], 0.0); } else { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeValueIndex], 0.0); // repeat the chip -> upsample + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeValueIndex], 0.0); // repeat the chip -> upsample } } } @@ -250,32 +247,30 @@ void gps_l5i_code_gen_complex_sampled(gsl::span> _dest, uint void gps_l5q_code_gen_complex(gsl::span> _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5q(_code_span, _prn - 1); + make_l5q(_code, _prn - 1); } for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[i], 0.0); + _dest[i] = std::complex(1.0 - 2.0 * static_cast(_code[i]), 0.0); } } void gps_l5q_code_gen_float(gsl::span _dest, uint32_t _prn) { - std::unique_ptr _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5q(_code_span, _prn - 1); + make_l5q(_code, _prn - 1); } for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) { - _dest[i] = 1.0 - 2.0 * static_cast(_code_span[i]); + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); } } @@ -285,11 +280,10 @@ void gps_l5q_code_gen_float(gsl::span _dest, uint32_t _prn) */ void gps_l5q_code_gen_complex_sampled(gsl::span> _dest, uint32_t _prn, int32_t _fs) { - std::unique_ptr _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; - gsl::span _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); + std::array _code{}; if (_prn > 0 and _prn < 51) { - make_l5q(_code_span, _prn - 1); + make_l5q(_code, _prn - 1); } int32_t _samplesPerCode, _codeValueIndex; @@ -316,11 +310,11 @@ void gps_l5q_code_gen_complex_sampled(gsl::span> _dest, uint if (i == _samplesPerCode - 1) { //--- Correct the last index (due to number rounding issues) ----------- - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeLength - 1], 0); + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeLength - 1], 0); } else { - _dest[i] = std::complex(1.0 - 2.0 * _code_span[_codeValueIndex], 0); // repeat the chip -> upsample + _dest[i] = std::complex(1.0 - 2.0 * _code[_codeValueIndex], 0); // repeat the chip -> upsample } } } diff --git a/src/algorithms/libs/gps_sdr_signal_processing.cc b/src/algorithms/libs/gps_sdr_signal_processing.cc index 1a4483200..66ebf8036 100644 --- a/src/algorithms/libs/gps_sdr_signal_processing.cc +++ b/src/algorithms/libs/gps_sdr_signal_processing.cc @@ -83,7 +83,7 @@ void gps_l1_ca_code_gen_int(gsl::span _dest, int32_t _prn, uint32_t _ch G1[lcv] = G1_register[0]; G2[lcv] = G2_register[0]; - feedback1 = G1_register[7] ^ G1_register[0]; + feedback1 = G1_register[7] xor G1_register[0]; feedback2 = G2_register[8] xor G2_register[7] xor G2_register[4] xor G2_register[2] xor G2_register[1] xor G2_register[0]; for (lcv2 = 0; lcv2 < 9; lcv2++) @@ -104,7 +104,7 @@ void gps_l1_ca_code_gen_int(gsl::span _dest, int32_t _prn, uint32_t _ch // Generate PRN from G1 and G2 Registers for (lcv = 0; lcv < _code_length; lcv++) { - aux = G1[(lcv + _chip_shift) % _code_length] ^ G2[delay]; + aux = G1[(lcv + _chip_shift) % _code_length] xor G2[delay]; if (aux == true) { _dest[lcv] = 1; @@ -172,28 +172,27 @@ void gps_l1_ca_code_gen_complex_sampled(gsl::span> _dest, ui for (int32_t i = 0; i < _samplesPerCode; i++) { - //=== Digitizing ======================================================= + //=== Digitizing =================================================== - //--- Make index array to read C/A code values ------------------------- + //--- Make index array to read C/A code values --------------------- // The length of the index array depends on the sampling frequency - // number of samples per millisecond (because one C/A code period is one // millisecond). - // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; aux = (_ts * (i + 1)) / _tc; _codeValueIndex = auxCeil(aux) - 1; - //--- Make the digitized version of the C/A code ----------------------- + //--- Make the digitized version of the C/A code ------------------- // The "upsampled" code is made by selecting values form the CA code // chip array (caCode) for the time instances of each sample. if (i == _samplesPerCode - 1) { - //--- Correct the last index (due to number rounding issues) ----------- + //--- Correct the last index (due to number rounding issues) _dest[i] = _code[_codeLength - 1]; } else { - _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + _dest[i] = _code[_codeValueIndex]; // repeat the chip -> upsample } } } diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c index 3544aad03..df25601c5 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c @@ -51,11 +51,11 @@ static const uint8_t BITN[16] = {0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4} */ uint8_t parity(uint32_t x) { - x ^= x >> 16; - x ^= x >> 8; - x ^= x >> 4; - x &= 0xF; - return (0x6996 >> x) & 1; + x ^= x >> 16U; + x ^= x >> 8U; + x ^= x >> 4U; + x &= 0xFU; + return (0x6996U >> x) & 1U; } @@ -74,7 +74,7 @@ uint32_t getbitu(const uint8_t *buff, uint32_t pos, uint8_t len) uint32_t i = 0; for (i = pos; i < pos + len; i++) { - bits = (bits << 1) + + bits = (bits << 1U) + ((buff[i / 8] >> (7 - i % 8)) & 1U); } @@ -121,7 +121,7 @@ void setbitu(uint8_t *buff, uint32_t pos, uint32_t len, uint32_t data) return; } uint32_t i = 0; - for (i = pos; i < pos + len; i++, mask >>= 1) + for (i = pos; i < pos + len; i++, mask >>= 1U) { if (data & mask) { @@ -246,10 +246,10 @@ void bitcopy(void *dst, uint32_t dst_index, const void *src, uint32_t src_index, uint8_t count_bits_u64(uint64_t v, uint8_t bv) { uint8_t r = 0; - int i = 0; + uint32_t i = 0; for (i = 0; i < 16; i++) { - r += BITN[(v >> (i * 4)) & 0xf]; + r += BITN[(v >> (i * 4U)) & 0xFU]; } return bv == 1 ? r : 64 - r; } @@ -265,10 +265,10 @@ uint8_t count_bits_u64(uint64_t v, uint8_t bv) uint8_t count_bits_u32(uint32_t v, uint8_t bv) { uint8_t r = 0; - int i = 0; + uint32_t i = 0; for (i = 0; i < 8; i++) { - r += BITN[(v >> (i * 4)) & 0xf]; + r += BITN[(v >> (i * 4U)) & 0xFU]; } return bv == 1 ? r : 32 - r; } @@ -284,10 +284,10 @@ uint8_t count_bits_u32(uint32_t v, uint8_t bv) uint8_t count_bits_u16(uint16_t v, uint8_t bv) { uint8_t r = 0; - int i = 0; + uint32_t i = 0; for (i = 0; i < 4; i++) { - r += BITN[(v >> (i * 4)) & 0xf]; + r += BITN[(v >> (i * 4U)) & 0xFU]; } return bv == 1 ? r : 16 - r; } @@ -303,10 +303,10 @@ uint8_t count_bits_u16(uint16_t v, uint8_t bv) uint8_t count_bits_u8(uint8_t v, uint8_t bv) { uint8_t r = 0; - int i = 0; + uint32_t i = 0; for (i = 0; i < 2; i++) { - r += BITN[(v >> (i * 4)) & 0xf]; + r += BITN[(v >> (i * 4U)) & 0xFU]; } return bv == 1 ? r : 8 - r; } diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.c index 260237d40..271fc6504 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/cnav_msg.c @@ -106,7 +106,7 @@ static uint32_t _cnav_extract_crc(const cnav_v27_part_t *part) GPS_CNAV_MSG_CRC_LENGTH); if (part->invert) { - crc ^= 0xFFFFFF; + crc ^= 0xFFFFFFU; } return crc; } diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c index 7bb1e644b..06aa471f4 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c @@ -93,7 +93,7 @@ uint32_t crc24q(const uint8_t *buf, uint32_t len, uint32_t crc) uint32_t i = 0; for (i = 0; i < len; i++) { - crc = ((crc << 8) & 0xFFFFFF) ^ CRC24QTAB[((crc >> 16) ^ buf[i]) & 0xff]; + crc = ((crc << 8U) & 0xFFFFFFU) ^ CRC24QTAB[((crc >> 16U) ^ buf[i]) & 0xFFU]; } return crc; } @@ -122,21 +122,21 @@ uint32_t crc24q_bits(uint32_t crc, const uint8_t *buf, uint32_t n_bits, bool inv uint32_t i = 0; for (i = 0; i < n_bits / 8; ++i) { - acc = (acc << 8) | *buf++; + acc = (acc << 8U) | *buf++; if (invert) { acc ^= 0xFFU; } b = (acc >> shift) & 0xFFU; - crc = ((crc << 8) & 0xFFFFFFU) ^ CRC24QTAB[((crc >> 16) ^ b) & 0xFFU]; + crc = ((crc << 8U) & 0xFFFFFFU) ^ CRC24QTAB[((crc >> 16U) ^ b) & 0xFFU]; } - acc = (acc << 8) | *buf; + acc = (acc << 8U) | *buf; if (invert) { acc ^= 0xFFU; } b = (acc >> shift) & 0xFFU; - crc = ((crc << 8) & 0xFFFFFFU) ^ CRC24QTAB[((crc >> 16) ^ b) & 0xFFU]; + crc = ((crc << 8U) & 0xFFFFFFU) ^ CRC24QTAB[((crc >> 16U) ^ b) & 0xFFU]; return crc; }