1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-22 04:53:14 +00:00

Miscelaneous code improvements by clang-tidy

This commit is contained in:
Carles Fernandez 2018-12-08 18:49:31 +01:00
parent 81a4d24ae9
commit 17260bbcea
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
100 changed files with 1039 additions and 990 deletions

View File

@ -94,7 +94,7 @@ public:
private:
rtklib_pvt_cc_sptr pvt_;
rtk_t rtk;
rtk_t rtk{};
std::string role_;
unsigned int in_streams_;
unsigned int out_streams_;

View File

@ -514,7 +514,7 @@ rtklib_pvt_cc::rtklib_pvt_cc(uint32_t nchannels,
if ((sysv_msqid = msgget(sysv_msg_key, msgflg)) == -1)
{
std::cout << "GNSS-SDR can not create message queues!" << std::endl;
throw new std::exception();
throw std::exception();
}
start = std::chrono::system_clock::now();
}

View File

@ -37,6 +37,7 @@
#include <boost/filesystem/path.hpp> // for path, operator<<
#include <boost/filesystem/path_traits.hpp> // for filesystem
#include <glog/logging.h>
#include <cstdint>
#include <iomanip>
#include <utility>
#include <fcntl.h> // for O_RDWR
@ -187,7 +188,7 @@ Rtcm_Printer::~Rtcm_Printer()
}
if (rtcm_file_descriptor.is_open())
{
long pos;
int64_t pos;
pos = rtcm_file_descriptor.tellp();
rtcm_file_descriptor.close();
if (pos == 0)
@ -345,13 +346,13 @@ int Rtcm_Printer::init_serial(const std::string& serial_device)
*/
int32_t fd = 0;
struct termios options;
long BAUD;
long DATABITS;
long STOPBITS;
long PARITYON;
long PARITY;
int64_t BAUD;
int64_t DATABITS;
int64_t STOPBITS;
int64_t PARITYON;
int64_t PARITY;
fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC);
if (fd == -1) return fd; // failed to open TTY port
if (fcntl(fd, F_SETFL, 0) == -1) LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O

View File

