mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2024-12-14 20:20:35 +00:00
Misc improvements
Remove cstdio Remove usage of cstring and memcpy when it is not needed Mark move cobstructor with noexcept
This commit is contained in:
parent
19b35b6cef
commit
def3a8875a
@ -203,7 +203,6 @@ signed int GalileoE1Pcps8msAmbiguousAcquisition::mag()
|
||||
void GalileoE1Pcps8msAmbiguousAcquisition::init()
|
||||
{
|
||||
acquisition_cc_->init();
|
||||
//set_local_code();
|
||||
}
|
||||
|
||||
|
||||
@ -215,8 +214,10 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_local_code()
|
||||
"Acquisition" + std::to_string(channel_) + ".cboc", false);
|
||||
|
||||
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
|
||||
std::array<char, 3> Signal_;
|
||||
std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3);
|
||||
std::array<char, 3> Signal_{};
|
||||
Signal_[0] = gnss_synchro_->Signal[0];
|
||||
Signal_[1] = gnss_synchro_->Signal[1];
|
||||
Signal_[2] = '\0';
|
||||
|
||||
galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code, code_length_), Signal_,
|
||||
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
|
||||
|
@ -232,7 +232,6 @@ signed int GalileoE1PcpsAmbiguousAcquisition::mag()
|
||||
void GalileoE1PcpsAmbiguousAcquisition::init()
|
||||
{
|
||||
acquisition_->init();
|
||||
//set_local_code();
|
||||
}
|
||||
|
||||
|
||||
@ -246,7 +245,7 @@ void GalileoE1PcpsAmbiguousAcquisition::set_local_code()
|
||||
|
||||
if (acquire_pilot_ == true)
|
||||
{
|
||||
//set local signal generator to Galileo E1 pilot component (1C)
|
||||
// set local signal generator to Galileo E1 pilot component (1C)
|
||||
std::array<char, 3> pilot_signal = {{'1', 'C', '\0'}};
|
||||
if (acq_parameters_.use_automatic_resampler)
|
||||
{
|
||||
@ -261,8 +260,10 @@ void GalileoE1PcpsAmbiguousAcquisition::set_local_code()
|
||||
}
|
||||
else
|
||||
{
|
||||
std::array<char, 3> Signal_;
|
||||
std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3);
|
||||
std::array<char, 3> Signal_{};
|
||||
Signal_[0] = gnss_synchro_->Signal[0];
|
||||
Signal_[1] = gnss_synchro_->Signal[1];
|
||||
Signal_[2] = '\0';
|
||||
if (acq_parameters_.use_automatic_resampler)
|
||||
{
|
||||
galileo_e1_code_gen_complex_sampled(code_span, Signal_,
|
||||
|
@ -237,7 +237,6 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::mag()
|
||||
void GalileoE1PcpsQuickSyncAmbiguousAcquisition::init()
|
||||
{
|
||||
acquisition_cc_->init();
|
||||
//set_local_code();
|
||||
}
|
||||
|
||||
|
||||
@ -249,8 +248,10 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_local_code()
|
||||
"Acquisition" + std::to_string(channel_) + ".cboc", false);
|
||||
|
||||
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
|
||||
std::array<char, 3> Signal_;
|
||||
std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3);
|
||||
std::array<char, 3> Signal_{};
|
||||
Signal_[0] = gnss_synchro_->Signal[0];
|
||||
Signal_[1] = gnss_synchro_->Signal[1];
|
||||
Signal_[2] = '\0';
|
||||
|
||||
galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), Signal_,
|
||||
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
|
||||
|
@ -207,7 +207,6 @@ signed int GalileoE1PcpsTongAmbiguousAcquisition::mag()
|
||||
void GalileoE1PcpsTongAmbiguousAcquisition::init()
|
||||
{
|
||||
acquisition_cc_->init();
|
||||
//set_local_code();
|
||||
}
|
||||
|
||||
|
||||
@ -219,8 +218,10 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_local_code()
|
||||
"Acquisition" + std::to_string(channel_) + ".cboc", false);
|
||||
|
||||
std::unique_ptr<std::complex<float>> code{new std::complex<float>[code_length_]};
|
||||
std::array<char, 3> Signal_;
|
||||
std::memcpy(Signal_.data(), gnss_synchro_->Signal, 3);
|
||||
std::array<char, 3> Signal_{};
|
||||
Signal_[0] = gnss_synchro_->Signal[0];
|
||||
Signal_[1] = gnss_synchro_->Signal[1];
|
||||
Signal_[2] = '\0';
|
||||
galileo_e1_code_gen_complex_sampled(gsl::span<std::complex<float>>(code.get(), code_length_), Signal_,
|
||||
cboc, gnss_synchro_->PRN, fs_in_, 0, false);
|
||||
|
||||
|
@ -37,7 +37,6 @@
|
||||
#include "telemetry_decoder_interface.h"
|
||||
#include "tracking_interface.h"
|
||||
#include <glog/logging.h>
|
||||
#include <cstring> // for memcpy
|
||||
#include <utility> // for std::move
|
||||
|
||||
|
||||
@ -209,9 +208,9 @@ void Channel::set_signal(const Gnss_Signal& gnss_signal)
|
||||
std::lock_guard<std::mutex> lk(mx);
|
||||
gnss_signal_ = gnss_signal;
|
||||
std::string str_aux = gnss_signal_.get_signal_str();
|
||||
const char* str = str_aux.c_str(); // get a C style null terminated string
|
||||
std::memcpy(static_cast<void*>(gnss_synchro_.Signal), str, 3); // copy string into synchro char array: 2 char + null
|
||||
gnss_synchro_.Signal[2] = 0; // make sure that string length is only two characters
|
||||
gnss_synchro_.Signal[0] = str_aux[0];
|
||||
gnss_synchro_.Signal[1] = str_aux[1];
|
||||
gnss_synchro_.Signal[2] = '\0'; // make sure that string length is only two characters
|
||||
gnss_synchro_.PRN = gnss_signal_.get_satellite().get_PRN();
|
||||
gnss_synchro_.System = gnss_signal_.get_satellite().get_system_short().c_str()[0];
|
||||
acq_->set_local_code();
|
||||
|
@ -182,7 +182,7 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u
|
||||
// Expand packet bits to bitsets. Notice the reverse order of the bits sequence, required by the CNAV message decoder
|
||||
for (uint32_t i = 0; i < GPS_L5_CNAV_DATA_PAGE_BITS; i++)
|
||||
{
|
||||
raw_bits[GPS_L5_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i / 8] >> (7 - i % 8)) & 1u);
|
||||
raw_bits[GPS_L5_CNAV_DATA_PAGE_BITS - 1 - i] = ((msg.raw_msg[i / 8] >> (7 - i % 8)) & 1U);
|
||||
}
|
||||
|
||||
d_CNAV_Message.decode_page(raw_bits);
|
||||
|
@ -91,7 +91,7 @@ bool operator==(const Gnss_Satellite& sat1, const Gnss_Satellite& sat2)
|
||||
|
||||
|
||||
// Copy constructor
|
||||
Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other)
|
||||
Gnss_Satellite::Gnss_Satellite(Gnss_Satellite&& other) noexcept
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
@ -113,14 +113,14 @@ Gnss_Satellite& Gnss_Satellite::operator=(const Gnss_Satellite& rhs)
|
||||
|
||||
|
||||
// Move constructor
|
||||
Gnss_Satellite::Gnss_Satellite(const Gnss_Satellite& other)
|
||||
Gnss_Satellite::Gnss_Satellite(const Gnss_Satellite& other) noexcept
|
||||
{
|
||||
*this = std::move(other);
|
||||
*this = other;
|
||||
}
|
||||
|
||||
|
||||
// Move assignment operator
|
||||
Gnss_Satellite& Gnss_Satellite::operator=(Gnss_Satellite&& other)
|
||||
Gnss_Satellite& Gnss_Satellite::operator=(Gnss_Satellite&& other) noexcept
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
|
@ -62,10 +62,10 @@ public:
|
||||
friend bool operator==(const Gnss_Satellite& /*sat1*/, const Gnss_Satellite& /*sat2*/); //!< operator== for comparison
|
||||
friend std::ostream& operator<<(std::ostream& /*out*/, const Gnss_Satellite& /*sat*/); //!< operator<< for pretty printing
|
||||
|
||||
Gnss_Satellite(Gnss_Satellite&& other); //!< Copy constructor
|
||||
Gnss_Satellite(Gnss_Satellite&& other) noexcept; //!< Copy constructor
|
||||
Gnss_Satellite& operator=(const Gnss_Satellite&); //!< Copy assignment operator
|
||||
Gnss_Satellite(const Gnss_Satellite& other); //!< Move constructor
|
||||
Gnss_Satellite& operator=(Gnss_Satellite&& other); //!< Move assignment operator
|
||||
Gnss_Satellite(const Gnss_Satellite& other) noexcept; //!< Move constructor
|
||||
Gnss_Satellite& operator=(Gnss_Satellite&& other) noexcept; //!< Move assignment operator
|
||||
|
||||
private:
|
||||
uint32_t PRN{};
|
||||
|
@ -49,7 +49,6 @@
|
||||
|
||||
#include <gflags/gflags.h>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstdlib> // for getenv()
|
||||
#include <cstring> // for strncpy
|
||||
#include <fstream>
|
||||
|
@ -33,7 +33,25 @@
|
||||
#include <gnuradio/gr_complex.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <matio.h>
|
||||
#include <cstdio>
|
||||
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for create_directories, exists
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
|
||||
TEST(MatioTest, WriteAndReadDoubles)
|
||||
{
|
||||
@ -73,7 +91,8 @@ TEST(MatioTest, WriteAndReadDoubles)
|
||||
EXPECT_DOUBLE_EQ(x[i], x_read[i]);
|
||||
}
|
||||
Mat_VarFree(matvar_read);
|
||||
ASSERT_EQ(remove(filename.c_str()), 0);
|
||||
errorlib::error_code ec;
|
||||
ASSERT_EQ(fs::remove(fs::path(filename), ec), true);
|
||||
}
|
||||
|
||||
|
||||
@ -156,5 +175,6 @@ TEST(MatioTest, WriteAndReadGrComplex)
|
||||
EXPECT_FLOAT_EQ(x_v[i].real(), x_v_read[i].real());
|
||||
EXPECT_FLOAT_EQ(x_v[i].imag(), x_v_read[i].imag());
|
||||
}
|
||||
ASSERT_EQ(remove(filename.c_str()), 0);
|
||||
errorlib::error_code ec;
|
||||
ASSERT_EQ(fs::remove(fs::path(filename), ec), true);
|
||||
}
|
||||
|
@ -32,10 +32,27 @@
|
||||
#include "nmea_printer.h"
|
||||
#include "rtklib_rtkpos.h"
|
||||
#include "rtklib_solver.h"
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#if HAS_STD_FILESYSTEM
|
||||
#include <system_error>
|
||||
namespace errorlib = std;
|
||||
#if HAS_STD_FILESYSTEM_EXPERIMENTAL
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
#else
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#endif
|
||||
#else
|
||||
#include <boost/filesystem/operations.hpp> // for create_directories, exists
|
||||
#include <boost/filesystem/path.hpp> // for path, operator<<
|
||||
#include <boost/filesystem/path_traits.hpp> // for filesystem
|
||||
#include <boost/system/error_code.hpp> // for error_code
|
||||
namespace fs = boost::filesystem;
|
||||
namespace errorlib = boost::system;
|
||||
#endif
|
||||
|
||||
class NmeaPrinterTest : public ::testing::Test
|
||||
{
|
||||
@ -196,5 +213,6 @@ TEST_F(NmeaPrinterTest, PrintLine)
|
||||
}
|
||||
test_file.close();
|
||||
}
|
||||
EXPECT_EQ(0, remove(filename.c_str())) << "Failure deleting a temporary file.";
|
||||
errorlib::error_code ec;
|
||||
EXPECT_EQ(true, fs::remove(fs::path(filename), ec)) << "Failure deleting a temporary file.";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user