mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Remove uses of bitwise operations on signed integer types
Based in the High Integrity C++ Standard, Section 5.6.1 See https://www.perforce.com/resources/qac/high-integrity-c-coding-standard-expressions Removed some c arrays by std::array
This commit is contained in:
parent
7ee1394f2f
commit
9572b37da7
@ -234,7 +234,7 @@ void GalileoE5aPcpsAcquisition::init()
|
|||||||
void GalileoE5aPcpsAcquisition::set_local_code()
|
void GalileoE5aPcpsAcquisition::set_local_code()
|
||||||
{
|
{
|
||||||
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
|
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
|
||||||
std::array<char, 3> signal_;
|
std::array<char, 3> signal_{};
|
||||||
signal_[0] = '5';
|
signal_[0] = '5';
|
||||||
signal_[2] = '\0';
|
signal_[2] = '\0';
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ void beidou_b1i_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _c
|
|||||||
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)] ^ G2_register[-(phase2[prn_idx] - 11)];
|
||||||
|
|
||||||
feedback1 = (G1_register[0] + G1_register[1] + G1_register[2] + G1_register[3] + G1_register[4] + G1_register[10]) & 0x1;
|
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] + G2_register[2] + G2_register[3] + G2_register[6] + G2_register[7] + G2_register[8] + G2_register[9] + G2_register[10]) & 0x1;
|
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];
|
||||||
|
|
||||||
for (lcv2 = 0; lcv2 < 10; lcv2++)
|
for (lcv2 = 0; lcv2 < 10; lcv2++)
|
||||||
{
|
{
|
||||||
|
@ -129,10 +129,9 @@ void beidou_b3i_code_gen_int(gsl::span<int> _dest, signed int _prn, unsigned int
|
|||||||
G2[lcv] = G2_register[0];
|
G2[lcv] = G2_register[0];
|
||||||
|
|
||||||
//feedback1 = (test_G1_register[0]+test_G1_register[2]+test_G1_register[3]+test_G1_register[12]) & 0x1;
|
//feedback1 = (test_G1_register[0]+test_G1_register[2]+test_G1_register[3]+test_G1_register[12]) & 0x1;
|
||||||
feedback1 = (G1_register[0] + G1_register[9] + G1_register[10] + G1_register[12]) & 0x01;
|
feedback1 = G1_register[0] xor G1_register[9] xor G1_register[10] xor G1_register[12];
|
||||||
feedback2 = (G2_register[0] + G2_register[1] + G2_register[3] + G2_register[4] +
|
feedback2 = G2_register[0] xor G2_register[1] xor G2_register[3] xor G2_register[4] xor
|
||||||
G2_register[6] + G2_register[7] + G2_register[8] + G2_register[12]) &
|
G2_register[6] xor G2_register[7] xor G2_register[8] xor G2_register[12];
|
||||||
0x01;
|
|
||||||
|
|
||||||
for (lcv2 = 0; lcv2 < 12; lcv2++)
|
for (lcv2 = 0; lcv2 < 12; lcv2++)
|
||||||
{
|
{
|
||||||
@ -157,7 +156,7 @@ void beidou_b3i_code_gen_int(gsl::span<int> _dest, signed int _prn, unsigned int
|
|||||||
// 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]) & 0x01;
|
aux = G1[(lcv + _chip_shift) % _code_length] xor G2[delay];
|
||||||
if (aux == true)
|
if (aux == true)
|
||||||
{
|
{
|
||||||
_dest[lcv] = 1;
|
_dest[lcv] = 1;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "geofunctions.h"
|
#include "geofunctions.h"
|
||||||
|
#include <array>
|
||||||
#include <cmath> // for sin, cos, sqrt, abs, pow
|
#include <cmath> // for sin, cos, sqrt, abs, pow
|
||||||
|
|
||||||
const double STRP_PI = 3.1415926535898; // Pi as defined in IS-GPS-200E
|
const double STRP_PI = 3.1415926535898; // Pi as defined in IS-GPS-200E
|
||||||
@ -350,8 +351,8 @@ arma::mat Euler_to_CTM(const arma::vec &eul)
|
|||||||
|
|
||||||
arma::vec cart2geo(const arma::vec &XYZ, int elipsoid_selection)
|
arma::vec cart2geo(const arma::vec &XYZ, int elipsoid_selection)
|
||||||
{
|
{
|
||||||
const double a[5] = {6378388.0, 6378160.0, 6378135.0, 6378137.0, 6378137.0};
|
const std::array<double, 5> a{6378388.0, 6378160.0, 6378135.0, 6378137.0, 6378137.0};
|
||||||
const double f[5] = {1.0 / 297.0, 1.0 / 298.247, 1.0 / 298.26, 1.0 / 298.257222101, 1.0 / 298.257223563};
|
const std::array<double, 5> f{1.0 / 297.0, 1.0 / 298.247, 1.0 / 298.26, 1.0 / 298.257222101, 1.0 / 298.257223563};
|
||||||
|
|
||||||
double lambda = atan2(XYZ[1], XYZ[0]);
|
double lambda = atan2(XYZ[1], XYZ[0]);
|
||||||
double ex2 = (2.0 - f[elipsoid_selection]) * f[elipsoid_selection] / ((1.0 - f[elipsoid_selection]) * (1.0 - f[elipsoid_selection]));
|
double ex2 = (2.0 - f[elipsoid_selection]) * f[elipsoid_selection] / ((1.0 - f[elipsoid_selection]) * (1.0 - f[elipsoid_selection]));
|
||||||
|
@ -36,19 +36,19 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
int32_t gps_l2c_m_shift(int32_t x)
|
uint32_t gps_l2c_m_shift(uint32_t x)
|
||||||
{
|
{
|
||||||
return static_cast<int32_t>((x >> 1) ^ ((x & 1) * 0445112474));
|
return static_cast<uint32_t>((x >> 1U) ^ ((x & 1U) * 0445112474U));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void gps_l2c_m_code(gsl::span<int32_t> _dest, uint32_t _prn)
|
void gps_l2c_m_code(gsl::span<int32_t> _dest, uint32_t _prn)
|
||||||
{
|
{
|
||||||
int32_t x;
|
uint32_t x;
|
||||||
x = GPS_L2C_M_INIT_REG[_prn - 1];
|
x = GPS_L2C_M_INIT_REG[_prn - 1];
|
||||||
for (int32_t 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<int8_t>(x & 1);
|
_dest[n] = static_cast<int8_t>(x & 1U);
|
||||||
x = gps_l2c_m_shift(x);
|
x = gps_l2c_m_shift(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ void gps_l1_ca_code_gen_int(gsl::span<int32_t> _dest, int32_t _prn, uint32_t _ch
|
|||||||
G2[lcv] = G2_register[0];
|
G2[lcv] = G2_register[0];
|
||||||
|
|
||||||
feedback1 = G1_register[7] ^ G1_register[0];
|
feedback1 = G1_register[7] ^ G1_register[0];
|
||||||
feedback2 = (G2_register[8] + G2_register[7] + G2_register[4] + G2_register[2] + G2_register[1] + G2_register[0]) & 0x1;
|
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++)
|
||||||
{
|
{
|
||||||
|
@ -578,8 +578,10 @@ void dll_pll_veml_tracking::start_tracking()
|
|||||||
d_carrier_phase_rate_step_rad = 0.0;
|
d_carrier_phase_rate_step_rad = 0.0;
|
||||||
d_carr_ph_history.clear();
|
d_carr_ph_history.clear();
|
||||||
d_code_ph_history.clear();
|
d_code_ph_history.clear();
|
||||||
std::array<char, 3> Signal_;
|
std::array<char, 3> Signal_{};
|
||||||
std::memcpy(Signal_.data(), d_acquisition_gnss_synchro->Signal, 3);
|
Signal_[0] = d_acquisition_gnss_synchro->Signal[0];
|
||||||
|
Signal_[1] = d_acquisition_gnss_synchro->Signal[1];
|
||||||
|
Signal_[2] = d_acquisition_gnss_synchro->Signal[2];
|
||||||
|
|
||||||
if (systemName == "GPS" and signal_type == "1C")
|
if (systemName == "GPS" and signal_type == "1C")
|
||||||
{
|
{
|
||||||
|
@ -467,9 +467,9 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri
|
|||||||
}
|
}
|
||||||
//assign the GNURadio block output data
|
//assign the GNURadio block output data
|
||||||
current_synchro_data.System = {'E'};
|
current_synchro_data.System = {'E'};
|
||||||
std::string str_aux = "1B";
|
current_synchro_data.Signal[0] = '1';
|
||||||
const char *str = str_aux.c_str(); // get a C style null terminated string
|
current_synchro_data.Signal[1] = 'B';
|
||||||
std::memcpy(static_cast<void *>(current_synchro_data.Signal), str, 3);
|
current_synchro_data.Signal[2] = '\0';
|
||||||
|
|
||||||
current_synchro_data.fs = d_fs_in;
|
current_synchro_data.fs = d_fs_in;
|
||||||
*out[0] = current_synchro_data;
|
*out[0] = current_synchro_data;
|
||||||
|
@ -502,9 +502,9 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib
|
|||||||
|
|
||||||
// assign the GNU Radio block output data
|
// assign the GNU Radio block output data
|
||||||
current_synchro_data.System = {'G'};
|
current_synchro_data.System = {'G'};
|
||||||
std::string str_aux = "1C";
|
current_synchro_data.Signal[0] = '1';
|
||||||
const char *str = str_aux.c_str(); // get a C style null terminated string
|
current_synchro_data.Signal[1] = 'C';
|
||||||
std::memcpy(static_cast<void *>(current_synchro_data.Signal), str, 3);
|
current_synchro_data.Signal[2] = '\0';
|
||||||
|
|
||||||
current_synchro_data.fs = d_fs_in;
|
current_synchro_data.fs = d_fs_in;
|
||||||
*out[0] = current_synchro_data;
|
*out[0] = current_synchro_data;
|
||||||
|
Loading…
Reference in New Issue
Block a user