From 65a08040847622c6c4e3d5e8b991d0424a9f8270 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 13 Aug 2018 10:18:05 +0200 Subject: [PATCH] Add more extensive use of cstdint typenames --- src/algorithms/channel/adapters/channel.cc | 6 +- src/algorithms/channel/adapters/channel.h | 4 +- src/algorithms/channel/libs/channel_fsm.cc | 12 +-- src/algorithms/channel/libs/channel_fsm.h | 7 +- .../libs/galileo_e1_signal_processing.cc | 94 ++++++++++--------- .../libs/galileo_e1_signal_processing.h | 11 ++- .../libs/galileo_e5_signal_processing.cc | 27 +++--- .../libs/galileo_e5_signal_processing.h | 8 +- .../libs/glonass_l1_signal_processing.cc | 22 ++--- .../libs/glonass_l1_signal_processing.h | 7 +- .../libs/glonass_l2_signal_processing.cc | 22 ++--- .../libs/glonass_l2_signal_processing.h | 7 +- .../libs/gnss_sdr_fpga_sample_counter.cc | 6 +- src/algorithms/libs/gnss_signal_processing.cc | 23 +++-- src/algorithms/libs/gnss_signal_processing.h | 15 +-- src/algorithms/libs/gps_l2c_signal.cc | 26 ++--- src/algorithms/libs/gps_l2c_signal.h | 9 +- src/algorithms/libs/gps_l5_signal.cc | 69 +++++++------- src/algorithms/libs/gps_l5_signal.h | 14 +-- .../libs/gps_sdr_signal_processing.cc | 42 ++++----- .../libs/gps_sdr_signal_processing.h | 17 ++-- 21 files changed, 233 insertions(+), 215 deletions(-) diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 154f75a4d..c16f25422 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -39,7 +39,7 @@ using google::LogMessage; // Constructor -Channel::Channel(ConfigurationInterface* configuration, unsigned int channel, +Channel::Channel(ConfigurationInterface* configuration, uint32_t channel, std::shared_ptr pass_through, std::shared_ptr acq, std::shared_ptr trk, std::shared_ptr nav, std::string role, std::string implementation, gr::msg_queue::sptr queue) @@ -76,9 +76,9 @@ Channel::Channel(ConfigurationInterface* configuration, unsigned int channel, // IMPORTANT: Do not change the order between set_doppler_step and set_threshold - unsigned int doppler_step = configuration->property("Acquisition_" + implementation_ + boost::lexical_cast(channel_) + ".doppler_step", 0); + uint32_t doppler_step = configuration->property("Acquisition_" + implementation_ + boost::lexical_cast(channel_) + ".doppler_step", 0); if (doppler_step == 0) doppler_step = configuration->property("Acquisition_" + implementation_ + ".doppler_step", 500); - if (FLAGS_doppler_step != 0) doppler_step = static_cast(FLAGS_doppler_step); + if (FLAGS_doppler_step != 0) doppler_step = static_cast(FLAGS_doppler_step); DLOG(INFO) << "Channel " << channel_ << " Doppler_step = " << doppler_step; acq_->set_doppler_step(doppler_step); diff --git a/src/algorithms/channel/adapters/channel.h b/src/algorithms/channel/adapters/channel.h index d82ad0870..780ee1ec2 100644 --- a/src/algorithms/channel/adapters/channel.h +++ b/src/algorithms/channel/adapters/channel.h @@ -60,7 +60,7 @@ class Channel : public ChannelInterface { public: //! Constructor - Channel(ConfigurationInterface* configuration, unsigned int channel, + Channel(ConfigurationInterface* configuration, uint32_t channel, std::shared_ptr pass_through, std::shared_ptr acq, std::shared_ptr trk, std::shared_ptr nav, std::string role, std::string implementation, gr::msg_queue::sptr queue); @@ -99,7 +99,7 @@ private: std::string role_; std::string implementation_; bool flag_enable_fpga; - unsigned int channel_; + uint32_t channel_; Gnss_Synchro gnss_synchro_; Gnss_Signal gnss_signal_; bool connected_; diff --git a/src/algorithms/channel/libs/channel_fsm.cc b/src/algorithms/channel/libs/channel_fsm.cc index 5ac015f2d..4296ccf0d 100644 --- a/src/algorithms/channel/libs/channel_fsm.cc +++ b/src/algorithms/channel/libs/channel_fsm.cc @@ -39,16 +39,16 @@ ChannelFsm::ChannelFsm() { acq_ = nullptr; trk_ = nullptr; - channel_ = 0; - d_state = 0; + channel_ = 0U; + d_state = 0U; } ChannelFsm::ChannelFsm(std::shared_ptr acquisition) : acq_(acquisition) { trk_ = nullptr; - channel_ = 0; - d_state = 0; + channel_ = 0U; + d_state = 0U; } @@ -129,7 +129,7 @@ bool ChannelFsm::Event_failed_tracking_standby() } else { - d_state = 0; + d_state = 0U; notify_stop_tracking(); DLOG(INFO) << "CH = " << channel_ << ". Ev failed tracking standby"; return true; @@ -158,7 +158,7 @@ void ChannelFsm::set_queue(gr::msg_queue::sptr queue) } -void ChannelFsm::set_channel(unsigned int channel) +void ChannelFsm::set_channel(uint32_t channel) { std::lock_guard lk(mx); channel_ = channel; diff --git a/src/algorithms/channel/libs/channel_fsm.h b/src/algorithms/channel/libs/channel_fsm.h index 7489ca171..d1fe8e1bf 100644 --- a/src/algorithms/channel/libs/channel_fsm.h +++ b/src/algorithms/channel/libs/channel_fsm.h @@ -36,6 +36,7 @@ #include "tracking_interface.h" #include "telemetry_decoder_interface.h" #include +#include #include #include @@ -52,7 +53,7 @@ public: void set_acquisition(std::shared_ptr acquisition); void set_tracking(std::shared_ptr tracking); void set_queue(gr::msg_queue::sptr queue); - void set_channel(unsigned int channel); + void set_channel(uint32_t channel); //FSM EVENTS bool Event_start_acquisition(); @@ -70,8 +71,8 @@ private: std::shared_ptr acq_; std::shared_ptr trk_; gr::msg_queue::sptr queue_; - unsigned int channel_; - unsigned int d_state; + uint32_t channel_; + uint32_t d_state; std::mutex mx; }; diff --git a/src/algorithms/libs/galileo_e1_signal_processing.cc b/src/algorithms/libs/galileo_e1_signal_processing.cc index 2e0d224cf..e4b589a9d 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.cc +++ b/src/algorithms/libs/galileo_e1_signal_processing.cc @@ -36,11 +36,11 @@ #include -void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn) +void galileo_e1_code_gen_int(int* _dest, char _Signal[3], int32_t _prn) { std::string _galileo_signal = _Signal; - signed int prn = _prn - 1; - int index = 0; + int32_t prn = _prn - 1; + int32_t index = 0; /* A simple error check */ if ((_prn < 1) || (_prn > 50)) @@ -67,17 +67,17 @@ void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn) } -void galileo_e1_sinboc_11_gen_int(int* _dest, int* _prn, unsigned int _length_out) +void galileo_e1_sinboc_11_gen_int(int* _dest, int* _prn, uint32_t _length_out) { - const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; - unsigned int _period = static_cast(_length_out / _length_in); - for (unsigned int i = 0; i < _length_in; i++) + const uint32_t _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; + uint32_t _period = static_cast(_length_out / _length_in); + for (uint32_t i = 0; i < _length_in; i++) { - for (unsigned int j = 0; j < (_period / 2); j++) + for (uint32_t j = 0; j < (_period / 2); j++) { _dest[i * _period + j] = _prn[i]; } - for (unsigned int j = (_period / 2); j < _period; j++) + for (uint32_t j = (_period / 2); j < _period; j++) { _dest[i * _period + j] = -_prn[i]; } @@ -85,53 +85,55 @@ void galileo_e1_sinboc_11_gen_int(int* _dest, int* _prn, unsigned int _length_ou } -void galileo_e1_sinboc_61_gen_int(int* _dest, int* _prn, unsigned int _length_out) +void galileo_e1_sinboc_61_gen_int(int* _dest, int* _prn, uint32_t _length_out) { - const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; - unsigned int _period = static_cast(_length_out / _length_in); + const uint32_t _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; + uint32_t _period = static_cast(_length_out / _length_in); - for (unsigned int i = 0; i < _length_in; i++) + for (uint32_t i = 0; i < _length_in; i++) { - for (unsigned int j = 0; j < _period; j += 2) + for (uint32_t j = 0; j < _period; j += 2) { _dest[i * _period + j] = _prn[i]; } - for (unsigned int j = 1; j < _period; j += 2) + for (uint32_t j = 1; j < _period; j += 2) { _dest[i * _period + j] = -_prn[i]; } } } -void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], unsigned int _prn) + +void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], uint32_t _prn) { std::string _galileo_signal = _Signal; - unsigned int _codeLength = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); - int primary_code_E1_chips[4092]; // _codeLength not accepted by Clang + uint32_t _codeLength = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); + int32_t primary_code_E1_chips[4092]; // _codeLength not accepted by Clang galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); //generate Galileo E1 code, 1 sample per chip - for (unsigned int i = 0; i < _codeLength; i++) + for (uint32_t i = 0; i < _codeLength; i++) { _dest[2 * i] = static_cast(primary_code_E1_chips[i]); _dest[2 * i + 1] = -_dest[2 * i]; } } + void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) { std::string _galileo_signal = _Signal; - const unsigned int _codeLength = 12 * Galileo_E1_B_CODE_LENGTH_CHIPS; + const uint32_t _codeLength = 12 * Galileo_E1_B_CODE_LENGTH_CHIPS; const float alpha = sqrt(10.0 / 11.0); const float beta = sqrt(1.0 / 11.0); - int sinboc_11[12 * 4092]; // _codeLength not accepted by Clang - int sinboc_61[12 * 4092]; + int32_t sinboc_11[12 * 4092]; // _codeLength not accepted by Clang + int32_t sinboc_61[12 * 4092]; galileo_e1_sinboc_11_gen_int(sinboc_11, _prn, _codeLength); //generate sinboc(1,1) 12 samples per chip galileo_e1_sinboc_61_gen_int(sinboc_61, _prn, _codeLength); //generate sinboc(6,1) 12 samples per chip if (_galileo_signal.rfind("1B") != std::string::npos && _galileo_signal.length() >= 2) { - for (unsigned int i = 0; i < _codeLength; i++) + for (uint32_t i = 0; i < _codeLength; i++) { _dest[i] = alpha * static_cast(sinboc_11[i]) + beta * static_cast(sinboc_61[i]); @@ -139,7 +141,7 @@ void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) } else if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2) { - for (unsigned int i = 0; i < _codeLength; i++) + for (uint32_t i = 0; i < _codeLength; i++) { _dest[i] = alpha * static_cast(sinboc_11[i]) - beta * static_cast(sinboc_61[i]); @@ -149,19 +151,19 @@ void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, bool _secondary_flag) { // This function is based on the GNU software GPS for MATLAB in Kay Borre's book std::string _galileo_signal = _Signal; - unsigned int _samplesPerCode; - const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz - unsigned int _codeLength = Galileo_E1_B_CODE_LENGTH_CHIPS; - int primary_code_E1_chips[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)]; - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); - const int _samplesPerChip = (_cboc == true) ? 12 : 2; + uint32_t _samplesPerCode; + const int32_t _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz + uint32_t _codeLength = Galileo_E1_B_CODE_LENGTH_CHIPS; + int32_t primary_code_E1_chips[static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS)]; + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); + const int32_t _samplesPerChip = (_cboc == true) ? 12 : 2; - const unsigned int 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; + 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(primary_code_E1_chips, _Signal, _prn); //generate Galileo E1 code, 1 sample per chip @@ -176,10 +178,10 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], } else { - int _signal_E1_int[_codeLength]; + int32_t _signal_E1_int[_codeLength]; galileo_e1_sinboc_11_gen_int(_signal_E1_int, primary_code_E1_chips, _codeLength); //generate sinboc(1,1) 2 samples per chip - for (unsigned int ii = 0; ii < _codeLength; ++ii) + for (uint32_t ii = 0; ii < _codeLength; ++ii) { _signal_E1[ii] = static_cast(_signal_E1_int[ii]); } @@ -197,9 +199,9 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) { - float* _signal_E1C_secondary = new float[static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode]; + float* _signal_E1C_secondary = new float[static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode]; - for (unsigned int i = 0; i < static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); i++) + for (uint32_t i = 0; i < static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); i++) { for (unsigned k = 0; k < _samplesPerCode; k++) { @@ -207,13 +209,13 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], } } - _samplesPerCode *= static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); + _samplesPerCode *= static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); delete[] _signal_E1; _signal_E1 = _signal_E1C_secondary; } - for (unsigned int i = 0; i < _samplesPerCode; i++) + for (uint32_t i = 0; i < _samplesPerCode; i++) { _dest[(i + delay) % _samplesPerCode] = _signal_E1[i]; } @@ -223,24 +225,24 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, bool _secondary_flag) { std::string _galileo_signal = _Signal; - const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz - unsigned int _samplesPerCode = static_cast(static_cast(_fs) / - (static_cast(_codeFreqBasis) / static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS))); + const int32_t _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz + uint32_t _samplesPerCode = static_cast(static_cast(_fs) / + (static_cast(_codeFreqBasis) / static_cast(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); + _samplesPerCode *= static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); } float real_code[_samplesPerCode]; galileo_e1_code_gen_float_sampled(real_code, _Signal, _cboc, _prn, _fs, _chip_shift, _secondary_flag); - for (unsigned int ii = 0; ii < _samplesPerCode; ++ii) + for (uint32_t ii = 0; ii < _samplesPerCode; ++ii) { _dest[ii] = std::complex(real_code[ii], 0.0f); } @@ -248,14 +250,14 @@ void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signa void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift) + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift) { galileo_e1_code_gen_float_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false); } void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift) + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift) { galileo_e1_code_gen_complex_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false); } diff --git a/src/algorithms/libs/galileo_e1_signal_processing.h b/src/algorithms/libs/galileo_e1_signal_processing.h index f7133fd2d..6784e6f22 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.h +++ b/src/algorithms/libs/galileo_e1_signal_processing.h @@ -33,12 +33,13 @@ #define GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ #include +#include /*! * \brief This function generates Galileo E1 code (can select E1B or E1C sinboc). * */ -void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], unsigned int _prn); +void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], uint32_t _prn); /*! * \brief This function generates Galileo E1 code (can select E1B or E1C, cboc or sinboc @@ -46,7 +47,7 @@ void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], unsigned * */ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, bool _secondary_flag); /*! @@ -55,7 +56,7 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], * */ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift); + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift); /*! * \brief This function generates Galileo E1 code (can select E1B or E1C, cboc or sinboc @@ -63,13 +64,13 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], * */ void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, bool _secondary_flag); /*! * \brief galileo_e1_code_gen_complex_sampled without _secondary_flag for backward compatibility. */ void galileo_e1_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift); + bool _cboc, uint32_t _prn, int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GALILEO_E1_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/galileo_e5_signal_processing.cc b/src/algorithms/libs/galileo_e5_signal_processing.cc index ca6eb675a..29d7615dd 100644 --- a/src/algorithms/libs/galileo_e5_signal_processing.cc +++ b/src/algorithms/libs/galileo_e5_signal_processing.cc @@ -37,11 +37,11 @@ #include -void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed int _prn, char _Signal[3]) +void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, int32_t _prn, char _Signal[3]) { - unsigned int prn = _prn - 1; - unsigned int index = 0; - int a[4]; + uint32_t prn = _prn - 1; + uint32_t index = 0; + int32_t a[4]; if ((_prn < 1) || (_prn > 50)) { return; @@ -80,7 +80,7 @@ void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed in } else if (_Signal[0] == '5' && _Signal[1] == 'X') { - int b[4]; + int32_t b[4]; for (size_t i = 0; i < Galileo_E5a_I_PRIMARY_CODE[prn].length() - 1; i++) { hex_to_binary_converter(a, Galileo_E5a_I_PRIMARY_CODE[prn].at(i)); @@ -99,19 +99,20 @@ void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed in } } + void galileo_e5_a_code_gen_complex_sampled(std::complex* _dest, char _Signal[3], - unsigned int _prn, signed int _fs, unsigned int _chip_shift) + uint32_t _prn, int32_t _fs, uint32_t _chip_shift) { - unsigned int _samplesPerCode; - unsigned int delay; - const unsigned int _codeLength = Galileo_E5a_CODE_LENGTH_CHIPS; - const int _codeFreqBasis = Galileo_E5a_CODE_CHIP_RATE_HZ; + uint32_t _samplesPerCode; + uint32_t delay; + const uint32_t _codeLength = Galileo_E5a_CODE_LENGTH_CHIPS; + const int32_t _codeFreqBasis = Galileo_E5a_CODE_CHIP_RATE_HZ; std::complex* _code = new std::complex[_codeLength](); galileo_e5_a_code_gen_complex_primary(_code, _prn, _Signal); - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(_codeFreqBasis) / static_cast(_codeLength))); delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength; @@ -121,12 +122,12 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex* _dest, char _Sig if (posix_memalign((void**)&_resampled_signal, 16, _samplesPerCode * sizeof(gr_complex)) == 0) { }; - resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); //resamples code to fs + resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); // resamples code to fs delete[] _code; _code = _resampled_signal; } - for (unsigned int i = 0; i < _samplesPerCode; i++) + for (uint32_t i = 0; i < _samplesPerCode; i++) { _dest[(i + delay) % _samplesPerCode] = _code[i]; } diff --git a/src/algorithms/libs/galileo_e5_signal_processing.h b/src/algorithms/libs/galileo_e5_signal_processing.h index 998d3b98f..46deaae24 100644 --- a/src/algorithms/libs/galileo_e5_signal_processing.h +++ b/src/algorithms/libs/galileo_e5_signal_processing.h @@ -35,23 +35,23 @@ #define GNSS_SDR_GALILEO_E5_SIGNAL_PROCESSING_H_ #include +#include /*! * \brief Generates Galileo E5a code at 1 sample/chip * bool _pilot generates E5aQ code if true and E5aI (data signal) if false. */ -void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, signed int _prn, char _Signal[3]); +void galileo_e5_a_code_gen_complex_primary(std::complex* _dest, int32_t _prn, char _Signal[3]); - -void galileo_e5_a_code_gen_tiered(std::complex* _dest, std::complex* _primary, unsigned int _prn, char _Signal[3]); +void galileo_e5_a_code_gen_tiered(std::complex* _dest, std::complex* _primary, uint32_t _prn, char _Signal[3]); /*! * \brief Generates Galileo E5a complex code, shifted to the desired chip and sampled at a frequency fs * bool _pilot generates E5aQ code if true and E5aI (data signal) if false. */ void galileo_e5_a_code_gen_complex_sampled(std::complex* _dest, - char _Signal[3], unsigned int _prn, signed int _fs, unsigned int _chip_shift); + char _Signal[3], uint32_t _prn, int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GALILEO_E5_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/glonass_l1_signal_processing.cc b/src/algorithms/libs/glonass_l1_signal_processing.cc index 509137d15..045b53626 100644 --- a/src/algorithms/libs/glonass_l1_signal_processing.cc +++ b/src/algorithms/libs/glonass_l1_signal_processing.cc @@ -32,17 +32,17 @@ #include "glonass_l1_signal_processing.h" -auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; -void glonass_l1_ca_code_gen_complex(std::complex* _dest, /* signed int _prn,*/ unsigned int _chip_shift) +void glonass_l1_ca_code_gen_complex(std::complex* _dest, /* int32_t _prn,*/ uint32_t _chip_shift) { - const unsigned int _code_length = 511; + const uint32_t _code_length = 511; bool G1[_code_length]; bool G1_register[9]; bool feedback1; bool aux; - unsigned int delay; - unsigned int lcv, lcv2; + uint32_t delay; + uint32_t lcv, lcv2; for (lcv = 0; lcv < 9; lcv++) { @@ -104,26 +104,26 @@ void glonass_l1_ca_code_gen_complex(std::complex* _dest, /* signed int _p /* * Generates complex GLONASS L1 C/A code for the desired SV ID and sampled to specific sampling frequency */ -void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift) +void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift) { // This function is based on the GNU software GPS for MATLAB in the Kay Borre book std::complex _code[511]; - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; float aux; - const signed int _codeFreqBasis = 511000; //Hz - const signed int _codeLength = 511; + const int32_t _codeFreqBasis = 511000; //Hz + const int32_t _codeLength = 511; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); //--- Find time constants -------------------------------------------------- _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(_code, _chip_shift); //generate C/A code 1 sample per chip - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= diff --git a/src/algorithms/libs/glonass_l1_signal_processing.h b/src/algorithms/libs/glonass_l1_signal_processing.h index bcf1e89f2..0b1a26cfc 100644 --- a/src/algorithms/libs/glonass_l1_signal_processing.h +++ b/src/algorithms/libs/glonass_l1_signal_processing.h @@ -34,14 +34,15 @@ #define GNSS_SDR_GLONASS_SDR_SIGNAL_PROCESSING_H_ #include +#include //!Generates complex GLONASS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency -void glonass_l1_ca_code_gen_complex(std::complex* _dest, /*signed int _prn,*/ unsigned int _chip_shift); +void glonass_l1_ca_code_gen_complex(std::complex* _dest, /*int32_t _prn,*/ uint32_t _chip_shift); //! Generates N complex GLONASS L1 C/A codes for the desired SV ID and code shift -void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift, unsigned int _ncodes); +void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes); //! Generates complex GLONASS L1 C/A code for the desired SV ID and code shift -void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift); +void glonass_l1_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GLONASS_SDR_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/glonass_l2_signal_processing.cc b/src/algorithms/libs/glonass_l2_signal_processing.cc index fa82b88b1..f486429e1 100644 --- a/src/algorithms/libs/glonass_l2_signal_processing.cc +++ b/src/algorithms/libs/glonass_l2_signal_processing.cc @@ -32,17 +32,17 @@ #include "glonass_l2_signal_processing.h" -auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; -void glonass_l2_ca_code_gen_complex(std::complex* _dest, /* signed int _prn,*/ unsigned int _chip_shift) +void glonass_l2_ca_code_gen_complex(std::complex* _dest, /* int32_t _prn,*/ uint32_t _chip_shift) { - const unsigned int _code_length = 511; + const uint32_t _code_length = 511; bool G1[_code_length]; bool G1_register[9]; bool feedback1; bool aux; - unsigned int delay; - unsigned int lcv, lcv2; + uint32_t delay; + uint32_t lcv, lcv2; for (lcv = 0; lcv < 9; lcv++) { @@ -104,26 +104,26 @@ void glonass_l2_ca_code_gen_complex(std::complex* _dest, /* signed int _p /* * Generates complex GLONASS L2 C/A code for the desired SV ID and sampled to specific sampling frequency */ -void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift) +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift) { // This function is based on the GNU software GPS for MATLAB in the Kay Borre book std::complex _code[511]; - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; float aux; - const signed int _codeFreqBasis = 511000; //Hz - const signed int _codeLength = 511; + const int32_t _codeFreqBasis = 511000; //Hz + const int32_t _codeLength = 511; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); //--- Find time constants -------------------------------------------------- _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(_code, _chip_shift); //generate C/A code 1 sample per chip - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= diff --git a/src/algorithms/libs/glonass_l2_signal_processing.h b/src/algorithms/libs/glonass_l2_signal_processing.h index ff4a699e1..7c798f45a 100644 --- a/src/algorithms/libs/glonass_l2_signal_processing.h +++ b/src/algorithms/libs/glonass_l2_signal_processing.h @@ -34,14 +34,15 @@ #define GNSS_SDR_GLONASS_L2_SIGNAL_PROCESSING_H_ #include +#include //!Generates complex GLONASS L2 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency -void glonass_l2_ca_code_gen_complex(std::complex* _dest, /*signed int _prn,*/ unsigned int _chip_shift); +void glonass_l2_ca_code_gen_complex(std::complex* _dest, /*int32_t _prn,*/ uint32_t _chip_shift); //! Generates N complex GLONASS L2 C/A codes for the desired SV ID and code shift -void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift, unsigned int _ncodes); +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes); //! Generates complex GLONASS L2 C/A code for the desired SV ID and code shift -void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift); +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* uint32_t _prn,*/ int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GLONASS_L2_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc index fd5709ceb..234367318 100644 --- a/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc +++ b/src/algorithms/libs/gnss_sdr_fpga_sample_counter.cc @@ -45,12 +45,12 @@ gnss_sdr_fpga_sample_counter::gnss_sdr_fpga_sample_counter(double _fs, int32_t _ interval_ms = _interval_ms; fs = _fs; samples_per_output = std::round(fs * static_cast(interval_ms) / 1e3); - //todo: Load here the hardware counter register with this amount of samples. It should produde an + //todo: Load here the hardware counter register with this amount of samples. It should produce an //interrupt every samples_per_output count. - //The hardware timmer must keep always interrupting the PS. It must not wait for the interrupt to + //The hardware timer must keep always interrupting the PS. It must not wait for the interrupt to //be served. - sample_counter = 0; + sample_counter = 0ULL; current_T_rx_ms = 0; current_s = 0; current_m = 0; diff --git a/src/algorithms/libs/gnss_signal_processing.cc b/src/algorithms/libs/gnss_signal_processing.cc index 1d3be66e3..52b0c25ea 100644 --- a/src/algorithms/libs/gnss_signal_processing.cc +++ b/src/algorithms/libs/gnss_signal_processing.cc @@ -36,9 +36,9 @@ #include -auto auxCeil2 = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil2 = [](float x) { return static_cast(static_cast((x) + 1)); }; -void complex_exp_gen(std::complex* _dest, double _f, double _fs, unsigned int _samps) +void complex_exp_gen(std::complex* _dest, double _f, double _fs, uint32_t _samps) { gr::fxpt_nco d_nco; d_nco.set_freq((GPS_TWO_PI * _f) / _fs); @@ -46,14 +46,15 @@ void complex_exp_gen(std::complex* _dest, double _f, double _fs, unsigned } -void complex_exp_gen_conj(std::complex* _dest, double _f, double _fs, unsigned int _samps) +void complex_exp_gen_conj(std::complex* _dest, double _f, double _fs, uint32_t _samps) { gr::fxpt_nco d_nco; d_nco.set_freq(-(GPS_TWO_PI * _f) / _fs); d_nco.sincos(_dest, _samps, 1); } -void hex_to_binary_converter(int* _dest, char _from) + +void hex_to_binary_converter(int32_t* _dest, char _from) { switch (_from) { @@ -156,15 +157,16 @@ void hex_to_binary_converter(int* _dest, char _from) } } + void resampler(float* _from, float* _dest, float _fs_in, - float _fs_out, unsigned int _length_in, unsigned int _length_out) + float _fs_out, uint32_t _length_in, uint32_t _length_out) { - unsigned int _codeValueIndex; + uint32_t _codeValueIndex; float aux; //--- Find time constants -------------------------------------------------- const float _t_in = 1 / _fs_in; // Incoming sampling period in sec const float _t_out = 1 / _fs_out; // Out sampling period in sec - for (unsigned int i = 0; i < _length_out - 1; i++) + for (uint32_t i = 0; i < _length_out - 1; i++) { //=== Digitizing ======================================================= //--- compute index array to read sampled values ------------------------- @@ -179,15 +181,16 @@ void resampler(float* _from, float* _dest, float _fs_in, _dest[_length_out - 1] = _from[_length_in - 1]; } + void resampler(std::complex* _from, std::complex* _dest, float _fs_in, - float _fs_out, unsigned int _length_in, unsigned int _length_out) + float _fs_out, uint32_t _length_in, uint32_t _length_out) { - unsigned int _codeValueIndex; + uint32_t _codeValueIndex; float aux; //--- Find time constants -------------------------------------------------- const float _t_in = 1 / _fs_in; // Incoming sampling period in sec const float _t_out = 1 / _fs_out; // Out sampling period in sec - for (unsigned int i = 0; i < _length_out - 1; i++) + for (uint32_t i = 0; i < _length_out - 1; i++) { //=== Digitizing ======================================================= //--- compute index array to read sampled values ------------------------- diff --git a/src/algorithms/libs/gnss_signal_processing.h b/src/algorithms/libs/gnss_signal_processing.h index 514815d82..6a08d942e 100644 --- a/src/algorithms/libs/gnss_signal_processing.h +++ b/src/algorithms/libs/gnss_signal_processing.h @@ -36,6 +36,7 @@ #define GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ #include +#include /*! @@ -43,14 +44,14 @@ * */ void complex_exp_gen(std::complex* _dest, double _f, double _fs, - unsigned int _samps); + uint32_t _samps); /*! * \brief This function generates a conjugate complex exponential in _dest. * */ void complex_exp_gen_conj(std::complex* _dest, double _f, double _fs, - unsigned int _samps); + uint32_t _samps); /*! @@ -58,21 +59,21 @@ void complex_exp_gen_conj(std::complex* _dest, double _f, double _fs, * to binary (the output are 4 ints with +1 or -1 values). * */ -void hex_to_binary_converter(int* _dest, char _from); +void hex_to_binary_converter(int32_t* _dest, char _from); /*! * \brief This function resamples a sequence of float values. * */ void resampler(float* _from, float* _dest, - float _fs_in, float _fs_out, unsigned int _length_in, - unsigned int _length_out); + float _fs_in, float _fs_out, uint32_t _length_in, + uint32_t _length_out); /*! * \brief This function resamples a sequence of complex values. * */ void resampler(std::complex* _from, std::complex* _dest, - float _fs_in, float _fs_out, unsigned int _length_in, - unsigned int _length_out); + float _fs_in, float _fs_out, uint32_t _length_in, + uint32_t _length_out); #endif /* GNSS_SDR_GNSS_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/gps_l2c_signal.cc b/src/algorithms/libs/gps_l2c_signal.cc index 81ad79c78..4f41e620f 100644 --- a/src/algorithms/libs/gps_l2c_signal.cc +++ b/src/algorithms/libs/gps_l2c_signal.cc @@ -32,7 +32,6 @@ #include "gps_l2c_signal.h" #include "GPS_L2C.h" -#include #include @@ -42,11 +41,11 @@ int32_t gps_l2c_m_shift(int32_t x) } -void gps_l2c_m_code(int32_t* _dest, unsigned int _prn) +void gps_l2c_m_code(int32_t* _dest, uint32_t _prn) { int32_t x; x = GPS_L2C_M_INIT_REG[_prn - 1]; - for (int n = 0; n < GPS_L2_M_CODE_LENGTH_CHIPS; n++) + for (int32_t n = 0; n < GPS_L2_M_CODE_LENGTH_CHIPS; n++) { _dest[n] = static_cast(x & 1); x = gps_l2c_m_shift(x); @@ -54,7 +53,7 @@ void gps_l2c_m_code(int32_t* _dest, unsigned int _prn) } -void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn) +void gps_l2c_m_code_gen_complex(std::complex* _dest, uint32_t _prn) { int32_t* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; @@ -63,7 +62,7 @@ void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn) gps_l2c_m_code(_code, _prn); } - for (signed int 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(1.0 - 2.0 * _code[i], 0.0); } @@ -71,7 +70,8 @@ void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } -void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn) + +void gps_l2c_m_code_gen_float(float* _dest, uint32_t _prn) { int32_t* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; @@ -80,7 +80,7 @@ void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn) gps_l2c_m_code(_code, _prn); } - for (signed int 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(_code[i]); } @@ -92,7 +92,7 @@ void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn) /* * Generates complex GPS L2C M code for the desired SV ID and sampled to specific sampling frequency */ -void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs) +void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs) { int32_t* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) @@ -100,20 +100,20 @@ void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, unsigned int gps_l2c_m_code(_code, _prn); } - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; - const signed int _codeLength = GPS_L2_M_CODE_LENGTH_CHIPS; + const int32_t _codeLength = GPS_L2_M_CODE_LENGTH_CHIPS; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L2_M_CODE_RATE_HZ) / static_cast(_codeLength))); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L2_M_CODE_RATE_HZ) / static_cast(_codeLength))); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(GPS_L2_M_CODE_RATE_HZ); // C/A chip period in sec //float aux; - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= @@ -121,7 +121,7 @@ void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, unsigned int //TODO: Check this formula! Seems to start with an extra sample _codeValueIndex = ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; //aux = (_ts * (i + 1)) / _tc; - //_codeValueIndex = static_cast(static_cast(aux)) - 1; + //_codeValueIndex = static_cast(static_cast(aux)) - 1; //--- Make the digitized version of the L2C code ----------------------- if (i == _samplesPerCode - 1) diff --git a/src/algorithms/libs/gps_l2c_signal.h b/src/algorithms/libs/gps_l2c_signal.h index c76c4692f..84d51e485 100644 --- a/src/algorithms/libs/gps_l2c_signal.h +++ b/src/algorithms/libs/gps_l2c_signal.h @@ -34,13 +34,14 @@ #define GNSS_SDR_GPS_L2C_SIGNAL_H_ #include +#include -//!Generates complex GPS L2C M code for the desired SV ID -void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn); -void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn); +//! Generates complex GPS L2C M code for the desired SV ID +void gps_l2c_m_code_gen_complex(std::complex* _dest, uint32_t _prn); +void gps_l2c_m_code_gen_float(float* _dest, uint32_t _prn); //! Generates complex GPS L2C M code for the desired SV ID, and sampled to specific sampling frequency -void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs); +void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs); #endif /* GNSS_GPS_L2C_SIGNAL_H_ */ diff --git a/src/algorithms/libs/gps_l5_signal.cc b/src/algorithms/libs/gps_l5_signal.cc index 84cc1843e..26656d569 100644 --- a/src/algorithms/libs/gps_l5_signal.cc +++ b/src/algorithms/libs/gps_l5_signal.cc @@ -89,7 +89,7 @@ std::deque make_l5i_xa() std::deque xa = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; std::deque y(GPS_L5i_CODE_LENGTH_CHIPS, 0); - for (int i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) { y[i] = xa[12]; xa = l5i_xa_shift(xa); @@ -103,7 +103,7 @@ std::deque make_l5i_xb() std::deque xb = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; std::deque y(GPS_L5i_CODE_LENGTH_CHIPS, 0); - for (int i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) { y[i] = xb[12]; xb = l5i_xb_shift(xb); @@ -117,7 +117,7 @@ std::deque make_l5q_xa() std::deque xa = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; std::deque y(GPS_L5q_CODE_LENGTH_CHIPS, 0); - for (int i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) { y[i] = xa[12]; xa = l5q_xa_shift(xa); @@ -131,7 +131,7 @@ std::deque make_l5q_xb() std::deque xb = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; std::deque y(GPS_L5q_CODE_LENGTH_CHIPS, 0); - for (int i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) + for (int32_t i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) { y[i] = xb[12]; xb = l5q_xb_shift(xb); @@ -140,47 +140,47 @@ std::deque make_l5q_xb() } -void make_l5i(int32_t* _dest, int prn) +void make_l5i(int32_t* _dest, int32_t prn) { - int xb_offset = GPS_L5i_INIT_REG[prn]; + int32_t xb_offset = GPS_L5i_INIT_REG[prn]; std::deque xb = make_l5i_xb(); std::deque xa = make_l5i_xa(); std::deque xb_shift(GPS_L5i_CODE_LENGTH_CHIPS, 0); - for (int n = 0; n < GPS_L5i_CODE_LENGTH_CHIPS; n++) + for (int32_t n = 0; n < GPS_L5i_CODE_LENGTH_CHIPS; n++) { xb_shift[n] = xb[(xb_offset + n) % GPS_L5i_CODE_LENGTH_CHIPS]; } std::deque out_code(GPS_L5i_CODE_LENGTH_CHIPS, 0); - for (int n = 0; n < GPS_L5i_CODE_LENGTH_CHIPS; n++) + for (int32_t n = 0; n < GPS_L5i_CODE_LENGTH_CHIPS; n++) { _dest[n] = xa[n] xor xb_shift[n]; } } -void make_l5q(int32_t* _dest, int prn) +void make_l5q(int32_t* _dest, int32_t prn) { - int xb_offset = GPS_L5q_INIT_REG[prn]; + int32_t xb_offset = GPS_L5q_INIT_REG[prn]; std::deque xb = make_l5q_xb(); std::deque xa = make_l5q_xa(); std::deque xb_shift(GPS_L5q_CODE_LENGTH_CHIPS, 0); - for (int n = 0; n < GPS_L5q_CODE_LENGTH_CHIPS; n++) + for (int32_t n = 0; n < GPS_L5q_CODE_LENGTH_CHIPS; n++) { xb_shift[n] = xb[(xb_offset + n) % GPS_L5q_CODE_LENGTH_CHIPS]; } std::deque out_code(GPS_L5q_CODE_LENGTH_CHIPS, 0); - for (int n = 0; n < GPS_L5q_CODE_LENGTH_CHIPS; n++) + for (int32_t n = 0; n < GPS_L5q_CODE_LENGTH_CHIPS; n++) { _dest[n] = xa[n] xor xb_shift[n]; } } -void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn) +void gps_l5i_code_gen_complex(std::complex* _dest, uint32_t _prn) { int32_t* _code = new int32_t[GPS_L5i_CODE_LENGTH_CHIPS]; @@ -189,7 +189,7 @@ void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn) make_l5i(_code, _prn - 1); } - for (signed int 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(1.0 - 2.0 * _code[i], 0.0); } @@ -197,7 +197,8 @@ void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } -void gps_l5i_code_gen_float(float* _dest, unsigned int _prn) + +void gps_l5i_code_gen_float(float* _dest, uint32_t _prn) { int32_t* _code = new int32_t[GPS_L5i_CODE_LENGTH_CHIPS]; @@ -206,7 +207,7 @@ void gps_l5i_code_gen_float(float* _dest, unsigned int _prn) make_l5i(_code, _prn - 1); } - for (signed int 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(_code[i]); } @@ -214,10 +215,11 @@ void gps_l5i_code_gen_float(float* _dest, unsigned int _prn) delete[] _code; } + /* * Generates complex GPS L5i code for the desired SV ID and sampled to specific sampling frequency */ -void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs) +void gps_l5i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs) { int32_t* _code = new int32_t[GPS_L5i_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) @@ -225,20 +227,20 @@ void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _ make_l5i(_code, _prn - 1); } - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; - const signed int _codeLength = GPS_L5i_CODE_LENGTH_CHIPS; + const int32_t _codeLength = GPS_L5i_CODE_LENGTH_CHIPS; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L5i_CODE_RATE_HZ) / static_cast(_codeLength))); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L5i_CODE_RATE_HZ) / static_cast(_codeLength))); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(GPS_L5i_CODE_RATE_HZ); // C/A chip period in sec //float aux; - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= @@ -246,7 +248,7 @@ void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _ //TODO: Check this formula! Seems to start with an extra sample _codeValueIndex = ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; //aux = (_ts * (i + 1)) / _tc; - //_codeValueIndex = static_cast(static_cast(aux)) - 1; + //_codeValueIndex = static_cast (static_cast(aux)) - 1; //--- Make the digitized version of the L2C code ----------------------- if (i == _samplesPerCode - 1) @@ -263,7 +265,7 @@ void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _ } -void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn) +void gps_l5q_code_gen_complex(std::complex* _dest, uint32_t _prn) { int32_t* _code = new int32_t[GPS_L5q_CODE_LENGTH_CHIPS]; @@ -272,7 +274,7 @@ void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn) make_l5q(_code, _prn - 1); } - for (signed int 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(1.0 - 2.0 * _code[i], 0.0); } @@ -280,7 +282,8 @@ void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } -void gps_l5q_code_gen_float(float* _dest, unsigned int _prn) + +void gps_l5q_code_gen_float(float* _dest, uint32_t _prn) { int32_t* _code = new int32_t[GPS_L5q_CODE_LENGTH_CHIPS]; @@ -289,17 +292,19 @@ void gps_l5q_code_gen_float(float* _dest, unsigned int _prn) make_l5q(_code, _prn - 1); } - for (signed int 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(_code[i]); } delete[] _code; } + + /* * Generates complex GPS L5i code for the desired SV ID and sampled to specific sampling frequency */ -void gps_l5q_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs) +void gps_l5q_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs) { int32_t* _code = new int32_t[GPS_L5q_CODE_LENGTH_CHIPS]; if (_prn > 0 and _prn < 51) @@ -307,20 +312,20 @@ void gps_l5q_code_gen_complex_sampled(std::complex* _dest, unsigned int _ make_l5q(_code, _prn - 1); } - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; - const signed int _codeLength = GPS_L5q_CODE_LENGTH_CHIPS; + const int32_t _codeLength = GPS_L5q_CODE_LENGTH_CHIPS; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L5q_CODE_RATE_HZ) / static_cast(_codeLength))); + _samplesPerCode = static_cast(static_cast(_fs) / (static_cast(GPS_L5q_CODE_RATE_HZ) / static_cast(_codeLength))); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(GPS_L5q_CODE_RATE_HZ); // C/A chip period in sec //float aux; - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= @@ -328,7 +333,7 @@ void gps_l5q_code_gen_complex_sampled(std::complex* _dest, unsigned int _ //TODO: Check this formula! Seems to start with an extra sample _codeValueIndex = ceil((_ts * (static_cast(i) + 1)) / _tc) - 1; //aux = (_ts * (i + 1)) / _tc; - //_codeValueIndex = static_cast(static_cast(aux)) - 1; + //_codeValueIndex = static_cast (static_cast(aux)) - 1; //--- Make the digitized version of the L2C code ----------------------- if (i == _samplesPerCode - 1) diff --git a/src/algorithms/libs/gps_l5_signal.h b/src/algorithms/libs/gps_l5_signal.h index d226b0288..b0b24d2a5 100644 --- a/src/algorithms/libs/gps_l5_signal.h +++ b/src/algorithms/libs/gps_l5_signal.h @@ -34,21 +34,21 @@ #define GNSS_SDR_GPS_L5_SIGNAL_H_ #include - +#include //!Generates complex GPS L5i M code for the desired SV ID -void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn); -void gps_l5i_code_gen_float(float* _dest, unsigned int _prn); +void gps_l5i_code_gen_complex(std::complex* _dest, uint32_t _prn); +void gps_l5i_code_gen_float(float* _dest, uint32_t _prn); //!Generates complex GPS L5q M code for the desired SV ID -void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn); -void gps_l5q_code_gen_float(float* _dest, unsigned int _prn); +void gps_l5q_code_gen_complex(std::complex* _dest, uint32_t _prn); +void gps_l5q_code_gen_float(float* _dest, uint32_t _prn); //! Generates complex GPS L5i M code for the desired SV ID, and sampled to specific sampling frequency -void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs); +void gps_l5i_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs); //! Generates complex GPS L5q M code for the desired SV ID, and sampled to specific sampling frequency -void gps_l5q_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs); +void gps_l5q_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs); #endif /* GNSS_SDR_GPS_L5_SIGNAL_H_ */ diff --git a/src/algorithms/libs/gps_sdr_signal_processing.cc b/src/algorithms/libs/gps_sdr_signal_processing.cc index 279f7d173..932c96ff2 100644 --- a/src/algorithms/libs/gps_sdr_signal_processing.cc +++ b/src/algorithms/libs/gps_sdr_signal_processing.cc @@ -32,22 +32,22 @@ #include "gps_sdr_signal_processing.h" -auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; -void gps_l1_ca_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift) +void gps_l1_ca_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift) { - const unsigned int _code_length = 1023; + const uint32_t _code_length = 1023; bool G1[_code_length]; bool G2[_code_length]; bool G1_register[10], G2_register[10]; bool feedback1, feedback2; bool aux; - unsigned int lcv, lcv2; - unsigned int delay; - signed int prn_idx; + uint32_t lcv, lcv2; + uint32_t delay; + int32_t prn_idx; /* G2 Delays as defined in GPS-ISD-200D */ - const signed int delays[51] = {5 /*PRN1*/, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254, 255, 256, 257, 258, 469, 470, 471, 472, + const int32_t delays[51] = {5 /*PRN1*/, 6, 7, 8, 17, 18, 139, 140, 141, 251, 252, 254, 255, 256, 257, 258, 469, 470, 471, 472, 473, 474, 509, 512, 513, 514, 515, 516, 859, 860, 861, 862 /*PRN32*/, 145 /*PRN120*/, 175, 52, 21, 237, 235, 886, 657, 634, 762, 355, 1012, 176, 603, 130, 359, 595, 68, 386 /*PRN138*/}; @@ -114,28 +114,28 @@ void gps_l1_ca_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shif } -void gps_l1_ca_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift) +void gps_l1_ca_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift) { - unsigned int _code_length = 1023; - int ca_code_int[_code_length]; + uint32_t _code_length = 1023; + int32_t ca_code_int[_code_length]; gps_l1_ca_code_gen_int(ca_code_int, _prn, _chip_shift); - for (unsigned int ii = 0; ii < _code_length; ++ii) + for (uint32_t ii = 0; ii < _code_length; ++ii) { _dest[ii] = static_cast(ca_code_int[ii]); } } -void gps_l1_ca_code_gen_complex(std::complex* _dest, signed int _prn, unsigned int _chip_shift) +void gps_l1_ca_code_gen_complex(std::complex* _dest, int32_t _prn, uint32_t _chip_shift) { - unsigned int _code_length = 1023; - int ca_code_int[_code_length]; + uint32_t _code_length = 1023; + int32_t ca_code_int[_code_length]; gps_l1_ca_code_gen_int(ca_code_int, _prn, _chip_shift); - for (unsigned int ii = 0; ii < _code_length; ++ii) + for (uint32_t ii = 0; ii < _code_length; ++ii) { _dest[ii] = std::complex(static_cast(ca_code_int[ii]), 0.0f); } @@ -146,26 +146,26 @@ void gps_l1_ca_code_gen_complex(std::complex* _dest, signed int _prn, uns * Generates complex GPS L1 C/A code for the desired SV ID and sampled to specific sampling frequency * NOTICE: the number of samples is rounded towards zero (integer truncation) */ -void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift) +void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift) { // This function is based on the GNU software GPS for MATLAB in the Kay Borre book std::complex _code[1023]; - signed int _samplesPerCode, _codeValueIndex; + int32_t _samplesPerCode, _codeValueIndex; float _ts; float _tc; float aux; - const signed int _codeFreqBasis = 1023000; //Hz - const signed int _codeLength = 1023; + const int32_t _codeFreqBasis = 1023000; //Hz + const int32_t _codeLength = 1023; //--- Find number of samples per spreading code ---------------------------- - _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); //--- Find time constants -------------------------------------------------- _ts = 1.0 / static_cast(_fs); // Sampling period in sec _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec gps_l1_ca_code_gen_complex(_code, _prn, _chip_shift); //generate C/A code 1 sample per chip - for (signed int i = 0; i < _samplesPerCode; i++) + for (int32_t i = 0; i < _samplesPerCode; i++) { //=== Digitizing ======================================================= diff --git a/src/algorithms/libs/gps_sdr_signal_processing.h b/src/algorithms/libs/gps_sdr_signal_processing.h index b65db9144..44bb815dd 100644 --- a/src/algorithms/libs/gps_sdr_signal_processing.h +++ b/src/algorithms/libs/gps_sdr_signal_processing.h @@ -34,20 +34,21 @@ #define GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ #include +#include -//!Generates int GPS L1 C/A code for the desired SV ID and code shift -void gps_l1_ca_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates int GPS L1 C/A code for the desired SV ID and code shift +void gps_l1_ca_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift); -//!Generates float GPS L1 C/A code for the desired SV ID and code shift -void gps_l1_ca_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates float GPS L1 C/A code for the desired SV ID and code shift +void gps_l1_ca_code_gen_float(float* _dest, int32_t _prn, uint32_t _chip_shift); -//!Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency -void gps_l1_ca_code_gen_complex(std::complex* _dest, signed int _prn, unsigned int _chip_shift); +//! Generates complex GPS L1 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency +void gps_l1_ca_code_gen_complex(std::complex* _dest, int32_t _prn, uint32_t _chip_shift); //! Generates N complex GPS L1 C/A codes for the desired SV ID and code shift -void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift, unsigned int _ncodes); +void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift, uint32_t _ncodes); //! Generates complex GPS L1 C/A code for the desired SV ID and code shift -void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs, unsigned int _chip_shift); +void gps_l1_ca_code_gen_complex_sampled(std::complex* _dest, uint32_t _prn, int32_t _fs, uint32_t _chip_shift); #endif /* GNSS_SDR_GPS_SDR_SIGNAL_PROCESSING_H_ */