@ -59,7 +59,6 @@
#include "GLONASS_L1_L2_CA.h"
#include <matio.h>
#include <glog/logging.h>
#include <utility>
@ -75,10 +74,10 @@ rtklib_solver::rtklib_solver(int nchannels, std::string dump_filename, bool flag
count_valid_position = 0;
this->set_averaging_flag(false);
rtk_ = rtk;
for (double & i : dop_) i = 0.0;
for (double &i : dop_) i = 0.0;
pvt_sol = {{0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, '0', '0', '0', 0, 0, 0};
ssat_t ssat0 = {0, 0, {0.0}, {0.0}, {0.0}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {}, {}, {}, {}, 0.0, 0.0, 0.0, 0.0, {{{0, 0}}, {{0, 0}}}, {{}, {}}};
for (auto & i : pvt_ssat)
for (auto &i : pvt_ssat)
{
i = ssat0;
}
@ -777,7 +776,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
nav_data.n = valid_obs;
nav_data.ng = glo_valid_obs;
for (auto & i : nav_data.lam)
for (auto &i : nav_data.lam)
{
i[0] = SPEED_OF_LIGHT / FREQ1; // L1/E1
i[1] = SPEED_OF_LIGHT / FREQ2; // L2
@ -811,7 +810,7 @@ bool rtklib_solver::get_PVT(const std::map<int, Gnss_Synchro> &gnss_observables_
std::vector<double> azel;
azel.reserve(used_sats * 2);
unsigned int index_aux = 0;
for (auto & i : rtk_.ssat)
for (auto &i : rtk_.ssat)
{
if (i.vs == 1)
{

View File

@ -342,11 +342,9 @@ gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisition::get_left_block()
{
return cbyte_to_float_x2_;
}
else
{
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}

View File

@ -327,11 +327,9 @@ gr::basic_block_sptr GlonassL1CaPcpsAcquisition::get_left_block()
{
return cbyte_to_float_x2_;
}
else
{
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}

View File

@ -326,11 +326,9 @@ gr::basic_block_sptr GlonassL2CaPcpsAcquisition::get_left_block()
{
return cbyte_to_float_x2_;
}
else
{
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}

View File

@ -315,11 +315,9 @@ gr::basic_block_sptr GpsL1CaPcpsAcquisition::get_left_block()
{
return cbyte_to_float_x2_;
}
else
{
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}

View File

@ -329,11 +329,9 @@ gr::basic_block_sptr GpsL2MPcpsAcquisition::get_left_block()
{
return cbyte_to_float_x2_;
}
else
{
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}

View File

@ -317,11 +317,9 @@ gr::basic_block_sptr GpsL5iPcpsAcquisition::get_left_block()
{
return cbyte_to_float_x2_;
}
else
{
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}
LOG(WARNING) << item_type_ << " unknown acquisition item type";
return nullptr;
}

View File

@ -41,9 +41,12 @@
using google::LogMessage;
galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc(
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool dump, std::string dump_filename)
{
return galileo_pcps_8ms_acquisition_cc_sptr(
@ -52,9 +55,12 @@ galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc(
}
galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc(
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool dump,
std::string dump_filename) : gr::block("galileo_pcps_8ms_acquisition_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms),
@ -101,11 +107,12 @@ galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc(
d_channel = 0;
}
galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc()
{
if (d_num_doppler_bins > 0)
{
for (unsigned int i = 0; i < d_num_doppler_bins; i++)
for (uint32_t i = 0; i < d_num_doppler_bins; i++)
{
volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]);
}
@ -125,6 +132,7 @@ galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc()
}
}
void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex<float> *code)
{
// code A: two replicas of a primary code
@ -146,6 +154,7 @@ void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex<float> *code)
volk_32fc_conjugate_32fc(d_fft_code_B, d_fft_if->get_outbuf(), d_fft_size);
}
void galileo_pcps_8ms_acquisition_cc::init()
{
d_gnss_synchro->Flag_valid_acquisition = false;
@ -161,8 +170,8 @@ void galileo_pcps_8ms_acquisition_cc::init()
const double GALILEO_TWO_PI = 6.283185307179600;
// Count the number of bins
d_num_doppler_bins = 0;
for (int doppler = static_cast<int>(-d_doppler_max);
doppler <= static_cast<int>(d_doppler_max);
for (auto doppler = static_cast<int32_t>(-d_doppler_max);
doppler <= static_cast<int32_t>(d_doppler_max);
doppler += d_doppler_step)
{
d_num_doppler_bins++;
@ -170,10 +179,10 @@ void galileo_pcps_8ms_acquisition_cc::init()
// Create the carrier Doppler wipeoff signals
d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins];
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
int32_t doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = static_cast<float>(GALILEO_TWO_PI) * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
@ -182,7 +191,7 @@ void galileo_pcps_8ms_acquisition_cc::init()
}
void galileo_pcps_8ms_acquisition_cc::set_state(int state)
void galileo_pcps_8ms_acquisition_cc::set_state(int32_t state)
{
d_state = state;
if (d_state == 1)
@ -210,7 +219,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items,
gr_vector_int &ninput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items __attribute__((unused)))
{
int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
switch (d_state)
{
@ -240,7 +249,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items,
case 1:
{
// initialize acquisition algorithm
int doppler;
int32_t doppler;
uint32_t indext = 0;
uint32_t indext_A = 0;
uint32_t indext_B = 0;
@ -268,10 +277,10 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items,
d_input_power /= static_cast<float>(d_fft_size);
// 2- Doppler frequency search loop
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
// doppler search steps
doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in,
d_grid_doppler_wipeoffs[doppler_index], d_fft_size);

View File

@ -44,10 +44,14 @@ class galileo_pcps_8ms_acquisition_cc;
typedef boost::shared_ptr<galileo_pcps_8ms_acquisition_cc> galileo_pcps_8ms_acquisition_cc_sptr;
galileo_pcps_8ms_acquisition_cc_sptr
galileo_pcps_8ms_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
bool dump, std::string dump_filename);
galileo_pcps_8ms_make_acquisition_cc(uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool dump,
std::string dump_filename);
/*!
* \brief This class implements a Parallel Code Phase Search Acquisition for
@ -57,41 +61,52 @@ class galileo_pcps_8ms_acquisition_cc : public gr::block
{
private:
friend galileo_pcps_8ms_acquisition_cc_sptr
galileo_pcps_8ms_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
bool dump, std::string dump_filename);
galileo_pcps_8ms_make_acquisition_cc(
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool dump,
std::string dump_filename);
galileo_pcps_8ms_acquisition_cc(
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool dump,
std::string dump_filename);
galileo_pcps_8ms_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
bool dump, std::string dump_filename);
void calculate_magnitudes(
gr_complex* fft_begin,
int32_t doppler_shift,
int32_t doppler_offset);
void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift,
int doppler_offset);
long d_fs_in;
int d_samples_per_ms;
int d_samples_per_code;
unsigned int d_doppler_resolution;
int64_t d_fs_in;
int32_t d_samples_per_ms;
int32_t d_samples_per_code;
uint32_t d_doppler_resolution;
float d_threshold;
std::string d_satellite_str;
unsigned int d_doppler_max;
unsigned int d_doppler_step;
unsigned int d_sampled_ms;
unsigned int d_max_dwells;
unsigned int d_well_count;
unsigned int d_fft_size;
uint32_t d_doppler_max;
uint32_t d_doppler_step;
uint32_t d_sampled_ms;
uint32_t d_max_dwells;
uint32_t d_well_count;
uint32_t d_fft_size;
uint64_t d_sample_counter;
gr_complex** d_grid_doppler_wipeoffs;
unsigned int d_num_doppler_bins;
uint32_t d_num_doppler_bins;
gr_complex* d_fft_code_A;
gr_complex* d_fft_code_B;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase;
uint32_t d_code_phase;
float d_doppler_freq;
float d_mag;
float* d_magnitude;
@ -99,9 +114,9 @@ private:
float d_test_statistics;
std::ofstream d_dump_file;
bool d_active;
int d_state;
int32_t d_state;
bool d_dump;
unsigned int d_channel;
uint32_t d_channel;
std::string d_dump_filename;
public:
@ -123,7 +138,7 @@ public:
/*!
* \brief Returns the maximum peak of grid search.
*/
inline unsigned int mag() const
inline uint32_t mag() const
{
return d_mag;
}
@ -154,13 +169,13 @@ public:
* first available sample.
* \param state - int=1 forces start of acquisition
*/
void set_state(int state);
void set_state(int32_t state);
/*!
* \brief Set acquisition channel unique ID
* \param channel - receiver channel.
*/
inline void set_channel(unsigned int channel)
inline void set_channel(uint32_t channel)
{
d_channel = channel;
}
@ -179,7 +194,7 @@ public:
* \brief Set maximum Doppler grid search
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
*/
inline void set_doppler_max(unsigned int doppler_max)
inline void set_doppler_max(uint32_t doppler_max)
{
d_doppler_max = doppler_max;
}
@ -188,7 +203,7 @@ public:
* \brief Set Doppler steps for the grid search
* \param doppler_step - Frequency bin of the search grid [Hz].
*/
inline void set_doppler_step(unsigned int doppler_step)
inline void set_doppler_step(uint32_t doppler_step)
{
d_doppler_step = doppler_step;
}

View File

@ -47,8 +47,8 @@ extern concurrent_map<Gps_Acq_Assist> global_gps_acq_assist_map;
using google::LogMessage;
pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc(
int max_dwells, unsigned int sampled_ms, int doppler_max, int doppler_min,
long fs_in, int samples_per_ms, bool dump,
int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min,
int64_t fs_in, int32_t samples_per_ms, bool dump,
std::string dump_filename)
{
return pcps_assisted_acquisition_cc_sptr(
@ -58,8 +58,8 @@ pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc(
pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc(
int max_dwells, unsigned int sampled_ms, int doppler_max, int doppler_min,
long fs_in, int samples_per_ms, bool dump,
int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min,
int64_t fs_in, int32_t samples_per_ms, bool dump,
std::string dump_filename) : gr::block("pcps_assisted_acquisition_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex)),
gr::io_signature::make(0, 0, sizeof(gr_complex)))
@ -109,7 +109,7 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc(
}
void pcps_assisted_acquisition_cc::set_doppler_step(unsigned int doppler_step)
void pcps_assisted_acquisition_cc::set_doppler_step(uint32_t doppler_step)
{
d_doppler_step = doppler_step;
}
@ -117,7 +117,7 @@ void pcps_assisted_acquisition_cc::set_doppler_step(unsigned int doppler_step)
void pcps_assisted_acquisition_cc::free_grid_memory()
{
for (int i = 0; i < d_num_doppler_points; i++)
for (int32_t i = 0; i < d_num_doppler_points; i++)
{
delete[] d_grid_data[i];
delete[] d_grid_doppler_wipeoffs[i];
@ -206,9 +206,9 @@ void pcps_assisted_acquisition_cc::get_assistance()
void pcps_assisted_acquisition_cc::reset_grid()
{
d_well_count = 0;
for (int i = 0; i < d_num_doppler_points; i++)
for (int32_t i = 0; i < d_num_doppler_points; i++)
{
for (unsigned int j = 0; j < d_fft_size; j++)
for (uint32_t j = 0; j < d_fft_size; j++)
{
d_grid_data[i][j] = 0.0;
}
@ -227,16 +227,16 @@ void pcps_assisted_acquisition_cc::redefine_grid()
d_num_doppler_points = floor(std::abs(d_doppler_max - d_doppler_min) / d_doppler_step);
d_grid_data = new float *[d_num_doppler_points];
for (int i = 0; i < d_num_doppler_points; i++)
for (int32_t i = 0; i < d_num_doppler_points; i++)
{
d_grid_data[i] = new float[d_fft_size];
}
// create the carrier Doppler wipeoff signals
int doppler_hz;
int32_t doppler_hz;
float phase_step_rad;
d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_points];
for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++)
for (int32_t doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++)
{
doppler_hz = d_doppler_min + d_doppler_step * doppler_index;
// doppler search steps
@ -254,11 +254,11 @@ double pcps_assisted_acquisition_cc::search_maximum()
{
float magt = 0.0;
float fft_normalization_factor;
int index_doppler = 0;
int32_t index_doppler = 0;
uint32_t tmp_intex_t = 0;
uint32_t index_time = 0;
for (int i = 0; i < d_num_doppler_points; i++)
for (int32_t i = 0; i < d_num_doppler_points; i++)
{
volk_gnsssdr_32f_index_max_32u(&tmp_intex_t, d_grid_data[i], d_fft_size);
if (d_grid_data[i][tmp_intex_t] > magt)
@ -316,7 +316,7 @@ float pcps_assisted_acquisition_cc::estimate_input_power(gr_vector_const_void_st
}
int pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_void_star &input_items)
int32_t pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_void_star &input_items)
{
// initialize acquisition algorithm
const auto *in = reinterpret_cast<const gr_complex *>(input_items[0]); //Get the input samples pointer
@ -331,7 +331,7 @@ int pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_vo
// 2- Doppler frequency search loop
auto *p_tmp_vector = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++)
for (int32_t doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++)
{
// doppler search steps
// Perform the carrier wipe-off
@ -394,7 +394,7 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items,
d_state = 2;
break;
case 2: // S2. ComputeGrid
int consumed_samples;
int32_t consumed_samples;
consumed_samples = compute_and_accumulate_grid(input_items);
d_well_count++;
if (d_well_count >= d_max_dwells)

View File

@ -61,8 +61,13 @@ typedef boost::shared_ptr<pcps_assisted_acquisition_cc>
pcps_assisted_acquisition_cc_sptr;
pcps_assisted_acquisition_cc_sptr
pcps_make_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms,
int doppler_max, int doppler_min, long fs_in, int samples_per_ms,
pcps_make_assisted_acquisition_cc(
int32_t max_dwells,
uint32_t sampled_ms,
int32_t doppler_max,
int32_t doppler_min,
int64_t fs_in,
int32_t samples_per_ms,
bool dump, std::string dump_filename);
/*!
@ -75,20 +80,20 @@ class pcps_assisted_acquisition_cc : public gr::block
{
private:
friend pcps_assisted_acquisition_cc_sptr
pcps_make_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms,
int doppler_max, int doppler_min, long fs_in,
int samples_per_ms, bool dump,
pcps_make_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms,
int32_t doppler_max, int32_t doppler_min, int64_t fs_in,
int32_t samples_per_ms, bool dump,
std::string dump_filename);
pcps_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms,
int doppler_max, int doppler_min, long fs_in,
int samples_per_ms, bool dump,
pcps_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms,
int32_t doppler_max, int32_t doppler_min, int64_t fs_in,
int32_t samples_per_ms, bool dump,
std::string dump_filename);
void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift,
int doppler_offset);
void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift,
int32_t doppler_offset);
int compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
int32_t compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
float estimate_input_power(gr_vector_const_void_star& input_items);
double search_maximum();
void get_assistance();
@ -96,22 +101,22 @@ private:
void redefine_grid();
void free_grid_memory();
long d_fs_in;
int d_samples_per_ms;
int d_max_dwells;
unsigned int d_doppler_resolution;
int d_gnuradio_forecast_samples;
int64_t d_fs_in;
int32_t d_samples_per_ms;
int32_t d_max_dwells;
uint32_t d_doppler_resolution;
int32_t d_gnuradio_forecast_samples;
float d_threshold;
std::string d_satellite_str;
int d_doppler_max;
int d_doppler_min;
int d_config_doppler_max;
int d_config_doppler_min;
int32_t d_doppler_max;
int32_t d_doppler_min;
int32_t d_config_doppler_max;
int32_t d_config_doppler_min;
int d_num_doppler_points;
int d_doppler_step;
unsigned int d_sampled_ms;
unsigned int d_fft_size;
int32_t d_num_doppler_points;
int32_t d_doppler_step;
uint32_t d_sampled_ms;
uint32_t d_fft_size;
uint64_t d_sample_counter;
gr_complex* d_carrier;
gr_complex* d_fft_codes;
@ -122,17 +127,17 @@ private:
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase;
uint32_t d_code_phase;
float d_doppler_freq;
float d_input_power;
float d_test_statistics;
std::ofstream d_dump_file;
int d_state;
int32_t d_state;
bool d_active;
bool d_disable_assist;
int d_well_count;
int32_t d_well_count;
bool d_dump;
unsigned int d_channel;
uint32_t d_channel;
std::string d_dump_filename;
@ -155,7 +160,7 @@ public:
/*!
* \brief Returns the maximum peak of grid search.
*/
inline unsigned int mag() const
inline uint32_t mag() const
{
return d_test_statistics;
}
@ -185,7 +190,7 @@ public:
* \brief Set acquisition channel unique ID
* \param channel - receiver channel.
*/
inline void set_channel(unsigned int channel)
inline void set_channel(uint32_t channel)
{
d_channel = channel;
}
@ -204,7 +209,7 @@ public:
* \brief Set maximum Doppler grid search
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
*/
inline void set_doppler_max(unsigned int doppler_max)
inline void set_doppler_max(uint32_t doppler_max)
{
d_doppler_max = doppler_max;
}
@ -213,7 +218,7 @@ public:
* \brief Set Doppler steps for the grid search
* \param doppler_step - Frequency bin of the search grid [Hz].
*/
void set_doppler_step(unsigned int doppler_step);
void set_doppler_step(uint32_t doppler_step);
/*!
* \brief Parallel Code Phase Search Acquisition signal processing.

View File

@ -35,22 +35,24 @@
*/
#include "pcps_cccwsr_acquisition_cc.h"
#include <sstream>
#include <utility>
#include "control_message_factory.h"
#include "GPS_L1_CA.h" // GPS_TWO_PI
#include <glog/logging.h>
#include <gnuradio/io_signature.h>
#include <volk/volk.h>
#include <volk_gnsssdr/volk_gnsssdr.h>
#include "control_message_factory.h"
#include "GPS_L1_CA.h" //GPS_TWO_PI
#include <sstream>
#include <utility>
using google::LogMessage;
pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc(
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool dump, std::string dump_filename)
{
return pcps_cccwsr_acquisition_cc_sptr(
@ -58,10 +60,14 @@ pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc(
samples_per_ms, samples_per_code, dump, std::move(dump_filename)));
}
pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc(
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool dump,
std::string dump_filename) : gr::block("pcps_cccwsr_acquisition_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms),
@ -116,7 +122,7 @@ pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc()
{
if (d_num_doppler_bins > 0)
{
for (unsigned int i = 0; i < d_num_doppler_bins; i++)
for (uint32_t i = 0; i < d_num_doppler_bins; i++)
{
volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]);
}
@ -175,8 +181,8 @@ void pcps_cccwsr_acquisition_cc::init()
// Count the number of bins
d_num_doppler_bins = 0;
for (int doppler = static_cast<int>(-d_doppler_max);
doppler <= static_cast<int>(d_doppler_max);
for (auto doppler = static_cast<int32_t>(-d_doppler_max);
doppler <= static_cast<int32_t>(d_doppler_max);
doppler += d_doppler_step)
{
d_num_doppler_bins++;
@ -184,11 +190,11 @@ void pcps_cccwsr_acquisition_cc::init()
// Create the carrier Doppler wipeoff signals
d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins];
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
int32_t doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = GPS_TWO_PI * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
@ -197,7 +203,7 @@ void pcps_cccwsr_acquisition_cc::init()
}
void pcps_cccwsr_acquisition_cc::set_state(int state)
void pcps_cccwsr_acquisition_cc::set_state(int32_t state)
{
d_state = state;
if (d_state == 1)
@ -225,7 +231,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items,
gr_vector_int &ninput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items __attribute__((unused)))
{
int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
switch (d_state)
{
@ -254,7 +260,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items,
case 1:
{
// initialize acquisition algorithm
int doppler;
int32_t doppler;
uint32_t indext = 0;
uint32_t indext_plus = 0;
@ -281,11 +287,11 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items,
d_input_power /= static_cast<float>(d_fft_size);
// 2- Doppler frequency search loop
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
// doppler search steps
doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in,
d_grid_doppler_wipeoffs[doppler_index], d_fft_size);
@ -320,7 +326,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items,
// d_data_correlation.
memcpy(d_pilot_correlation, d_ifft->get_outbuf(), sizeof(gr_complex) * d_fft_size);
for (unsigned int i = 0; i < d_fft_size; i++)
for (uint32_t i = 0; i < d_fft_size; i++)
{
d_correlation_plus[i] = std::complex<float>(
d_data_correlation[i].real() - d_pilot_correlation[i].imag(),

View File

@ -50,10 +50,15 @@ class pcps_cccwsr_acquisition_cc;
typedef boost::shared_ptr<pcps_cccwsr_acquisition_cc> pcps_cccwsr_acquisition_cc_sptr;
pcps_cccwsr_acquisition_cc_sptr
pcps_cccwsr_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
bool dump, std::string dump_filename);
pcps_cccwsr_make_acquisition_cc(
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool dump,
std::string dump_filename);
/*!
* \brief This class implements a Parallel Code Phase Search Acquisition with
@ -63,40 +68,40 @@ class pcps_cccwsr_acquisition_cc : public gr::block
{
private:
friend pcps_cccwsr_acquisition_cc_sptr
pcps_cccwsr_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
pcps_cccwsr_make_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells,
uint32_t doppler_max, int64_t fs_in,
int32_t samples_per_ms, int32_t samples_per_code,
bool dump, std::string dump_filename);
pcps_cccwsr_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
pcps_cccwsr_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells,
uint32_t doppler_max, int64_t fs_in,
int32_t samples_per_ms, int32_t samples_per_code,
bool dump, std::string dump_filename);
void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift,
int doppler_offset);
void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift,
int32_t doppler_offset);
long d_fs_in;
int d_samples_per_ms;
int d_samples_per_code;
unsigned int d_doppler_resolution;
int64_t d_fs_in;
int32_t d_samples_per_ms;
int32_t d_samples_per_code;
uint32_t d_doppler_resolution;
float d_threshold;
std::string d_satellite_str;
unsigned int d_doppler_max;
unsigned int d_doppler_step;
unsigned int d_sampled_ms;
unsigned int d_max_dwells;
unsigned int d_well_count;
unsigned int d_fft_size;
uint32_t d_doppler_max;
uint32_t d_doppler_step;
uint32_t d_sampled_ms;
uint32_t d_max_dwells;
uint32_t d_well_count;
uint32_t d_fft_size;
uint64_t d_sample_counter;
gr_complex** d_grid_doppler_wipeoffs;
unsigned int d_num_doppler_bins;
uint32_t d_num_doppler_bins;
gr_complex* d_fft_code_data;
gr_complex* d_fft_code_pilot;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase;
uint32_t d_code_phase;
float d_doppler_freq;
float d_mag;
float* d_magnitude;
@ -108,9 +113,9 @@ private:
float d_test_statistics;
std::ofstream d_dump_file;
bool d_active;
int d_state;
int32_t d_state;
bool d_dump;
unsigned int d_channel;
uint32_t d_channel;
std::string d_dump_filename;
public:
@ -132,7 +137,7 @@ public:
/*!
* \brief Returns the maximum peak of grid search.
*/
inline unsigned int mag() const
inline uint32_t mag() const
{
return d_mag;
}
@ -164,13 +169,13 @@ public:
* first available sample.
* \param state - int=1 forces start of acquisition
*/
void set_state(int state);
void set_state(int32_t state);
/*!
* \brief Set acquisition channel unique ID
* \param channel - receiver channel.
*/
inline void set_channel(unsigned int channel)
inline void set_channel(uint32_t channel)
{
d_channel = channel;
}
@ -189,7 +194,7 @@ public:
* \brief Set maximum Doppler grid search
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
*/
inline void set_doppler_max(unsigned int doppler_max)
inline void set_doppler_max(uint32_t doppler_max)
{
d_doppler_max = doppler_max;
}
@ -198,7 +203,7 @@ public:
* \brief Set Doppler steps for the grid search
* \param doppler_step - Frequency bin of the search grid [Hz].
*/
inline void set_doppler_step(unsigned int doppler_step)
inline void set_doppler_step(uint32_t doppler_step)
{
d_doppler_step = doppler_step;
}

View File

@ -43,10 +43,13 @@
using google::LogMessage;
pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc(
unsigned int folding_factor,
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
uint32_t folding_factor,
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool bit_transition_flag,
bool dump,
std::string dump_filename)
@ -63,10 +66,10 @@ pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc(
pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc(
unsigned int folding_factor,
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
uint32_t folding_factor,
uint32_t sampled_ms, uint32_t max_dwells,
uint32_t doppler_max, int64_t fs_in,
int32_t samples_per_ms, int32_t samples_per_code,
bool bit_transition_flag,
bool dump,
std::string dump_filename) : gr::block("pcps_quicksync_acquisition_cc",
@ -97,7 +100,7 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc(
d_magnitude = static_cast<float*>(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(float), volk_gnsssdr_get_alignment()));
d_magnitude_folded = static_cast<float*>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
d_possible_delay = new unsigned int[d_folding_factor];
d_possible_delay = new uint32_t[d_folding_factor];
d_corr_output_f = new float[d_folding_factor];
/*Create the d_code signal , which would store the values of the code in its
@ -138,7 +141,7 @@ pcps_quicksync_acquisition_cc::~pcps_quicksync_acquisition_cc()
//DLOG(INFO) << "START DESTROYER";
if (d_num_doppler_bins > 0)
{
for (unsigned int i = 0; i < d_num_doppler_bins; i++)
for (uint32_t i = 0; i < d_num_doppler_bins; i++)
{
volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]);
}
@ -176,7 +179,7 @@ void pcps_quicksync_acquisition_cc::set_local_code(std::complex<float>* code)
/*perform folding of the code by the factorial factor parameter. Notice that
folding of the code in the time stage would result in a downsampled spectrum
in the frequency domain after applying the fftw operation*/
for (unsigned int i = 0; i < d_folding_factor; i++)
for (uint32_t i = 0; i < d_folding_factor; i++)
{
std::transform((code + i * d_fft_size), (code + ((i + 1) * d_fft_size)),
d_fft_if->get_inbuf(), d_fft_if->get_inbuf(),
@ -209,8 +212,8 @@ void pcps_quicksync_acquisition_cc::init()
// Count the number of bins
d_num_doppler_bins = 0;
for (int doppler = static_cast<int>(-d_doppler_max);
doppler <= static_cast<int>(d_doppler_max);
for (auto doppler = static_cast<int32_t>(-d_doppler_max);
doppler <= static_cast<int32_t>(d_doppler_max);
doppler += d_doppler_step)
{
d_num_doppler_bins++;
@ -218,10 +221,10 @@ void pcps_quicksync_acquisition_cc::init()
// Create the carrier Doppler wipeoff signals
d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins];
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
int32_t doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = GPS_TWO_PI * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
@ -231,7 +234,7 @@ void pcps_quicksync_acquisition_cc::init()
}
void pcps_quicksync_acquisition_cc::set_state(int state)
void pcps_quicksync_acquisition_cc::set_state(int32_t state)
{
d_state = state;
if (d_state == 1)
@ -270,7 +273,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
* 6. Declare positive or negative acquisition using a message queue
*/
//DLOG(INFO) << "START GENERAL WORK";
int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
//std::cout<<"general_work in quicksync gnuradio block"<<std::endl;
switch (d_state)
{
@ -302,7 +305,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
{
/* initialize acquisition implementing the QuickSync algorithm*/
//DLOG(INFO) << "START CASE 1";
int doppler;
int32_t doppler;
uint32_t indext = 0;
float magt = 0.0;
const auto* in = reinterpret_cast<const gr_complex*>(input_items[0]); //Get the input samples pointer
@ -349,7 +352,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_samples_per_code * d_folding_factor);
d_input_power /= static_cast<float>(d_samples_per_code * d_folding_factor);
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
/*Ensure that the signal is going to start with all samples
at zero. This is done to avoid over acumulation when performing
@ -360,7 +363,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
/*Doppler search steps and then multiplication of the incoming
signal with the doppler wipeoffs to eliminate frequency offset
*/
doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
/*Perform multiplication of the incoming signal with the
complex exponential vector. This removes the frequency doppler
@ -372,7 +375,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
/*Perform folding of the carrier wiped-off incoming signal. Since
superlinear method is being used the folding factor in the
incoming raw data signal is of d_folding_factor^2*/
for (int i = 0; i < static_cast<int>(d_folding_factor * d_folding_factor); i++)
for (int32_t i = 0; i < static_cast<int32_t>(d_folding_factor * d_folding_factor); i++)
{
std::transform((in_temp + i * d_fft_size),
(in_temp + ((i + 1) * d_fft_size)),
@ -423,17 +426,17 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
restarted between consecutive dwells in multidwell operation.*/
if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag)
{
unsigned int detected_delay_samples_folded = 0;
uint32_t detected_delay_samples_folded = 0;
detected_delay_samples_folded = (indext % d_samples_per_code);
gr_complex complex_acumulator[100];
//gr_complex complex_acumulator[d_folding_factor];
for (int i = 0; i < static_cast<int>(d_folding_factor); i++)
for (int32_t i = 0; i < static_cast<int32_t>(d_folding_factor); i++)
{
d_possible_delay[i] = detected_delay_samples_folded + (i)*d_fft_size;
}
for (int i = 0; i < static_cast<int>(d_folding_factor); i++)
for (int32_t i = 0; i < static_cast<int32_t>(d_folding_factor); i++)
{
/*Copy a signal of 1 code length into suggested buffer.
The copied signal must have doppler effect corrected*/
@ -447,7 +450,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
of a shift*/
volk_32fc_x2_multiply_32fc(corr_output, in_1code, d_code, d_samples_per_code);
for (int j = 0; j < d_samples_per_code; j++)
for (int32_t j = 0; j < d_samples_per_code; j++)
{
complex_acumulator[i] += (corr_output[j]);
}
@ -532,7 +535,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
DLOG(INFO) << "test statistics threshold " << d_threshold;
DLOG(INFO) << "folding factor " << d_folding_factor;
DLOG(INFO) << "possible delay correlation output";
for (int i = 0; i < static_cast<int>(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i];
for (int32_t i = 0; i < static_cast<int32_t>(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i];
DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples;
DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz;
DLOG(INFO) << "magnitude folded " << d_mag;
@ -561,7 +564,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
DLOG(INFO) << "test statistics threshold " << d_threshold;
DLOG(INFO) << "folding factor " << d_folding_factor;
DLOG(INFO) << "possible delay corr output";
for (int i = 0; i < static_cast<int>(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i];
for (int32_t i = 0; i < static_cast<int32_t>(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i];
DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples;
DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz;
DLOG(INFO) << "magnitude folded " << d_mag;

View File

@ -67,10 +67,14 @@ typedef boost::shared_ptr<pcps_quicksync_acquisition_cc>
pcps_quicksync_acquisition_cc_sptr;
pcps_quicksync_acquisition_cc_sptr
pcps_quicksync_make_acquisition_cc(unsigned int folding_factor,
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
pcps_quicksync_make_acquisition_cc(
uint32_t folding_factor,
uint32_t sampled_ms,
uint32_t max_dwells,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
bool bit_transition_flag,
bool dump,
std::string dump_filename);
@ -86,56 +90,56 @@ class pcps_quicksync_acquisition_cc : public gr::block
{
private:
friend pcps_quicksync_acquisition_cc_sptr
pcps_quicksync_make_acquisition_cc(unsigned int folding_factor,
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
pcps_quicksync_make_acquisition_cc(uint32_t folding_factor,
uint32_t sampled_ms, uint32_t max_dwells,
uint32_t doppler_max, int64_t fs_in,
int32_t samples_per_ms, int32_t samples_per_code,
bool bit_transition_flag,
bool dump,
std::string dump_filename);
pcps_quicksync_acquisition_cc(unsigned int folding_factor,
unsigned int sampled_ms, unsigned int max_dwells,
unsigned int doppler_max, long fs_in,
int samples_per_ms, int samples_per_code,
pcps_quicksync_acquisition_cc(uint32_t folding_factor,
uint32_t sampled_ms, uint32_t max_dwells,
uint32_t doppler_max, int64_t fs_in,
int32_t samples_per_ms, int32_t samples_per_code,
bool bit_transition_flag,
bool dump,
std::string dump_filename);
void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift,
int doppler_offset);
void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift,
int32_t doppler_offset);
gr_complex* d_code;
unsigned int d_folding_factor; // also referred in the paper as 'p'
uint32_t d_folding_factor; // also referred in the paper as 'p'
float* d_corr_acumulator;
unsigned int* d_possible_delay;
uint32_t * d_possible_delay;
float* d_corr_output_f;
float* d_magnitude_folded;
gr_complex* d_signal_folded;
gr_complex* d_code_folded;
float d_noise_floor_power;
long d_fs_in;
int d_samples_per_ms;
int d_samples_per_code;
unsigned int d_doppler_resolution;
int64_t d_fs_in;
int32_t d_samples_per_ms;
int32_t d_samples_per_code;
uint32_t d_doppler_resolution;
float d_threshold;
std::string d_satellite_str;
unsigned int d_doppler_max;
unsigned int d_doppler_step;
unsigned int d_sampled_ms;
unsigned int d_max_dwells;
unsigned int d_well_count;
unsigned int d_fft_size;
uint32_t d_doppler_max;
uint32_t d_doppler_step;
uint32_t d_sampled_ms;
uint32_t d_max_dwells;
uint32_t d_well_count;
uint32_t d_fft_size;
uint64_t d_sample_counter;
gr_complex** d_grid_doppler_wipeoffs;
unsigned int d_num_doppler_bins;
uint32_t d_num_doppler_bins;
gr_complex* d_fft_codes;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_fft_if2;
gr::fft::fft_complex* d_ifft;
Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase;
uint32_t d_code_phase;
float d_doppler_freq;
float d_mag;
float* d_magnitude;
@ -144,9 +148,9 @@ private:
bool d_bit_transition_flag;
std::ofstream d_dump_file;
bool d_active;
int d_state;
int32_t d_state;
bool d_dump;
unsigned int d_channel;
uint32_t d_channel;
std::string d_dump_filename;
public:
@ -168,7 +172,7 @@ public:
/*!
* \brief Returns the maximum peak of grid search.
*/
inline unsigned int mag() const
inline uint32_t mag() const
{
return d_mag;
}
@ -199,13 +203,13 @@ public:
* first available sample.
* \param state - int=1 forces start of acquisition
*/
void set_state(int state);
void set_state(int32_t state);
/*!
* \brief Set acquisition channel unique ID
* \param channel - receiver channel.
*/
inline void set_channel(unsigned int channel)
inline void set_channel(uint32_t channel)
{
d_channel = channel;
}
@ -224,7 +228,7 @@ public:
* \brief Set maximum Doppler grid search
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
*/
inline void set_doppler_max(unsigned int doppler_max)
inline void set_doppler_max(uint32_t doppler_max)
{
d_doppler_max = doppler_max;
}
@ -233,7 +237,7 @@ public:
* \brief Set Doppler steps for the grid search
* \param doppler_step - Frequency bin of the search grid [Hz].
*/
inline void set_doppler_step(unsigned int doppler_step)
inline void set_doppler_step(uint32_t doppler_step)
{
d_doppler_step = doppler_step;
}

View File

@ -61,10 +61,14 @@
using google::LogMessage;
pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc(
unsigned int sampled_ms, unsigned int doppler_max,
long fs_in, int samples_per_ms,
int samples_per_code, unsigned int tong_init_val,
unsigned int tong_max_val, unsigned int tong_max_dwells,
uint32_t sampled_ms,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
uint32_t tong_init_val,
uint32_t tong_max_val,
uint32_t tong_max_dwells,
bool dump, std::string dump_filename)
{
return pcps_tong_acquisition_cc_sptr(
@ -73,10 +77,14 @@ pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc(
}
pcps_tong_acquisition_cc::pcps_tong_acquisition_cc(
unsigned int sampled_ms, unsigned int doppler_max,
long fs_in, int samples_per_ms,
int samples_per_code, unsigned int tong_init_val,
unsigned int tong_max_val, unsigned int tong_max_dwells,
uint32_t sampled_ms,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
uint32_t tong_init_val,
uint32_t tong_max_val,
uint32_t tong_max_dwells,
bool dump,
std::string dump_filename) : gr::block("pcps_tong_acquisition_cc",
gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms),
@ -130,7 +138,7 @@ pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc()
{
if (d_num_doppler_bins > 0)
{
for (unsigned int i = 0; i < d_num_doppler_bins; i++)
for (uint32_t i = 0; i < d_num_doppler_bins; i++)
{
volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]);
volk_gnsssdr_free(d_grid_data[i]);
@ -176,8 +184,8 @@ void pcps_tong_acquisition_cc::init()
// Count the number of bins
d_num_doppler_bins = 0;
for (int doppler = static_cast<int>(-d_doppler_max);
doppler <= static_cast<int>(d_doppler_max);
for (auto doppler = static_cast<int32_t>(-d_doppler_max);
doppler <= static_cast<int32_t>(d_doppler_max);
doppler += d_doppler_step)
{
d_num_doppler_bins++;
@ -186,11 +194,11 @@ void pcps_tong_acquisition_cc::init()
// Create the carrier Doppler wipeoff signals and allocate data grid.
d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins];
d_grid_data = new float *[d_num_doppler_bins];
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
d_grid_doppler_wipeoffs[doppler_index] = static_cast<gr_complex *>(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
int doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
int32_t doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
float phase_step_rad = GPS_TWO_PI * doppler / static_cast<float>(d_fs_in);
float _phase[1];
_phase[0] = 0;
@ -198,14 +206,14 @@ void pcps_tong_acquisition_cc::init()
d_grid_data[doppler_index] = static_cast<float *>(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment()));
for (unsigned int i = 0; i < d_fft_size; i++)
for (uint32_t i = 0; i < d_fft_size; i++)
{
d_grid_data[doppler_index][i] = 0;
}
}
}
void pcps_tong_acquisition_cc::set_state(int state)
void pcps_tong_acquisition_cc::set_state(int32_t state)
{
d_state = state;
if (d_state == 1)
@ -220,9 +228,9 @@ void pcps_tong_acquisition_cc::set_state(int state)
d_input_power = 0.0;
d_test_statistics = 0.0;
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
for (unsigned int i = 0; i < d_fft_size; i++)
for (uint32_t i = 0; i < d_fft_size; i++)
{
d_grid_data[doppler_index][i] = 0;
}
@ -241,7 +249,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items,
gr_vector_int &ninput_items, gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items __attribute__((unused)))
{
int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL
switch (d_state)
{
@ -260,9 +268,9 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items,
d_input_power = 0.0;
d_test_statistics = 0.0;
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
for (unsigned int i = 0; i < d_fft_size; i++)
for (uint32_t i = 0; i < d_fft_size; i++)
{
d_grid_data[doppler_index][i] = 0;
}
@ -280,7 +288,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items,
case 1:
{
// initialize acquisition algorithm
int doppler;
int32_t doppler;
uint32_t indext = 0;
float magt = 0.0;
const auto *in = reinterpret_cast<const gr_complex *>(input_items[0]); //Get the input samples pointer
@ -304,11 +312,11 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items,
d_input_power /= static_cast<float>(d_fft_size);
// 2- Doppler frequency search loop
for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++)
{
// doppler search steps
doppler = -static_cast<int>(d_doppler_max) + d_doppler_step * doppler_index;
doppler = -static_cast<int32_t>(d_doppler_max) + d_doppler_step * doppler_index;
volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in,
d_grid_doppler_wipeoffs[doppler_index], d_fft_size);

View File

@ -64,11 +64,17 @@ class pcps_tong_acquisition_cc;
typedef boost::shared_ptr<pcps_tong_acquisition_cc> pcps_tong_acquisition_cc_sptr;
pcps_tong_acquisition_cc_sptr
pcps_tong_make_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max,
long fs_in, int samples_per_ms,
int samples_per_code, unsigned int tong_init_val,
unsigned int tong_max_val, unsigned int tong_max_dwells,
bool dump, std::string dump_filename);
pcps_tong_make_acquisition_cc(
uint32_t sampled_ms,
uint32_t doppler_max,
int64_t fs_in,
int32_t samples_per_ms,
int32_t samples_per_code,
uint32_t tong_init_val,
uint32_t tong_max_val,
uint32_t tong_max_dwells,
bool dump,
std::string dump_filename);
/*!
* \brief This class implements a Parallel Code Phase Search Acquisition with
@ -78,45 +84,45 @@ class pcps_tong_acquisition_cc : public gr::block
{
private:
friend pcps_tong_acquisition_cc_sptr
pcps_tong_make_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max,
long fs_in, int samples_per_ms,
int samples_per_code, unsigned int tong_init_val,
unsigned int tong_max_val, unsigned int tong_max_dwells,
pcps_tong_make_acquisition_cc(uint32_t sampled_ms, uint32_t doppler_max,
int64_t fs_in, int32_t samples_per_ms,
int32_t samples_per_code, uint32_t tong_init_val,
uint32_t tong_max_val, uint32_t tong_max_dwells,
bool dump, std::string dump_filename);
pcps_tong_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max,
long fs_in, int samples_per_ms,
int samples_per_code, unsigned int tong_init_val,
unsigned int tong_max_val, unsigned int tong_max_dwells,
pcps_tong_acquisition_cc(uint32_t sampled_ms, uint32_t doppler_max,
int64_t fs_in, int32_t samples_per_ms,
int32_t samples_per_code, uint32_t tong_init_val,
uint32_t tong_max_val, uint32_t tong_max_dwells,
bool dump, std::string dump_filename);
void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift,
int doppler_offset);
void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift,
int32_t doppler_offset);
long d_fs_in;
int d_samples_per_ms;
int d_samples_per_code;
unsigned int d_doppler_resolution;
int64_t d_fs_in;
int32_t d_samples_per_ms;
int32_t d_samples_per_code;
uint32_t d_doppler_resolution;
float d_threshold;
std::string d_satellite_str;
unsigned int d_doppler_max;
unsigned int d_doppler_step;
unsigned int d_sampled_ms;
unsigned int d_dwell_count;
unsigned int d_tong_count;
unsigned int d_tong_init_val;
unsigned int d_tong_max_val;
unsigned int d_tong_max_dwells;
unsigned int d_fft_size;
uint32_t d_doppler_max;
uint32_t d_doppler_step;
uint32_t d_sampled_ms;
uint32_t d_dwell_count;
uint32_t d_tong_count;
uint32_t d_tong_init_val;
uint32_t d_tong_max_val;
uint32_t d_tong_max_dwells;
uint32_t d_fft_size;
uint64_t d_sample_counter;
gr_complex** d_grid_doppler_wipeoffs;
unsigned int d_num_doppler_bins;
uint32_t d_num_doppler_bins;
gr_complex* d_fft_codes;
float** d_grid_data;
gr::fft::fft_complex* d_fft_if;
gr::fft::fft_complex* d_ifft;
Gnss_Synchro* d_gnss_synchro;
unsigned int d_code_phase;
uint32_t d_code_phase;
float d_doppler_freq;
float d_mag;
float* d_magnitude;
@ -124,9 +130,9 @@ private:
float d_test_statistics;
std::ofstream d_dump_file;
bool d_active;
int d_state;
int32_t d_state;
bool d_dump;
unsigned int d_channel;
uint32_t d_channel;
std::string d_dump_filename;
public:
@ -148,7 +154,7 @@ public:
/*!
* \brief Returns the maximum peak of grid search.
*/
inline unsigned int mag() const
inline uint32_t mag() const
{
return d_mag;
}
@ -179,13 +185,13 @@ public:
* first available sample.
* \param state - int=1 forces start of acquisition
*/
void set_state(int state);
void set_state(int32_t state);
/*!
* \brief Set acquisition channel unique ID
* \param channel - receiver channel.
*/
inline void set_channel(unsigned int channel)
inline void set_channel(uint32_t channel)
{
d_channel = channel;
}
@ -204,7 +210,7 @@ public:
* \brief Set maximum Doppler grid search
* \param doppler_max - Maximum Doppler shift considered in the grid search [Hz].
*/
inline void set_doppler_max(unsigned int doppler_max)
inline void set_doppler_max(uint32_t doppler_max)
{
d_doppler_max = doppler_max;
}
@ -213,7 +219,7 @@ public:
* \brief Set Doppler steps for the grid search
* \param doppler_step - Frequency bin of the search grid [Hz].
*/
inline void set_doppler_step(unsigned int doppler_step)
inline void set_doppler_step(uint32_t doppler_step)
{
d_doppler_step = doppler_step;
}

View File

@ -31,7 +31,7 @@
#include "byte_to_short.h"
#include "configuration_interface.h"
#include <glog/logging.h>
#include <cstdint>
#include <utility>
@ -51,7 +51,7 @@ ByteToShort::ByteToShort(ConfigurationInterface* configuration, std::string role
dump_ = config_->property(role_ + ".dump", false);
dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename);
size_t item_size = sizeof(short);
size_t item_size = sizeof(int16_t);
gr_char_to_short_ = gr::blocks::char_to_short::make();

View File

@ -291,11 +291,11 @@ gr::basic_block_sptr FirFilter::get_left_block()
{
return cbyte_to_float_x2_;
}
else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte"))
if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte"))
{
return cbyte_to_float_x2_;
}
else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex"))
if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex"))
{
return cshort_to_float_x2_;
}
@ -321,11 +321,11 @@ gr::basic_block_sptr FirFilter::get_right_block()
{
return float_to_complex_;
}
else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte"))
if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte"))
{
return char_x2_cbyte_;
}
else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex"))
if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex"))
{
return float_to_complex_;
}

View File

@ -331,11 +331,11 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_left_block()
{
return freq_xlating_fir_filter_scf_;
}
else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort"))
if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort"))
{
return freq_xlating_fir_filter_scf_;
}
else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex"))
if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex"))
{
return gr_char_to_short_;
}
@ -365,11 +365,11 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_right_block()
{
return freq_xlating_fir_filter_scf_;
}
else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort"))
if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort"))
{
return short_x2_to_cshort_;
}
else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex"))
if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex"))
{
return freq_xlating_fir_filter_scf_;
}

View File

@ -49,7 +49,7 @@ beamformer::beamformer()
{
//initialize weight vector
if (posix_memalign((void **)&weight_vector, 16, GNSS_SDR_BEAMFORMER_CHANNELS * sizeof(gr_complex)) == 0)
if (posix_memalign(reinterpret_cast<void **>(&weight_vector), 16, GNSS_SDR_BEAMFORMER_CHANNELS * sizeof(gr_complex)) == 0)
{
};

View File

@ -119,7 +119,7 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
if (_fs != _codeFreqBasis)
{
std::complex<float>* _resampled_signal;
if (posix_memalign((void**)&_resampled_signal, 16, _samplesPerCode * sizeof(gr_complex)) == 0)
if (posix_memalign(reinterpret_cast<void**>(&_resampled_signal), 16, _samplesPerCode * sizeof(gr_complex)) == 0)
{
};
resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); // resamples code to fs

View File

@ -40,7 +40,7 @@
#include <utility>
gnss_sdr_valve::gnss_sdr_valve(size_t sizeof_stream_item,
unsigned long long nitems,
uint64_t nitems,
gr::msg_queue::sptr queue,
bool stop_flowgraph) : gr::sync_block("valve",
gr::io_signature::make(1, 1, sizeof_stream_item),
@ -54,14 +54,14 @@ gnss_sdr_valve::gnss_sdr_valve(size_t sizeof_stream_item,
}
boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item, unsigned long long nitems, gr::msg_queue::sptr queue, bool stop_flowgraph)
boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, gr::msg_queue::sptr queue, bool stop_flowgraph)
{
boost::shared_ptr<gnss_sdr_valve> valve_(new gnss_sdr_valve(sizeof_stream_item, nitems, std::move(queue), stop_flowgraph));
return valve_;
}
boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item, unsigned long long nitems, gr::msg_queue::sptr queue)
boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, gr::msg_queue::sptr queue)
{
boost::shared_ptr<gnss_sdr_valve> valve_(new gnss_sdr_valve(sizeof_stream_item, nitems, std::move(queue), true));
return valve_;
@ -93,7 +93,7 @@ int gnss_sdr_valve::work(int noutput_items,
usleep(1000000);
return 0; // do not produce or consume
}
unsigned long long n = std::min(d_nitems - d_ncopied_items, static_cast<long long unsigned int>(noutput_items));
uint64_t n = std::min(d_nitems - d_ncopied_items, static_cast<uint64_t>(noutput_items));
if (n == 0) return 0;
memcpy(output_items[0], input_items[0], n * input_signature()->sizeof_stream_item(0));
d_ncopied_items += n;

View File

@ -37,13 +37,14 @@
#include <gnuradio/sync_block.h>
#include <gnuradio/msg_queue.h>
#include <boost/shared_ptr.hpp>
#include <cstdint>
boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item,
unsigned long long nitems,
uint64_t nitems,
gr::msg_queue::sptr queue);
boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item,
unsigned long long nitems,
uint64_t nitems,
gr::msg_queue::sptr queue,
bool stop_flowgraph);
@ -54,22 +55,22 @@ boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item,
class gnss_sdr_valve : public gr::sync_block
{
friend boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item,
unsigned long long nitems,
uint64_t nitems,
gr::msg_queue::sptr queue);
friend boost::shared_ptr<gr::block> gnss_sdr_make_valve(size_t sizeof_stream_item,
unsigned long long nitems,
uint64_t nitems,
gr::msg_queue::sptr queue,
bool stop_flowgraph);
unsigned long long d_nitems;
unsigned long long d_ncopied_items;
uint64_t d_nitems;
uint64_t d_ncopied_items;
gr::msg_queue::sptr d_queue;
bool d_stop_flowgraph;
bool d_open_valve;
public:
gnss_sdr_valve(size_t sizeof_stream_item,
unsigned long long nitems,
uint64_t nitems,
gr::msg_queue::sptr queue, bool stop_flowgraph);
void open_valve();

View File

@ -157,11 +157,8 @@ gr::basic_block_sptr Pass_Through::get_left_block()
{
return conjugate_ic_;
}
else
{
LOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
LOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
return kludge_copy_;
@ -184,11 +181,8 @@ gr::basic_block_sptr Pass_Through::get_right_block()
{
return conjugate_ic_;
}
else
{
DLOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
DLOG(WARNING) << "Setting inverted_spectrum to true with item_type "
<< item_type_ << " is not defined and has no effect.";
}
return kludge_copy_;

View File

@ -63,6 +63,7 @@
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
/* macros --------------------------------------------------------------------*/

View File

@ -66,7 +66,7 @@ int getindex(double value, const double *range)
if (range[2] == 0.0) return 0;
if (range[1] > 0.0 && (value < range[0] || range[1] < value)) return -1;
if (range[1] < 0.0 && (value < range[1] || range[0] < value)) return -1;
return (int)floor((value - range[0]) / range[2] + 0.5);
return static_cast<int>(floor((value - range[0]) / range[2] + 0.5));
}
@ -103,7 +103,7 @@ tec_t *addtec(const double *lats, const double *lons, const double *hgts,
if (nav->nt >= nav->ntmax)
{
nav->ntmax += 256;
if (!(nav_tec = (tec_t *)realloc(nav->tec, sizeof(tec_t) * nav->ntmax)))
if (!(nav_tec = static_cast<tec_t *>(realloc(nav->tec, sizeof(tec_t) * nav->ntmax))))
{
trace(1, "readionex malloc error ntmax=%d\n", nav->ntmax);
free(nav->tec);
@ -125,8 +125,8 @@ tec_t *addtec(const double *lats, const double *lons, const double *hgts,
}
n = ndata[0] * ndata[1] * ndata[2];
if (!(p->data = (double *)malloc(sizeof(double) * n)) ||
!(p->rms = (float *)malloc(sizeof(float) * n)))
if (!(p->data = static_cast<double *>(malloc(sizeof(double) * n))) ||
!(p->rms = static_cast<float *>(malloc(sizeof(float) * n))))
{
return nullptr;
}
@ -310,7 +310,7 @@ int readionexb(FILE *fp, const double *lats, const double *lons,
if (type == 1)
p->data[index] = x * std::pow(10.0, nexp);
else
p->rms[index] = (float)(x * std::pow(10.0, nexp));
p->rms[index] = static_cast<float>(x * std::pow(10.0, nexp));
}
}
}
@ -384,7 +384,7 @@ void readtec(const char *file, nav_t *nav, int opt)
}
for (i = 0; i < MAXEXFILE; i++)
{
if (!(efiles[i] = (char *)malloc(1024)))
if (!(efiles[i] = static_cast<char *>(malloc(1024))))
{
for (i--; i >= 0; i--) free(efiles[i]);
return;
@ -395,7 +395,7 @@ void readtec(const char *file, nav_t *nav, int opt)
for (i = 0; i < n; i++)
{
if (!(fp = fopen(efiles[i], "r")))
if (!(fp = fopen(efiles[i], "re")))
{
trace(2, "ionex file open error %s\n", efiles[i]);
continue;
@ -447,9 +447,9 @@ int interptec(const tec_t *tec, int k, const double *posp, double *value,
a = dlat / tec->lats[2];
b = dlon / tec->lons[2];
i = (int)floor(a);
i = static_cast<int>(floor(a));
a -= i;
j = (int)floor(b);
j = static_cast<int>(floor(b));
b -= j;
/* get gridded tec data */

View File

@ -84,10 +84,10 @@ void gauss(int n, double *L, double *Z, int i, int j)
{
int k, mu;
if ((mu = (int)ROUND_LAMBDA(L[i + j * n])) != 0)
if ((mu = static_cast<int>ROUND_LAMBDA(L[i + j * n])) != 0)
{
for (k = i; k < n; k++) L[k + n * j] -= (double)mu * L[k + i * n];
for (k = 0; k < n; k++) Z[k + n * j] -= (double)mu * Z[k + i * n];
for (k = i; k < n; k++) L[k + n * j] -= static_cast<double>(mu) * L[k + i * n];
for (k = 0; k < n; k++) Z[k + n * j] -= static_cast<double>(mu) * Z[k + i * n];
}
}

View File

@ -609,11 +609,11 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts,
sol->dtr[2] = x[5] / SPEED_OF_LIGHT; /* gal-gps time offset (s) */
sol->dtr[3] = x[6] / SPEED_OF_LIGHT; /* bds-gps time offset (s) */
for (j = 0; j < 6; j++) sol->rr[j] = j < 3 ? x[j] : 0.0;
for (j = 0; j < 3; j++) sol->qr[j] = (float)Q[j + j * NX];
sol->qr[3] = (float)Q[1]; /* cov xy */
sol->qr[4] = (float)Q[2 + NX]; /* cov yz */
sol->qr[5] = (float)Q[2]; /* cov zx */
sol->ns = (unsigned char)ns;
for (j = 0; j < 3; j++) sol->qr[j] = static_cast<float>(Q[j + j * NX]);
sol->qr[3] = static_cast<float>(Q[1]); /* cov xy */
sol->qr[4] = static_cast<float>(Q[2 + NX]); /* cov yz */
sol->qr[5] = static_cast<float>(Q[2]); /* cov zx */
sol->ns = static_cast<unsigned char>(ns);
sol->age = sol->ratio = 0.0;
/* validate solution */
@ -652,7 +652,7 @@ int raim_fde(const obsd_t *obs, int n, const double *rs,
trace(3, "raim_fde: %s n=%2d\n", time_str(obs[0].time, 0), n);
if (!(obs_e = (obsd_t *)malloc(sizeof(obsd_t) * n))) return 0;
if (!(obs_e = static_cast<obsd_t *>(malloc(sizeof(obsd_t) * n)))) return 0;
rs_e = mat(6, n);
dts_e = mat(2, n);
vare_e = mat(1, n);

View File

@ -518,7 +518,7 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n)
return 0;
}
rtk->sol.ratio = (float)(MIN_PPP(s[1] / s[0], 999.9));
rtk->sol.ratio = static_cast<float>(MIN_PPP(s[1] / s[0], 999.9));
/* varidation by ratio-test */
if (rtk->opt.thresar[0] > 0.0 && rtk->sol.ratio < rtk->opt.thresar[0])
@ -1113,7 +1113,7 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav)
/* reset phase-bias if expire obs outage counter */
for (i = 0; i < MAXSAT; i++)
{
if (++rtk->ssat[i].outc[0] > (unsigned int)rtk->opt.maxout)
if (++rtk->ssat[i].outc[0] > static_cast<unsigned int>(rtk->opt.maxout))
{
initx(rtk, 0.0, 0.0, IB_PPP(i + 1, &rtk->opt));
}
@ -1492,11 +1492,11 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav)
for (i = 0; i < 3; i++)
{
rtk->sol.rr[i] = rtk->x[i];
rtk->sol.qr[i] = (float)rtk->P[i + i * rtk->nx];
rtk->sol.qr[i] = static_cast<float>(rtk->P[i + i * rtk->nx]);
}
rtk->sol.qr[3] = (float)rtk->P[1];
rtk->sol.qr[4] = (float)rtk->P[2 + rtk->nx];
rtk->sol.qr[5] = (float)rtk->P[2];
rtk->sol.qr[3] = static_cast<float>(rtk->P[1]);
rtk->sol.qr[4] = static_cast<float>(rtk->P[2 + rtk->nx]);
rtk->sol.qr[5] = static_cast<float>(rtk->P[2]);
rtk->sol.dtr[0] = rtk->x[IC_PPP(0, opt)];
rtk->sol.dtr[1] = rtk->x[IC_PPP(1, opt)] - rtk->x[IC_PPP(0, opt)];
for (i = 0; i < n && i < MAXOBS; i++)

View File

@ -98,12 +98,12 @@ int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats,
{
if (i == 2)
{
ns = (int)str2num(buff, 4, 2);
ns = static_cast<int>(str2num(buff, 4, 2));
}
for (j = 0; j < 17 && k < ns; j++)
{
sys = code2sys(buff[9 + 3 * j]);
prn = (int)str2num(buff, 10 + 3 * j, 2);
prn = static_cast<int>(str2num(buff, 10 + 3 * j, 2));
if (k < MAXSAT) sats[k++] = satno(sys, prn);
}
}
@ -130,7 +130,7 @@ int addpeph(nav_t *nav, peph_t *peph)
if (nav->ne >= nav->nemax)
{
nav->nemax += 256;
if (!(nav_peph = (peph_t *)realloc(nav->peph, sizeof(peph_t) * nav->nemax)))
if (!(nav_peph = static_cast<peph_t *>(realloc(nav->peph, sizeof(peph_t) * nav->nemax))))
{
trace(1, "readsp3b malloc error n=%d\n", nav->nemax);
free(nav->peph);
@ -190,7 +190,7 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do
if (strlen(buff) < 4 || (buff[0] != 'P' && buff[0] != 'V')) continue;
sys = buff[1] == ' ' ? SYS_GPS : code2sys(buff[1]);
prn = (int)str2num(buff, 2, 2);
prn = static_cast<int>(str2num(buff, 2, 2));
if (sys == SYS_SBS)
prn += 100;
else if (sys == SYS_QZS)
@ -223,7 +223,7 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do
}
if ((base = bfact[j < 3 ? 0 : 1]) > 0.0 && std > 0.0)
{
peph.std[sat - 1][j] = (float)(std::pow(base, std) * (j < 3 ? 1e-3 : 1e-12));
peph.std[sat - 1][j] = static_cast<float>(std::pow(base, std) * (j < 3 ? 1e-3 : 1e-12));
}
}
else if (v)
@ -234,7 +234,7 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do
}
if ((base = bfact[j < 3 ? 0 : 1]) > 0.0 && std > 0.0)
{
peph.vst[sat - 1][j] = (float)(std::pow(base, std) * (j < 3 ? 1e-7 : 1e-16));
peph.vst[sat - 1][j] = static_cast<float>(std::pow(base, std) * (j < 3 ? 1e-7 : 1e-16));
}
}
}
@ -315,7 +315,7 @@ void readsp3(const char *file, nav_t *nav, int opt)
for (i = 0; i < MAXEXFILE; i++)
{
if (!(efiles[i] = (char *)malloc(1024)))
if (!(efiles[i] = static_cast<char *>(malloc(1024))))
{
for (i--; i >= 0; i--) free(efiles[i]);
return;
@ -331,7 +331,7 @@ void readsp3(const char *file, nav_t *nav, int opt)
if (!strstr(ext + 1, "sp3") && !strstr(ext + 1, ".SP3") &&
!strstr(ext + 1, "eph") && !strstr(ext + 1, ".EPH")) continue;
if (!(fp = fopen(efiles[i], "r")))
if (!(fp = fopen(efiles[i], "re")))
{
trace(2, "sp3 file open error %s\n", efiles[i]);
continue;
@ -389,7 +389,7 @@ int readdcbf(const char *file, nav_t *nav, const sta_t *sta)
trace(3, "readdcbf: file=%s\n", file);
if (!(fp = fopen(file, "r")))
if (!(fp = fopen(file, "re")))
{
trace(2, "dcb parameters file open error: %s\n", file);
return 0;
@ -453,7 +453,7 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta)
}
for (i = 0; i < MAXEXFILE; i++)
{
if (!(efiles[i] = (char *)malloc(1024)))
if (!(efiles[i] = static_cast<char *>(malloc(1024))))
{
for (i--; i >= 0; i--) free(efiles[i]);
return 0;
@ -490,7 +490,7 @@ int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat,
if (nav->nf >= nav->nfmax)
{
nav->nfmax = nav->nfmax <= 0 ? 2048 : nav->nfmax * 2;
if (!(nav_fcb = (fcbd_t *)realloc(nav->fcb, sizeof(fcbd_t) * nav->nfmax)))
if (!(nav_fcb = static_cast<fcbd_t *>(realloc(nav->fcb, sizeof(fcbd_t) * nav->nfmax))))
{
free(nav->fcb);
nav->nf = nav->nfmax = 0;
@ -525,7 +525,7 @@ int readfcbf(const char *file, nav_t *nav)
trace(3, "readfcbf: file=%s\n", file);
if (!(fp = fopen(file, "r")))
if (!(fp = fopen(file, "re")))
{
trace(2, "fcb parameters file open error: %s\n", file);
return 0;
@ -578,7 +578,7 @@ int readfcb(const char *file, nav_t *nav)
for (i = 0; i < MAXEXFILE; i++)
{
if (!(efiles[i] = (char *)malloc(1024)))
if (!(efiles[i] = static_cast<char *>(malloc(1024))))
{
for (i--; i >= 0; i--) free(efiles[i]);
return 0;

View File

@ -113,9 +113,9 @@ int init_rtcm(rtcm_t *rtcm)
rtcm->nav.geph = nullptr;
/* reallocate memory for observation and ephemris buffer */
if (!(rtcm->obs.data = (obsd_t *)malloc(sizeof(obsd_t) * MAXOBS)) ||
!(rtcm->nav.eph = (eph_t *)malloc(sizeof(eph_t) * MAXSAT)) ||
!(rtcm->nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO)))
if (!(rtcm->obs.data = static_cast<obsd_t *>(malloc(sizeof(obsd_t) * MAXOBS))) ||
!(rtcm->nav.eph = static_cast<eph_t *>(malloc(sizeof(eph_t) * MAXSAT))) ||
!(rtcm->nav.geph = static_cast<geph_t *>(malloc(sizeof(geph_t) * MAXPRNGLO))))
{
free_rtcm(rtcm);
return 0;
@ -182,7 +182,7 @@ int input_rtcm2(rtcm_t *rtcm, unsigned char data)
/* synchronize frame */
if (rtcm->nbyte == 0)
{
preamb = (unsigned char)(rtcm->word >> 22);
preamb = static_cast<unsigned char>(rtcm->word >> 22);
if (rtcm->word & 0x40000000) preamb ^= 0xFF; /* decode preamble */
if (preamb != RTCM2PREAMB) continue;
@ -330,7 +330,7 @@ int input_rtcm2f(rtcm_t *rtcm, FILE *fp)
for (i = 0; i < 4096; i++)
{
if ((data = fgetc(fp)) == EOF) return -2;
if ((ret = input_rtcm2(rtcm, (unsigned char)data))) return ret;
if ((ret = input_rtcm2(rtcm, static_cast<unsigned char>(data)))) return ret;
}
return 0; /* return at every 4k bytes */
}
@ -352,7 +352,7 @@ int input_rtcm3f(rtcm_t *rtcm, FILE *fp)
for (i = 0; i < 4096; i++)
{
if ((data = fgetc(fp)) == EOF) return -2;
if ((ret = input_rtcm3(rtcm, (unsigned char)data))) return ret;
if ((ret = input_rtcm3(rtcm, static_cast<unsigned char>(data)))) return ret;
}
return 0; /* return at every 4k bytes */
}

View File

@ -173,7 +173,7 @@ double adjcp(rtcm_t *rtcm, int sat, int freq, double cp)
int lossoflock(rtcm_t *rtcm, int sat, int freq, int lock)
{
int lli = (!lock && !rtcm->lock[sat - 1][freq]) || lock < rtcm->lock[sat - 1][freq];
rtcm->lock[sat - 1][freq] = (unsigned short)lock;
rtcm->lock[sat - 1][freq] = static_cast<uint16_t>(lock);
return lli;
}
@ -181,7 +181,7 @@ int lossoflock(rtcm_t *rtcm, int sat, int freq, int lock)
/* s/n ratio -----------------------------------------------------------------*/
unsigned char snratio(double snr)
{
return (unsigned char)(snr <= 0.0 || 255.5 <= snr ? 0.0 : snr * 4.0 + 0.5);
return static_cast<unsigned char>(snr <= 0.0 || 255.5 <= snr ? 0.0 : snr * 4.0 + 0.5);
}
@ -337,7 +337,7 @@ int decode_type1002(rtcm_t *rtcm)
}
if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue;
pr1 = pr1 * 0.02 + amb * PRUNIT_GPS;
if (ppr1 != (int)0xFFF80000)
if (ppr1 != static_cast<int>(0xFFF80000))
{
rtcm->obs.data[index].P[0] = pr1;
cp1 = adjcp(rtcm, sat, 0, ppr1 * 0.0005 / lam_carr[0]);
@ -418,7 +418,7 @@ int decode_type1004(rtcm_t *rtcm)
}
if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue;
pr1 = pr1 * 0.02 + amb * PRUNIT_GPS;
if (ppr1 != (int)0xFFF80000)
if (ppr1 != static_cast<int>(0xFFF80000))
{
rtcm->obs.data[index].P[0] = pr1;
cp1 = adjcp(rtcm, sat, 0, ppr1 * 0.0005 / lam_carr[0]);
@ -428,11 +428,11 @@ int decode_type1004(rtcm_t *rtcm)
rtcm->obs.data[index].SNR[0] = snratio(cnr1 * 0.25);
rtcm->obs.data[index].code[0] = code1 ? CODE_L1P : CODE_L1C;
if (pr21 != (int)0xFFFFE000)
if (pr21 != static_cast<int>(0xFFFFE000))
{
rtcm->obs.data[index].P[1] = pr1 + pr21 * 0.02;
}
if (ppr2 != (int)0xFFF80000)
if (ppr2 != static_cast<int>(0xFFF80000))
{
cp2 = adjcp(rtcm, sat, 1, ppr2 * 0.0005 / lam_carr[1]);
rtcm->obs.data[index].L[1] = pr1 / lam_carr[1] + cp2;
@ -449,7 +449,7 @@ int decode_type1004(rtcm_t *rtcm)
/* get signed 38bit field ----------------------------------------------------*/
double getbits_38(const unsigned char *buff, int pos)
{
return (double)getbits(buff, pos, 32) * 64.0 + getbitu(buff, pos + 32, 6);
return static_cast<double>(getbits(buff, pos, 32)) * 64.0 + getbitu(buff, pos + 32, 6);
}
@ -564,7 +564,7 @@ int decode_type1007(rtcm_t *rtcm)
i += 12 + 8;
for (j = 0; j < n && j < 31; j++)
{
des[j] = (char)getbitu(rtcm->buff, i, 8);
des[j] = static_cast<char>(getbitu(rtcm->buff, i, 8));
i += 8;
}
setup = getbitu(rtcm->buff, i, 8);
@ -606,14 +606,14 @@ int decode_type1008(rtcm_t *rtcm)
i += 12 + 8;
for (j = 0; j < n && j < 31; j++)
{
des[j] = (char)getbitu(rtcm->buff, i, 8);
des[j] = static_cast<char>(getbitu(rtcm->buff, i, 8));
i += 8;
}
setup = getbitu(rtcm->buff, i, 8);
i += 8 + 8;
for (j = 0; j < m && j < 31; j++)
{
sno[j] = (char)getbitu(rtcm->buff, i, 8);
sno[j] = static_cast<char>(getbitu(rtcm->buff, i, 8));
i += 8;
}
}
@ -730,7 +730,7 @@ int decode_type1010(rtcm_t *rtcm)
}
if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue;
pr1 = pr1 * 0.02 + amb * PRUNIT_GLO;
if (ppr1 != (int)0xFFF80000)
if (ppr1 != static_cast<int>(0xFFF80000))
{
rtcm->obs.data[index].P[0] = pr1;
lam1 = SPEED_OF_LIGHT / (FREQ1_GLO + DFRQ1_GLO * (freq - 7));
@ -804,7 +804,7 @@ int decode_type1012(rtcm_t *rtcm)
}
if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue;
pr1 = pr1 * 0.02 + amb * PRUNIT_GLO;
if (ppr1 != (int)0xFFF80000)
if (ppr1 != static_cast<int>(0xFFF80000))
{
lam1 = SPEED_OF_LIGHT / (FREQ1_GLO + DFRQ1_GLO * (freq - 7));
rtcm->obs.data[index].P[0] = pr1;
@ -815,11 +815,11 @@ int decode_type1012(rtcm_t *rtcm)
rtcm->obs.data[index].SNR[0] = snratio(cnr1 * 0.25);
rtcm->obs.data[index].code[0] = code1 ? CODE_L1P : CODE_L1C;
if (pr21 != (int)0xFFFFE000)
if (pr21 != static_cast<int>(0xFFFFE000))
{
rtcm->obs.data[index].P[1] = pr1 + pr21 * 0.02;
}
if (ppr2 != (int)0xFFF80000)
if (ppr2 != static_cast<int>(0xFFF80000))
{
lam2 = SPEED_OF_LIGHT / (FREQ2_GLO + DFRQ2_GLO * (freq - 7));
cp2 = adjcp(rtcm, sat, 1, ppr2 * 0.0005 / lam2);
@ -1189,32 +1189,32 @@ int decode_type1033(rtcm_t *rtcm)
i += 12 + 8;
for (j = 0; j < n && j < 31; j++)
{
des[j] = (char)getbitu(rtcm->buff, i, 8);
des[j] = static_cast<char>(getbitu(rtcm->buff, i, 8));
i += 8;
}
setup = getbitu(rtcm->buff, i, 8);
i += 8 + 8;
for (j = 0; j < m && j < 31; j++)
{
sno[j] = (char)getbitu(rtcm->buff, i, 8);
sno[j] = static_cast<char>(getbitu(rtcm->buff, i, 8));
i += 8;
}
i += 8;
for (j = 0; j < n1 && j < 31; j++)
{
rec[j] = (char)getbitu(rtcm->buff, i, 8);
rec[j] = static_cast<char>(getbitu(rtcm->buff, i, 8));
i += 8;
}
i += 8;
for (j = 0; j < n2 && j < 31; j++)
{
ver[j] = (char)getbitu(rtcm->buff, i, 8);
ver[j] = static_cast<char>(getbitu(rtcm->buff, i, 8));
i += 8;
}
i += 8;
for (j = 0; j < n3 && j < 31; j++)
{
rsn[j] = (char)getbitu(rtcm->buff, i, 8);
rsn[j] = static_cast<char>(getbitu(rtcm->buff, i, 8));
i += 8;
}
}
@ -2222,7 +2222,7 @@ int decode_ssr3(rtcm_t *rtcm, int sys)
i += 14;
if (mode <= ncode)
{
cbias[codes[mode] - 1] = (float)bias;
cbias[codes[mode] - 1] = static_cast<float>(bias);
}
else
{
@ -2240,7 +2240,7 @@ int decode_ssr3(rtcm_t *rtcm, int sys)
for (k = 0; k < MAXCODE; k++)
{
rtcm->ssr[sat - 1].cbias[k] = (float)cbias[k];
rtcm->ssr[sat - 1].cbias[k] = static_cast<float>(cbias[k]);
}
rtcm->ssr[sat - 1].update = 1;
}
@ -2579,7 +2579,7 @@ int decode_ssr7(rtcm_t *rtcm, int sys)
for (k = 0; k < MAXCODE; k++)
{
rtcm->ssr[sat - 1].pbias[k] = pbias[k];
rtcm->ssr[sat - 1].stdpb[k] = (float)stdpb[k];
rtcm->ssr[sat - 1].stdpb[k] = static_cast<float>(stdpb[k]);
}
}
return 20;
@ -2773,11 +2773,11 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r,
/* doppler (hz) */
if (rr && rrf && rrf[j] > -1E12 && wl > 0.0)
{
rtcm->obs.data[index].D[ind[k]] = (float)(-(rr[i] + rrf[j]) / wl);
rtcm->obs.data[index].D[ind[k]] = static_cast<float>(-(rr[i] + rrf[j]) / wl);
}
rtcm->obs.data[index].LLI[ind[k]] =
lossoflock(rtcm, sat, ind[k], lock[j]) + (half[j] ? 3 : 0);
rtcm->obs.data[index].SNR[ind[k]] = (unsigned char)(cnr[j] * 4.0);
rtcm->obs.data[index].SNR[ind[k]] = static_cast<unsigned char>(cnr[j] * 4.0);
rtcm->obs.data[index].code[ind[k]] = code[k];
}
j++;

View File

@ -153,7 +153,7 @@ char codepris[7][MAXFREQ][16] = {
fatalfunc_t *fatalfunc = nullptr; /* fatal callback function */
/* crc tables generated by util/gencrc ---------------------------------------*/
const unsigned short tbl_CRC16[] = {
const uint16_t tbl_CRC16[] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
@ -519,7 +519,7 @@ int testsnr(int base, int freq, double el, double snr,
if (!mask->ena[base] || freq < 0 || freq >= NFREQ) return 0;
a = (el * R2D + 5.0) / 10.0;
i = (int)floor(a);
i = static_cast<int>(floor(a));
a -= i;
if (i < 1)
minsnr = mask->mask[freq][0];
@ -546,9 +546,9 @@ unsigned char obs2code(const char *obs, int *freq)
if (freq) *freq = 0;
for (i = 1; *obscodes[i]; i++)
{
if (strcmp(obscodes[i], obs)) continue;
if (strcmp(obscodes[i], obs) != 0) continue;
if (freq) *freq = obsfreqs[i];
return (unsigned char)i;
return static_cast<unsigned char>(i);
}
return CODE_NONE;
}
@ -657,7 +657,7 @@ int getcodepri(int sys, unsigned char code, const char *opt)
return str[1] == obs[1] ? 15 : 0;
}
/* search code priority */
return (p = strchr(codepris[i][j - 1], obs[1])) ? 14 - (int)(p - codepris[i][j - 1]) : 0;
return (p = strchr(codepris[i][j - 1], obs[1])) ? 14 - static_cast<int>(p - codepris[i][j - 1]) : 0;
}
@ -680,8 +680,8 @@ unsigned int getbitu(const unsigned char *buff, int pos, int len)
int getbits(const unsigned char *buff, int pos, int len)
{
unsigned int bits = getbitu(buff, pos, len);
if (len <= 0 || 32 <= len || !(bits & (1u << (len - 1)))) return (int)bits;
return (int)(bits | (~0u << len)); /* extend sign */
if (len <= 0 || 32 <= len || !(bits & (1u << (len - 1)))) return static_cast<int>(bits);
return static_cast<int>(bits | (~0u << len)); /* extend sign */
}
@ -714,7 +714,7 @@ void setbits(unsigned char *buff, int pos, int len, int data)
data |= 1 << (len - 1);
else
data &= ~(1 << (len - 1)); /* set sign bit */
setbitu(buff, pos, len, (unsigned int)data);
setbitu(buff, pos, len, static_cast<unsigned int>(data));
}
@ -773,9 +773,9 @@ unsigned int rtk_crc24q(const unsigned char *buff, int len)
* return : crc-16 parity
* notes : see reference [10] A.3.
*-----------------------------------------------------------------------------*/
unsigned short rtk_crc16(const unsigned char *buff, int len)
uint16_t rtk_crc16(const unsigned char *buff, int len)
{
unsigned short crc = 0;
uint16_t crc = 0;
int i;
trace(4, "rtk_crc16: len=%d\n", len);
@ -815,7 +815,7 @@ int decode_word(unsigned int word, unsigned char *data)
}
if (parity != (word & 0x3F)) return 0;
for (i = 0; i < 3; i++) data[i] = (unsigned char)(word >> (22 - i * 8));
for (i = 0; i < 3; i++) data[i] = static_cast<unsigned char>(word >> (22 - i * 8));
return 1;
}
@ -830,7 +830,7 @@ double *mat(int n, int m)
double *p;
if (n <= 0 || m <= 0) return nullptr;
if (!(p = (double *)malloc(sizeof(double) * n * m)))
if (!(p = static_cast<double *>(malloc(sizeof(double) * n * m))))
{
fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m);
}
@ -848,7 +848,7 @@ int *imat(int n, int m)
int *p;
if (n <= 0 || m <= 0) return nullptr;
if (!(p = (int *)malloc(sizeof(int) * n * m)))
if (!(p = static_cast<int *>(malloc(sizeof(int) * n * m))))
{
fatalerr("integer matrix memory allocation error: n=%d,m=%d\n", n, m);
}
@ -870,7 +870,7 @@ double *zeros(int n, int m)
for (n = n * m - 1; n >= 0; n--) p[n] = 0.0;
#else
if (n <= 0 || m <= 0) return nullptr;
if (!(p = (double *)calloc(sizeof(double), n * m)))
if (!(p = static_cast<double *>(calloc(sizeof(double), n * m))))
{
fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m);
}
@ -983,7 +983,7 @@ void matmul(const char *tr, int n, int k, int m, double alpha,
{
int lda = tr[0] == 'T' ? m : n, ldb = tr[1] == 'T' ? k : m;
dgemm_((char *)tr, (char *)tr + 1, &n, &k, &m, &alpha, (double *)A, &lda, (double *)B,
dgemm_(const_cast<char *>(tr), const_cast<char *>(tr) + 1, &n, &k, &m, &alpha, const_cast<double *>(A), &lda, const_cast<double *>(B),
&ldb, &beta, C, &n);
}
@ -1028,7 +1028,7 @@ int solve(const char *tr, const double *A, const double *Y, int n,
matcpy(B, A, n, n);
matcpy(X, Y, n, m);
dgetrf_(&n, &n, B, &n, ipiv, &info);
if (!info) dgetrs_((char *)tr, &n, &m, B, &n, ipiv, X, &n, &info);
if (!info) dgetrs_(const_cast<char *>(tr), &n, &m, B, &n, ipiv, X, &n, &info);
free(ipiv);
free(B);
return info;
@ -1239,7 +1239,7 @@ double str2num(const char *s, int i, int n)
double value;
char str[256], *p = str;
if (i < 0 || (int)strlen(s) < i || (int)sizeof(str) - 1 < n) return 0.0;
if (i < 0 || static_cast<int>(strlen(s)) < i || static_cast<int>(sizeof(str)) - 1 < n) return 0.0;
for (s += i; *s && --n >= 0; s++)
{
*p++ = *s == 'd' || *s == 'D' ? 'E' : *s;
@ -1261,7 +1261,7 @@ int str2time(const char *s, int i, int n, gtime_t *t)
double ep[6];
char str[256], *p = str;
if (i < 0 || (int)strlen(s) < i || (int)sizeof(str) - 1 < i) return -1;
if (i < 0 || static_cast<int>(strlen(s)) < i || static_cast<int>(sizeof(str)) - 1 < i) return -1;
for (s += i; *s && --n >= 0;)
{
*p++ = *s++;
@ -1285,14 +1285,14 @@ gtime_t epoch2time(const double *ep)
{
const int doy[] = {1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
gtime_t time = {0, 0};
int days, sec, year = (int)ep[0], mon = (int)ep[1], day = (int)ep[2];
int days, sec, year = static_cast<int>(ep[0]), mon = static_cast<int>(ep[1]), day = static_cast<int>(ep[2]);
if (year < 1970 || 2099 < year || mon < 1 || 12 < mon) return time;
/* leap year if year%4==0 in 1901-2099 */
days = (year - 1970) * 365 + (year - 1969) / 4 + doy[mon - 1] + day - 2 + (year % 4 == 0 && mon >= 3 ? 1 : 0);
sec = (int)floor(ep[5]);
time.time = (time_t)days * 86400 + (int)ep[3] * 3600 + (int)ep[4] * 60 + sec;
sec = static_cast<int>(floor(ep[5]));
time.time = static_cast<time_t>(days) * 86400 + static_cast<int>(ep[3]) * 3600 + static_cast<int>(ep[4]) * 60 + sec;
time.sec = ep[5] - sec;
return time;
}
@ -1313,8 +1313,8 @@ void time2epoch(gtime_t t, double *ep)
int days, sec, mon, day;
/* leap year if year%4==0 in 1901-2099 */
days = (int)(t.time / 86400);
sec = (int)(t.time - (time_t)days * 86400);
days = static_cast<int>(t.time / 86400);
sec = static_cast<int>(t.time - static_cast<time_t>(days) * 86400);
for (day = days % 1461, mon = 0; mon < 48; mon++)
{
if (day >= mday[mon])
@ -1342,8 +1342,8 @@ gtime_t gpst2time(int week, double sec)
gtime_t t = epoch2time(gpst0);
if (sec < -1e9 || 1e9 < sec) sec = 0.0;
t.time += (time_t)86400 * 7 * week + (int)sec;
t.sec = sec - (int)sec;
t.time += static_cast<time_t>(86400) * 7 * week + static_cast<int>(sec);
t.sec = sec - static_cast<int>(sec);
return t;
}
@ -1376,8 +1376,8 @@ gtime_t gst2time(int week, double sec)
gtime_t t = epoch2time(gst0);
if (sec < -1e9 || 1e9 < sec) sec = 0.0;
t.time += (time_t)86400 * 7 * week + (int)sec;
t.sec = sec - (int)sec;
t.time += static_cast<time_t>(86400) * 7 * week + static_cast<int>(sec);
t.sec = sec - static_cast<int>(sec);
return t;
}
@ -1392,10 +1392,10 @@ double time2gst(gtime_t t, int *week)
{
gtime_t t0 = epoch2time(gst0);
time_t sec = t.time - t0.time;
int w = (int)(sec / (86400 * 7));
int w = static_cast<int>(sec / (86400 * 7));
if (week) *week = w;
return (double)(sec - (double)w * 86400 * 7) + t.sec;
return (sec - static_cast<double>(w) * 86400 * 7) + t.sec;
}
@ -1410,8 +1410,8 @@ gtime_t bdt2time(int week, double sec)
gtime_t t = epoch2time(bdt0);
if (sec < -1e9 || 1e9 < sec) sec = 0.0;
t.time += (time_t)86400 * 7 * week + (int)sec;
t.sec = sec - (int)sec;
t.time += static_cast<time_t>(86400) * 7 * week + static_cast<int>(sec);
t.sec = sec - static_cast<int>(sec);
return t;
}
@ -1426,10 +1426,10 @@ double time2bdt(gtime_t t, int *week)
{
gtime_t t0 = epoch2time(bdt0);
time_t sec = t.time - t0.time;
int w = (int)(sec / (86400 * 7));
int w = static_cast<int>(sec / (86400 * 7));
if (week) *week = w;
return (double)(sec - (double)w * 86400 * 7) + t.sec;
return (sec - static_cast<double>(w) * 86400 * 7) + t.sec;
}
@ -1445,7 +1445,7 @@ gtime_t timeadd(gtime_t t, double sec)
t.sec += sec;
tt = floor(t.sec);
t.time += (int)tt;
t.time += static_cast<int>(tt);
t.sec -= tt;
return t;
}
@ -1471,7 +1471,7 @@ gtime_t timeget(void)
{
gtime_t time;
double ep[6] = {};
struct timeval tv;
struct timeval tv{};
struct tm *tt;
if (!gettimeofday(&tv, nullptr) && (tt = gmtime(&tv.tv_sec)))
@ -1547,7 +1547,7 @@ int read_leaps_usno(FILE *fp)
ls[n][0] = y;
ls[n][1] = m;
ls[n][2] = d;
ls[n++][6] = (char)(19.0 - tai_utc);
ls[n++][6] = static_cast<char>(19.0 - tai_utc);
}
for (i = 0; i < n; i++)
for (j = 0; j < 7; j++)
@ -1574,7 +1574,7 @@ int read_leaps(const char *file)
FILE *fp;
int i, n;
if (!(fp = fopen(file, "r"))) return 0;
if (!(fp = fopen(file, "re"))) return 0;
/* read leap seconds table by text or usno */
if (!(n = read_leaps_text(fp)) && !(n = read_leaps_usno(fp)))
@ -1794,8 +1794,8 @@ void sleepms(int ms)
{
struct timespec ts = {0, 0};
if (ms <= 0) return;
ts.tv_sec = (time_t)(ms / 1000);
ts.tv_nsec = (long)(ms % 1000 * 1000000);
ts.tv_sec = static_cast<time_t>(ms / 1000);
ts.tv_nsec = static_cast<int64_t>(ms % 1000 * 1000000);
nanosleep(&ts, nullptr);
}
@ -2242,7 +2242,7 @@ void addpcv(const pcv_t *pcv, pcvs_t *pcvs)
if (pcvs->nmax <= pcvs->n)
{
pcvs->nmax += 256;
if (!(pcvs_pcv = (pcv_t *)realloc(pcvs->pcv, sizeof(pcv_t) * pcvs->nmax)))
if (!(pcvs_pcv = static_cast<pcv_t *>(realloc(pcvs->pcv, sizeof(pcv_t) * pcvs->nmax))))
{
trace(1, "addpcv: memory allocation error\n");
free(pcvs->pcv);
@ -2266,7 +2266,7 @@ int readngspcv(const char *file, pcvs_t *pcvs)
int n = 0;
char buff[256];
if (!(fp = fopen(file, "r")))
if (!(fp = fopen(file, "re")))
{
trace(2, "ngs pcv file open error: %s\n", file);
return 0;
@ -2327,7 +2327,7 @@ int readantex(const char *file, pcvs_t *pcvs)
trace(3, "readantex: file=%s\n", file);
if (!(fp = fopen(file, "r")))
if (!(fp = fopen(file, "re")))
{
trace(2, "antex pcv file open error: %s\n", file);
return 0;
@ -2521,7 +2521,7 @@ void readpos(const char *file, const char *rcv, double *pos)
trace(3, "readpos: file=%s\n", file);
if (!(fp = fopen(file, "r")))
if (!(fp = fopen(file, "re")))
{
fprintf(stderr, "reference position file open error : %s\n", file);
return;
@ -2536,10 +2536,10 @@ void readpos(const char *file, const char *rcv, double *pos)
stas[np++][15] = '\0';
}
fclose(fp);
len = (int)strlen(rcv);
len = static_cast<int>(strlen(rcv));
for (i = 0; i < np; i++)
{
if (strncmp(stas[i], rcv, len)) continue;
if (strncmp(stas[i], rcv, len) != 0) continue;
for (j = 0; j < 3; j++) pos[j] = poss[i][j];
pos[0] *= D2R;
pos[1] *= D2R;
@ -2582,10 +2582,10 @@ int readblq(const char *file, const char *sta, double *odisp)
/* station name to upper case */
sscanf(sta, "%16s", staname);
for (p = staname; (*p = (char)toupper((int)(*p))); p++)
for (p = staname; (*p = static_cast<char>(toupper(static_cast<int>(*p)))); p++)
;
if (!(fp = fopen(file, "r")))
if (!(fp = fopen(file, "re")))
{
trace(2, "blq file open error: file=%s\n", file);
return 0;
@ -2595,9 +2595,9 @@ int readblq(const char *file, const char *sta, double *odisp)
if (!strncmp(buff, "$$", 2) || strlen(buff) < 2) continue;
if (sscanf(buff + 2, "%16s", name) < 1) continue;
for (p = name; (*p = (char)toupper((int)(*p))); p++)
for (p = name; (*p = static_cast<char>(toupper(static_cast<int>(*p)))); p++)
;
if (strcmp(name, staname)) continue;
if (strcmp(name, staname) != 0) continue;
/* read blq record */
if (readblqrecord(fp, odisp))
@ -2627,7 +2627,7 @@ int readerp(const char *file, erp_t *erp)
trace(3, "readerp: file=%s\n", file);
if (!(fp = fopen(file, "r")))
if (!(fp = fopen(file, "re")))
{
trace(2, "erp file open error: file=%s\n", file);
return 0;
@ -2642,7 +2642,7 @@ int readerp(const char *file, erp_t *erp)
if (erp->n >= erp->nmax)
{
erp->nmax = erp->nmax <= 0 ? 128 : erp->nmax * 2;
erp_data = (erpd_t *)realloc(erp->data, sizeof(erpd_t) * erp->nmax);
erp_data = static_cast<erpd_t *>(realloc(erp->data, sizeof(erpd_t) * erp->nmax));
if (!erp_data)
{
free(erp->data);
@ -2730,7 +2730,7 @@ int geterp(const erp_t *erp, gtime_t time, double *erpv)
int cmpeph(const void *p1, const void *p2)
{
auto *q1 = (eph_t *)p1, *q2 = (eph_t *)p2;
return q1->ttr.time != q2->ttr.time ? (int)(q1->ttr.time - q2->ttr.time) : (q1->toe.time != q2->toe.time ? (int)(q1->toe.time - q2->toe.time) : q1->sat - q2->sat);
return q1->ttr.time != q2->ttr.time ? static_cast<int>(q1->ttr.time - q2->ttr.time) : (q1->toe.time != q2->toe.time ? static_cast<int>(q1->toe.time - q2->toe.time) : q1->sat - q2->sat);
}
@ -2756,7 +2756,7 @@ void uniqeph(nav_t *nav)
}
nav->n = j + 1;
if (!(nav_eph = (eph_t *)realloc(nav->eph, sizeof(eph_t) * nav->n)))
if (!(nav_eph = static_cast<eph_t *>(realloc(nav->eph, sizeof(eph_t) * nav->n))))
{
trace(1, "uniqeph malloc error n=%d\n", nav->n);
free(nav->eph);
@ -2775,7 +2775,7 @@ void uniqeph(nav_t *nav)
int cmpgeph(const void *p1, const void *p2)
{
auto *q1 = (geph_t *)p1, *q2 = (geph_t *)p2;
return q1->tof.time != q2->tof.time ? (int)(q1->tof.time - q2->tof.time) : (q1->toe.time != q2->toe.time ? (int)(q1->toe.time - q2->toe.time) : q1->sat - q2->sat);
return q1->tof.time != q2->tof.time ? static_cast<int>(q1->tof.time - q2->tof.time) : (q1->toe.time != q2->toe.time ? static_cast<int>(q1->toe.time - q2->toe.time) : q1->sat - q2->sat);
}
@ -2802,7 +2802,7 @@ void uniqgeph(nav_t *nav)
}
nav->ng = j + 1;
if (!(nav_geph = (geph_t *)realloc(nav->geph, sizeof(geph_t) * nav->ng)))
if (!(nav_geph = static_cast<geph_t *>(realloc(nav->geph, sizeof(geph_t) * nav->ng))))
{
trace(1, "uniqgeph malloc error ng=%d\n", nav->ng);
free(nav->geph);
@ -2821,7 +2821,7 @@ void uniqgeph(nav_t *nav)
int cmpseph(const void *p1, const void *p2)
{
auto *q1 = (seph_t *)p1, *q2 = (seph_t *)p2;
return q1->tof.time != q2->tof.time ? (int)(q1->tof.time - q2->tof.time) : (q1->t0.time != q2->t0.time ? (int)(q1->t0.time - q2->t0.time) : q1->sat - q2->sat);
return q1->tof.time != q2->tof.time ? static_cast<int>(q1->tof.time - q2->tof.time) : (q1->t0.time != q2->t0.time ? static_cast<int>(q1->t0.time - q2->t0.time) : q1->sat - q2->sat);
}
@ -2847,7 +2847,7 @@ void uniqseph(nav_t *nav)
}
nav->ns = j + 1;
if (!(nav_seph = (seph_t *)realloc(nav->seph, sizeof(seph_t) * nav->ns)))
if (!(nav_seph = static_cast<seph_t *>(realloc(nav->seph, sizeof(seph_t) * nav->ns))))
{
trace(1, "uniqseph malloc error ns=%d\n", nav->ns);
free(nav->seph);
@ -2893,8 +2893,8 @@ int cmpobs(const void *p1, const void *p2)
auto *q1 = (obsd_t *)p1, *q2 = (obsd_t *)p2;
double tt = timediff(q1->time, q2->time);
if (fabs(tt) > DTTOL) return tt < 0 ? -1 : 1;
if (q1->rcv != q2->rcv) return (int)q1->rcv - (int)q2->rcv;
return (int)q1->sat - (int)q2->sat;
if (q1->rcv != q2->rcv) return static_cast<int>(q1->rcv) - static_cast<int>(q2->rcv);
return static_cast<int>(q1->sat) - static_cast<int>(q2->sat);
}
@ -2965,12 +2965,12 @@ int readnav(const char *file, nav_t *nav)
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0};
geph_t geph0 = {0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {}, {}, {}, 0.0, 0.0, 0.0};
char buff[4096], *p;
long toe_time, tof_time, toc_time, ttr_time;
int32_t toe_time, tof_time, toc_time, ttr_time;
int i, sat, prn;
trace(3, "loadnav: file=%s\n", file);
if (!(fp = fopen(file, "r"))) return 0;
if (!(fp = fopen(file, "re"))) return 0;
while (fgets(buff, sizeof(buff), fp))
{
@ -2997,7 +2997,7 @@ int readnav(const char *file, nav_t *nav)
nav->geph[prn - 1].sat = sat;
toe_time = tof_time = 0;
sscanf(p + 1,
"%d,%d,%d,%d,%d,%ld,%ld,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,"
"%d,%d,%d,%d,%d,%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,"
"%lf,%lf,%lf,%lf",
&nav->geph[prn - 1].iode, &nav->geph[prn - 1].frq, &nav->geph[prn - 1].svh,
&nav->geph[prn - 1].sva, &nav->geph[prn - 1].age,
@ -3015,7 +3015,7 @@ int readnav(const char *file, nav_t *nav)
nav->eph[sat - 1].sat = sat;
toe_time = toc_time = ttr_time = 0;
sscanf(p + 1,
"%d,%d,%d,%d,%ld,%ld,%ld,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,"
"%d,%d,%d,%d,%d,%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,"
"%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d,%d",
&nav->eph[sat - 1].iode, &nav->eph[sat - 1].iodc, &nav->eph[sat - 1].sva,
&nav->eph[sat - 1].svh,
@ -3046,7 +3046,7 @@ int savenav(const char *file, const nav_t *nav)
trace(3, "savenav: file=%s\n", file);
if (!(fp = fopen(file, "w"))) return 0;
if (!(fp = fopen(file, "we"))) return 0;
for (i = 0; i < MAXSAT; i++)
{
@ -3057,8 +3057,8 @@ int savenav(const char *file, const nav_t *nav)
"%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
"%.14E,%.14E,%.14E,%.14E,%.14E,%d,%d\n",
id, nav->eph[i].iode, nav->eph[i].iodc, nav->eph[i].sva,
nav->eph[i].svh, (int)nav->eph[i].toe.time,
(int)nav->eph[i].toc.time, (int)nav->eph[i].ttr.time,
nav->eph[i].svh, static_cast<int>(nav->eph[i].toe.time),
static_cast<int>(nav->eph[i].toc.time), static_cast<int>(nav->eph[i].ttr.time),
nav->eph[i].A, nav->eph[i].e, nav->eph[i].i0, nav->eph[i].OMG0,
nav->eph[i].omg, nav->eph[i].M0, nav->eph[i].deln, nav->eph[i].OMGd,
nav->eph[i].idot, nav->eph[i].crc, nav->eph[i].crs, nav->eph[i].cuc,
@ -3074,8 +3074,8 @@ int savenav(const char *file, const nav_t *nav)
"%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,"
"%.14E,%.14E,%.14E,%.14E,%.14E,%.14E\n",
id, nav->geph[i].iode, nav->geph[i].frq, nav->geph[i].svh,
nav->geph[i].sva, nav->geph[i].age, (int)nav->geph[i].toe.time,
(int)nav->geph[i].tof.time,
nav->geph[i].sva, nav->geph[i].age, static_cast<int>(nav->geph[i].toe.time),
static_cast<int>(nav->geph[i].tof.time),
nav->geph[i].pos[0], nav->geph[i].pos[1], nav->geph[i].pos[2],
nav->geph[i].vel[0], nav->geph[i].vel[1], nav->geph[i].vel[2],
nav->geph[i].acc[0], nav->geph[i].acc[1], nav->geph[i].acc[2],
@ -3187,8 +3187,8 @@ void traceswap(void)
rtk_lock(&lock_trace);
if ((int)(time2gpst(time, nullptr) / INT_SWAP_TRAC) ==
(int)(time2gpst(time_trace, nullptr) / INT_SWAP_TRAC))
if (static_cast<int>(time2gpst(time, nullptr) / INT_SWAP_TRAC) ==
static_cast<int>(time2gpst(time_trace, nullptr) / INT_SWAP_TRAC))
{
rtk_unlock(&lock_trace);
return;
@ -3202,7 +3202,7 @@ void traceswap(void)
}
if (fp_trace) fclose(fp_trace);
if (!(fp_trace = fopen(path, "w")))
if (!(fp_trace = fopen(path, "we")))
{
fp_trace = stderr;
}
@ -3216,7 +3216,7 @@ void traceopen(const char *file)
char path[1024];
reppath(file, path, time, "", "");
if (!*path || !(fp_trace = fopen(path, "w"))) fp_trace = stderr;
if (!*path || !(fp_trace = fopen(path, "we"))) fp_trace = stderr;
if (strlen(file) < 1025)
strcpy(file_trace, file);
else
@ -3447,7 +3447,7 @@ void createdir(const char *path)
/* replace string ------------------------------------------------------------*/
int repstr(char *str, const char *pat, const char *rep)
{
int len = (int)strlen(pat);
int len = static_cast<int>(strlen(pat));
char buff[1024], *p, *q, *r;
for (p = str, r = buff; *p; p = q + len)
@ -3512,13 +3512,13 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov,
{
time2epoch(time, ep);
ep0[0] = ep[0];
dow = (int)floor(time2gpst(time, &week) / 86400.0);
doy = (int)floor(timediff(time, epoch2time(ep0)) / 86400.0) + 1;
sprintf(rep, "%02d", ((int)ep[3] / 3) * 3);
dow = static_cast<int>(floor(time2gpst(time, &week) / 86400.0));
doy = static_cast<int>(floor(timediff(time, epoch2time(ep0)) / 86400.0)) + 1;
sprintf(rep, "%02d", (static_cast<int>(ep[3]) / 3) * 3);
stat |= repstr(rpath, "%ha", rep);
sprintf(rep, "%02d", ((int)ep[3] / 6) * 6);
sprintf(rep, "%02d", (static_cast<int>(ep[3]) / 6) * 6);
stat |= repstr(rpath, "%hb", rep);
sprintf(rep, "%02d", ((int)ep[3] / 12) * 12);
sprintf(rep, "%02d", (static_cast<int>(ep[3]) / 12) * 12);
stat |= repstr(rpath, "%hc", rep);
sprintf(rep, "%04.0f", ep[0]);
stat |= repstr(rpath, "%Y", rep);
@ -3540,9 +3540,9 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov,
stat |= repstr(rpath, "%W", rep);
sprintf(rep, "%d", dow);
stat |= repstr(rpath, "%D", rep);
sprintf(rep, "%c", 'a' + (int)ep[3]);
sprintf(rep, "%c", 'a' + static_cast<int>(ep[3]));
stat |= repstr(rpath, "%H", rep);
sprintf(rep, "%02d", ((int)ep[4] / 15) * 15);
sprintf(rep, "%02d", (static_cast<int>(ep[4]) / 15) * 15);
stat |= repstr(rpath, "%t", rep);
}
else if (strstr(rpath, "%ha") || strstr(rpath, "%hb") || strstr(rpath, "%hc") ||
@ -3593,7 +3593,7 @@ int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts,
while (timediff(time, te) <= 0.0 && n < nmax)
{
reppath(path, rpath[n], time, rov, base);
if (n == 0 || strcmp(rpath[n], rpath[n - 1])) n++;
if (n == 0 || strcmp(rpath[n], rpath[n - 1]) != 0) n++;
time = timeadd(time, tint);
}
for (i = 0; i < n; i++) trace(3, "reppaths: rpath=%s\n", rpath[i]);
@ -3646,9 +3646,9 @@ double satwavelen(int sat, int frq, const nav_t *nav)
return SPEED_OF_LIGHT / FREQ2; /* L2 */
if (frq == 2)
return SPEED_OF_LIGHT / FREQ5; /* L5/E5a */
else if (frq == 3)
if (frq == 3)
return SPEED_OF_LIGHT / FREQ6; /* L6/LEX */
else if (frq == 4)
if (frq == 4)
return SPEED_OF_LIGHT / FREQ7; /* E5b */
else if (frq == 5)
return SPEED_OF_LIGHT / FREQ8; /* E5a+b */
@ -3881,7 +3881,7 @@ double tropmodel(gtime_t time __attribute__((unused)), const double *pos, const
double interpc(const double coef[], double lat)
{
int i = (int)(lat / 15.0);
int i = static_cast<int>(lat / 15.0);
if (i < 1)
return coef[0];
if (i > 4)
@ -3994,7 +3994,7 @@ double tropmapf(gtime_t time, const double pos[], const double azel[],
double interpvar(double ang, const double *var)
{
double a = ang / 5.0; /* ang=0-90 */
int i = (int)a;
int i = static_cast<int>(a);
if (i < 0)
return var[0];
if (i >= 18)
@ -4307,8 +4307,8 @@ int expath(const char *path, char *paths[], int nmax)
if (*(d->d_name) == '.') continue;
sprintf(s1, "^%s$", d->d_name);
sprintf(s2, "^%s$", file);
for (p = s1; *p; p++) *p = (char)tolower((int)*p);
for (p = s2; *p; p++) *p = (char)tolower((int)*p);
for (p = s1; *p; p++) *p = static_cast<char>(tolower(static_cast<int>(*p)));
for (p = s2; *p; p++) *p = static_cast<char>(tolower(static_cast<int>(*p)));
for (p = s1, q = strtok_r(s2, "*", &r); q; q = strtok_r(nullptr, "*", &r))
{

View File

@ -151,7 +151,7 @@ int rtkopenstat(const char *file, int level)
reppath(file, path, time, "", "");
if (!(fp_stat = fopen(path, "w")))
if (!(fp_stat = fopen(path, "we")))
{
trace(1, "rtkopenstat: file open error path=%s\n", path);
return 0;
@ -301,8 +301,8 @@ void swapsolstat(void)
gtime_t time = utc2gpst(timeget());
char path[1024];
if ((int)(time2gpst(time, nullptr) / INT_SWAP_STAT) ==
(int)(time2gpst(time_stat, nullptr) / INT_SWAP_STAT))
if (static_cast<int>(time2gpst(time, nullptr) / INT_SWAP_STAT) ==
static_cast<int>(time2gpst(time_stat, nullptr) / INT_SWAP_STAT))
{
return;
}
@ -314,7 +314,7 @@ void swapsolstat(void)
}
if (fp_stat) fclose(fp_stat);
if (!(fp_stat = fopen(path, "w")))
if (!(fp_stat = fopen(path, "we")))
{
trace(2, "swapsolstat: file open error path=%s\n", path);
return;
@ -795,7 +795,7 @@ void detslp_ll(rtk_t *rtk, const obsd_t *obs, int i, int rcv)
setbitu(&rtk->ssat[sat - 1].slip[f], 2, 2, obs[i].LLI[f]);
/* save slip and half-cycle valid flag */
rtk->ssat[sat - 1].slip[f] |= (unsigned char)slip;
rtk->ssat[sat - 1].slip[f] |= static_cast<unsigned char>(slip);
rtk->ssat[sat - 1].half[f] = (obs[i].LLI[f] & 2) ? 0 : 1;
}
}
@ -923,7 +923,7 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat,
/* reset phase-bias if instantaneous AR or expire obs outage counter */
for (i = 1; i <= MAXSAT; i++)
{
reset = ++rtk->ssat[i - 1].outc[f] > (unsigned int)rtk->opt.maxout;
reset = ++rtk->ssat[i - 1].outc[f] > static_cast<unsigned int>(rtk->opt.maxout);
if (rtk->opt.modear == ARMODE_INST && rtk->x[IB_RTK(i, f, &rtk->opt)] != 0.0)
{
@ -1786,7 +1786,7 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa)
trace(4, "N(2)=");
tracemat(4, b + nb, 1, nb, 10, 3);
rtk->sol.ratio = s[0] > 0 ? (float)(s[1] / s[0]) : 0.0f;
rtk->sol.ratio = s[0] > 0 ? static_cast<float>(s[1] / s[0]) : 0.0f;
if (rtk->sol.ratio > 999.9) rtk->sol.ratio = 999.9f;
/* validation by popular ratio-test */
@ -2077,22 +2077,22 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr,
for (i = 0; i < 3; i++)
{
rtk->sol.rr[i] = rtk->xa[i];
rtk->sol.qr[i] = (float)rtk->Pa[i + i * rtk->na];
rtk->sol.qr[i] = static_cast<float>(rtk->Pa[i + i * rtk->na]);
}
rtk->sol.qr[3] = (float)rtk->Pa[1];
rtk->sol.qr[4] = (float)rtk->Pa[1 + 2 * rtk->na];
rtk->sol.qr[5] = (float)rtk->Pa[2];
rtk->sol.qr[3] = static_cast<float>(rtk->Pa[1]);
rtk->sol.qr[4] = static_cast<float>(rtk->Pa[1 + 2 * rtk->na]);
rtk->sol.qr[5] = static_cast<float>(rtk->Pa[2]);
}
else
{
for (i = 0; i < 3; i++)
{
rtk->sol.rr[i] = rtk->x[i];
rtk->sol.qr[i] = (float)rtk->P[i + i * rtk->nx];
rtk->sol.qr[i] = static_cast<float>(rtk->P[i + i * rtk->nx]);
}
rtk->sol.qr[3] = (float)rtk->P[1];
rtk->sol.qr[4] = (float)rtk->P[1 + 2 * rtk->nx];
rtk->sol.qr[5] = (float)rtk->P[2];
rtk->sol.qr[3] = static_cast<float>(rtk->P[1]);
rtk->sol.qr[4] = static_cast<float>(rtk->P[1 + 2 * rtk->nx]);
rtk->sol.qr[5] = static_cast<float>(rtk->P[2]);
rtk->nfix = 0;
}
for (i = 0; i < n; i++)
@ -2321,7 +2321,7 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav)
errmsg(rtk, "base station position error (%s)\n", msg);
return 0;
}
rtk->sol.age = (float)timediff(rtk->sol.time, solb.time);
rtk->sol.age = static_cast<float>(timediff(rtk->sol.time, solb.time));
if (fabs(rtk->sol.age) > TTOL_MOVEB)
{
@ -2335,7 +2335,7 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav)
}
else
{
rtk->sol.age = (float)timediff(obs[0].time, obs[nu].time);
rtk->sol.age = static_cast<float>(timediff(obs[0].time, obs[nu].time));
if (fabs(rtk->sol.age) > opt->maxtdiff)
{

View File

@ -393,7 +393,7 @@ void decodefile(rtksvr_t *svr, int index)
rtksvrunlock(svr);
return;
}
strncpy(file, (char *)svr->buff[index], nb - 2);
strncpy(file, reinterpret_cast<char *>(svr->buff[index]), nb - 2);
file[nb - 2] = '\0';
svr->nb[index] = 0;
@ -446,7 +446,7 @@ void decodefile(rtksvr_t *svr, int index)
/* rtk server thread ---------------------------------------------------------*/
void *rtksvrthread(void *arg)
{
auto *svr = (rtksvr_t *)arg;
auto *svr = static_cast<rtksvr_t *>(arg);
obs_t obs;
obsd_t data[MAXOBS * 2];
double tt;
@ -518,14 +518,14 @@ void *rtksvrthread(void *arg)
if (svr->rtk.sol.stat != SOLQ_NONE)
{
/* adjust current time */
tt = (int)(tickget() - tick) / 1000.0 + DTTOL;
tt = static_cast<int>(tickget() - tick) / 1000.0 + DTTOL;
timeset(gpst2utc(timeadd(svr->rtk.sol.time, tt)));
/* write solution */
writesol(svr, i);
}
/* if cpu overload, inclement obs outage counter and break */
if ((int)(tickget() - tick) >= svr->cycle)
if (static_cast<int>(tickget() - tick) >= svr->cycle)
{
svr->prcout += fobs[0] - i - 1;
#if 0 /* omitted v.2.4.1 */
@ -539,7 +539,7 @@ void *rtksvrthread(void *arg)
writesol(svr, 0);
}
/* send nmea request to base/nrtk input stream */
if (svr->nmeacycle > 0 && (int)(tick - ticknmea) >= svr->nmeacycle)
if (svr->nmeacycle > 0 && static_cast<int>(tick - ticknmea) >= svr->nmeacycle)
{
if (svr->stream[1].state == 1)
{
@ -554,7 +554,7 @@ void *rtksvrthread(void *arg)
}
ticknmea = tick;
}
if ((cputime = (int)(tickget() - tick)) > 0) svr->cputime = cputime;
if ((cputime = static_cast<int>(tickget() - tick)) > 0) svr->cputime = cputime;
/* sleep until next cycle */
sleepms(svr->cycle - cputime);
@ -620,12 +620,12 @@ int rtksvrinit(rtksvr_t *svr)
for (i = 0; i < 3; i++) svr->files[i][0] = '\0';
svr->moni = nullptr;
svr->tick = 0;
svr->thread = 0;
svr->thread = 0; // NOLINT
svr->cputime = svr->prcout = 0;
if (!(svr->nav.eph = (eph_t *)malloc(sizeof(eph_t) * MAXSAT * 2)) ||
!(svr->nav.geph = (geph_t *)malloc(sizeof(geph_t) * NSATGLO * 2)) ||
!(svr->nav.seph = (seph_t *)malloc(sizeof(seph_t) * NSATSBS * 2)))
if (!(svr->nav.eph = static_cast<eph_t *>(malloc(sizeof(eph_t) * MAXSAT * 2))) ||
!(svr->nav.geph = static_cast<geph_t *>(malloc(sizeof(geph_t) * NSATGLO * 2))) ||
!(svr->nav.seph = static_cast<seph_t *>(malloc(sizeof(seph_t) * NSATSBS * 2))))
{
tracet(1, "rtksvrinit: malloc error\n");
return 0;
@ -640,7 +640,7 @@ int rtksvrinit(rtksvr_t *svr)
for (i = 0; i < 3; i++)
for (j = 0; j < MAXOBSBUF; j++)
{
if (!(svr->obs[i][j].data = (obsd_t *)malloc(sizeof(obsd_t) * MAXOBS)))
if (!(svr->obs[i][j].data = static_cast<obsd_t *>(malloc(sizeof(obsd_t) * MAXOBS))))
{
tracet(1, "rtksvrinit: malloc error\n");
return 0;
@ -760,8 +760,8 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs,
for (i = 0; i < 3; i++)
{ /* input/log streams */
svr->nb[i] = svr->npb[i] = 0;
if (!(svr->buff[i] = (unsigned char *)malloc(buffsize)) ||
!(svr->pbuf[i] = (unsigned char *)malloc(buffsize)))
if (!(svr->buff[i] = static_cast<unsigned char *>(malloc(buffsize))) ||
!(svr->pbuf[i] = static_cast<unsigned char *>(malloc(buffsize))))
{
tracet(1, "rtksvrstart: malloc error\n");
return 0;
@ -782,7 +782,7 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs,
}
for (i = 0; i < 2; i++)
{ /* output peek buffer */
if (!(svr->sbuf[i] = (unsigned char *)malloc(buffsize)))
if (!(svr->sbuf[i] = static_cast<unsigned char *>(malloc(buffsize))))
{
tracet(1, "rtksvrstart: malloc error\n");
return 0;
@ -979,7 +979,7 @@ int rtksvrostat(rtksvr_t *svr, int rcv, gtime_t *time, int *sat,
el[i] = svr->rtk.ssat[sat[i] - 1].azel[1];
for (j = 0; j < NFREQ; j++)
{
snr[i][j] = (int)(svr->obs[rcv][0].data[i].SNR[j] * 0.25);
snr[i][j] = static_cast<int>(svr->obs[rcv][0].data[i].SNR[j] * 0.25);
}
if (svr->rtk.sol.stat == SOLQ_NONE || svr->rtk.sol.stat == SOLQ_SINGLE)
{

View File

@ -148,7 +148,7 @@ int decode_sbstype2(const sbsmsg_t *msg, sbssat_t *sbssat)
trace(4, "decode_sbstype2:\n");
if (sbssat->iodp != (int)getbitu(msg->msg, 16, 2)) return 0;
if (sbssat->iodp != static_cast<int>(getbitu(msg->msg, 16, 2))) return 0;
type = getbitu(msg->msg, 8, 6);
iodf = getbitu(msg->msg, 14, 2);
@ -209,7 +209,7 @@ int decode_sbstype7(const sbsmsg_t *msg, sbssat_t *sbssat)
trace(4, "decode_sbstype7\n");
if (sbssat->iodp != (int)getbitu(msg->msg, 18, 2)) return 0;
if (sbssat->iodp != static_cast<int>(getbitu(msg->msg, 18, 2))) return 0;
sbssat->tlat = getbitu(msg->msg, 14, 4);
@ -234,7 +234,7 @@ int decode_sbstype9(const sbsmsg_t *msg, nav_t *nav)
trace(2, "invalid prn in sbas type 9: prn=%3d\n", msg->prn);
return 0;
}
t = (int)getbitu(msg->msg, 22, 13) * 16 - (int)msg->tow % 86400;
t = static_cast<int>(getbitu(msg->msg, 22, 13)) * 16 - msg->tow % 86400;
if (t <= -43200)
t += 86400;
else if (t > 43200)
@ -292,7 +292,7 @@ int decode_sbstype18(const sbsmsg_t *msg, sbsion_t *sbsion)
else
return 0;
sbsion[band].iodi = (short)getbitu(msg->msg, 22, 2);
sbsion[band].iodi = static_cast<int16_t>(getbitu(msg->msg, 22, 2));
for (i = 1, n = 0; i <= 201; i++)
{
@ -355,7 +355,7 @@ int decode_longcorr1(const sbsmsg_t *msg, int p, sbssat_t *sbssat)
}
sbssat->sat[n - 1].lcorr.daf0 = getbits(msg->msg, p + 47, 11) * TWO_N31;
sbssat->sat[n - 1].lcorr.daf1 = getbits(msg->msg, p + 82, 8) * TWO_N39;
t = (int)getbitu(msg->msg, p + 90, 13) * 16 - (int)msg->tow % 86400;
t = static_cast<int>(getbitu(msg->msg, p + 90, 13)) * 16 - msg->tow % 86400;
if (t <= -43200)
t += 86400;
else if (t > 43200)
@ -374,13 +374,13 @@ int decode_longcorrh(const sbsmsg_t *msg, int p, sbssat_t *sbssat)
if (getbitu(msg->msg, p, 1) == 0)
{ /* vel code=0 */
if (sbssat->iodp == (int)getbitu(msg->msg, p + 103, 2))
if (sbssat->iodp == static_cast<int>(getbitu(msg->msg, p + 103, 2)))
{
return decode_longcorr0(msg, p + 1, sbssat) &&
decode_longcorr0(msg, p + 52, sbssat);
}
}
else if (sbssat->iodp == (int)getbitu(msg->msg, p + 104, 2))
else if (sbssat->iodp == static_cast<int>(getbitu(msg->msg, p + 104, 2)))
{
return decode_longcorr1(msg, p + 1, sbssat);
}
@ -395,7 +395,7 @@ int decode_sbstype24(const sbsmsg_t *msg, sbssat_t *sbssat)
trace(4, "decode_sbstype24:\n");
if (sbssat->iodp != (int)getbitu(msg->msg, 110, 2)) return 0; /* check IODP */
if (sbssat->iodp != static_cast<int>(getbitu(msg->msg, 110, 2))) return 0; /* check IODP */
blk = getbitu(msg->msg, 112, 2);
iodf = getbitu(msg->msg, 114, 2);
@ -430,7 +430,7 @@ int decode_sbstype26(const sbsmsg_t *msg, sbsion_t *sbsion)
trace(4, "decode_sbstype26:\n");
if (band > MAXBAND || sbsion[band].iodi != (int)getbitu(msg->msg, 217, 2)) return 0;
if (band > MAXBAND || sbsion[band].iodi != static_cast<int>(getbitu(msg->msg, 217, 2))) return 0;
block = getbitu(msg->msg, 18, 4);
@ -529,7 +529,7 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te,
trace(3, "readmsgs: file=%s sel=%d\n", file, sel);
if (!(fp = fopen(file, "r")))
if (!(fp = fopen(file, "re")))
{
trace(2, "sbas message file open error: %s\n", file);
return;
@ -575,7 +575,7 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te,
if (sbs->n >= sbs->nmax)
{
sbs->nmax = sbs->nmax == 0 ? 1024 : sbs->nmax * 2;
if (!(sbs_msgs = (sbsmsg_t *)realloc(sbs->msgs, sbs->nmax * sizeof(sbsmsg_t))))
if (!(sbs_msgs = static_cast<sbsmsg_t *>(realloc(sbs->msgs, sbs->nmax * sizeof(sbsmsg_t)))))
{
trace(1, "readsbsmsg malloc error: nmax=%d\n", sbs->nmax);
free(sbs->msgs);
@ -587,12 +587,12 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te,
sbs->msgs = sbs_msgs;
}
sbs->msgs[sbs->n].week = week;
sbs->msgs[sbs->n].tow = (int)(tow + 0.5);
sbs->msgs[sbs->n].tow = static_cast<int>(tow + 0.5);
sbs->msgs[sbs->n].prn = prn;
for (i = 0; i < 29; i++) sbs->msgs[sbs->n].msg[i] = 0;
for (i = 0; *(p - 1) && *p && i < 29; p += 2, i++)
{
if (sscanf(p, "%2X", &b) == 1) sbs->msgs[sbs->n].msg[i] = (unsigned char)b;
if (sscanf(p, "%2X", &b) == 1) sbs->msgs[sbs->n].msg[i] = static_cast<unsigned char>(b);
}
sbs->msgs[sbs->n++].msg[28] &= 0xC0;
}
@ -633,7 +633,7 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te,
for (i = 0; i < MAXEXFILE; i++)
{
if (!(efiles[i] = (char *)malloc(1024)))
if (!(efiles[i] = static_cast<char *>(malloc(1024))))
{
for (i--; i >= 0; i--) free(efiles[i]);
return 0;
@ -645,8 +645,8 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te,
for (i = 0; i < n; i++)
{
if (!(ext = strrchr(efiles[i], '.'))) continue;
if (strcmp(ext, ".sbs") && strcmp(ext, ".SBS") &&
strcmp(ext, ".ems") && strcmp(ext, ".EMS")) continue;
if (strcmp(ext, ".sbs") != 0 && strcmp(ext, ".SBS") &&
strcmp(ext, ".ems") != 0 && strcmp(ext, ".EMS") != 0) continue;
readmsgs(efiles[i], sel, ts, te, sbs);
}
@ -702,38 +702,38 @@ void searchigp(gtime_t time __attribute__((unused)), const double *pos, const sb
if (lon >= 180.0) lon -= 360.0;
if (-55.0 <= lat && lat < 55.0)
{
latp[0] = (int)floor(lat / 5.0) * 5;
latp[0] = static_cast<int>(floor(lat / 5.0)) * 5;
latp[1] = latp[0] + 5;
lonp[0] = lonp[1] = (int)floor(lon / 5.0) * 5;
lonp[0] = lonp[1] = static_cast<int>(floor(lon / 5.0)) * 5;
lonp[2] = lonp[3] = lonp[0] + 5;
*x = (lon - lonp[0]) / 5.0;
*y = (lat - latp[0]) / 5.0;
}
else
{
latp[0] = (int)floor((lat - 5.0) / 10.0) * 10 + 5;
latp[0] = static_cast<int>(floor((lat - 5.0) / 10.0)) * 10 + 5;
latp[1] = latp[0] + 10;
lonp[0] = lonp[1] = (int)floor(lon / 10.0) * 10;
lonp[0] = lonp[1] = static_cast<int>(floor(lon / 10.0)) * 10;
lonp[2] = lonp[3] = lonp[0] + 10;
*x = (lon - lonp[0]) / 10.0;
*y = (lat - latp[0]) / 10.0;
if (75.0 <= lat && lat < 85.0)
{
lonp[1] = (int)floor(lon / 90.0) * 90;
lonp[1] = static_cast<int>(floor(lon / 90.0)) * 90;
lonp[3] = lonp[1] + 90;
}
else if (-85.0 <= lat && lat < -75.0)
{
lonp[0] = (int)floor((lon - 50.0) / 90.0) * 90 + 40;
lonp[0] = static_cast<int>(floor((lon - 50.0) / 90.0)) * 90 + 40;
lonp[2] = lonp[0] + 90;
}
else if (lat >= 85.0)
{
for (i = 0; i < 4; i++) lonp[i] = (int)floor(lon / 90.0) * 90;
for (i = 0; i < 4; i++) lonp[i] = static_cast<int>(floor(lon / 90.0)) * 90;
}
else if (lat < -85.0)
{
for (i = 0; i < 4; i++) lonp[i] = (int)floor((lon - 50.0) / 90.0) * 90 + 40;
for (i = 0; i < 4; i++) lonp[i] = static_cast<int>(floor((lon - 50.0) / 90.0)) * 90 + 40;
}
}
for (i = 0; i < 4; i++)
@ -864,7 +864,7 @@ void getmet(double lat, double *met)
for (i = 0; i < 10; i++) met[i] = metprm[4][i];
else
{
j = (int)(lat / 15.0);
j = static_cast<int>(lat / 15.0);
a = (lat - j * 15.0) / 15.0;
for (i = 0; i < 10; i++) met[i] = (1.0 - a) * metprm[j - 1][i] + a * metprm[j][i];
}
@ -1049,14 +1049,14 @@ int sbsdecodemsg(gtime_t time, int prn, const unsigned int *words,
if (time.time == 0) return 0;
tow = time2gpst(time, &sbsmsg->week);
sbsmsg->tow = (int)(tow + DTTOL);
sbsmsg->tow = static_cast<int>(tow + DTTOL);
sbsmsg->prn = prn;
for (i = 0; i < 7; i++)
for (j = 0; j < 4; j++)
{
sbsmsg->msg[i * 4 + j] = (unsigned char)(words[i] >> ((3 - j) * 8));
sbsmsg->msg[i * 4 + j] = static_cast<unsigned char>(words[i] >> ((3 - j) * 8));
}
sbsmsg->msg[28] = (unsigned char)(words[7] >> 18) & 0xC0;
sbsmsg->msg[28] = static_cast<unsigned char>(words[7] >> 18) & 0xC0;
for (i = 28; i > 0; i--) f[i] = (sbsmsg->msg[i] >> 6) + (sbsmsg->msg[i - 1] << 2);
f[0] = sbsmsg->msg[0] >> 6;

View File

@ -51,7 +51,7 @@
*
*----------------------------------------------------------------------------*/
#include <ctype.h>
#include <cctype>
#include "rtklib_solution.h"
#include "rtklib_rtkcmn.h"
#include "rtklib_rtksvr.h"
@ -88,7 +88,7 @@ const char *opt2sep(const solopt_t *opt)
/* separate fields -----------------------------------------------------------*/
int tonum(char *buff, const char *sep, double *v)
{
int n, len = (int)strlen(sep);
int n, len = static_cast<int>(strlen(sep));
char *p, *q;
for (p = buff, n = 0; n < MAXFIELD; p = q + len)
@ -140,12 +140,12 @@ void soltocov(const sol_t *sol, double *P)
/* covariance to solution ----------------------------------------------------*/
void covtosol(const double *P, sol_t *sol)
{
sol->qr[0] = (float)P[0]; /* xx or ee */
sol->qr[1] = (float)P[4]; /* yy or nn */
sol->qr[2] = (float)P[8]; /* zz or uu */
sol->qr[3] = (float)P[1]; /* xy or en */
sol->qr[4] = (float)P[5]; /* yz or nu */
sol->qr[5] = (float)P[2]; /* zx or ue */
sol->qr[0] = static_cast<float>(P[0]); /* xx or ee */
sol->qr[1] = static_cast<float>(P[4]); /* yy or nn */
sol->qr[2] = static_cast<float>(P[8]); /* zz or uu */
sol->qr[3] = static_cast<float>(P[1]); /* xy or en */
sol->qr[4] = static_cast<float>(P[5]); /* yz or nu */
sol->qr[5] = static_cast<float>(P[2]); /* zx or ue */
}
@ -364,7 +364,7 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time)
strcpy(s, "\t");
else if (*opt->sep)
strcpy(s, opt->sep);
len = (int)strlen(s);
len = static_cast<int>(strlen(s));
/* yyyy/mm/dd hh:mm:ss or yyyy mm dd hh:mm:ss */
if (sscanf(buff, "%lf/%lf/%lf %lf:%lf:%lf", v, v + 1, v + 2, v + 3, v + 4, v + 5) >= 6)
@ -383,7 +383,7 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time)
*time = utc2gpst(timeadd(*time, -9 * 3600.0));
}
if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) return nullptr;
for (p++; isdigit((int)*p) || *p == '.';) p++;
for (p++; isdigit(static_cast<int>(*p)) || *p == '.';) p++;
return p + len;
}
if (opt->posf == SOLF_GSIF)
@ -394,7 +394,7 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time)
}
*time = timeadd(epoch2time(v), -12.0 * 3600.0);
if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) return nullptr;
for (p++; isdigit((int)*p) || *p == '.';) p++;
for (p++; isdigit(static_cast<int>(*p)) || *p == '.';) p++;
return p + len;
}
/* wwww ssss */
@ -406,7 +406,7 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time)
}
if (n >= 2 && 0.0 <= v[0] && v[0] <= 3000.0 && 0.0 <= v[1] && v[1] < 604800.0)
{
*time = gpst2time((int)v[0], v[1]);
*time = gpst2time(static_cast<int>(v[0]), v[1]);
return p;
}
return nullptr;
@ -428,8 +428,8 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol)
{
sol->rr[j] = val[i++]; /* xyz */
}
if (i < n) sol->stat = (unsigned char)val[i++];
if (i < n) sol->ns = (unsigned char)val[i++];
if (i < n) sol->stat = static_cast<unsigned char>(val[i++]);
if (i < n) sol->ns = static_cast<unsigned char>(val[i++]);
if (i + 3 < n)
{
P[0] = val[i] * val[i];
@ -449,8 +449,8 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol)
}
covtosol(P, sol);
}
if (i < n) sol->age = (float)val[i++];
if (i < n) sol->ratio = (float)val[i];
if (i < n) sol->age = static_cast<float>(val[i++]);
if (i < n) sol->ratio = static_cast<float>(val[i]);
sol->type = 0; /* position type = xyz */
@ -486,8 +486,8 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol)
i += 7;
}
pos2ecef(pos, sol->rr);
if (i < n) sol->stat = (unsigned char)val[i++];
if (i < n) sol->ns = (unsigned char)val[i++];
if (i < n) sol->stat = static_cast<unsigned char>(val[i++]);
if (i < n) sol->ns = static_cast<unsigned char>(val[i++]);
if (i + 3 < n)
{
Q[4] = val[i] * val[i];
@ -508,8 +508,8 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol)
covecef(pos, Q, P);
covtosol(P, sol);
}
if (i < n) sol->age = (float)val[i++];
if (i < n) sol->ratio = (float)val[i];
if (i < n) sol->age = static_cast<float>(val[i++]);
if (i < n) sol->ratio = static_cast<float>(val[i]);
sol->type = 0; /* position type = xyz */
@ -533,8 +533,8 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol)
{
sol->rr[j] = val[i++]; /* enu */
}
if (i < n) sol->stat = (unsigned char)val[i++];
if (i < n) sol->ns = (unsigned char)val[i++];
if (i < n) sol->stat = static_cast<unsigned char>(val[i++]);
if (i < n) sol->ns = static_cast<unsigned char>(val[i++]);
if (i + 3 < n)
{
Q[0] = val[i] * val[i];
@ -554,8 +554,8 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol)
}
covtosol(Q, sol);
}
if (i < n) sol->age = (float)val[i++];
if (i < n) sol->ratio = (float)val[i];
if (i < n) sol->age = static_cast<float>(val[i++]);
if (i < n) sol->ratio = static_cast<float>(val[i]);
sol->type = 1; /* position type = enu */
@ -682,7 +682,7 @@ void decode_solopt(char *buff, solopt_t *opt)
trace(4, "decode_solhead: buff=%s\n", buff);
if (strncmp(buff, COMMENTH, 1) && strncmp(buff, "+", 1)) return;
if (strncmp(buff, COMMENTH, 1) != 0 && strncmp(buff, "+", 1)) return;
if (strstr(buff, "GPST"))
opt->times = TIMES_GPST;
@ -776,13 +776,13 @@ int inputsol(unsigned char data, gtime_t ts, gtime_t te, double tint,
solbuf->nb = 0;
/* check disconnect message */
if (!strcmp((char *)solbuf->buff, MSG_DISCONN))
if (!strcmp(reinterpret_cast<char *>(solbuf->buff), MSG_DISCONN))
{
trace(3, "disconnect received\n");
return -1;
}
/* decode solution */
if ((stat = decode_sol((char *)solbuf->buff, opt, &sol, solbuf->rb)) > 0)
if ((stat = decode_sol(reinterpret_cast<char *>(solbuf->buff), opt, &sol, solbuf->rb)) > 0)
{
solbuf->time = sol.time; /* update current time */
}
@ -806,7 +806,7 @@ int readsoldata(FILE *fp, gtime_t ts, gtime_t te, double tint, int qflag,
while ((c = fgetc(fp)) != EOF)
{
/* input solution */
inputsol((unsigned char)c, ts, te, tint, qflag, opt, solbuf);
inputsol(static_cast<unsigned char>(c), ts, te, tint, qflag, opt, solbuf);
}
return solbuf->n > 0;
}
@ -830,7 +830,7 @@ int sort_solbuf(solbuf_t *solbuf)
if (solbuf->n <= 0) return 0;
if (!(solbuf_data = (sol_t *)realloc(solbuf->data, sizeof(sol_t) * solbuf->n)))
if (!(solbuf_data = static_cast<sol_t *>(realloc(solbuf->data, sizeof(sol_t) * solbuf->n))))
{
trace(1, "sort_solbuf: memory allocation error\n");
free(solbuf->data);
@ -871,7 +871,7 @@ int readsolt(char *files[], int nfile, gtime_t ts, gtime_t te,
for (i = 0; i < nfile; i++)
{
if (!(fp = fopen(files[i], "rb")))
if (!(fp = fopen(files[i], "rbe")))
{
trace(1, "readsolt: file open error %s\n", files[i]);
continue;
@ -931,7 +931,7 @@ int addsol(solbuf_t *solbuf, const sol_t *sol)
if (solbuf->n >= solbuf->nmax)
{
solbuf->nmax = solbuf->nmax == 0 ? 8192 : solbuf->nmax * 2;
if (!(solbuf_data = (sol_t *)realloc(solbuf->data, sizeof(sol_t) * solbuf->nmax)))
if (!(solbuf_data = static_cast<sol_t *>(realloc(solbuf->data, sizeof(sol_t) * solbuf->nmax))))
{
trace(1, "addsol: memory allocation error\n");
free(solbuf->data);
@ -985,7 +985,7 @@ void initsolbuf(solbuf_t *solbuf, int cyclic, int nmax)
if (cyclic)
{
if (nmax <= 2) nmax = 2;
if (!(solbuf->data = (sol_t *)malloc(sizeof(sol_t) * nmax)))
if (!(solbuf->data = static_cast<sol_t *>(malloc(sizeof(sol_t) * nmax))))
{
trace(1, "initsolbuf: memory allocation error\n");
return;
@ -1038,7 +1038,7 @@ int sort_solstat(solstatbuf_t *statbuf)
if (statbuf->n <= 0) return 0;
if (!(statbuf_data = (solstat_t *)realloc(statbuf->data, sizeof(solstat_t) * statbuf->n)))
if (!(statbuf_data = static_cast<solstat_t *>(realloc(statbuf->data, sizeof(solstat_t) * statbuf->n))))
{
trace(1, "sort_solstat: memory allocation error\n");
free(statbuf->data);
@ -1084,18 +1084,18 @@ int decode_solstat(char *buff, solstat_t *stat)
}
*stat = stat0;
stat->time = gpst2time(week, tow);
stat->sat = (unsigned char)sat;
stat->frq = (unsigned char)frq;
stat->az = (float)(az * D2R);
stat->el = (float)(el * D2R);
stat->resp = (float)resp;
stat->resc = (float)resc;
stat->flag = (unsigned char)((vsat << 5) + (slip << 3) + fix);
stat->snr = (unsigned char)(snr * 4.0 + 0.5);
stat->lock = (unsigned short)lock;
stat->outc = (unsigned short)outc;
stat->slipc = (unsigned short)slipc;
stat->rejc = (unsigned short)rejc;
stat->sat = static_cast<unsigned char>(sat);
stat->frq = static_cast<unsigned char>(frq);
stat->az = static_cast<float>(az * D2R);
stat->el = static_cast<float>(el * D2R);
stat->resp = static_cast<float>(resp);
stat->resc = static_cast<float>(resc);
stat->flag = static_cast<unsigned char>((vsat << 5) + (slip << 3) + fix);
stat->snr = static_cast<unsigned char>(snr * 4.0 + 0.5);
stat->lock = static_cast<uint16_t>(lock);
stat->outc = static_cast<uint16_t>(outc);
stat->slipc = static_cast<uint16_t>(slipc);
stat->rejc = static_cast<uint16_t>(rejc);
return 1;
}
@ -1110,8 +1110,8 @@ void addsolstat(solstatbuf_t *statbuf, const solstat_t *stat)
if (statbuf->n >= statbuf->nmax)
{
statbuf->nmax = statbuf->nmax == 0 ? 8192 : statbuf->nmax * 2;
if (!(statbuf_data = (solstat_t *)realloc(statbuf->data, sizeof(solstat_t) *
statbuf->nmax)))
if (!(statbuf_data = static_cast<solstat_t *>(realloc(statbuf->data, sizeof(solstat_t) *
statbuf->nmax))))
{
trace(1, "addsolstat: memory allocation error\n");
free(statbuf->data);
@ -1174,7 +1174,7 @@ int readsolstatt(char *files[], int nfile, gtime_t ts, gtime_t te,
for (i = 0; i < nfile; i++)
{
sprintf(path, "%s.stat", files[i]);
if (!(fp = fopen(path, "r")))
if (!(fp = fopen(path, "re")))
{
trace(1, "readsolstatt: file open error %s\n", path);
continue;
@ -1205,7 +1205,7 @@ int outecef(unsigned char *buff, const char *s, const sol_t *sol,
const solopt_t *opt)
{
const char *sep = opt2sep(opt);
char *p = (char *)buff;
char *p = reinterpret_cast<char *>(buff);
trace(3, "outecef:\n");
@ -1214,7 +1214,7 @@ int outecef(unsigned char *buff, const char *s, const sol_t *sol,
sol->ns, sep, SQRT_SOL(sol->qr[0]), sep, SQRT_SOL(sol->qr[1]), sep, SQRT_SOL(sol->qr[2]),
sep, sqvar(sol->qr[3]), sep, sqvar(sol->qr[4]), sep, sqvar(sol->qr[5]),
sep, sol->age, sep, sol->ratio);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
@ -1224,7 +1224,7 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol,
{
double pos[3], dms1[3], dms2[3], P[9], Q[9];
const char *sep = opt2sep(opt);
char *p = (char *)buff;
char *p = reinterpret_cast<char *>(buff);
trace(3, "outpos :\n");
@ -1249,7 +1249,7 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol,
sep, pos[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[4]), sep,
SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]), sep, sqvar(Q[2]),
sep, sqvar(Q[5]), sep, sol->age, sep, sol->ratio);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
@ -1260,7 +1260,7 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol,
double pos[3], rr[3], enu[3], P[9], Q[9];
int i;
const char *sep = opt2sep(opt);
char *p = (char *)buff;
char *p = reinterpret_cast<char *>(buff);
trace(3, "outenu :\n");
@ -1273,7 +1273,7 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol,
s, sep, enu[0], sep, enu[1], sep, enu[2], sep, sol->stat, sep, sol->ns, sep,
SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[4]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]),
sep, sqvar(Q[5]), sep, sqvar(Q[2]), sep, sol->age, sep, sol->ratio);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
@ -1283,16 +1283,16 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol)
static double dirp = 0.0;
gtime_t time;
double ep[6], pos[3], enuv[3], dms1[3], dms2[3], vel, dir, amag = 0.0;
char *p = (char *)buff, *q, sum, *emag = (char *)"E";
char *p = reinterpret_cast<char *>(buff), *q, sum, *emag = (char *)"E";
trace(3, "outnmea_rmc:\n");
if (sol->stat <= SOLQ_NONE)
{
p += sprintf(p, "$GPRMC,,,,,,,,,,,,");
for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q;
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) sum ^= *q;
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
time = gpst2utc(sol->time);
if (time.sec >= 0.995)
@ -1317,11 +1317,11 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol)
p += sprintf(p, "$GPRMC,%02.0f%02.0f%05.2f,A,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%4.2f,%4.2f,%02.0f%02.0f%02d,%.1f,%s,%s",
ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S",
dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", vel / KNOT2M, dir,
ep[2], ep[1], (int)ep[0] % 100, amag, emag,
ep[2], ep[1], static_cast<int>(ep[0]) % 100, amag, emag,
sol->stat == SOLQ_DGPS || sol->stat == SOLQ_FLOAT || sol->stat == SOLQ_FIX ? "D" : "A");
for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
@ -1331,16 +1331,16 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol)
gtime_t time;
double h, ep[6], pos[3], dms1[3], dms2[3], dop = 1.0;
int solq;
char *p = (char *)buff, *q, sum;
char *p = reinterpret_cast<char *>(buff), *q, sum;
trace(3, "outnmea_gga:\n");
if (sol->stat <= SOLQ_NONE)
{
p += sprintf(p, "$GPGGA,,,,,,,,,,,,,,");
for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q;
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) sum ^= *q;
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
for (solq = 0; solq < 8; solq++)
if (solq_nmea[solq] == sol->stat) break;
@ -1360,9 +1360,9 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol)
ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S",
dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", solq,
sol->ns, dop, pos[2] - h, h, sol->age);
for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
@ -1372,16 +1372,16 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol,
{
double azel[MAXSAT * 2], dop[4];
int i, sat, sys, nsat, prn[MAXSAT];
char *p = (char *)buff, *q, *s, sum;
char *p = reinterpret_cast<char *>(buff), *q, *s, sum;
trace(3, "outnmea_gsa:\n");
if (sol->stat <= SOLQ_NONE)
{
p += sprintf(p, "$GPGSA,A,1,,,,,,,,,,,,,,,");
for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q;
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) sum ^= *q;
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
/* GPGSA: gps/sbas */
@ -1458,7 +1458,7 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol,
for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A);
}
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
@ -1468,16 +1468,16 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
{
double az, el, snr;
int i, j, k, n, sat, prn, sys, nmsg, sats[MAXSAT];
char *p = (char *)buff, *q, *s, sum;
char *p = reinterpret_cast<char *>(buff), *q, *s, sum;
trace(3, "outnmea_gsv:\n");
if (sol->stat <= SOLQ_NONE)
{
p += sprintf(p, "$GPGSV,1,1,0,,,,,,,,,,,,,,,,");
for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q;
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) sum ^= *q;
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
/* GPGSV: gps/sbas */
for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++)
@ -1574,7 +1574,7 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A);
}
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
@ -1601,7 +1601,7 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt)
const char *s8[] = {"off", "continuous", "instantaneous", "fix and hold", ""};
const char *s9[] = {"off", "on", "auto calib", "external calib", ""};
int i;
char *p = (char *)buff;
char *p = reinterpret_cast<char *>(buff);
trace(3, "outprcopts:\n");
@ -1660,7 +1660,7 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt)
i + 1, opt->anttype[i], opt->antdel[i][0], opt->antdel[i][1],
opt->antdel[i][2]);
}
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}
@ -1674,7 +1674,7 @@ int outsolheads(unsigned char *buff, const solopt_t *opt)
{
const char *s1[] = {"WGS84", "Tokyo"}, *s2[] = {"ellipsoidal", "geodetic"};
const char *s3[] = {"GPST", "UTC ", "JST "}, *sep = opt2sep(opt);
char *p = (char *)buff;
char *p = reinterpret_cast<char *>(buff);
int timeu = opt->timeu < 0 ? 0 : (opt->timeu > 20 ? 20 : opt->timeu);
trace(3, "outsolheads:\n");
@ -1725,7 +1725,7 @@ int outsolheads(unsigned char *buff, const solopt_t *opt)
"Q", sep, "ns", sep, "sde(m)", sep, "sdn(m)", sep, "sdu(m)", sep,
"sden(m)", sep, "sdnu(m)", sep, "sdue(m)", sep, "age(s)", sep, "ratio");
}
return p - (char *)buff;
return p - reinterpret_cast<char *>(buff);
}

View File

@ -53,12 +53,12 @@
#include <rtklib_stream.h>
#include <rtklib_rtkcmn.h>
#include <rtklib_solution.h>
#include <ctype.h>
#include <cctype>
#include <fcntl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <errno.h>
#include <cerrno>
#include <termios.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
@ -90,13 +90,13 @@ serial_t *openserial(const char *path, int mode, char *msg)
const speed_t bs[] = {
B300, B600, B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400};
struct termios ios;
struct termios ios{};
int rw = 0;
tracet(3, "openserial: path=%s mode=%d\n", path, mode);
if (!(serial = (serial_t *)malloc(sizeof(serial_t)))) return nullptr;
if (!(serial = static_cast<serial_t *>(malloc(sizeof(serial_t))))) return nullptr;
if ((p = strchr((char *)path, ':')))
if ((p = strchr(const_cast<char *>(path), ':')))
{
strncpy(port, path, p - path);
port[p - path] = '\0';
@ -114,7 +114,7 @@ serial_t *openserial(const char *path, int mode, char *msg)
free(serial);
return nullptr;
}
parity = (char)toupper((int)parity);
parity = static_cast<char>(toupper(static_cast<int>(parity)));
// sprintf(dev, "/dev/%s", port); This line triggers a warning. Replaced by:
std::string s_aux = "/dev/" + std::string(port);
@ -277,7 +277,7 @@ int openfile_(file_t *file, gtime_t time, char *msg)
}
else if (file->mode & STR_MODE_W)
{ /* remove time-tag */
if ((fp = fopen(tagpath, "rb")))
if ((fp = fopen(tagpath, "rbe")))
{
fclose(fp);
if (remove(tagpath) != 0) trace(1, "Error removing file");
@ -313,7 +313,7 @@ file_t *openfile(const char *path, int mode, char *msg)
if (!(mode & (STR_MODE_R | STR_MODE_W))) return nullptr;
/* file options */
for (p = (char *)path; (p = strstr(p, "::")); p += 2)
for (p = const_cast<char *>(path); (p = strstr(p, "::")); p += 2)
{ /* file options */
if (*(p + 2) == 'T')
timetag = 1;
@ -327,7 +327,7 @@ file_t *openfile(const char *path, int mode, char *msg)
if (start <= 0.0) start = 0.0;
if (swapintv <= 0.0) swapintv = 0.0;
if (!(file = (file_t *)malloc(sizeof(file_t)))) return nullptr;
if (!(file = static_cast<file_t *>(malloc(sizeof(file_t))))) return nullptr;
file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr;
if (strlen(path) < MAXSTRPATH) strcpy(file->path, path);
@ -435,11 +435,11 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg)
{
if (file->repmode)
{ /* slave */
t = (unsigned int)(tick_master + file->offset);
t = (tick_master + file->offset);
}
else
{ /* master */
t = (unsigned int)((tickget() - file->tick) * file->speed + file->start * 1000.0);
t = static_cast<unsigned int>((tickget() - file->tick) * file->speed + file->start * 1000.0);
}
for (;;)
{ /* seek file position */
@ -452,23 +452,23 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg)
}
if (file->repmode || file->speed > 0.0)
{
if ((int)(tick - t) < 1) continue;
if (static_cast<int>(tick - t) < 1) continue;
}
if (!file->repmode) tick_master = tick;
sprintf(msg, "T%+.1fs", (int)tick < 0 ? 0.0 : (int)tick / 1000.0);
sprintf(msg, "T%+.1fs", static_cast<int>(tick) < 0 ? 0.0 : static_cast<int>(tick) / 1000.0);
if ((int)(fpos - file->fpos) >= nmax)
if (static_cast<int>(fpos - file->fpos) >= nmax)
{
if (fseek(file->fp, fpos, SEEK_SET) != 0) trace(1, "Error fseek");
file->fpos = fpos;
return 0;
}
nmax = (int)(fpos - file->fpos);
nmax = static_cast<int>(fpos - file->fpos);
if (file->repmode || file->speed > 0.0)
{
if (fseek(file->fp_tag, -(long)(sizeof(tick) + sizeof(fpos)), SEEK_CUR) != 0) trace(1, "Error fseek");
if (fseek(file->fp_tag, -static_cast<int64_t>(sizeof(tick) + sizeof(fpos)), SEEK_CUR) != 0) trace(1, "Error fseek");
}
break;
}
@ -480,7 +480,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg)
if (nr <= 0) sprintf(msg, "end");
}
tracet(5, "readfile: fp=%d nr=%d fpos=%d\n", file->fp, nr, file->fpos);
return (int)nr;
return nr;
}
@ -546,7 +546,7 @@ int writefile(file_t *file, unsigned char *buff, int n, char *msg)
}
tracet(5, "writefile: fp=%d ns=%d tick=%5d fpos=%d\n", file->fp, ns, tick, fpos);
return (int)ns;
return static_cast<int>(ns);
}
@ -556,7 +556,7 @@ void syncfile(file_t *file1, file_t *file2)
if (!file1->fp_tag || !file2->fp_tag) return;
file1->repmode = 0;
file2->repmode = 1;
file2->offset = (int)(file1->tick_f - file2->tick_f);
file2->offset = static_cast<int>(file1->tick_f - file2->tick_f);
}
@ -622,21 +622,21 @@ int setsock(socket_t sock, char *msg)
tracet(3, "setsock: sock=%d\n", sock);
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)) == -1 ||
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char *)&tv, sizeof(tv)) == -1)
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<const char *>(&tv), sizeof(tv)) == -1 ||
setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast<const char *>(&tv), sizeof(tv)) == -1)
{
sprintf(msg, "sockopt error: notimeo");
tracet(1, "setsock: setsockopt error 1 sock=%d err=%d\n", sock, errsock());
closesocket(sock);
return 0;
}
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *)&bs, sizeof(bs)) == -1 ||
setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char *)&bs, sizeof(bs)) == -1)
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<const char *>(&bs), sizeof(bs)) == -1 ||
setsockopt(sock, SOL_SOCKET, SO_SNDBUF, reinterpret_cast<const char *>(&bs), sizeof(bs)) == -1)
{
tracet(1, "setsock: setsockopt error 2 sock=%d err=%d bs=%d\n", sock, errsock(), bs);
sprintf(msg, "sockopt error: bufsiz");
}
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&mode, sizeof(mode)) == -1)
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<const char *>(&mode), sizeof(mode)) == -1)
{
tracet(1, "setsock: setsockopt error 3 sock=%d err=%d\n", sock, errsock());
sprintf(msg, "sockopt error: nodelay");
@ -687,7 +687,7 @@ int recv_nb(socket_t sock, unsigned char *buff, int n)
FD_ZERO(&rs);
FD_SET(sock, &rs);
if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) return 0;
return recv(sock, (char *)buff, n, 0);
return recv(sock, reinterpret_cast<char *>(buff), n, 0);
}
@ -699,7 +699,7 @@ int send_nb(socket_t sock, unsigned char *buff, int n)
FD_ZERO(&ws);
FD_SET(sock, &ws);
if (!select(sock + 1, nullptr, &ws, nullptr, &tv)) return 0;
return send(sock, (char *)buff, n, 0);
return send(sock, reinterpret_cast<char *>(buff), n, 0);
}
@ -714,7 +714,7 @@ int gentcp(tcp_t *tcp, int type, char *msg)
tracet(3, "gentcp: type=%d\n", type);
/* generate socket */
if ((tcp->sock = socket(AF_INET, SOCK_STREAM, 0)) == (socket_t)-1)
if ((tcp->sock = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) == -1)
{
sprintf(msg, "socket error (%d)", errsock());
tracet(1, "gentcp: socket error err=%d\n", errsock());
@ -738,7 +738,7 @@ int gentcp(tcp_t *tcp, int type, char *msg)
setsockopt(tcp->sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt,
sizeof(opt));
#endif
if (bind(tcp->sock, (struct sockaddr *)&tcp->addr, sizeof(tcp->addr)) == -1)
if (bind(tcp->sock, reinterpret_cast<struct sockaddr *>(&tcp->addr), sizeof(tcp->addr)) == -1)
{
sprintf(msg, "bind error (%d) : %d", errsock(), tcp->port);
tracet(1, "gentcp: bind error port=%d err=%d\n", tcp->port, errsock());
@ -788,7 +788,7 @@ tcpsvr_t *opentcpsvr(const char *path, char *msg)
tcpsvr0 = {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}, {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}}};
tracet(3, "opentcpsvr: path=%s\n", path);
if (!(tcpsvr = (tcpsvr_t *)malloc(sizeof(tcpsvr_t)))) return nullptr;
if (!(tcpsvr = static_cast<tcpsvr_t *>(malloc(sizeof(tcpsvr_t))))) return nullptr;
*tcpsvr = tcpsvr0;
decodetcppath(path, tcpsvr->svr.saddr, port, nullptr, nullptr, nullptr, nullptr);
if (sscanf(port, "%d", &tcpsvr->svr.port) < 1)
@ -866,7 +866,7 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg)
/* accept client connection --------------------------------------------------*/
int accsock(tcpsvr_t *tcpsvr, char *msg)
{
struct sockaddr_in addr;
struct sockaddr_in addr{};
socket_t sock;
socklen_t len = sizeof(addr);
int i, err;
@ -877,7 +877,7 @@ int accsock(tcpsvr_t *tcpsvr, char *msg)
if (tcpsvr->cli[i].state == 0) break;
if (i >= MAXCLI) return 0; /* too many client */
if ((sock = accept_nb(tcpsvr->svr.sock, (struct sockaddr *)&addr, &len)) == (socket_t)-1)
if ((sock = accept_nb(tcpsvr->svr.sock, reinterpret_cast<struct sockaddr *>(&addr), &len)) == -1)
{
err = errsock();
sprintf(msg, "accept error (%d)", err);
@ -981,12 +981,12 @@ int consock(tcpcli_t *tcpcli, char *msg)
/* wait re-connect */
if (tcpcli->svr.tcon < 0 || (tcpcli->svr.tcon > 0 &&
(int)(tickget() - tcpcli->svr.tdis) < tcpcli->svr.tcon))
static_cast<int>(tickget() - tcpcli->svr.tdis) < tcpcli->svr.tcon))
{
return 0;
}
/* non-block connect */
if ((stat = connect_nb(tcpcli->svr.sock, (struct sockaddr *)&tcpcli->svr.addr,
if ((stat = connect_nb(tcpcli->svr.sock, reinterpret_cast<struct sockaddr *>(&tcpcli->svr.addr),
sizeof(tcpcli->svr.addr))) == -1)
{
err = errsock();
@ -1018,7 +1018,7 @@ tcpcli_t *opentcpcli(const char *path, char *msg)
tracet(3, "opentcpcli: path=%s\n", path);
if (!(tcpcli = (tcpcli_t *)malloc(sizeof(tcpcli_t)))) return nullptr;
if (!(tcpcli = static_cast<tcpcli_t *>(malloc(sizeof(tcpcli_t))))) return nullptr;
*tcpcli = tcpcli0;
decodetcppath(path, tcpcli->svr.saddr, port, nullptr, nullptr, nullptr, nullptr);
if (sscanf(port, "%d", &tcpcli->svr.port) < 1)
@ -1062,7 +1062,7 @@ int waittcpcli(tcpcli_t *tcpcli, char *msg)
if (tcpcli->svr.state == 2)
{ /* connect */
if (tcpcli->toinact > 0 &&
(int)(tickget() - tcpcli->svr.tact) > tcpcli->toinact)
static_cast<int>(tickget() - tcpcli->svr.tact) > tcpcli->toinact)
{
sprintf(msg, "timeout");
tracet(2, "waittcpcli: inactive timeout sock=%d\n", tcpcli->svr.sock);
@ -1164,7 +1164,7 @@ int reqntrip_s(ntrip_t *ntrip, char *msg)
p += sprintf(p, "STR: %s\r\n", ntrip->str);
p += sprintf(p, "\r\n");
if (writetcpcli(ntrip->tcp, (unsigned char *)buff, p - buff, msg) != p - buff) return 0;
if (writetcpcli(ntrip->tcp, reinterpret_cast<unsigned char *>(buff), p - buff, msg) != p - buff) return 0;
tracet(2, "reqntrip_s: send request state=%d ns=%d\n", ntrip->state, p - buff);
tracet(5, "reqntrip_s: n=%d buff=\n%s\n", p - buff, buff);
@ -1192,12 +1192,12 @@ int reqntrip_c(ntrip_t *ntrip, char *msg)
{
sprintf(user, "%s:%s", ntrip->user, ntrip->passwd);
p += sprintf(p, "Authorization: Basic ");
p += encbase64(p, (unsigned char *)user, strlen(user));
p += encbase64(p, reinterpret_cast<unsigned char *>(user), strlen(user));
p += sprintf(p, "\r\n");
}
p += sprintf(p, "\r\n");
if (writetcpcli(ntrip->tcp, (unsigned char *)buff, p - buff, msg) != p - buff) return 0;
if (writetcpcli(ntrip->tcp, reinterpret_cast<unsigned char *>(buff), p - buff, msg) != p - buff) return 0;
tracet(2, "reqntrip_c: send request state=%d ns=%d\n", ntrip->state, p - buff);
tracet(5, "reqntrip_c: n=%d buff=\n%s\n", p - buff, buff);
@ -1216,9 +1216,9 @@ int rspntrip_s(ntrip_t *ntrip, char *msg)
ntrip->buff[ntrip->nb] = '0';
tracet(5, "rspntrip_s: n=%d buff=\n%s\n", ntrip->nb, ntrip->buff);
if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_OK_SVR)))
if ((p = strstr(reinterpret_cast<char *>(ntrip->buff), NTRIP_RSP_OK_SVR)))
{ /* ok */
q = (char *)ntrip->buff;
q = reinterpret_cast<char *>(ntrip->buff);
p += strlen(NTRIP_RSP_OK_SVR);
ntrip->nb -= p - q;
for (i = 0; i < ntrip->nb; i++) *q++ = *p++;
@ -1227,11 +1227,11 @@ int rspntrip_s(ntrip_t *ntrip, char *msg)
tracet(2, "rspntrip_s: response ok nb=%d\n", ntrip->nb);
return 1;
}
if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_ERROR)))
if ((p = strstr(reinterpret_cast<char *>(ntrip->buff), NTRIP_RSP_ERROR)))
{ /* error */
nb = ntrip->nb < MAXSTATMSG ? ntrip->nb : MAXSTATMSG;
// strncpy(msg, (char *)ntrip->buff, nb); This line triggers a warning. Replaced by;
std::string s_aux((char *)ntrip->buff);
std::string s_aux(reinterpret_cast<char *>(ntrip->buff));
s_aux.resize(nb, '\0');
for (int i = 0; i < nb; i++) msg[i] = s_aux[i];
@ -1266,9 +1266,9 @@ int rspntrip_c(ntrip_t *ntrip, char *msg)
ntrip->buff[ntrip->nb] = '0';
tracet(5, "rspntrip_c: n=%d buff=\n%s\n", ntrip->nb, ntrip->buff);
if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_OK_CLI)))
if ((p = strstr(reinterpret_cast<char *>(ntrip->buff), NTRIP_RSP_OK_CLI)))
{ /* ok */
q = (char *)ntrip->buff;
q = reinterpret_cast<char *>(ntrip->buff);
p += strlen(NTRIP_RSP_OK_CLI);
ntrip->nb -= p - q;
for (i = 0; i < ntrip->nb; i++) *q++ = *p++;
@ -1277,7 +1277,7 @@ int rspntrip_c(ntrip_t *ntrip, char *msg)
tracet(2, "rspntrip_c: response ok nb=%d\n", ntrip->nb);
return 1;
}
if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_SRCTBL)))
if ((p = strstr(reinterpret_cast<char *>(ntrip->buff), NTRIP_RSP_SRCTBL)))
{ /* source table */
if (!*ntrip->mntpnt)
{ /* source table request */
@ -1293,7 +1293,7 @@ int rspntrip_c(ntrip_t *ntrip, char *msg)
ntrip->state = 0;
discontcp(&ntrip->tcp->svr, ntrip->tcp->tirecon);
}
else if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_HTTP)))
else if ((p = strstr(reinterpret_cast<char *>(ntrip->buff), NTRIP_RSP_HTTP)))
{ /* http response */
if ((q = strchr(p, '\r')))
*q = '\0';
@ -1342,8 +1342,8 @@ int waitntrip(ntrip_t *ntrip, char *msg)
}
if (ntrip->state == 1)
{ /* read response */
p = (char *)ntrip->buff + ntrip->nb;
if ((n = readtcpcli(ntrip->tcp, (unsigned char *)p, NTRIP_MAXRSP - ntrip->nb - 1, msg)) == 0)
p = reinterpret_cast<char *>(ntrip->buff) + ntrip->nb;
if ((n = readtcpcli(ntrip->tcp, reinterpret_cast<unsigned char *>(p), NTRIP_MAXRSP - ntrip->nb - 1, msg)) == 0)
{
tracet(5, "waitntrip: readtcp n=%d\n", n);
return 0;
@ -1367,7 +1367,7 @@ ntrip_t *openntrip(const char *path, int type, char *msg)
tracet(3, "openntrip: path=%s type=%d\n", path, type);
if (!(ntrip = (ntrip_t *)malloc(sizeof(ntrip_t)))) return nullptr;
if (!(ntrip = static_cast<ntrip_t *>(malloc(sizeof(ntrip_t))))) return nullptr;
ntrip->state = 0;
ntrip->type = type; /* 0:server, 1:client */
@ -1534,7 +1534,7 @@ gtime_t nextdltime(const int *topts, int stat)
/* ftp thread ----------------------------------------------------------------*/
void *ftpthread(void *arg)
{
auto *ftp = (ftp_t *)arg;
auto *ftp = static_cast<ftp_t *>(arg);
FILE *fp;
gtime_t time;
char remote[1024], local[1024], tmpfile[1024], errfile[1024], *p;
@ -1578,7 +1578,7 @@ void *ftpthread(void *arg)
{
*p = '\0';
}
if ((fp = fopen(tmpfile, "rb")))
if ((fp = fopen(tmpfile, "rbe")))
{
fclose(fp);
strcpy(ftp->local, tmpfile);
@ -1672,12 +1672,12 @@ ftp_t *openftp(const char *path, int type, char *msg)
msg[0] = '\0';
if (!(ftp = (ftp_t *)malloc(sizeof(ftp_t)))) return nullptr;
if (!(ftp = static_cast<ftp_t *>(malloc(sizeof(ftp_t))))) return nullptr;
ftp->state = 0;
ftp->proto = type;
ftp->error = 0;
ftp->thread = 0;
ftp->thread = 0; // NOLINT
ftp->local[0] = '\0';
/* decode ftp path */
@ -1739,9 +1739,9 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg)
}
/* return local file path if ftp completed */
p = buff;
q = (unsigned char *)ftp->local;
while (*q && (int)(p - buff) < n) *p++ = *q++;
p += sprintf((char *)p, "\r\n");
q = reinterpret_cast<unsigned char *>(ftp->local);
while (*q && static_cast<int>(p - buff) < n) *p++ = *q++;
p += sprintf(reinterpret_cast<char *>(p), "\r\n");
/* set next download time */
ftp->tnext = nextdltime(ftp->topts, 1);
@ -1749,7 +1749,7 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg)
strcpy(msg, "");
return (int)(p - buff);
return static_cast<int>(p - buff);
}
@ -1888,28 +1888,28 @@ void strclose(stream_t *stream)
switch (stream->type)
{
case STR_SERIAL:
closeserial((serial_t *)stream->port);
closeserial(static_cast<serial_t *>(stream->port));
break;
case STR_FILE:
closefile((file_t *)stream->port);
closefile(static_cast<file_t *>(stream->port));
break;
case STR_TCPSVR:
closetcpsvr((tcpsvr_t *)stream->port);
closetcpsvr(static_cast<tcpsvr_t *>(stream->port));
break;
case STR_TCPCLI:
closetcpcli((tcpcli_t *)stream->port);
closetcpcli(static_cast<tcpcli_t *>(stream->port));
break;
case STR_NTRIPSVR:
closentrip((ntrip_t *)stream->port);
closentrip(static_cast<ntrip_t *>(stream->port));
break;
case STR_NTRIPCLI:
closentrip((ntrip_t *)stream->port);
closentrip(static_cast<ntrip_t *>(stream->port));
break;
case STR_FTP:
closeftp((ftp_t *)stream->port);
closeftp(static_cast<ftp_t *>(stream->port));
break;
case STR_HTTP:
closeftp((ftp_t *)stream->port);
closeftp(static_cast<ftp_t *>(stream->port));
break;
}
}
@ -1938,8 +1938,8 @@ void strsync(stream_t *stream1, stream_t *stream2)
{
file_t *file1, *file2;
if (stream1->type != STR_FILE || stream2->type != STR_FILE) return;
file1 = (file_t *)stream1->port;
file2 = (file_t *)stream2->port;
file1 = static_cast<file_t *>(stream1->port);
file2 = static_cast<file_t *>(stream2->port);
if (file1 && file2) syncfile(file1, file2);
}
@ -1977,25 +1977,25 @@ int strread(stream_t *stream, unsigned char *buff, int n)
switch (stream->type)
{
case STR_SERIAL:
nr = readserial((serial_t *)stream->port, buff, n, msg);
nr = readserial(static_cast<serial_t *>(stream->port), buff, n, msg);
break;
case STR_FILE:
nr = readfile((file_t *)stream->port, buff, n, msg);
nr = readfile(static_cast<file_t *>(stream->port), buff, n, msg);
break;
case STR_TCPSVR:
nr = readtcpsvr((tcpsvr_t *)stream->port, buff, n, msg);
nr = readtcpsvr(static_cast<tcpsvr_t *>(stream->port), buff, n, msg);
break;
case STR_TCPCLI:
nr = readtcpcli((tcpcli_t *)stream->port, buff, n, msg);
nr = readtcpcli(static_cast<tcpcli_t *>(stream->port), buff, n, msg);
break;
case STR_NTRIPCLI:
nr = readntrip((ntrip_t *)stream->port, buff, n, msg);
nr = readntrip(static_cast<ntrip_t *>(stream->port), buff, n, msg);
break;
case STR_FTP:
nr = readftp((ftp_t *)stream->port, buff, n, msg);
nr = readftp(static_cast<ftp_t *>(stream->port), buff, n, msg);
break;
case STR_HTTP:
nr = readftp((ftp_t *)stream->port, buff, n, msg);
nr = readftp(static_cast<ftp_t *>(stream->port), buff, n, msg);
break;
default:
strunlock(stream);
@ -2005,7 +2005,7 @@ int strread(stream_t *stream, unsigned char *buff, int n)
tick = tickget();
if (nr > 0) stream->tact = tick;
if ((int)(tick - stream->tick) >= tirate)
if (static_cast<int>(tick - stream->tick) >= tirate)
{
stream->inr = (stream->inb - stream->inbt) * 8000 / (tick - stream->tick);
stream->tick = tick;
@ -2039,20 +2039,20 @@ int strwrite(stream_t *stream, unsigned char *buff, int n)
switch (stream->type)
{
case STR_SERIAL:
ns = writeserial((serial_t *)stream->port, buff, n, msg);
ns = writeserial(static_cast<serial_t *>(stream->port), buff, n, msg);
break;
case STR_FILE:
ns = writefile((file_t *)stream->port, buff, n, msg);
ns = writefile(static_cast<file_t *>(stream->port), buff, n, msg);
break;
case STR_TCPSVR:
ns = writetcpsvr((tcpsvr_t *)stream->port, buff, n, msg);
ns = writetcpsvr(static_cast<tcpsvr_t *>(stream->port), buff, n, msg);
break;
case STR_TCPCLI:
ns = writetcpcli((tcpcli_t *)stream->port, buff, n, msg);
ns = writetcpcli(static_cast<tcpcli_t *>(stream->port), buff, n, msg);
break;
case STR_NTRIPCLI:
case STR_NTRIPSVR:
ns = writentrip((ntrip_t *)stream->port, buff, n, msg);
ns = writentrip(static_cast<ntrip_t *>(stream->port), buff, n, msg);
break;
case STR_FTP:
case STR_HTTP:
@ -2064,7 +2064,7 @@ int strwrite(stream_t *stream, unsigned char *buff, int n)
tick = tickget();
if (ns > 0) stream->tact = tick;
if ((int)(tick - stream->tick) > tirate)
if (static_cast<int>(tick - stream->tick) > tirate)
{
stream->outr = (stream->outb - stream->outbt) * 8000 / (tick - stream->tick);
stream->tick = tick;
@ -2104,32 +2104,32 @@ int strstat(stream_t *stream, char *msg)
switch (stream->type)
{
case STR_SERIAL:
state = stateserial((serial_t *)stream->port);
state = stateserial(static_cast<serial_t *>(stream->port));
break;
case STR_FILE:
state = statefile((file_t *)stream->port);
state = statefile(static_cast<file_t *>(stream->port));
break;
case STR_TCPSVR:
state = statetcpsvr((tcpsvr_t *)stream->port);
state = statetcpsvr(static_cast<tcpsvr_t *>(stream->port));
break;
case STR_TCPCLI:
state = statetcpcli((tcpcli_t *)stream->port);
state = statetcpcli(static_cast<tcpcli_t *>(stream->port));
break;
case STR_NTRIPSVR:
case STR_NTRIPCLI:
state = statentrip((ntrip_t *)stream->port);
state = statentrip(static_cast<ntrip_t *>(stream->port));
break;
case STR_FTP:
state = stateftp((ftp_t *)stream->port);
state = stateftp(static_cast<ftp_t *>(stream->port));
break;
case STR_HTTP:
state = stateftp((ftp_t *)stream->port);
state = stateftp(static_cast<ftp_t *>(stream->port));
break;
default:
strunlock(stream);
return 0;
}
if (state == 2 && (int)(tickget() - stream->tact) <= TINTACT) state = 3;
if (state == 2 && static_cast<int>(tickget() - stream->tact) <= TINTACT) state = 3;
strunlock(stream);
return state;
}
@ -2198,11 +2198,11 @@ void strsettimeout(stream_t *stream, int toinact, int tirecon)
if (stream->type == STR_TCPCLI)
{
tcpcli = (tcpcli_t *)stream->port;
tcpcli = static_cast<tcpcli_t *>(stream->port);
}
else if (stream->type == STR_NTRIPCLI || stream->type == STR_NTRIPSVR)
{
tcpcli = ((ntrip_t *)stream->port)->tcp;
tcpcli = (static_cast<ntrip_t *>(stream->port))->tcp;
}
else
return;
@ -2245,7 +2245,7 @@ gtime_t strgettime(stream_t *stream)
{
file_t *file;
if (stream->type == STR_FILE && (stream->mode & STR_MODE_R) &&
(file = (file_t *)stream->port))
(file = static_cast<file_t *>(stream->port)))
{
return timeadd(file->time, file->start); /* replay start time */
}
@ -2292,9 +2292,9 @@ int gen_hex(const char *msg, unsigned char *buff)
}
for (i = 0; i < narg; i++)
{
if (sscanf(args[i], "%x", &byte)) *q++ = (unsigned char)byte;
if (sscanf(args[i], "%x", &byte)) *q++ = static_cast<unsigned char>(byte);
}
return (int)(q - buff);
return static_cast<int>(q - buff);
}
@ -2317,7 +2317,7 @@ void strsendcmd(stream_t *str, const char *cmd)
{
for (q = p;; q++)
if (*q == '\r' || *q == '\n' || *q == '\0') break;
n = (int)(q - p);
n = static_cast<int>(q - p);
strncpy(msg, p, n);
msg[n] = '\0';
@ -2357,8 +2357,8 @@ void strsendcmd(stream_t *str, const char *cmd)
}
else
{
strwrite(str, (unsigned char *)msg, n);
strwrite(str, (unsigned char *)cmdend, 2);
strwrite(str, reinterpret_cast<unsigned char *>(msg), n);
strwrite(str, reinterpret_cast<unsigned char *>(cmdend), 2);
}
if (*q == '\0')
break;

View File

@ -41,8 +41,8 @@ short_x2_to_cshort_sptr make_short_x2_to_cshort()
short_x2_to_cshort::short_x2_to_cshort() : sync_block("short_x2_to_cshort",
gr::io_signature::make(2, 2, sizeof(short)),
gr::io_signature::make(1, 1, sizeof(lv_16sc_t))) // lv_8sc_t is a Volk's typedef for std::complex<signed char>
gr::io_signature::make(2, 2, sizeof(int16_t)),
gr::io_signature::make(1, 1, sizeof(lv_16sc_t)))
{
const int alignment_multiple = volk_get_alignment() / sizeof(lv_16sc_t);
set_alignment(std::max(1, alignment_multiple));
@ -53,12 +53,12 @@ int short_x2_to_cshort::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const auto *in0 = reinterpret_cast<const short *>(input_items[0]);
const auto *in1 = reinterpret_cast<const short *>(input_items[1]);
const auto *in0 = reinterpret_cast<const int16_t *>(input_items[0]);
const auto *in1 = reinterpret_cast<const int16_t *>(input_items[1]);
auto *out = reinterpret_cast<lv_16sc_t *>(output_items[0]);
// This could be put into a volk kernel
short real_part;
short imag_part;
int16_t real_part;
int16_t imag_part;
for (int number = 0; number < noutput_items; number++)
{
// lv_cmake(r, i) defined at volk/volk_complex.h

View File

@ -542,7 +542,7 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused)
int32_t n_valid = 0;
for (uint32_t n = 0; n < d_nchannels_out; n++)
{
Gnss_Synchro interpolated_gnss_synchro;
Gnss_Synchro interpolated_gnss_synchro{};
if (!interp_trk_obs(interpolated_gnss_synchro, n, d_Rx_clock_buffer.front() + T_rx_TOW_offset_ms * T_rx_clock_step_samples))
{
// Produce an empty observation

View File

@ -38,6 +38,7 @@
#include <gnuradio/blocks/file_sink.h>
#include <volk/volk.h>
#include <cmath>
#include <cstdint>
#include <limits>
using google::LogMessage;
@ -94,7 +95,7 @@ DirectResamplerConditioner::DirectResamplerConditioner(
else
{
LOG(WARNING) << item_type_ << " unrecognized item type for resampler";
item_size_ = sizeof(short);
item_size_ = sizeof(int16_t);
}
if (dump_)
{

View File

@ -37,7 +37,7 @@
#include "Galileo_E5a.h"
#include "GLONASS_L1_L2_CA.h"
#include <glog/logging.h>
#include <cstdint>
#include <utility>
@ -104,11 +104,11 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration,
{
if (signal1[0].at(0) == '1')
{
vector_length = round((float)fs_in / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS));
vector_length = round(static_cast<float>(fs_in) / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS));
}
else
{
vector_length = round((float)fs_in / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS));
vector_length = round(static_cast<float>(fs_in) / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS));
}
}
@ -128,7 +128,7 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration,
else
{
LOG(WARNING) << item_type_ << " unrecognized item type for resampler";
item_size_ = sizeof(short);
item_size_ = sizeof(int16_t);
}
if (dump_)

View File

@ -32,7 +32,7 @@
#include "configuration_interface.h"
#include "labsat23_source.h"
#include <glog/logging.h>
#include <cstdint>
#include <utility>
@ -63,7 +63,7 @@ LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration,
else
{
LOG(WARNING) << item_type_ << " unrecognized item type for LabSat source";
item_size_ = sizeof(short);
item_size_ = sizeof(int16_t);
}
if (dump_)
{

View File

@ -36,6 +36,7 @@
#include "GPS_L1_CA.h"
#include <boost/format.hpp>
#include <glog/logging.h>
#include <cstdint>
#include <iostream>
#include <utility>
@ -63,7 +64,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
// rtl_tcp PARAMETERS
std::string default_address = "127.0.0.1";
short default_port = 1234;
int16_t default_port = 1234;
AGC_enabled_ = configuration->property(role + ".AGC_enabled", true);
freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ);
gain_ = configuration->property(role + ".gain", 40.0);
@ -77,7 +78,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
if (item_type_ == "short")
{
item_size_ = sizeof(short);
item_size_ = sizeof(int16_t);
}
else if (item_type_ == "gr_complex")
{
@ -118,7 +119,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
else
{
LOG(WARNING) << item_type_ << " unrecognized item type. Using short.";
item_size_ = sizeof(short);
item_size_ = sizeof(int16_t);
}
if (samples_ != 0)

View File

@ -90,7 +90,7 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac
// well read them in as bytes.
if (big_endian_items_)
{
item_size_ = sizeof(short);
item_size_ = sizeof(int16_t);
}
else
{

View File

@ -369,121 +369,118 @@ int labsat23_source::general_work(int noutput_items,
std::cout << "Labsat file header error: section 2 is not available." << std::endl;
return -1;
}
else
{
std::cout << "Labsat file read error: file is empty." << std::endl;
return -1;
}
std::cout << "Labsat file read error: file is empty." << std::endl;
return -1;
}
else
// ready to start reading samples
switch (d_bits_per_sample)
{
// ready to start reading samples
switch (d_bits_per_sample)
{
case 2:
case 2:
{
switch (d_channel_selector)
{
switch (d_channel_selector)
{
case 0:
// dual channel 2 bits per complex sample
break;
default:
// single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16)
int n_int16_to_read = noutput_items / 8;
if (n_int16_to_read > 0)
{
int16_t memblock[n_int16_to_read];
binary_input_file->read(reinterpret_cast<char *>(memblock), n_int16_to_read * 2);
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
if (n_int16_to_read > 0)
{
int output_pointer = 0;
for (int i = 0; i < n_int16_to_read; i++)
{
decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample);
output_pointer += 8;
}
return output_pointer;
}
// trigger the read of the next file in the sequence
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
d_current_file_number++;
binary_input_file->close();
binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary);
if (binary_input_file->is_open())
{
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
}
else
{
std::cout << "Last file reached, LabSat source stop" << std::endl;
return -1;
}
}
else
{
return 0;
}
};
case 0:
// dual channel 2 bits per complex sample
break;
}
case 4:
{
switch (d_channel_selector)
default:
// single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16)
int n_int16_to_read = noutput_items / 8;
if (n_int16_to_read > 0)
{
case 0:
// dual channel
break;
default:
// single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16)
int n_int16_to_read = noutput_items / 4;
int16_t memblock[n_int16_to_read];
binary_input_file->read(reinterpret_cast<char *>(memblock), n_int16_to_read * 2);
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
if (n_int16_to_read > 0)
{
int16_t memblock[n_int16_to_read];
binary_input_file->read(reinterpret_cast<char *>(memblock), n_int16_to_read * 2);
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
if (n_int16_to_read > 0)
int output_pointer = 0;
for (int i = 0; i < n_int16_to_read; i++)
{
int output_pointer = 0;
for (int i = 0; i < n_int16_to_read; i++)
{
decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample);
output_pointer += 4;
}
return output_pointer;
decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample);
output_pointer += 8;
}
return output_pointer;
}
// trigger the read of the next file in the sequence
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
// trigger the read of the next file in the sequence
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
d_current_file_number++;
binary_input_file->close();
binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary);
if (binary_input_file->is_open())
{
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
}
else
{
std::cout << "Last file reached, LabSat source stop" << std::endl;
return -1;
}
d_current_file_number++;
binary_input_file->close();
binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary);
if (binary_input_file->is_open())
{
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
}
else
{
return 0;
std::cout << "Last file reached, LabSat source stop" << std::endl;
return -1;
}
}
break;
}
default:
else
{
return 0;
}
};
break;
}
case 4:
{
switch (d_channel_selector)
{
return -1;
case 0:
// dual channel
break;
default:
// single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16)
int n_int16_to_read = noutput_items / 4;
if (n_int16_to_read > 0)
{
int16_t memblock[n_int16_to_read];
binary_input_file->read(reinterpret_cast<char *>(memblock), n_int16_to_read * 2);
n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16
if (n_int16_to_read > 0)
{
int output_pointer = 0;
for (int i = 0; i < n_int16_to_read; i++)
{
decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample);
output_pointer += 4;
}
return output_pointer;
}
// trigger the read of the next file in the sequence
std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl;
d_current_file_number++;
binary_input_file->close();
binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary);
if (binary_input_file->is_open())
{
std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl;
}
else
{
std::cout << "Last file reached, LabSat source stop" << std::endl;
return -1;
}
}
else
{
return 0;
}
}
}
break;
}
default:
{
return -1;
}
}
std::cout << "Warning!!" << std::endl;
return 0;
}

