mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into newsatdispatcher
This commit is contained in:
		| @@ -397,11 +397,11 @@ set(GNSSSDR_PROTOBUF_MIN_VERSION "3.0.0") | |||||||
| ################################################################################ | ################################################################################ | ||||||
| set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") | set(GNSSSDR_GFLAGS_LOCAL_VERSION "2.2.2") | ||||||
| set(GNSSSDR_GLOG_LOCAL_VERSION "0.4.0") | 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_GTEST_LOCAL_VERSION "1.8.1") | ||||||
| set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") | set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "master") | ||||||
| set(GNSSSDR_GPSTK_LOCAL_VERSION "2.10.6") | 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_PUGIXML_LOCAL_VERSION "1.9") | ||||||
| set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "3.9.0") | set(GNSSSDR_PROTOCOLBUFFERS_LOCAL_VERSION "3.9.0") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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 yum install lapack-devel blas-devel             # For Fedora/CentOS/RHEL | ||||||
| $ sudo zypper install lapack-devel blas-devel          # For OpenSUSE | $ sudo zypper install lapack-devel blas-devel          # For OpenSUSE | ||||||
| $ sudo pacman -S blas lapack                           # For Arch Linux | $ sudo pacman -S blas lapack                           # For Arch Linux | ||||||
| $ wget http://sourceforge.net/projects/arma/files/armadillo-9.400.4.tar.xz | $ wget http://sourceforge.net/projects/arma/files/armadillo-9.600.4.tar.xz | ||||||
| $ tar xvfz armadillo-9.400.4.tar.xz | $ tar xvfz armadillo-9.600.4.tar.xz | ||||||
| $ cd armadillo-9.400.4 | $ cd armadillo-9.600.4 | ||||||
| $ cmake . | $ cmake . | ||||||
| $ make | $ make | ||||||
| $ sudo make install | $ sudo make install | ||||||
|   | |||||||
| @@ -71,7 +71,7 @@ void beidou_b1i_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _c | |||||||
|     for (lcv = 0; lcv < _code_length; lcv++) |     for (lcv = 0; lcv < _code_length; lcv++) | ||||||
|         { |         { | ||||||
|             G1[lcv] = G1_register[0]; |             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]; |             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]; |             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<int32_t> _dest, int32_t _prn, uint32_t _c | |||||||
|     // Generate PRN from G1 and G2 Registers |     // Generate PRN from G1 and G2 Registers | ||||||
|     for (lcv = 0; lcv < _code_length; lcv++) |     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) |             if (aux == true) | ||||||
|                 { |                 { | ||||||
|                     _dest[lcv] = 1; |                     _dest[lcv] = 1; | ||||||
|   | |||||||
| @@ -42,9 +42,9 @@ void beidou_b3i_code_gen_int(gsl::span<int> _dest, signed int _prn, unsigned int | |||||||
|     const unsigned int _code_length = 10230; |     const unsigned int _code_length = 10230; | ||||||
|     std::bitset<_code_length> G1{}; |     std::bitset<_code_length> G1{}; | ||||||
|     std::bitset<_code_length> G2{}; |     std::bitset<_code_length> G2{}; | ||||||
|     auto G1_register = std::move(std::bitset<13>{}.set());  // All true |     auto G1_register = std::bitset<13>{}.set();  // All true | ||||||
|     auto G2_register = std::move(std::bitset<13>{}.set());  // All true |     auto G2_register = std::bitset<13>{}.set();  // All true | ||||||
|     auto G1_register_reset = std::move(std::bitset<13>{}.set()); |     auto G1_register_reset = std::bitset<13>{}.set(); | ||||||
|     G1_register_reset.reset(0); |     G1_register_reset.reset(0); | ||||||
|     G1_register_reset.reset(1);  // {false, false, true, true, true, true, true, true, true, true, true, true, true}; |     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<int> _dest, signed int _prn, unsigned int | |||||||
|             // Reset G1 register if sequence found |             // Reset G1 register if sequence found | ||||||
|             if (G1_register == G1_register_reset) |             if (G1_register == G1_register_reset) | ||||||
|                 { |                 { | ||||||
|                     G1_register = std::move(std::bitset<13>{}.set());  // All true |                     G1_register = std::bitset<13>{}.set();  // All true | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -33,10 +33,10 @@ | |||||||
| #include "galileo_e1_signal_processing.h" | #include "galileo_e1_signal_processing.h" | ||||||
| #include "Galileo_E1.h" | #include "Galileo_E1.h" | ||||||
| #include "gnss_signal_processing.h" | #include "gnss_signal_processing.h" | ||||||
| #include <volk_gnsssdr/volk_gnsssdr.h> |  | ||||||
| #include <array> | #include <array> | ||||||
| #include <memory> | #include <memory> | ||||||
| #include <string> | #include <string> | ||||||
|  | #include <vector> | ||||||
|  |  | ||||||
|  |  | ||||||
| void galileo_e1_code_gen_int(gsl::span<int> _dest, const std::array<char, 3>& _Signal, int32_t _prn) | void galileo_e1_code_gen_int(gsl::span<int> _dest, const std::array<char, 3>& _Signal, int32_t _prn) | ||||||
| @@ -111,8 +111,8 @@ void galileo_e1_code_gen_sinboc11_float(gsl::span<float> _dest, const std::array | |||||||
| { | { | ||||||
|     std::string _galileo_signal = _Signal.data(); |     std::string _galileo_signal = _Signal.data(); | ||||||
|     const auto _codeLength = static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS); |     const auto _codeLength = static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS); | ||||||
|     std::array<int32_t, 4092> primary_code_E1_chips{};                                               // _codeLength not accepted by Clang |     std::array<int32_t, 4092> primary_code_E1_chips{}; | ||||||
|     galileo_e1_code_gen_int(gsl::span<int32_t>(primary_code_E1_chips.data(), 4092), _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 | ||||||
|     for (uint32_t i = 0; i < _codeLength; i++) |     for (uint32_t i = 0; i < _codeLength; i++) | ||||||
|         { |         { | ||||||
|             _dest[2 * i] = static_cast<float>(primary_code_E1_chips[i]); |             _dest[2 * i] = static_cast<float>(primary_code_E1_chips[i]); | ||||||
| @@ -163,35 +163,31 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array< | |||||||
|     std::string _galileo_signal = _Signal.data(); |     std::string _galileo_signal = _Signal.data(); | ||||||
|     uint32_t _samplesPerCode; |     uint32_t _samplesPerCode; | ||||||
|     const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ;  // Hz |     const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ;  // Hz | ||||||
|     auto _codeLength = static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS); |     std::vector<int32_t> primary_code_E1_chips(static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)); | ||||||
|     auto* primary_code_E1_chips = static_cast<int32_t*>(volk_gnsssdr_malloc(static_cast<uint32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) * sizeof(int32_t), volk_gnsssdr_get_alignment())); |     _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS)); | ||||||
|  |  | ||||||
|     _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength))); |  | ||||||
|     const int32_t _samplesPerChip = (_cboc == true) ? 12 : 2; |     const int32_t _samplesPerChip = (_cboc == true) ? 12 : 2; | ||||||
|  |  | ||||||
|     const uint32_t delay = ((static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / GALILEO_E1_B_CODE_LENGTH_CHIPS; |     const uint32_t delay = ((static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) % static_cast<int32_t>(GALILEO_E1_B_CODE_LENGTH_CHIPS)) * _samplesPerCode / GALILEO_E1_B_CODE_LENGTH_CHIPS; | ||||||
|  |  | ||||||
|     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 |     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<float> _signal_E1{new float[_codeLength]}; |     std::unique_ptr<float> _signal_E1{new float[_codeLength]}; | ||||||
|     gsl::span<float> _signal_E1_span(_signal_E1, _codeLength); |     gsl::span<float> _signal_E1_span(_signal_E1, _codeLength); | ||||||
|  |  | ||||||
|     if (_cboc == true) |     if (_cboc == true) | ||||||
|         { |         { | ||||||
|             galileo_e1_gen_float(_signal_E1_span, gsl::span<int>(primary_code_E1_chips, static_cast<uint32_t>(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 |     else | ||||||
|         { |         { | ||||||
|             auto* _signal_E1_int = static_cast<int32_t*>(volk_gnsssdr_malloc(_codeLength * sizeof(int32_t), volk_gnsssdr_get_alignment())); |             std::vector<int32_t> _signal_E1_int(static_cast<int32_t>(_codeLength)); | ||||||
|             gsl::span<int32_t> _signal_E1_int_span(_signal_E1_int, _codeLength); |             galileo_e1_sinboc_11_gen_int(_signal_E1_int, primary_code_E1_chips);  // generate sinboc(1,1) 2 samples per chip | ||||||
|             galileo_e1_sinboc_11_gen_int(_signal_E1_int_span, 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) |             for (uint32_t ii = 0; ii < _codeLength; ++ii) | ||||||
|                 { |                 { | ||||||
|                     _signal_E1_span[ii] = static_cast<float>(_signal_E1_int_span[ii]); |                     _signal_E1_span[ii] = static_cast<float>(_signal_E1_int[ii]); | ||||||
|                 } |                 } | ||||||
|             volk_gnsssdr_free(_signal_E1_int); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     if (_fs != _samplesPerChip * _codeFreqBasis) |     if (_fs != _samplesPerChip * _codeFreqBasis) | ||||||
| @@ -233,8 +229,6 @@ void galileo_e1_code_gen_float_sampled(gsl::span<float> _dest, const std::array< | |||||||
|         { |         { | ||||||
|             _dest[(i + delay) % _samplesPerCode] = _signal_E1_span_aux2[i]; |             _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<std::complex<float>> _dest, c | |||||||
|     std::string _galileo_signal = _Signal.data(); |     std::string _galileo_signal = _Signal.data(); | ||||||
|     const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ;  // Hz |     const int32_t _codeFreqBasis = GALILEO_E1_CODE_CHIP_RATE_HZ;  // Hz | ||||||
|     auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / |     auto _samplesPerCode = static_cast<uint32_t>(static_cast<double>(_fs) / | ||||||
|                                                  (static_cast<double>(_codeFreqBasis) / static_cast<double>(GALILEO_E1_B_CODE_LENGTH_CHIPS))); |                                                  (static_cast<double>(_codeFreqBasis) / GALILEO_E1_B_CODE_LENGTH_CHIPS)); | ||||||
|  |  | ||||||
|     if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) |     if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) | ||||||
|         { |         { | ||||||
|             _samplesPerCode *= static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH); |             _samplesPerCode *= static_cast<int32_t>(GALILEO_E1_C_SECONDARY_CODE_LENGTH); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     auto* real_code = static_cast<float*>(volk_gnsssdr_malloc(_samplesPerCode * sizeof(float), volk_gnsssdr_get_alignment())); |     std::vector<float> real_code(_samplesPerCode); | ||||||
|     gsl::span<float> real_code_span(real_code, _samplesPerCode); |     galileo_e1_code_gen_float_sampled(real_code, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag); | ||||||
|     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) |     for (uint32_t ii = 0; ii < _samplesPerCode; ++ii) | ||||||
|         { |         { | ||||||
|             _dest[ii] = std::complex<float>(real_code_span[ii], 0.0F); |             _dest[ii] = std::complex<float>(real_code[ii], 0.0F); | ||||||
|         } |         } | ||||||
|     volk_gnsssdr_free(real_code); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -32,30 +32,26 @@ | |||||||
|  |  | ||||||
| #include "glonass_l1_signal_processing.h" | #include "glonass_l1_signal_processing.h" | ||||||
| #include <array> | #include <array> | ||||||
|  | #include <bitset> | ||||||
|  |  | ||||||
| auto auxCeil = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); }; | auto auxCeil = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); }; | ||||||
|  |  | ||||||
| void glonass_l1_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, /* int32_t  _prn,*/ uint32_t _chip_shift) | void glonass_l1_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, /* int32_t  _prn,*/ uint32_t _chip_shift) | ||||||
| { | { | ||||||
|     const uint32_t _code_length = 511; |     const uint32_t _code_length = 511; | ||||||
|     std::array<bool, _code_length> G1{}; |     std::bitset<_code_length> G1{}; | ||||||
|     std::array<bool, 9> G1_register{}; |     auto G1_register = std::bitset<9>{}.set();  // All true | ||||||
|     bool feedback1; |     bool feedback1; | ||||||
|     bool aux; |     bool aux; | ||||||
|     uint32_t delay; |     uint32_t delay; | ||||||
|     uint32_t lcv, lcv2; |     uint32_t lcv, lcv2; | ||||||
|  |  | ||||||
|     for (lcv = 0; lcv < 9; lcv++) |  | ||||||
|         { |  | ||||||
|             G1_register[lcv] = true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|     /* Generate G1 Register */ |     /* Generate G1 Register */ | ||||||
|     for (lcv = 0; lcv < _code_length; lcv++) |     for (lcv = 0; lcv < _code_length; lcv++) | ||||||
|         { |         { | ||||||
|             G1[lcv] = G1_register[2]; |             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++) |             for (lcv2 = 0; lcv2 < 8; lcv2++) | ||||||
|                 { |                 { | ||||||
| @@ -123,7 +119,7 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest | |||||||
|     _ts = 1.0 / static_cast<float>(_fs);             // Sampling period in sec |     _ts = 1.0 / static_cast<float>(_fs);             // Sampling period in sec | ||||||
|     _tc = 1.0 / static_cast<float>(_codeFreqBasis);  // C/A chip period in sec |     _tc = 1.0 / static_cast<float>(_codeFreqBasis);  // C/A chip period in sec | ||||||
|  |  | ||||||
|     glonass_l1_ca_code_gen_complex(gsl::span<std::complex<float>>(_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++) |     for (int32_t i = 0; i < _samplesPerCode; i++) | ||||||
|         { |         { | ||||||
| @@ -134,7 +130,6 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest | |||||||
|             // number of samples per millisecond (because one C/A code period is one |             // number of samples per millisecond (because one C/A code period is one | ||||||
|             // millisecond). |             // millisecond). | ||||||
|  |  | ||||||
|             // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; |  | ||||||
|             aux = (_ts * (i + 1)) / _tc; |             aux = (_ts * (i + 1)) / _tc; | ||||||
|             _codeValueIndex = auxCeil(aux) - 1; |             _codeValueIndex = auxCeil(aux) - 1; | ||||||
|  |  | ||||||
| @@ -148,7 +143,7 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest | |||||||
|                 } |                 } | ||||||
|             else |             else | ||||||
|                 { |                 { | ||||||
|                     _dest[i] = _code[_codeValueIndex];  //repeat the chip -> upsample |                     _dest[i] = _code[_codeValueIndex];  // repeat the chip -> upsample | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -32,30 +32,26 @@ | |||||||
|  |  | ||||||
| #include "glonass_l2_signal_processing.h" | #include "glonass_l2_signal_processing.h" | ||||||
| #include <array> | #include <array> | ||||||
|  | #include <bitset> | ||||||
|  |  | ||||||
| auto auxCeil = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); }; | auto auxCeil = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); }; | ||||||
|  |  | ||||||
| void glonass_l2_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, /* int32_t _prn,*/ uint32_t _chip_shift) | void glonass_l2_ca_code_gen_complex(gsl::span<std::complex<float>> _dest, /* int32_t _prn,*/ uint32_t _chip_shift) | ||||||
| { | { | ||||||
|     const uint32_t _code_length = 511; |     const uint32_t _code_length = 511; | ||||||
|     std::array<bool, _code_length> G1{}; |     std::bitset<_code_length> G1{}; | ||||||
|     std::array<bool, 9> G1_register{}; |     auto G1_register = std::bitset<9>{}.set();  // All true | ||||||
|     bool feedback1; |     bool feedback1; | ||||||
|     bool aux; |     bool aux; | ||||||
|     uint32_t delay; |     uint32_t delay; | ||||||
|     uint32_t lcv, lcv2; |     uint32_t lcv, lcv2; | ||||||
|  |  | ||||||
|     for (lcv = 0; lcv < 9; lcv++) |  | ||||||
|         { |  | ||||||
|             G1_register[lcv] = true; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|     /* Generate G1 Register */ |     /* Generate G1 Register */ | ||||||
|     for (lcv = 0; lcv < _code_length; lcv++) |     for (lcv = 0; lcv < _code_length; lcv++) | ||||||
|         { |         { | ||||||
|             G1[lcv] = G1_register[2]; |             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++) |             for (lcv2 = 0; lcv2 < 8; lcv2++) | ||||||
|                 { |                 { | ||||||
| @@ -123,7 +119,7 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest | |||||||
|     _ts = 1.0 / static_cast<float>(_fs);             // Sampling period in sec |     _ts = 1.0 / static_cast<float>(_fs);             // Sampling period in sec | ||||||
|     _tc = 1.0 / static_cast<float>(_codeFreqBasis);  // C/A chip period in sec |     _tc = 1.0 / static_cast<float>(_codeFreqBasis);  // C/A chip period in sec | ||||||
|  |  | ||||||
|     glonass_l2_ca_code_gen_complex(gsl::span<std::complex<float>>(_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++) |     for (int32_t i = 0; i < _samplesPerCode; i++) | ||||||
|         { |         { | ||||||
| @@ -134,7 +130,6 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest | |||||||
|             // number of samples per millisecond (because one C/A code period is one |             // number of samples per millisecond (because one C/A code period is one | ||||||
|             // millisecond). |             // millisecond). | ||||||
|  |  | ||||||
|             // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; |  | ||||||
|             aux = (_ts * (i + 1)) / _tc; |             aux = (_ts * (i + 1)) / _tc; | ||||||
|             _codeValueIndex = auxCeil(aux) - 1; |             _codeValueIndex = auxCeil(aux) - 1; | ||||||
|  |  | ||||||
| @@ -148,7 +143,7 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest | |||||||
|                 } |                 } | ||||||
|             else |             else | ||||||
|                 { |                 { | ||||||
|                     _dest[i] = _code[_codeValueIndex];  //repeat the chip -> upsample |                     _dest[i] = _code[_codeValueIndex];  // repeat the chip -> upsample | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -154,6 +154,8 @@ void hex_to_binary_converter(gsl::span<int32_t> _dest, char _from) | |||||||
|             _dest[2] = -1; |             _dest[2] = -1; | ||||||
|             _dest[3] = -1; |             _dest[3] = -1; | ||||||
|             break; |             break; | ||||||
|  |         default: | ||||||
|  |             break; | ||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -168,13 +170,12 @@ void resampler(const gsl::span<float> _from, gsl::span<float> _dest, float _fs_i | |||||||
|     const float _t_out = 1 / _fs_out;  // Out sampling period in sec |     const float _t_out = 1 / _fs_out;  // Out sampling period in sec | ||||||
|     for (uint32_t i = 0; i < _dest.size() - 1; i++) |     for (uint32_t i = 0; i < _dest.size() - 1; i++) | ||||||
|         { |         { | ||||||
|             //=== Digitizing ======================================================= |             //=== Digitizing =================================================== | ||||||
|             //--- compute index array to read sampled values ------------------------- |             //--- compute index array to read sampled values ------------------- | ||||||
|             //_codeValueIndex = ceil((_t_out * ((float)i + 1)) / _t_in) - 1; |  | ||||||
|             aux = (_t_out * (i + 1)) / _t_in; |             aux = (_t_out * (i + 1)) / _t_in; | ||||||
|             _codeValueIndex = auxCeil2(aux) - 1; |             _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]; |             _dest[i] = _from[_codeValueIndex]; | ||||||
|         } |         } | ||||||
|     //--- Correct the last index (due to number rounding issues) ----------- |     //--- Correct the last index (due to number rounding issues) ----------- | ||||||
| @@ -192,13 +193,12 @@ void resampler(gsl::span<const std::complex<float>> _from, gsl::span<std::comple | |||||||
|     const float _t_out = 1 / _fs_out;  // Out sampling period in sec |     const float _t_out = 1 / _fs_out;  // Out sampling period in sec | ||||||
|     for (uint32_t i = 0; i < _dest.size() - 1; i++) |     for (uint32_t i = 0; i < _dest.size() - 1; i++) | ||||||
|         { |         { | ||||||
|             //=== Digitizing ======================================================= |             //=== Digitizing =================================================== | ||||||
|             //--- compute index array to read sampled values ------------------------- |             //--- compute index array to read sampled values ------------------- | ||||||
|             //_codeValueIndex = ceil((_t_out * ((float)i + 1)) / _t_in) - 1; |  | ||||||
|             aux = (_t_out * (i + 1)) / _t_in; |             aux = (_t_out * (i + 1)) / _t_in; | ||||||
|             _codeValueIndex = auxCeil2(aux) - 1; |             _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]; |             _dest[i] = _from[_codeValueIndex]; | ||||||
|         } |         } | ||||||
|     //--- Correct the last index (due to number rounding issues) ----------- |     //--- Correct the last index (due to number rounding issues) ----------- | ||||||
|   | |||||||
| @@ -32,13 +32,14 @@ | |||||||
|  |  | ||||||
| #include "gps_l2c_signal.h" | #include "gps_l2c_signal.h" | ||||||
| #include "GPS_L2C.h" | #include "GPS_L2C.h" | ||||||
|  | #include <array> | ||||||
| #include <cmath> | #include <cmath> | ||||||
| #include <memory> | #include <memory> | ||||||
|  |  | ||||||
|  |  | ||||||
| uint32_t gps_l2c_m_shift(uint32_t x) | uint32_t gps_l2c_m_shift(uint32_t x) | ||||||
| { | { | ||||||
|     return static_cast<uint32_t>((x >> 1U) ^ ((x & 1U) * 0445112474U)); |     return static_cast<uint32_t>((x >> 1U) xor ((x & 1U) * 0445112474U)); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -56,32 +57,30 @@ 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) | void gps_l2c_m_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L2_M_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     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++) |     for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) | ||||||
|         { |         { | ||||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0); |             _dest[i] = std::complex<float>(1.0 - 2.0 * _code[i], 0.0); | ||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | void gps_l2c_m_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L2_M_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     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++) |     for (int32_t i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) | ||||||
|         { |         { | ||||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]); |             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]); | ||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -91,11 +90,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) | void gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L2_M_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L2_M_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     if (_prn > 0 and _prn < 51) | ||||||
|         { |         { | ||||||
|             gps_l2c_m_code(_code_span, _prn); |             gps_l2c_m_code(_code, _prn); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     int32_t _samplesPerCode, _codeValueIndex; |     int32_t _samplesPerCode, _codeValueIndex; | ||||||
| @@ -121,11 +119,11 @@ void gps_l2c_m_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, ui | |||||||
|             if (i == _samplesPerCode - 1) |             if (i == _samplesPerCode - 1) | ||||||
|                 { |                 { | ||||||
|                     //--- Correct the last index (due to number rounding issues) ----------- |                     //--- Correct the last index (due to number rounding issues) ----------- | ||||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0); |                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0); | ||||||
|                 } |                 } | ||||||
|             else |             else | ||||||
|                 { |                 { | ||||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0);  //repeat the chip -> upsample |                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0);  //repeat the chip -> upsample | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -32,9 +32,9 @@ | |||||||
|  |  | ||||||
| #include "gps_l5_signal.h" | #include "gps_l5_signal.h" | ||||||
| #include "GPS_L5.h" | #include "GPS_L5.h" | ||||||
|  | #include <array> | ||||||
| #include <deque> | #include <deque> | ||||||
|  |  | ||||||
|  |  | ||||||
| std::deque<bool> l5i_xa_shift(std::deque<bool> xa)  // GPS-IS-705E Figure 3-4 pp. 15 | std::deque<bool> l5i_xa_shift(std::deque<bool> xa)  // GPS-IS-705E Figure 3-4 pp. 15 | ||||||
| { | { | ||||||
|     if (xa == std::deque<bool>{true, true, true, true, true, true, true, true, true, true, true, false, true}) |     if (xa == std::deque<bool>{true, true, true, true, true, true, true, true, true, true, true, false, true}) | ||||||
| @@ -173,32 +173,30 @@ 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) | void gps_l5i_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L5I_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     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++) |     for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) | ||||||
|         { |         { | ||||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0); |             _dest[i] = std::complex<float>(1.0 - 2.0 * static_cast<float>(_code[i]), 0.0); | ||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | void gps_l5i_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L5I_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     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++) |     for (int32_t i = 0; i < GPS_L5I_CODE_LENGTH_CHIPS; i++) | ||||||
|         { |         { | ||||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]); |             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]); | ||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -208,11 +206,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) | void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5I_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L5I_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5I_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     if (_prn > 0 and _prn < 51) | ||||||
|         { |         { | ||||||
|             make_l5i(_code_span, _prn - 1); |             make_l5i(_code, _prn - 1); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     int32_t _samplesPerCode, _codeValueIndex; |     int32_t _samplesPerCode, _codeValueIndex; | ||||||
| @@ -238,11 +235,11 @@ void gps_l5i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint | |||||||
|             if (i == _samplesPerCode - 1) |             if (i == _samplesPerCode - 1) | ||||||
|                 { |                 { | ||||||
|                     //--- Correct the last index (due to number rounding issues) ----------- |                     //--- Correct the last index (due to number rounding issues) ----------- | ||||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0.0); |                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0.0); | ||||||
|                 } |                 } | ||||||
|             else |             else | ||||||
|                 { |                 { | ||||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0.0);  // repeat the chip -> upsample |                     _dest[i] = std::complex<float>(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<std::complex<float>> _dest, uint | |||||||
|  |  | ||||||
| void gps_l5q_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | void gps_l5q_code_gen_complex(gsl::span<std::complex<float>> _dest, uint32_t _prn) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L5Q_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     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++) |     for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) | ||||||
|         { |         { | ||||||
|             _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[i], 0.0); |             _dest[i] = std::complex<float>(1.0 - 2.0 * static_cast<float>(_code[i]), 0.0); | ||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | void gps_l5q_code_gen_float(gsl::span<float> _dest, uint32_t _prn) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L5Q_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     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++) |     for (int32_t i = 0; i < GPS_L5Q_CODE_LENGTH_CHIPS; i++) | ||||||
|         { |         { | ||||||
|             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code_span[i]); |             _dest[i] = 1.0 - 2.0 * static_cast<float>(_code[i]); | ||||||
|         } |         } | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -285,11 +280,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) | void gps_l5q_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint32_t _prn, int32_t _fs) | ||||||
| { | { | ||||||
|     std::unique_ptr<int32_t> _code{new int32_t[GPS_L5Q_CODE_LENGTH_CHIPS]}; |     std::array<int32_t, GPS_L5Q_CODE_LENGTH_CHIPS> _code{}; | ||||||
|     gsl::span<int32_t> _code_span(_code, GPS_L5Q_CODE_LENGTH_CHIPS); |  | ||||||
|     if (_prn > 0 and _prn < 51) |     if (_prn > 0 and _prn < 51) | ||||||
|         { |         { | ||||||
|             make_l5q(_code_span, _prn - 1); |             make_l5q(_code, _prn - 1); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     int32_t _samplesPerCode, _codeValueIndex; |     int32_t _samplesPerCode, _codeValueIndex; | ||||||
| @@ -316,11 +310,11 @@ void gps_l5q_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, uint | |||||||
|             if (i == _samplesPerCode - 1) |             if (i == _samplesPerCode - 1) | ||||||
|                 { |                 { | ||||||
|                     //--- Correct the last index (due to number rounding issues) ----------- |                     //--- Correct the last index (due to number rounding issues) ----------- | ||||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeLength - 1], 0); |                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeLength - 1], 0); | ||||||
|                 } |                 } | ||||||
|             else |             else | ||||||
|                 { |                 { | ||||||
|                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code_span[_codeValueIndex], 0);  // repeat the chip -> upsample |                     _dest[i] = std::complex<float>(1.0 - 2.0 * _code[_codeValueIndex], 0);  // repeat the chip -> upsample | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -83,7 +83,7 @@ void gps_l1_ca_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _ch | |||||||
|             G1[lcv] = G1_register[0]; |             G1[lcv] = G1_register[0]; | ||||||
|             G2[lcv] = G2_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]; |             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++) |             for (lcv2 = 0; lcv2 < 9; lcv2++) | ||||||
| @@ -104,7 +104,7 @@ void gps_l1_ca_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _ch | |||||||
|     // Generate PRN from G1 and G2 Registers |     // Generate PRN from G1 and G2 Registers | ||||||
|     for (lcv = 0; lcv < _code_length; lcv++) |     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) |             if (aux == true) | ||||||
|                 { |                 { | ||||||
|                     _dest[lcv] = 1; |                     _dest[lcv] = 1; | ||||||
| @@ -172,28 +172,27 @@ void gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, ui | |||||||
|  |  | ||||||
|     for (int32_t i = 0; i < _samplesPerCode; i++) |     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 - |             // The length of the index array depends on the sampling frequency - | ||||||
|             // number of samples per millisecond (because one C/A code period is one |             // number of samples per millisecond (because one C/A code period is one | ||||||
|             // millisecond). |             // millisecond). | ||||||
|  |  | ||||||
|             // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; |  | ||||||
|             aux = (_ts * (i + 1)) / _tc; |             aux = (_ts * (i + 1)) / _tc; | ||||||
|             _codeValueIndex = auxCeil(aux) - 1; |             _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 |             // The "upsampled" code is made by selecting values form the CA code | ||||||
|             // chip array (caCode) for the time instances of each sample. |             // chip array (caCode) for the time instances of each sample. | ||||||
|             if (i == _samplesPerCode - 1) |             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]; |                     _dest[i] = _code[_codeLength - 1]; | ||||||
|                 } |                 } | ||||||
|             else |             else | ||||||
|                 { |                 { | ||||||
|                     _dest[i] = _code[_codeValueIndex];  //repeat the chip -> upsample |                     _dest[i] = _code[_codeValueIndex];  // repeat the chip -> upsample | ||||||
|                 } |                 } | ||||||
|         } |         } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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) | uint8_t parity(uint32_t x) | ||||||
| { | { | ||||||
|     x ^= x >> 16; |     x ^= x >> 16U; | ||||||
|     x ^= x >> 8; |     x ^= x >> 8U; | ||||||
|     x ^= x >> 4; |     x ^= x >> 4U; | ||||||
|     x &= 0xF; |     x &= 0xFU; | ||||||
|     return (0x6996 >> x) & 1; |     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; |     uint32_t i = 0; | ||||||
|     for (i = pos; i < pos + len; i++) |     for (i = pos; i < pos + len; i++) | ||||||
|         { |         { | ||||||
|             bits = (bits << 1) + |             bits = (bits << 1U) + | ||||||
|                    ((buff[i / 8] >> (7 - i % 8)) & 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; |             return; | ||||||
|         } |         } | ||||||
|     uint32_t i = 0; |     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) |             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 count_bits_u64(uint64_t v, uint8_t bv) | ||||||
| { | { | ||||||
|     uint8_t r = 0; |     uint8_t r = 0; | ||||||
|     int i = 0; |     uint32_t i = 0; | ||||||
|     for (i = 0; i < 16; i++) |     for (i = 0; i < 16; i++) | ||||||
|         { |         { | ||||||
|             r += BITN[(v >> (i * 4)) & 0xf]; |             r += BITN[(v >> (i * 4U)) & 0xFU]; | ||||||
|         } |         } | ||||||
|     return bv == 1 ? r : 64 - r; |     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 count_bits_u32(uint32_t v, uint8_t bv) | ||||||
| { | { | ||||||
|     uint8_t r = 0; |     uint8_t r = 0; | ||||||
|     int i = 0; |     uint32_t i = 0; | ||||||
|     for (i = 0; i < 8; i++) |     for (i = 0; i < 8; i++) | ||||||
|         { |         { | ||||||
|             r += BITN[(v >> (i * 4)) & 0xf]; |             r += BITN[(v >> (i * 4U)) & 0xFU]; | ||||||
|         } |         } | ||||||
|     return bv == 1 ? r : 32 - r; |     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 count_bits_u16(uint16_t v, uint8_t bv) | ||||||
| { | { | ||||||
|     uint8_t r = 0; |     uint8_t r = 0; | ||||||
|     int i = 0; |     uint32_t i = 0; | ||||||
|     for (i = 0; i < 4; i++) |     for (i = 0; i < 4; i++) | ||||||
|         { |         { | ||||||
|             r += BITN[(v >> (i * 4)) & 0xf]; |             r += BITN[(v >> (i * 4U)) & 0xFU]; | ||||||
|         } |         } | ||||||
|     return bv == 1 ? r : 16 - r; |     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 count_bits_u8(uint8_t v, uint8_t bv) | ||||||
| { | { | ||||||
|     uint8_t r = 0; |     uint8_t r = 0; | ||||||
|     int i = 0; |     uint32_t i = 0; | ||||||
|     for (i = 0; i < 2; i++) |     for (i = 0; i < 2; i++) | ||||||
|         { |         { | ||||||
|             r += BITN[(v >> (i * 4)) & 0xf]; |             r += BITN[(v >> (i * 4U)) & 0xFU]; | ||||||
|         } |         } | ||||||
|     return bv == 1 ? r : 8 - r; |     return bv == 1 ? r : 8 - r; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -106,7 +106,7 @@ static uint32_t _cnav_extract_crc(const cnav_v27_part_t *part) | |||||||
|         GPS_CNAV_MSG_CRC_LENGTH); |         GPS_CNAV_MSG_CRC_LENGTH); | ||||||
|     if (part->invert) |     if (part->invert) | ||||||
|         { |         { | ||||||
|             crc ^= 0xFFFFFF; |             crc ^= 0xFFFFFFU; | ||||||
|         } |         } | ||||||
|     return crc; |     return crc; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -93,7 +93,7 @@ uint32_t crc24q(const uint8_t *buf, uint32_t len, uint32_t crc) | |||||||
|     uint32_t i = 0; |     uint32_t i = 0; | ||||||
|     for (i = 0; i < len; i++) |     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; |     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; |     uint32_t i = 0; | ||||||
|     for (i = 0; i < n_bits / 8; ++i) |     for (i = 0; i < n_bits / 8; ++i) | ||||||
|         { |         { | ||||||
|             acc = (acc << 8) | *buf++; |             acc = (acc << 8U) | *buf++; | ||||||
|             if (invert) |             if (invert) | ||||||
|                 { |                 { | ||||||
|                     acc ^= 0xFFU; |                     acc ^= 0xFFU; | ||||||
|                 } |                 } | ||||||
|             b = (acc >> shift) & 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) |     if (invert) | ||||||
|         { |         { | ||||||
|             acc ^= 0xFFU; |             acc ^= 0xFFU; | ||||||
|         } |         } | ||||||
|     b = (acc >> shift) & 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; |     return crc; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Javier Arribas
					Javier Arribas