View File

@ -51,7 +51,7 @@ enum
rtl_tcp_signal_source_c_sptr
rtl_tcp_make_signal_source_c(const std::string &address,
short port,
int16_t port,
bool flip_iq)
{
return gnuradio::get_initial_sptr(new rtl_tcp_signal_source_c(address,
@ -61,7 +61,7 @@ rtl_tcp_make_signal_source_c(const std::string &address,
rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address,
short port,
int16_t port,
bool flip_iq)
: gr::sync_block("rtl_tcp_signal_source_c",
gr::io_signature::make(0, 0, 0),

View File

@ -45,6 +45,7 @@
#include <boost/array.hpp>
#include <boost/circular_buffer.hpp>
#include <gnuradio/sync_block.h>
#include <cstdint>
#include <string>
class rtl_tcp_signal_source_c;
@ -54,7 +55,7 @@ typedef boost::shared_ptr<rtl_tcp_signal_source_c>
rtl_tcp_signal_source_c_sptr
rtl_tcp_make_signal_source_c(const std::string &address,
short port,
int16_t port,
bool flip_iq = false);
/*!
@ -81,11 +82,11 @@ private:
friend rtl_tcp_signal_source_c_sptr
rtl_tcp_make_signal_source_c(const std::string &address,
short port,
int16_t port,
bool flip_iq);
rtl_tcp_signal_source_c(const std::string &address,
short port,
int16_t port,
bool flip_iq);
rtl_tcp_dongle_info info_;

View File

@ -62,9 +62,9 @@ bool systemIsBigEndian()
bool systemBytesAreBigEndian()
{
byte_and_samples b;
byte_and_samples b{};
b.byte = static_cast<int8_t>(0x01);
if (*(char *)&b.byte == 1)
if (*reinterpret_cast<char *>(&b.byte) == 1)
return false;
return true;
@ -158,7 +158,7 @@ int unpack_2bit_samples::work(int noutput_items,
// 1) The samples in a byte are in big endian order
// 2) The samples in a byte are in little endian order
byte_and_samples raw_byte;
byte_and_samples raw_byte{};
int n = 0;
if (!reverse_interleaving_)

View File

@ -35,6 +35,7 @@
#include "unpack_byte_2bit_cpx_samples.h"
#include <gnuradio/io_signature.h>
#include <cstdint>
struct byte_2bit_struct
{
@ -49,8 +50,8 @@ unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples()
unpack_byte_2bit_cpx_samples::unpack_byte_2bit_cpx_samples() : sync_interpolator("unpack_byte_2bit_cpx_samples",
gr::io_signature::make(1, 1, sizeof(signed char)),
gr::io_signature::make(1, 1, sizeof(short)),
gr::io_signature::make(1, 1, sizeof(int8_t)),
gr::io_signature::make(1, 1, sizeof(int16_t)),
4)
{
}
@ -63,10 +64,10 @@ int unpack_byte_2bit_cpx_samples::work(int noutput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const auto *in = reinterpret_cast<const signed char *>(input_items[0]);
auto *out = reinterpret_cast<short *>(output_items[0]);
const auto *in = reinterpret_cast<const int8_t *>(input_items[0]);
auto *out = reinterpret_cast<int16_t *>(output_items[0]);
byte_2bit_struct sample;
byte_2bit_struct sample{};
int n = 0;
for (int i = 0; i < noutput_items / 4; i++)
{
@ -76,34 +77,34 @@ int unpack_byte_2bit_cpx_samples::work(int noutput_items,
//* Least Significant Nibble - Sample n+1
//* Packing order in Nibble Q1 Q0 I1 I0
//normal
// signed char c = in[i];
// int8_t c = in[i];
// //Q[n]
// sample.two_bit_sample = (c>>6) & 3;
// out[n++] = (2*(short)sample.two_bit_sample+1);
// out[n++] = (2*(int16_t)sample.two_bit_sample+1);
// //I[n]
// sample.two_bit_sample = (c>>4) & 3;
// out[n++] = (2*(short)sample.two_bit_sample+1);
// out[n++] = (2*(int16_t)sample.two_bit_sample+1);
// //Q[n+1]
// sample.two_bit_sample = (c>>2) & 3;
// out[n++] = (2*(short)sample.two_bit_sample+1);
// out[n++] = (2*(int16_t)sample.two_bit_sample+1);
// //I[n+1]
// sample.two_bit_sample = c & 3;
// out[n++] = (2*(short)sample.two_bit_sample+1);
// out[n++] = (2*(int16_t)sample.two_bit_sample+1);
//I/Q swap
signed char c = in[i];
int8_t c = in[i];
//I[n]
sample.two_bit_sample = (c >> 4) & 3;
out[n++] = (2 * static_cast<short>(sample.two_bit_sample) + 1);
out[n++] = (2 * static_cast<int16_t>(sample.two_bit_sample) + 1);
//Q[n]
sample.two_bit_sample = (c >> 6) & 3;
out[n++] = (2 * static_cast<short>(sample.two_bit_sample) + 1);
out[n++] = (2 * static_cast<int16_t>(sample.two_bit_sample) + 1);
//I[n+1]
sample.two_bit_sample = c & 3;
out[n++] = (2 * static_cast<short>(sample.two_bit_sample) + 1);
out[n++] = (2 * static_cast<int16_t>(sample.two_bit_sample) + 1);
//Q[n+1]
sample.two_bit_sample = (c >> 2) & 3;
out[n++] = (2 * static_cast<short>(sample.two_bit_sample) + 1);
out[n++] = (2 * static_cast<int16_t>(sample.two_bit_sample) + 1);
}
return noutput_items;
}

View File

@ -62,7 +62,7 @@ int unpack_byte_2bit_samples::work(int noutput_items,
const auto *in = reinterpret_cast<const signed char *>(input_items[0]);
auto *out = reinterpret_cast<float *>(output_items[0]);
byte_2bit_struct sample;
byte_2bit_struct sample{};
int n = 0;
for (int i = 0; i < noutput_items / 4; i++)
{

View File

@ -42,7 +42,7 @@
class rtl_tcp_dongle_info
{
private:
char magic_[4];
char magic_[4]{};
uint32_t tuner_type_;
uint32_t tuner_gain_count_;

View File

@ -463,7 +463,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
auto **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const auto **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block
Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block
// 1. Copy the current tracking output
current_symbol = in[0][0];
// add new symbol to the symbol queue

View File

@ -125,7 +125,7 @@ private:
// vars for Viterbi decoder
int32_t *out0, *out1, *state0, *state1;
int32_t g_encoder[2];
int32_t g_encoder[2]{};
const int32_t nn = 2; // Coding rate 1/n
const int32_t KK = 7; // Constraint Length
int32_t mm = KK - 1;

View File

@ -74,7 +74,7 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc(
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<int32_t *>(malloc(sizeof(int32_t) * d_symbols_per_preamble));
int32_t n = 0;
for (unsigned short d_preambles_bit : d_preambles_bits)
for (uint16_t d_preambles_bit : d_preambles_bits)
{
for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++)
{
@ -268,7 +268,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
auto **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const auto **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block
Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block
// 1. Copy the current tracking output
current_symbol = in[0][0];
d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue

View File

@ -82,7 +82,7 @@ private:
double d_preamble_time_samples;
//!< Preamble decoding
uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS];
uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]{};
int32_t *d_preambles_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;

View File

@ -74,7 +74,7 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc(
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<int32_t *>(malloc(sizeof(int32_t) * d_symbols_per_preamble));
int32_t n = 0;
for (unsigned short d_preambles_bit : d_preambles_bits)
for (uint16_t d_preambles_bit : d_preambles_bits)
{
for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++)
{
@ -268,7 +268,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu
auto **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const auto **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block
Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block
// 1. Copy the current tracking output
current_symbol = in[0][0];
d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue

View File

@ -80,7 +80,7 @@ private:
double d_preamble_time_samples;
//!< Preamble decoding
uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS];
uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]{};
int32_t *d_preambles_symbols;
uint32_t d_samples_per_symbol;
int32_t d_symbols_per_preamble;

View File

@ -67,7 +67,7 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc(
// preamble bits to sampled symbols
d_preambles_symbols = static_cast<int32_t *>(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment()));
int32_t n = 0;
for (unsigned short preambles_bit : preambles_bits)
for (uint16_t preambles_bit : preambles_bits)
{
for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++)
{
@ -316,7 +316,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__
auto **out = reinterpret_cast<Gnss_Synchro **>(&output_items[0]); // Get the output buffer pointer
const auto **in = reinterpret_cast<const Gnss_Synchro **>(&input_items[0]); // Get the input buffer pointer
Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block
Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block
// 1. Copy the current tracking output
current_symbol = in[0][0];

View File

@ -82,7 +82,7 @@ private:
// symbols
boost::circular_buffer<Gnss_Synchro> d_symbol_history;
float d_subframe_symbols[GPS_SUBFRAME_MS]; // symbols per subframe
float d_subframe_symbols[GPS_SUBFRAME_MS]{}; // symbols per subframe
int d_current_subframe_symbol;
// bits and frame

View File

@ -143,7 +143,7 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
consume_each(1); // one by one
// UPDATE GNSS SYNCHRO DATA
Gnss_Synchro current_synchro_data; // structure to save the synchronization information and send the output object to the next block
Gnss_Synchro current_synchro_data{}; // structure to save the synchronization information and send the output object to the next block
// 1. Copy the current tracking output
current_synchro_data = in[0];

View File

@ -91,7 +91,7 @@ private:
std::string d_dump_filename;
std::ofstream d_dump_file;
cnav_msg_decoder_t d_cnav_decoder;
cnav_msg_decoder_t d_cnav_decoder{};
int32_t d_state;
int32_t d_crc_error_count;

View File

@ -145,7 +145,7 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u
const auto *in = reinterpret_cast<const Gnss_Synchro *>(input_items[0]); // Get the input buffer pointer
// UPDATE GNSS SYNCHRO DATA
Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block
Gnss_Synchro current_synchro_data{}; //structure to save the synchronization information and send the output object to the next block
// 1. Copy the current tracking output
current_synchro_data = in[0];
consume_each(1); //one by one

View File

@ -83,14 +83,14 @@ private:
std::string d_dump_filename;
std::ofstream d_dump_file;
cnav_msg_decoder_t d_cnav_decoder;
cnav_msg_decoder_t d_cnav_decoder{};
uint32_t d_TOW_at_current_symbol_ms;
uint32_t d_TOW_at_Preamble_ms;
bool d_flag_valid_word;
Gps_CNAV_Navigation_Message d_CNAV_Message;
double bits_NH[GPS_L5i_NH_CODE_LENGTH];
double bits_NH[GPS_L5i_NH_CODE_LENGTH]{};
std::deque<double> sym_hist;
bool sync_NH;
bool new_sym;

View File

@ -425,7 +425,7 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__((
auto *out = reinterpret_cast<Gnss_Synchro *>(output_items[0]); // Get the output buffer pointer
const auto *in = reinterpret_cast<const Gnss_Synchro *>(input_items[0]); // Get the input buffer pointer
Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block
Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block
// 1. Copy the current tracking output
current_symbol = in[0];
// copy correlation samples into samples vector

View File

@ -133,7 +133,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl
// preamble bits to sampled symbols
d_gps_l1ca_preambles_symbols = static_cast<int32_t *>(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment()));
int32_t n = 0;
for (unsigned short preambles_bit : preambles_bits)
for (uint16_t preambles_bit : preambles_bits)
{
for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++)
{

View File

@ -572,9 +572,9 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel)
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl;
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl;
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what();
}
}
}
@ -913,9 +913,9 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at
uint32_t prn_ = d_acquisition_gnss_synchro->PRN;
d_dump_file.write(reinterpret_cast<char *>(&prn_), sizeof(uint32_t));
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "Exception writing trk dump file " << e->what();
LOG(WARNING) << "Exception writing trk dump file " << e.what();
}
}

View File

@ -563,9 +563,9 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel)
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl;
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl;
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what();
}
}
}
@ -902,9 +902,9 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at
uint32_t prn_ = d_acquisition_gnss_synchro->PRN;
d_dump_file.write(reinterpret_cast<char *>(&prn_), sizeof(uint32_t));
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "Exception writing trk dump file " << e->what();
LOG(WARNING) << "Exception writing trk dump file " << e.what();
}
}

View File

@ -569,9 +569,9 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel)
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl;
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl;
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what();
}
}
}
@ -910,9 +910,9 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at
uint32_t prn_ = d_acquisition_gnss_synchro->PRN;
d_dump_file.write(reinterpret_cast<char *>(&prn_), sizeof(uint32_t));
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "Exception writing trk dump file " << e->what();
LOG(WARNING) << "Exception writing trk dump file " << e.what();
}
}

View File

@ -562,9 +562,9 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel)
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl;
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl;
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what();
}
}
}
@ -901,9 +901,9 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at
uint32_t prn_ = d_acquisition_gnss_synchro->PRN;
d_dump_file.write(reinterpret_cast<char *>(&prn_), sizeof(uint32_t));
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "Exception writing trk dump file " << e->what();
LOG(WARNING) << "Exception writing trk dump file " << e.what();
}
}

View File

@ -551,9 +551,9 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel)
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str();
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl;
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what();
}
}
}
@ -891,9 +891,9 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib
uint32_t prn_ = d_acquisition_gnss_synchro->PRN;
d_dump_file.write(reinterpret_cast<char *>(&prn_), sizeof(uint32_t));
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "Exception writing trk dump file " << e->what();
LOG(WARNING) << "Exception writing trk dump file " << e.what();
}
}

View File

@ -553,9 +553,9 @@ void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel)
d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary);
LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str();
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what();
LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what();
}
}
}
@ -892,9 +892,9 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib
uint32_t prn_ = d_acquisition_gnss_synchro->PRN;
d_dump_file.write(reinterpret_cast<char *>(&prn_), sizeof(uint32_t));
}
catch (const std::ifstream::failure *e)
catch (const std::ifstream::failure &e)
{
LOG(WARNING) << "Exception writing trk dump file " << e->what();
LOG(WARNING) << "Exception writing trk dump file " << e.what();
}
}

View File

@ -517,7 +517,7 @@ int32_t Gps_L1_Ca_Kf_Tracking_cc::save_matfile()
filename.erase(filename.length() - 4, 4);
filename.append(".mat");
matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73);
if (reinterpret_cast<long *>(matfp) != nullptr)
if (reinterpret_cast<int64_t *>(matfp) != nullptr)
{
size_t dims[2] = {1, static_cast<size_t>(num_epoch)};
matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_VE, 0);

View File

@ -65,7 +65,7 @@ public:
double carrier_lock_th;
bool track_pilot;
char system;
char signal[3];
char signal[3]{};
Dll_Pll_Conf();
};

View File

@ -35,9 +35,7 @@
#include <string>
tcp_communication::tcp_communication() : tcp_socket_(io_service_)
{
}
tcp_communication::tcp_communication() : tcp_socket_(io_service_) {} // NOLINT
tcp_communication::~tcp_communication() = default;

View File

@ -52,6 +52,7 @@ Tracking_loop_filter::Tracking_loop_filter(float update_interval,
update_coefficients();
}
Tracking_loop_filter::Tracking_loop_filter()
: d_loop_order(2),
d_current_index(0),
@ -64,10 +65,9 @@ Tracking_loop_filter::Tracking_loop_filter()
update_coefficients();
}
Tracking_loop_filter::~Tracking_loop_filter()
{
// Don't need to do anything here
}
Tracking_loop_filter::~Tracking_loop_filter() = default;
float Tracking_loop_filter::apply(float current_input)
{
@ -108,6 +108,7 @@ float Tracking_loop_filter::apply(float current_input)
return result;
}
void Tracking_loop_filter::update_coefficients(void)
{
// Analog gains:
@ -216,17 +217,20 @@ void Tracking_loop_filter::update_coefficients(void)
};
}
void Tracking_loop_filter::set_noise_bandwidth(float noise_bandwidth)
{
d_noise_bandwidth = noise_bandwidth;
update_coefficients();
}
float Tracking_loop_filter::get_noise_bandwidth(void) const
{
return d_noise_bandwidth;
}
void Tracking_loop_filter::set_update_interval(float update_interval)
{
d_update_interval = update_interval;
@ -238,17 +242,20 @@ float Tracking_loop_filter::get_update_interval(void) const
return d_update_interval;
}
void Tracking_loop_filter::set_include_last_integrator(bool include_last_integrator)
{
d_include_last_integrator = include_last_integrator;
update_coefficients();
}
bool Tracking_loop_filter::get_include_last_integrator(void) const
{
return d_include_last_integrator;
}
void Tracking_loop_filter::set_order(int loop_order)
{
if (loop_order < 1 or loop_order > MAX_LOOP_ORDER)
@ -264,11 +271,13 @@ void Tracking_loop_filter::set_order(int loop_order)
update_coefficients();
}
int Tracking_loop_filter::get_order(void) const
{
return d_loop_order;
}
void Tracking_loop_filter::initialize(float initial_output)
{
d_inputs.assign(MAX_LOOP_HISTORY_LENGTH, 0.0);

View File

@ -64,16 +64,16 @@ int INIReader::ParseError()
}
std::string INIReader::Get(std::string section, std::string name, std::string default_value)
std::string INIReader::Get(const std::string& section, const std::string& name, std::string default_value)
{
std::string key = MakeKey(std::move(section), std::move(name));
std::string key = MakeKey(section, name);
return _values.count(key) ? _values[key] : default_value;
}
int64_t INIReader::GetInteger(std::string section, std::string name, int64_t default_value)
int64_t INIReader::GetInteger(const std::string& section, const std::string& name, int64_t default_value)
{
std::string valstr = Get(std::move(section), std::move(name), "");
std::string valstr = Get(section, name, "");
const char* value = valstr.c_str();
char* end;
// This parses "1234" (decimal) and also "0x4D2" (hex)
@ -86,7 +86,7 @@ std::string INIReader::MakeKey(const std::string& section, const std::string& na
{
std::string key = section + "." + name;
// Convert to lower case to make lookups case-insensitive
for (char & i : key)
for (char& i : key)
i = tolower(i);
return key;
}

View File

@ -66,11 +66,11 @@ public:
int ParseError();
//! Get a string value from INI file, returning default_value if not found.
std::string Get(std::string section, std::string name,
std::string Get(const std::string& section, const std::string& name,
std::string default_value);
//! Get an integer (long) value from INI file, returning default_value if not found.
int64_t GetInteger(std::string section, std::string name, int64_t default_value);
int64_t GetInteger(const std::string& section, const std::string& name, int64_t default_value);
private:
int _error;

View File

@ -74,9 +74,9 @@ private:
int lac;
int ci;
// assistance protocol structure
supl_ctx_t ctx;
supl_ctx_t ctx{};
// assistance data
supl_assist_t assist;
supl_assist_t assist{};
bool read_gal_almanac_from_gsa(const std::string& file_name);
public:

View File

@ -50,10 +50,8 @@ bool StringConverter::convert(const std::string& value, bool default_value)
{
return false;
}
else
{
return default_value;
}
return default_value;
}

View File

@ -788,7 +788,7 @@ static int argument_is_stdin(char *av[], int idx) {
static FILE *argument_to_file(char *av[], int idx) {
return argument_is_stdin(av, idx)
? stdin
: fopen(av[idx], "r");
: fopen(av[idx], "re");
}
static char *argument_to_name(char *av[], int idx) {

View File

@ -2,7 +2,7 @@
#include <asn_internal.h>
#include <per_encoder.h>
static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key);
static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t * /*constraints*/, void *sptr, asn_app_consume_bytes_f *cb, void *app_key);
asn_enc_rval_t
uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {

View File

@ -17,7 +17,7 @@ typedef struct uper_ugot_key
static int uper_ugot_refill(asn_per_data_t *pd);
static int per_skip_bits(asn_per_data_t *pd, int skip_nbits);
static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd);
static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t * /*ctx*/, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd);
int asn_debug_indent;

View File

@ -2,7 +2,7 @@
#include <asn_internal.h>
#include <per_encoder.h>
static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key);
static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t * /*constraints*/, void *sptr, asn_app_consume_bytes_f *cb, void *app_key);
asn_enc_rval_t
uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) {

View File

@ -17,7 +17,7 @@ typedef struct uper_ugot_key
static int uper_ugot_refill(asn_per_data_t *pd);
static int per_skip_bits(asn_per_data_t *pd, int skip_nbits);
static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd);
static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t * /*ctx*/, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd);
int asn_debug_indent;

View File

@ -274,7 +274,7 @@ static int server_connect(char *server) {
}
for (aip = ailist; aip; aip = aip->ai_next) {
if ((fd = socket(aip->ai_family, SOCK_STREAM, 0)) < 0) {
if ((fd = socket(aip->ai_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0) {
err = errno;
}
if (connect(fd, aip->ai_addr, aip->ai_addrlen) != 0) {

View File

@ -35,7 +35,7 @@
#include <sstream>
#include <iostream>
Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(std::vector<std::string> addresses, const unsigned short& port) : socket{io_service}
Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(std::vector<std::string> addresses, const uint16_t& port) : socket{io_service}
{
for (auto address : addresses)
{

View File

@ -38,7 +38,7 @@
class Gnss_Synchro_Udp_Sink
{
public:
Gnss_Synchro_Udp_Sink(std::vector<std::string> addresses, const unsigned short &port);
Gnss_Synchro_Udp_Sink(std::vector<std::string> addresses, const uint16_t &port);
bool write_gnss_synchro(std::vector<Gnss_Synchro> stocks);
private:

View File

@ -301,7 +301,7 @@ int32_t Rtcm::bin_to_int(const std::string& s) const
int32_t reading;
// Handle negative numbers
if (s.substr(0, 1).compare("0"))
if (s.substr(0, 1) != "0")
{
// Computing two's complement
boost::dynamic_bitset<> original_bitset(s);
@ -327,7 +327,7 @@ int32_t Rtcm::bin_to_sint(const std::string& s) const
int32_t sign;
// Check for sign bit as defined RTCM doc
if (s.substr(0, 1) == "0")
if (s.substr(0, 1) != "0")
{
sign = 1;
// Get the magnitude of the value
@ -363,7 +363,7 @@ double Rtcm::bin_to_double(const std::string& s) const
int64_t reading_int;
// Handle negative numbers
if (s.substr(0, 1).compare("0"))
if (s.substr(0, 1) != "0")
{
// Computing two's complement
boost::dynamic_bitset<> original_bitset(s);

View File

@ -121,7 +121,7 @@ int PositionSystemTest::generate_signal()
pid_t wait_result;
int child_status;
char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL};
char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], nullptr};
int pid;
if ((pid = fork()) == -1)
@ -342,12 +342,12 @@ int PositionSystemTest::run_receiver()
std::string argum2 = std::string("/bin/ls *kml | tail -1");
char buffer[1035];
fp = popen(&argum2[0], "r");
if (fp == NULL)
if (fp == nullptr)
{
std::cout << "Failed to run command: " << argum2 << std::endl;
return -1;
}
while (fgets(buffer, sizeof(buffer), fp) != NULL)
while (fgets(buffer, sizeof(buffer), fp) != nullptr)
{
std::string aux = std::string(buffer);
EXPECT_EQ(aux.empty(), false);
@ -910,7 +910,7 @@ void PositionSystemTest::print_results(const arma::mat& R_eb_enu)
}
}
TEST_F(PositionSystemTest, Position_system_test)
TEST_F(PositionSystemTest /*unused*/, Position_system_test /*unused*/)
{
if (FLAGS_config_file_ptest.empty())
{

View File

@ -417,7 +417,7 @@ void TtffTest::print_TTFF_report(const std::vector<double> &ttff_v, std::shared_
}
TEST_F(TtffTest, ColdStart)
TEST_F(TtffTest /*unused*/, ColdStart /*unused*/)
{
unsigned int num_measurements = 0;
@ -500,7 +500,7 @@ TEST_F(TtffTest, ColdStart)
}
TEST_F(TtffTest, HotStart)
TEST_F(TtffTest /*unused*/, HotStart /*unused*/)
{
unsigned int num_measurements = 0;
TTFF_v.clear();

View File

@ -62,7 +62,7 @@
// ######## GNURADIO BLOCK MESSAGE RECEVER #########
class GpsL1CaPcpsAcquisitionTest_msg_rx;
typedef boost::shared_ptr<GpsL1CaPcpsAcquisitionTest_msg_rx> GpsL1CaPcpsAcquisitionTest_msg_rx_sptr;
using GpsL1CaPcpsAcquisitionTest_msg_rx_sptr = boost::shared_ptr<GpsL1CaPcpsAcquisitionTest_msg_rx>;
GpsL1CaPcpsAcquisitionTest_msg_rx_sptr GpsL1CaPcpsAcquisitionTest_msg_rx_make();
@ -134,7 +134,7 @@ protected:
gr::top_block_sptr top_block;
std::shared_ptr<GNSSBlockFactory> factory;
std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro;
Gnss_Synchro gnss_synchro{};
size_t item_size;
unsigned int doppler_max;
unsigned int doppler_step;

View File

@ -61,7 +61,7 @@ public:
std::string file_name_input;
std::string file_name_output;
std::vector<int8_t> input_data_bytes;
std::vector<short> input_data_shorts;
std::vector<int16_t> input_data_shorts;
};
@ -70,12 +70,12 @@ DataTypeAdapter::DataTypeAdapter()
file_name_input = "adapter_test_input.dat";
file_name_output = "adapter_test_output.dat";
int8_t input_bytes[] = {2, 23, -1, 127, -127, 0};
short input_shorts[] = {2, 23, -1, 127, -127, 0, 255, 255};
int16_t input_shorts[] = {2, 23, -1, 127, -127, 0, 255, 255};
const std::vector<int8_t> input_data_bytes_(input_bytes, input_bytes + sizeof(input_bytes) / sizeof(int8_t));
input_data_bytes = input_data_bytes_;
const std::vector<short> input_data_shorts_(input_shorts, input_shorts + sizeof(input_shorts) / sizeof(short));
const std::vector<int16_t> input_data_shorts_(input_shorts, input_shorts + sizeof(input_shorts) / sizeof(int16_t));
input_data_shorts = input_data_shorts_;
}
@ -92,14 +92,14 @@ int DataTypeAdapter::run_ishort_to_cshort_block()
EXPECT_EQ(expected_implementation, ishort_to_cshort->implementation());
std::ofstream ofs(file_name_input.c_str(), std::ofstream::binary);
for (short aux : input_data_shorts)
for (int16_t aux : input_data_shorts)
{
ofs.write(reinterpret_cast<const char*>(&aux), sizeof(short));
ofs.write(reinterpret_cast<const char*>(&aux), sizeof(int16_t));
}
ofs.close();
auto top_block = gr::make_top_block("Ishort_To_Cshort test");
auto file_source = gr::blocks::file_source::make(sizeof(short), file_name_input.c_str());
auto file_source = gr::blocks::file_source::make(sizeof(int16_t), file_name_input.c_str());
auto sink = gr::blocks::file_sink::make(sizeof(lv_16sc_t), file_name_output.c_str(), false);
EXPECT_NO_THROW({
@ -120,14 +120,14 @@ int DataTypeAdapter::run_ishort_to_complex_block()
EXPECT_EQ(expected_implementation, ishort_to_complex->implementation());
std::ofstream ofs(file_name_input.c_str(), std::ofstream::binary);
for (short aux : input_data_shorts)
for (int16_t aux : input_data_shorts)
{
ofs.write(reinterpret_cast<const char*>(&aux), sizeof(short));
ofs.write(reinterpret_cast<const char*>(&aux), sizeof(int16_t));
}
ofs.close();
auto top_block = gr::make_top_block("Ishort_To_Complex test");
auto file_source = gr::blocks::file_source::make(sizeof(short), file_name_input.c_str());
auto file_source = gr::blocks::file_source::make(sizeof(int16_t), file_name_input.c_str());
auto sink = gr::blocks::file_sink::make(sizeof(gr_complex), file_name_output.c_str(), false);
EXPECT_NO_THROW({
@ -212,7 +212,7 @@ int DataTypeAdapter::run_ibyte_to_cbyte_block()
auto top_block = gr::make_top_block("Ibyte_To_Cbyte test");
auto file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name_input.c_str());
auto sink = gr::blocks::file_sink::make(sizeof(short), file_name_output.c_str(), false);
auto sink = gr::blocks::file_sink::make(sizeof(int16_t), file_name_output.c_str(), false);
EXPECT_NO_THROW({
top_block->connect(file_source, 0, ibyte_to_cbyte->get_left_block(), 0);
@ -364,9 +364,9 @@ TEST_F(DataTypeAdapter, IshortToComplexValidationOfResults)
{
while (ifs.read(reinterpret_cast<char*>(&iSample), sizeof(gr_complex)))
{
EXPECT_EQ(input_data_shorts.at(i), static_cast<short>(iSample.real()));
EXPECT_EQ(input_data_shorts.at(i), static_cast<int16_t>(iSample.real()));
i++;
EXPECT_EQ(input_data_shorts.at(i), static_cast<short>(iSample.imag()));
EXPECT_EQ(input_data_shorts.at(i), static_cast<int16_t>(iSample.imag()));
i++;
}
}
@ -390,9 +390,9 @@ TEST_F(DataTypeAdapter, IshortToCshortValidationOfResults)
{
while (ifs.read(reinterpret_cast<char*>(&iSample), sizeof(lv_16sc_t)))
{
EXPECT_EQ(input_data_shorts.at(i), static_cast<short>(iSample.real()));
EXPECT_EQ(input_data_shorts.at(i), static_cast<int16_t>(iSample.real()));
i++;
EXPECT_EQ(input_data_shorts.at(i), static_cast<short>(iSample.imag()));
EXPECT_EQ(input_data_shorts.at(i), static_cast<int16_t>(iSample.imag()));
i++;
}
}

View File

@ -73,7 +73,7 @@ protected:
gr::top_block_sptr top_block;
std::shared_ptr<GNSSBlockFactory> factory;
std::shared_ptr<InMemoryConfiguration> config;
Gnss_Synchro gnss_synchro;
Gnss_Synchro gnss_synchro{};
size_t item_size;
bool stop;
int message;

View File

@ -257,16 +257,14 @@ bool FrontEndCal::get_ephemeris()
}
return true;
}
else
std::cout << "Trying to read ephemeris from SUPL server..." << std::endl;
LOG(INFO) << "Trying to read ephemeris from SUPL server...";
if (Get_SUPL_Assist() == 0)
{
std::cout << "Trying to read ephemeris from SUPL server..." << std::endl;
LOG(INFO) << "Trying to read ephemeris from SUPL server...";
if (Get_SUPL_Assist() == 0)
{
return true;
}
return false;
return true;
}
return false;
}

View File

@ -66,7 +66,7 @@
#include <gnuradio/blocks/head.h>
#include <gnuradio/blocks/file_source.h>
#include <gnuradio/blocks/file_sink.h>
#include <stdlib.h>
#include <cstdlib>
#include <chrono>
#include <cstdint>
#include <ctime> // for ctime
@ -97,7 +97,7 @@ std::vector<Gnss_Synchro> gnss_sync_vector;
// ######## GNURADIO BLOCK MESSAGE RECEVER #########
class FrontEndCal_msg_rx;
typedef boost::shared_ptr<FrontEndCal_msg_rx> FrontEndCal_msg_rx_sptr;
using FrontEndCal_msg_rx_sptr = boost::shared_ptr<FrontEndCal_msg_rx>;
FrontEndCal_msg_rx_sptr FrontEndCal_msg_rx_make();
@ -402,7 +402,7 @@ int main(int argc, char** argv)
// record startup time
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::duration<double> elapsed_seconds;
std::chrono::duration<double> elapsed_seconds{};
start = std::chrono::system_clock::now();
bool start_msg = true;
@ -434,7 +434,7 @@ int main(int argc, char** argv)
{
std::cout << " " << PRN << " ";
double doppler_measurement_hz = 0;
for (auto & it : gnss_sync_vector)
for (auto& it : gnss_sync_vector)
{
doppler_measurement_hz += it.Acq_doppler_hz;
}
@ -541,7 +541,7 @@ int main(int argc, char** argv)
std::cout << "SV ID Measured [Hz] Predicted [Hz]" << std::endl;
for (auto & it : doppler_measurements_map)
for (auto& it : doppler_measurements_map)
{
try
{
@ -577,7 +577,7 @@ int main(int argc, char** argv)
double mean_osc_err_ppm = 0;
int n_elements = f_if_estimation_Hz_map.size();
for (auto & it : f_if_estimation_Hz_map)
for (auto& it : f_if_estimation_Hz_map)
{
mean_f_if_Hz += it.second;
mean_fs_Hz += f_fs_estimation_Hz_map.find(it.first)->second;
@ -598,7 +598,7 @@ int main(int argc, char** argv)
<< "Corrected Doppler vs. Predicted" << std::endl;
std::cout << "SV ID Corrected [Hz] Predicted [Hz]" << std::endl;
for (auto & it : doppler_measurements_map)
for (auto& it : doppler_measurements_map)
{
try
{