1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

Merge branch 'next' of https://github.com/gnss-sdr/gnss-sdr into next

This commit is contained in:
Carles Fernandez 2019-08-28 16:22:31 +02:00
commit 700acc318c
116 changed files with 781 additions and 434 deletions

View File

@ -1,6 +1,46 @@
--- ---
Checks: '-*, Checks: '-*,
boost-use-to-string, boost-use-to-string,
bugprone-argument-comment,
bugprone-assert-side-effect,
bugprone-bool-pointer-implicit-conversion,
bugprone-copy-constructor-init,
bugprone-dangling-handle,
bugprone-exception-escape,
bugprone-fold-init-type,
bugprone-forward-declaration-namespace,
bugprone-forwarding-reference-overload,
bugprone-inaccurate-erase,
bugprone-incorrect-roundings,
bugprone-integer-division,
bugprone-lambda-function-name,
bugprone-macro-parentheses,
bugprone-macro-repeated-side-effects,
bugprone-misplaced-operator-in-strlen-in-alloc,
bugprone-misplaced-widening-cast,
bugprone-move-forwarding-reference,
bugprone-multiple-statement-macro,
bugprone-parent-virtual-call,
bugprone-sizeof-container,
bugprone-sizeof-expression,
bugprone-string-constructor,
bugprone-string-integer-assignment,
bugprone-string-literal-with-embedded-nul,
bugprone-suspicious-enum-usage,
bugprone-suspicious-memset-usage,
bugprone-suspicious-missing-comma,
bugprone-suspicious-semicolon,
bugprone-suspicious-string-compare,
bugprone-swapped-arguments,
bugprone-terminating-continue,
bugprone-throw-keyword-missing,
bugprone-too-small-loop-variable,
bugprone-undefined-memory-manipulation,
bugprone-undelegated-constructor,
bugprone-unused-raii,
bugprone-unused-return-value,
bugprone-use-after-move,
bugprone-virtual-near-miss,
cert-dcl21-cpp, cert-dcl21-cpp,
cert-dcl58-cpp, cert-dcl58-cpp,
cert-env33-c, cert-env33-c,
@ -75,6 +115,48 @@ HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false AnalyzeTemporaryDtors: false
FormatStyle: 'file' FormatStyle: 'file'
CheckOptions: CheckOptions:
- key: bugprone-argument-comment.StrictMode
value: '0'
- key: bugprone-assert-side-effect.AssertMacros
value: assert
- key: bugprone-assert-side-effect.CheckFunctionCalls
value: '0'
- key: bugprone-dangling-handle.HandleClasses
value: 'std::basic_string_view;std::experimental::basic_string_view'
- key: bugprone-exception-escape.FunctionsThatShouldNotThrow
value: ''
- key: bugprone-exception-escape.IgnoredExceptions
value: ''
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
value: '0'
- key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant
value: '1'
- key: bugprone-sizeof-expression.WarnOnSizeOfConstant
value: '1'
- key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
value: '0'
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
value: '1'
- key: bugprone-string-constructor.LargeLengthThreshold
value: '8388608'
- key: bugprone-string-constructor.WarnOnLargeLength
value: '1'
- key: bugprone-suspicious-enum-usage.StrictMode
value: '0'
- key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens
value: '5'
- key: bugprone-suspicious-missing-comma.RatioThreshold
value: '0.200000'
- key: bugprone-suspicious-missing-comma.SizeThreshold
value: '5'
- key: bugprone-suspicious-string-compare.StringCompareLikeFunctions
value: ''
- key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
value: '1'
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
value: '0'
- key: bugprone-unused-return-value.CheckedFunctions
value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty'
- key: cert-dcl16-c.NewSuffixes - key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU' value: 'L;LL;LU;LLU'
- key: cert-msc51-cpp.DisallowedSeedTypes - key: cert-msc51-cpp.DisallowedSeedTypes

View File

@ -2352,14 +2352,14 @@ endif()
################################################################################ ################################################################################
# Set compiler flags # Set compiler flags
################################################################################ ################################################################################
set(CXX_WARNING_FLAGS -Wall -Wextra)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
# Add warning flags # Add warning flags
# For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html # For "-Wall" see https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
set(cxx_warning_flags -Wall -Wextra)
if(NOT (CMAKE_VERSION VERSION_LESS "3.3")) if(NOT (CMAKE_VERSION VERSION_LESS "3.3"))
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${cxx_warning_flags}>") add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${CXX_WARNING_FLAGS}>")
else() else()
add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${cxx_warning_flags}>") add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CXX_WARNING_FLAGS}>")
endif() endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
add_compile_options(-Wno-missing-field-initializers) add_compile_options(-Wno-missing-field-initializers)
@ -2368,6 +2368,13 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
add_compile_options(-Wno-psabi) add_compile_options(-Wno-psabi)
endif() endif()
endif() endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(NOT (CMAKE_VERSION VERSION_LESS "3.3"))
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${CXX_WARNING_FLAGS}>")
else()
add_compile_options("$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:${CXX_WARNING_FLAGS}>")
endif()
endif()
# Processor-architecture related flags # Processor-architecture related flags
# See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html # See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html

View File

@ -85,7 +85,7 @@ If you are using Arch Linux:
~~~~~~ ~~~~~~
$ pacman -S gcc make cmake git boost boost-libs log4cpp libvolk gnuradio \ $ pacman -S gcc make cmake git boost boost-libs log4cpp libvolk gnuradio \
gnuradio-osmosdr blas lapack gflags google-glog openssl pugixml \ blas lapack gflags google-glog openssl pugixml \
python-mako python-six libmatio libpcap gtest protobuf python-mako python-six libmatio libpcap gtest protobuf
~~~~~~ ~~~~~~

View File

@ -11,19 +11,24 @@
### Improvements in Portability: ### Improvements in Portability:
- The CMake scripts now find dependencies in Debian's riscv64 architecture. - The CMake scripts now find dependencies in Debian's riscv64 architecture.
- Enable AVX2 kernels of the volk_gnsssdr library when using the Clang compiler.
- Added a CMake toolchain for building volk_gnsssdr in a Raspberry Pi.
### Improvements in Reliability: ### Improvements in Reliability:
- Decoding of navigation messages no longer rely on implementation defined behavior for shifting left a signed integer. - Decoding of navigation messages no longer rely on implementation defined behavior for shifting left a signed integer.
- Removed usage of functions with insecure API (e.g., strcpy). - Removed usage of functions with insecure API (e.g., strcpy, sprintf).
- Added clang-tidy checks clang-analyzer-security.*, clang-analyzer-optin.portability.UnixAPI clang-tidy checks. Fixed raised warnings. - Added clang-tidy checks clang-analyzer-security.*, clang-analyzer-optin.portability.UnixAPI clang-tidy checks. Fixed raised warnings.
- Fixed cpplint.py runtime/printf and runtime/explicit errors.
- All constructors callable with one argument are marked with the keyword explicit. See MISRA C++:2008, 12-1-3 - All constructors that are callable with a single argument of fundamental type shall be declared explicit.
### Improvements in Usability: ### Improvements in Usability:
- Improved DLL-PLL binary dump MATLAB/Octave plot script. Old versions removed. - Improved DLL-PLL binary dump MATLAB/Octave plot script. Old versions removed.
- Simplified RTKLIB error log. - Simplified RTKLIB error log.
- Added a Python 3 plotting script to show relative performance of generic volk_gnsssdr kernels wrt SIMD fastest versions.

View File

@ -48,7 +48,7 @@ class Pvt_Solution;
class GeoJSON_Printer class GeoJSON_Printer
{ {
public: public:
GeoJSON_Printer(const std::string& base_path = "."); explicit GeoJSON_Printer(const std::string& base_path = ".");
~GeoJSON_Printer(); ~GeoJSON_Printer();
bool set_headers(const std::string& filename, bool time_tag_name = true); bool set_headers(const std::string& filename, bool time_tag_name = true);
bool print_position(const std::shared_ptr<Pvt_Solution>& position, bool print_average_values); bool print_position(const std::shared_ptr<Pvt_Solution>& position, bool print_average_values);

View File

@ -48,7 +48,7 @@ class Rtklib_Solver;
class Gpx_Printer class Gpx_Printer
{ {
public: public:
Gpx_Printer(const std::string& base_path = "."); explicit Gpx_Printer(const std::string& base_path = ".");
~Gpx_Printer(); ~Gpx_Printer();
bool set_headers(const std::string& filename, bool time_tag_name = true); bool set_headers(const std::string& filename, bool time_tag_name = true);
bool print_position(const std::shared_ptr<Rtklib_Solver>& position, bool print_average_values); bool print_position(const std::shared_ptr<Rtklib_Solver>& position, bool print_average_values);

View File

@ -47,7 +47,7 @@ class Rtklib_Solver;
class Kml_Printer class Kml_Printer
{ {
public: public:
Kml_Printer(const std::string& base_path = std::string(".")); explicit Kml_Printer(const std::string& base_path = std::string("."));
~Kml_Printer(); ~Kml_Printer();
bool set_headers(const std::string& filename, bool time_tag_name = true); bool set_headers(const std::string& filename, bool time_tag_name = true);
bool print_position(const std::shared_ptr<Rtklib_Solver>& position, bool print_average_values); bool print_position(const std::shared_ptr<Rtklib_Solver>& position, bool print_average_values);

View File

@ -34,6 +34,7 @@
#include "geofunctions.h" #include "geofunctions.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <array> #include <array>
#include <cstddef>
Pvt_Solution::Pvt_Solution() Pvt_Solution::Pvt_Solution()
@ -271,7 +272,7 @@ void Pvt_Solution::perform_pos_averaging()
d_avg_latitude_d = 0.0; d_avg_latitude_d = 0.0;
d_avg_longitude_d = 0.0; d_avg_longitude_d = 0.0;
d_avg_height_m = 0.0; d_avg_height_m = 0.0;
for (unsigned int i = 0; i < d_hist_longitude_d.size(); i++) for (size_t i = 0; i < d_hist_longitude_d.size(); i++)
{ {
d_avg_latitude_d = d_avg_latitude_d + d_hist_latitude_d.at(i); d_avg_latitude_d = d_avg_latitude_d + d_hist_latitude_d.at(i);
d_avg_longitude_d = d_avg_longitude_d + d_hist_longitude_d.at(i); d_avg_longitude_d = d_avg_longitude_d + d_hist_longitude_d.at(i);

View File

@ -439,7 +439,7 @@ std::string Rinex_Printer::getLocalTime()
line += std::string(12, ' '); line += std::string(12, ' ');
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -2398,7 +2398,7 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out)
line += Rinex_Printer::leftJustify("GNSS-SDR", 20); line += Rinex_Printer::leftJustify("GNSS-SDR", 20);
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -4842,7 +4842,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -5168,7 +5168,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -5523,7 +5523,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -5832,7 +5832,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris&
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -6155,7 +6155,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -6412,7 +6412,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -6663,7 +6663,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -6944,7 +6944,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -7290,7 +7290,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -7608,7 +7608,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris&
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -7875,7 +7875,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();
@ -8157,7 +8157,7 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme
line.clear(); line.clear();
std::string username; std::string username;
std::array<char, 20> c_username{}; std::array<char, 20> c_username{};
int32_t nGet = getlogin_r(c_username.data(), sizeof(c_username) - 1); int32_t nGet = getlogin_r(c_username.data(), c_username.size() - 1);
if (nGet == 0) if (nGet == 0)
{ {
username = c_username.data(); username = c_username.data();

View File

@ -89,7 +89,7 @@ public:
/*! /*!
* \brief Default constructor. Creates GNSS Navigation and Observables RINEX files and their headers * \brief Default constructor. Creates GNSS Navigation and Observables RINEX files and their headers
*/ */
Rinex_Printer(int version = 0, const std::string& base_path = "."); explicit Rinex_Printer(int version = 0, const std::string& base_path = ".");
/*! /*!
* \brief Default destructor. Closes GNSS Navigation and Observables RINEX files * \brief Default destructor. Closes GNSS Navigation and Observables RINEX files

View File

@ -41,7 +41,7 @@
#include <boost/exception/diagnostic_information.hpp> #include <boost/exception/diagnostic_information.hpp>
#include <algorithm> // for std::reverse #include <algorithm> // for std::reverse
#include <chrono> // std::chrono::seconds #include <chrono> // std::chrono::seconds
#include <cmath> // for std::fmod #include <cmath> // for std::fmod, std::lround
#include <cstdlib> // for strtol #include <cstdlib> // for strtol
#include <iostream> // for cout #include <iostream> // for cout
#include <sstream> // for std::stringstream #include <sstream> // for std::stringstream
@ -201,8 +201,8 @@ std::string Rtcm::bin_to_binary_data(const std::string& s) const
k++; k++;
} }
uint32_t start = std::max(remainder, 0); std::size_t start = std::max(remainder, 0);
for (uint32_t i = start; i < s.length() - 1; i = i + 8) for (std::size_t i = start; i < s.length() - 1; i = i + 8)
{ {
s_aux.assign(s, i, 4); s_aux.assign(s, i, 4);
std::bitset<4> bs(s_aux); std::bitset<4> bs(s_aux);
@ -250,8 +250,8 @@ std::string Rtcm::bin_to_hex(const std::string& s) const
ss << std::hex << n; ss << std::hex << n;
} }
uint32_t start = std::max(remainder, 0); std::size_t start = std::max(remainder, 0);
for (uint32_t i = start; i < s.length() - 1; i = i + 4) for (std::size_t i = start; i < s.length() - 1; i = i + 4)
{ {
s_aux.assign(s, i, 4); s_aux.assign(s, i, 4);
std::bitset<4> bs(s_aux); std::bitset<4> bs(s_aux);
@ -269,7 +269,7 @@ std::string Rtcm::hex_to_bin(const std::string& s) const
std::stringstream ss; std::stringstream ss;
ss << s; ss << s;
std::string s_lower = boost::to_upper_copy(ss.str()); std::string s_lower = boost::to_upper_copy(ss.str());
for (uint32_t i = 0; i < s.length(); i++) for (size_t i = 0; i < s.length(); i++)
{ {
uint64_t n; uint64_t n;
std::istringstream(s_lower.substr(i, 1)) >> std::hex >> n; std::istringstream(s_lower.substr(i, 1)) >> std::hex >> n;
@ -5312,7 +5312,7 @@ int32_t Rtcm::set_DF397(const Gnss_Synchro& gnss_synchro)
} }
else else
{ {
int_ms = static_cast<uint32_t>(std::floor(rough_range_s / meters_to_miliseconds / TWO_N10) + 0.5) >> 10; int_ms = static_cast<uint32_t>(std::lround(rough_range_s / meters_to_miliseconds / TWO_N10)) >> 10;
} }
DF397 = std::bitset<8>(int_ms); DF397 = std::bitset<8>(int_ms);
@ -5331,7 +5331,7 @@ int32_t Rtcm::set_DF398(const Gnss_Synchro& gnss_synchro)
} }
else else
{ {
rr_mod_ms = static_cast<uint32_t>(std::floor(rough_range_m / meters_to_miliseconds / TWO_N10) + 0.5) & 0x3FFU; rr_mod_ms = static_cast<uint32_t>(std::lround(rough_range_m / meters_to_miliseconds / TWO_N10)) & 0x3FFU;
} }
DF398 = std::bitset<10>(rr_mod_ms); DF398 = std::bitset<10>(rr_mod_ms);
return 0; return 0;

View File

@ -44,6 +44,7 @@
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include <glog/logging.h> #include <glog/logging.h>
#include <pmt/pmt.h> #include <pmt/pmt.h>
#include <algorithm> // for min
#include <bitset> #include <bitset>
#include <cstddef> // for size_t #include <cstddef> // for size_t
#include <cstdint> #include <cstdint>
@ -97,7 +98,7 @@ using b_io_context = boost::asio::io_service;
class Rtcm class Rtcm
{ {
public: public:
Rtcm(uint16_t port = 2101); //!< Default constructor that sets TCP port of the RTCM message server and RTCM Station ID. 2101 is the standard RTCM port according to the Internet Assigned Numbers Authority (IANA). See https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml explicit Rtcm(uint16_t port = 2101); //!< Default constructor that sets TCP port of the RTCM message server and RTCM Station ID. 2101 is the standard RTCM port according to the Internet Assigned Numbers Authority (IANA). See https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml
~Rtcm(); ~Rtcm();
/*! /*!
@ -593,7 +594,7 @@ private:
inline void encode_header() inline void encode_header()
{ {
char header[header_length + 1] = ""; char header[header_length + 1] = "";
std::sprintf(header, "GS%4d", static_cast<int>(body_length_)); std::snprintf(header, header_length + 1, "GS%4d", std::max(std::min(static_cast<int>(body_length_), static_cast<int>(max_body_length)), 0));
std::memcpy(data_, header, header_length); std::memcpy(data_, header, header_length);
} }

View File

@ -214,7 +214,7 @@ public:
private: private:
friend pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_); friend pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_);
pcps_acquisition(const Acq_Conf& conf_); explicit pcps_acquisition(const Acq_Conf& conf_);
bool d_active; bool d_active;
bool d_worker_active; bool d_worker_active;
bool d_cshort; bool d_cshort;

View File

@ -194,7 +194,7 @@ public:
private: private:
friend pcps_acquisition_fine_doppler_cc_sptr friend pcps_acquisition_fine_doppler_cc_sptr
pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_); pcps_make_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_); explicit pcps_acquisition_fine_doppler_cc(const Acq_Conf& conf_);
int compute_and_accumulate_grid(gr_vector_const_void_star& input_items); int compute_and_accumulate_grid(gr_vector_const_void_star& input_items);
int estimate_Doppler(); int estimate_Doppler();

View File

@ -203,7 +203,7 @@ public:
private: private:
friend pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_); friend pcps_acquisition_fpga_sptr pcps_make_acquisition_fpga(pcpsconf_fpga_t conf_);
pcps_acquisition_fpga(pcpsconf_fpga_t conf_); explicit pcps_acquisition_fpga(pcpsconf_fpga_t conf_);
bool d_active; bool d_active;
bool d_make_2_steps; bool d_make_2_steps;
uint32_t d_doppler_index; uint32_t d_doppler_index;

View File

@ -50,7 +50,7 @@ class ChannelFsm
{ {
public: public:
ChannelFsm(); ChannelFsm();
ChannelFsm(std::shared_ptr<AcquisitionInterface> acquisition); explicit ChannelFsm(std::shared_ptr<AcquisitionInterface> acquisition);
void set_acquisition(std::shared_ptr<AcquisitionInterface> acquisition); void set_acquisition(std::shared_ptr<AcquisitionInterface> acquisition);
void set_tracking(std::shared_ptr<TrackingInterface> tracking); void set_tracking(std::shared_ptr<TrackingInterface> tracking);

View File

@ -31,6 +31,7 @@
#include "beamformer.h" #include "beamformer.h"
#include <gnuradio/io_signature.h> #include <gnuradio/io_signature.h>
#include <cstddef>
beamformer_sptr make_beamformer_sptr() beamformer_sptr make_beamformer_sptr()
@ -67,7 +68,7 @@ int beamformer::work(int noutput_items, gr_vector_const_void_star &input_items,
for (int n = 0; n < noutput_items; n++) for (int n = 0; n < noutput_items; n++)
{ {
sum = gr_complex(0, 0); sum = gr_complex(0, 0);
for (unsigned int i = 0; i < weight_vector.size(); i++) for (size_t i = 0; i < weight_vector.size(); i++)
{ {
sum = sum + (reinterpret_cast<const gr_complex *>(input_items[i]))[n] * weight_vector[i]; sum = sum + (reinterpret_cast<const gr_complex *>(input_items[i]))[n] * weight_vector[i];
} }

View File

@ -156,7 +156,7 @@ void beidou_b1i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, u
const int32_t _codeLength = 2046; const int32_t _codeLength = 2046;
// --- Find number of samples per spreading code --------------------------- // --- Find number of samples per spreading code ---------------------------
_samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / static_cast<double>(_codeFreqBasis / _codeLength)); _samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
// --- Find time constants ------------------------------------------------- // --- Find time constants -------------------------------------------------
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec _ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec

View File

@ -220,7 +220,7 @@ void beidou_b3i_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, u
const int32_t _codeLength = 10230; const int32_t _codeLength = 10230;
// --- Find number of samples per spreading code --------------------------- // --- Find number of samples per spreading code ---------------------------
_samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / static_cast<double>(_codeFreqBasis / _codeLength)); _samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
// --- Find time constants ------------------------------------------------- // --- Find time constants -------------------------------------------------
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec _ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec

View File

@ -115,7 +115,7 @@ void glonass_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest
const int32_t _codeLength = 511; const int32_t _codeLength = 511;
// --- Find number of samples per spreading code --------------------------- // --- Find number of samples per spreading code ---------------------------
_samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / static_cast<double>(_codeFreqBasis / _codeLength)); _samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
// --- Find time constants ------------------------------------------------- // --- Find time constants -------------------------------------------------
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec _ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec

View File

@ -115,7 +115,7 @@ void glonass_l2_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest
const int32_t _codeLength = 511; const int32_t _codeLength = 511;
// --- Find number of samples per spreading code --------------------------- // --- Find number of samples per spreading code ---------------------------
_samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / static_cast<double>(_codeFreqBasis / _codeLength)); _samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
// --- Find time constants ------------------------------------------------- // --- Find time constants -------------------------------------------------
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec _ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec

View File

@ -34,6 +34,7 @@
#include "gnss_signal_processing.h" #include "gnss_signal_processing.h"
#include "GPS_L1_CA.h" #include "GPS_L1_CA.h"
#include <gnuradio/fxpt_nco.h> #include <gnuradio/fxpt_nco.h>
#include <cstddef> // for size_t
auto auxCeil2 = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); }; auto auxCeil2 = [](float x) { return static_cast<int32_t>(static_cast<int64_t>((x) + 1)); };
@ -168,7 +169,7 @@ void resampler(const gsl::span<float> _from, gsl::span<float> _dest, float _fs_i
// --- Find time constants ------------------------------------------------- // --- Find time constants -------------------------------------------------
const float _t_in = 1 / _fs_in; // Incoming sampling period in sec const float _t_in = 1 / _fs_in; // Incoming sampling period in sec
const float _t_out = 1 / _fs_out; // Out sampling period in sec const float _t_out = 1 / _fs_out; // Out sampling period in sec
for (uint32_t i = 0; i < _dest.size() - 1; i++) for (size_t i = 0; i < _dest.size() - 1; i++)
{ {
// === Digitizing ================================================== // === Digitizing ==================================================
// --- compute index array to read sampled values ------------------ // --- compute index array to read sampled values ------------------
@ -191,7 +192,7 @@ void resampler(gsl::span<const std::complex<float>> _from, gsl::span<std::comple
// --- Find time constants ------------------------------------------------- // --- Find time constants -------------------------------------------------
const float _t_in = 1 / _fs_in; // Incoming sampling period in sec const float _t_in = 1 / _fs_in; // Incoming sampling period in sec
const float _t_out = 1 / _fs_out; // Out sampling period in sec const float _t_out = 1 / _fs_out; // Out sampling period in sec
for (uint32_t i = 0; i < _dest.size() - 1; i++) for (size_t i = 0; i < _dest.size() - 1; i++)
{ {
// === Digitizing ================================================== // === Digitizing ==================================================
// --- compute index array to read sampled values ------------------ // --- compute index array to read sampled values ------------------

View File

@ -166,7 +166,7 @@ void gps_l1_ca_code_gen_complex_sampled(gsl::span<std::complex<float>> _dest, ui
const int32_t _codeLength = 1023; const int32_t _codeLength = 1023;
// --- Find number of samples per spreading code --------------------------- // --- Find number of samples per spreading code ---------------------------
_samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / static_cast<double>(_codeFreqBasis / _codeLength)); _samplesPerCode = static_cast<int32_t>(static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
// --- Find time constants ------------------------------------------------- // --- Find time constants -------------------------------------------------
_ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec _ts = 1.0 / static_cast<float>(_fs); // Sampling period in sec

View File

@ -66,7 +66,7 @@ static string
num2str(int num) num2str(int num)
{ {
char temp[200]; char temp[200];
sprintf(temp, "%d", num); snprintf(temp, sizeof(temp), "%d", num);
return string(temp); return string(temp);
} }
@ -814,7 +814,7 @@ createLocalMemfftKernelString(cl_fft_plan *plan)
(*kInfo)->in_place_possible = 1; (*kInfo)->in_place_possible = 1;
(*kInfo)->next = nullptr; (*kInfo)->next = nullptr;
(*kInfo)->kernel_name = (char *)malloc(sizeof(char) * (kernelName.size() + 1)); (*kInfo)->kernel_name = (char *)malloc(sizeof(char) * (kernelName.size() + 1));
strcpy((*kInfo)->kernel_name, kernelName.c_str()); snprintf((*kInfo)->kernel_name, sizeof((*kInfo)->kernel_name), kernelName.c_str());
unsigned int numWorkItemsPerXForm = n / radixArray[0]; unsigned int numWorkItemsPerXForm = n / radixArray[0];
unsigned int numWorkItemsPerWG = numWorkItemsPerXForm <= 64 ? 64 : numWorkItemsPerXForm; unsigned int numWorkItemsPerWG = numWorkItemsPerXForm <= 64 ? 64 : numWorkItemsPerXForm;
@ -1035,7 +1035,7 @@ createGlobalFFTKernelString(cl_fft_plan *plan, int n, int BS, cl_fft_kernel_dir
(*kInfo)->in_place_possible = 0; (*kInfo)->in_place_possible = 0;
(*kInfo)->next = nullptr; (*kInfo)->next = nullptr;
(*kInfo)->kernel_name = (char *)malloc(sizeof(char) * (kernelName.size() + 1)); (*kInfo)->kernel_name = (char *)malloc(sizeof(char) * (kernelName.size() + 1));
strcpy((*kInfo)->kernel_name, kernelName.c_str()); snprintf((*kInfo)->kernel_name, sizeof((*kInfo)->kernel_name), kernelName.c_str());
insertVariables(localString, R1); insertVariables(localString, R1);

View File

@ -463,7 +463,7 @@ void readtec(const char *file, nav_t *nav, int opt)
} }
for (i = 0; i < MAXEXFILE; i++) for (i = 0; i < MAXEXFILE; i++)
{ {
if (!(efiles[i] = static_cast<char *>(malloc(1024)))) if (!(efiles[i] = static_cast<char *>(malloc(MAXSTRPATH + 255))))
{ {
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
{ {

View File

@ -595,7 +595,7 @@ int valsol(const double *azel, const int *vsat, int n,
vv = dot(v, v, nv); vv = dot(v, v, nv);
if (nv > nx && vv > CHISQR[nv - nx - 1]) if (nv > nx && vv > CHISQR[nv - nx - 1])
{ {
sprintf(msg, "chi-square error nv=%d vv=%.1f cs=%.1f", nv, vv, CHISQR[nv - nx - 1]); std::snprintf(msg, MAXSOLBUF, "chi-square error nv=%d vv=%.1f cs=%.1f", nv, vv, CHISQR[nv - nx - 1]);
return 0; return 0;
} }
/* large gdop check */ /* large gdop check */
@ -612,7 +612,7 @@ int valsol(const double *azel, const int *vsat, int n,
dops(ns, azels, opt->elmin, dop); dops(ns, azels, opt->elmin, dop);
if (dop[0] <= 0.0 || dop[0] > opt->maxgdop) if (dop[0] <= 0.0 || dop[0] > opt->maxgdop)
{ {
sprintf(msg, "gdop error nv=%d gdop=%.1f", nv, dop[0]); std::snprintf(msg, MAXSOLBUF, "gdop error nv=%d gdop=%.1f", nv, dop[0]);
return 0; return 0;
} }
return 1; return 1;
@ -639,6 +639,7 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts,
int stat; int stat;
int nv; int nv;
int ns; int ns;
char msg_aux[128];
trace(3, "estpos : n=%d\n", n); trace(3, "estpos : n=%d\n", n);
@ -658,7 +659,7 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts,
if (nv < NX) if (nv < NX)
{ {
sprintf(msg, "lack of valid sats ns=%d", nv); std::snprintf(msg_aux, sizeof(msg_aux), "lack of valid sats ns=%d", nv);
break; break;
} }
/* weight by variance */ /* weight by variance */
@ -674,7 +675,7 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts,
/* least square estimation */ /* least square estimation */
if ((info = lsq(H, v, NX, nv, dx, Q))) if ((info = lsq(H, v, NX, nv, dx, Q)))
{ {
sprintf(msg, "lsq error info=%d", info); std::snprintf(msg_aux, sizeof(msg_aux), "lsq error info=%d", info);
break; break;
} }
for (j = 0; j < NX; j++) for (j = 0; j < NX; j++)
@ -712,18 +713,19 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts,
free(v); free(v);
free(H); free(H);
free(var); free(var);
msg = msg_aux;
return stat; return stat;
} }
} }
if (i >= MAXITR) if (i >= MAXITR)
{ {
sprintf(msg, "iteration divergent i=%d", i); std::snprintf(msg_aux, sizeof(msg_aux), "iteration divergent i=%d", i);
} }
free(v); free(v);
free(H); free(H);
free(var); free(var);
msg = msg_aux;
return 0; return 0;
} }

View File

@ -420,7 +420,7 @@ void readsp3(const char *file, nav_t *nav, int opt)
for (i = 0; i < MAXEXFILE; i++) for (i = 0; i < MAXEXFILE; i++)
{ {
if (!(efiles[i] = static_cast<char *>(malloc(1024)))) if (!(efiles[i] = static_cast<char *>(malloc(MAXSTRPATH + 255))))
{ {
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
{ {
@ -601,7 +601,7 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta)
} }
for (i = 0; i < MAXEXFILE; i++) for (i = 0; i < MAXEXFILE; i++)
{ {
if (!(efiles[i] = static_cast<char *>(malloc(1024)))) if (!(efiles[i] = static_cast<char *>(malloc(MAXSTRPATH + 255))))
{ {
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
{ {

View File

@ -644,7 +644,7 @@ int decode_rtcm2(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
sprintf(rtcm->msgtype, "RTCM %2d (%4d) zcnt=%7.1f staid=%3d seqno=%d", std::snprintf(rtcm->msgtype, sizeof(rtcm->msgtype), "RTCM %2d (%4d) zcnt=%7.1f staid=%3d seqno=%d",
type, rtcm->len, zcnt, staid, seqno); type, rtcm->len, zcnt, staid, seqno);
} }
if (type == 3 || type == 22 || type == 23 || type == 24) if (type == 3 || type == 22 || type == 23 || type == 24)

View File

@ -317,7 +317,7 @@ int decode_head1001(rtcm_t *rtcm, int *sync)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " staid=%4d %s nsat=%2d sync=%d", staid, std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d %s nsat=%2d sync=%d", staid,
time_str(rtcm->time, 2), nsat, *sync); time_str(rtcm->time, 2), nsat, *sync);
} }
return nsat; return nsat;
@ -583,7 +583,7 @@ int decode_type1005(rtcm_t *rtcm)
re[j] = rr[j] * 0.0001; re[j] = rr[j] * 0.0001;
} }
ecef2pos(re, pos); ecef2pos(re, pos);
sprintf(msg, " staid=%4d pos=%.8f %.8f %.3f", staid, pos[0] * R2D, pos[1] * R2D, std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d pos=%.8f %.8f %.3f", staid, pos[0] * R2D, pos[1] * R2D,
pos[2]); pos[2]);
} }
/* test station id */ /* test station id */
@ -644,7 +644,7 @@ int decode_type1006(rtcm_t *rtcm)
re[j] = rr[j] * 0.0001; re[j] = rr[j] * 0.0001;
} }
ecef2pos(re, pos); ecef2pos(re, pos);
sprintf(msg, " staid=%4d pos=%.8f %.8f %.3f anth=%.3f", staid, pos[0] * R2D, std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d pos=%.8f %.8f %.3f anth=%.3f", staid, pos[0] * R2D,
pos[1] * R2D, pos[2], anth); pos[1] * R2D, pos[2], anth);
} }
/* test station id */ /* test station id */
@ -697,7 +697,7 @@ int decode_type1007(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " staid=%4d", staid); std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d", staid);
} }
/* test station id */ /* test station id */
if (!test_staid(rtcm, staid)) if (!test_staid(rtcm, staid))
@ -754,7 +754,7 @@ int decode_type1008(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " staid=%4d", staid); std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d", staid);
} }
/* test station id */ /* test station id */
if (!test_staid(rtcm, staid)) if (!test_staid(rtcm, staid))
@ -813,7 +813,7 @@ int decode_head1009(rtcm_t *rtcm, int *sync)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " staid=%4d %s nsat=%2d sync=%d", staid, std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d %s nsat=%2d sync=%d", staid,
time_str(rtcm->time, 2), nsat, *sync); time_str(rtcm->time, 2), nsat, *sync);
} }
return nsat; return nsat;
@ -1127,7 +1127,7 @@ int decode_type1019(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X",
prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh); prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh);
} }
if (!(sat = satno(sys, prn))) if (!(sat = satno(sys, prn)))
@ -1228,7 +1228,7 @@ int decode_type1020(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " prn=%2d tk=%02.0f:%02.0f:%02.0f frq=%2d bn=%d tb=%d", std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d tk=%02.0f:%02.0f:%02.0f frq=%2d bn=%d tb=%d",
prn, tk_h, tk_m, tk_s, geph.frq, bn, tb); prn, tk_h, tk_m, tk_s, geph.frq, bn, tb);
} }
geph.sat = sat; geph.sat = sat;
@ -1371,7 +1371,7 @@ int decode_type1029(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " staid=%4d text=%s", staid, rtcm->msg); std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d text=%s", staid, rtcm->msg);
} }
return 0; return 0;
} }
@ -1469,7 +1469,7 @@ int decode_type1033(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " staid=%4d", staid); std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d", staid);
} }
/* test station id */ /* test station id */
if (!test_staid(rtcm, staid)) if (!test_staid(rtcm, staid))
@ -1619,7 +1619,7 @@ int decode_type1044(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " prn=%3d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%3d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X",
prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh); prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh);
} }
if (!(sat = satno(sys, prn))) if (!(sat = satno(sys, prn)))
@ -1732,7 +1732,7 @@ int decode_type1045(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d", std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d",
prn, eph.iode, week, eph.toes, toc, e5a_hs, e5a_dvs); prn, eph.iode, week, eph.toes, toc, e5a_hs, e5a_dvs);
} }
if (!(sat = satno(sys, prn))) if (!(sat = satno(sys, prn)))
@ -1846,7 +1846,7 @@ int decode_type1046(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d", std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d",
prn, eph.iode, week, eph.toes, toc, e5a_hs, e5a_dvs); prn, eph.iode, week, eph.toes, toc, e5a_hs, e5a_dvs);
} }
if (!(sat = satno(sys, prn))) if (!(sat = satno(sys, prn)))
@ -1963,7 +1963,7 @@ int decode_type1047(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X",
prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh); prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh);
} }
if (!(sat = satno(sys, prn))) if (!(sat = satno(sys, prn)))
@ -2077,7 +2077,7 @@ int decode_type63(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", std::snprintf(msg, sizeof(rtcm->msgtype), " prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X",
prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh); prn, eph.iode, eph.iodc, week, eph.toes, toc, eph.svh);
} }
if (!(sat = satno(sys, prn))) if (!(sat = satno(sys, prn)))
@ -2162,7 +2162,7 @@ int decode_ssr1_head(rtcm_t *rtcm, int sys, int *sync, int *iod,
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " %s nsat=%2d iod=%2d udi=%2d sync=%d", std::snprintf(msg, sizeof(rtcm->msgtype), " %s nsat=%2d iod=%2d udi=%2d sync=%d",
time_str(rtcm->time, 2), nsat, *iod, udi, *sync); time_str(rtcm->time, 2), nsat, *iod, udi, *sync);
} }
*hsize = i; *hsize = i;
@ -2224,7 +2224,7 @@ int decode_ssr2_head(rtcm_t *rtcm, int sys, int *sync, int *iod,
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " %s nsat=%2d iod=%2d udi=%2d sync=%d", std::snprintf(msg, sizeof(rtcm->msgtype), " %s nsat=%2d iod=%2d udi=%2d sync=%d",
time_str(rtcm->time, 2), nsat, *iod, udi, *sync); time_str(rtcm->time, 2), nsat, *iod, udi, *sync);
} }
*hsize = i; *hsize = i;
@ -2290,7 +2290,7 @@ int decode_ssr7_head(rtcm_t *rtcm, int sys, int *sync, int *iod,
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " %s nsat=%2d iod=%2d udi=%2d sync=%d", std::snprintf(msg, sizeof(rtcm->msgtype), " %s nsat=%2d iod=%2d udi=%2d sync=%d",
time_str(rtcm->time, 2), nsat, *iod, udi, *sync); time_str(rtcm->time, 2), nsat, *iod, udi, *sync);
} }
*hsize = i; *hsize = i;
@ -3167,14 +3167,14 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r,
{ {
if (q) if (q)
{ {
q += sprintf(q, "L%s%s", sig[i], i < h->nsig - 1 ? ", " : ""); q += std::snprintf(q, sizeof(rtcm->msmtype[0]), "L%s%s", sig[i], i < h->nsig - 1 ? ", " : "");
} }
} }
else else
{ {
if (q) if (q)
{ {
q += sprintf(q, "(%d)%s", h->sigs[i], i < h->nsig - 1 ? ", " : ""); q += std::snprintf(q, sizeof(rtcm->msmtype[0]), "(%d)%s", h->sigs[i], i < h->nsig - 1 ? ", " : "");
} }
trace(2, "rtcm3 %d: unknown signal id=%2d\n", type, h->sigs[i]); trace(2, "rtcm3 %d: unknown signal id=%2d\n", type, h->sigs[i]);
@ -3372,7 +3372,7 @@ int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod,
if (rtcm->outtype) if (rtcm->outtype)
{ {
msg = rtcm->msgtype + strlen(rtcm->msgtype); msg = rtcm->msgtype + strlen(rtcm->msgtype);
sprintf(msg, " staid=%4d %s nsat=%2d nsig=%2d iod=%2d ncell=%2d sync=%d", std::snprintf(msg, sizeof(rtcm->msgtype), " staid=%4d %s nsat=%2d nsig=%2d iod=%2d ncell=%2d sync=%d",
staid, time_str(rtcm->time, 2), h->nsat, h->nsig, *iod, ncell, *sync); staid, time_str(rtcm->time, 2), h->nsat, h->nsig, *iod, ncell, *sync);
} }
return ncell; return ncell;
@ -3893,7 +3893,7 @@ int decode_rtcm3(rtcm_t *rtcm)
if (rtcm->outtype) if (rtcm->outtype)
{ {
sprintf(rtcm->msgtype, "RTCM %4d (%4d):", type, rtcm->len); std::snprintf(rtcm->msgtype, sizeof(rtcm->msgtype), "RTCM %4d (%4d):", type, rtcm->len);
} }
/* real-time input option */ /* real-time input option */
if (strstr(rtcm->opt, "-RT_INP")) if (strstr(rtcm->opt, "-RT_INP"))

View File

@ -476,34 +476,34 @@ int satid2no(const char *id)
void satno2id(int sat, char *id) void satno2id(int sat, char *id)
{ {
int prn; int prn;
char id_aux[16];
switch (satsys(sat, &prn)) switch (satsys(sat, &prn))
{ {
case SYS_GPS: case SYS_GPS:
sprintf(id, "G%02d", prn - MINPRNGPS + 1); std::snprintf(id, sizeof(id_aux), "G%02d", prn - MINPRNGPS + 1);
return; return;
case SYS_GLO: case SYS_GLO:
sprintf(id, "R%02d", prn - MINPRNGLO + 1); snprintf(id, sizeof(id_aux), "R%02d", prn - MINPRNGLO + 1);
return; return;
case SYS_GAL: case SYS_GAL:
sprintf(id, "E%02d", prn - MINPRNGAL + 1); std::snprintf(id, sizeof(id_aux), "E%02d", prn - MINPRNGAL + 1);
return; return;
case SYS_QZS: case SYS_QZS:
sprintf(id, "J%02d", prn - MINPRNQZS + 1); std::snprintf(id, sizeof(id_aux), "J%02d", prn - MINPRNQZS + 1);
return; return;
case SYS_BDS: case SYS_BDS:
sprintf(id, "C%02d", prn - MINPRNBDS + 1); std::snprintf(id, sizeof(id_aux), "C%02d", prn - MINPRNBDS + 1);
return; return;
case SYS_IRN: case SYS_IRN:
sprintf(id, "I%02d", prn - MINPRNIRN + 1); std::snprintf(id, sizeof(id_aux), "I%02d", prn - MINPRNIRN + 1);
return; return;
case SYS_LEO: case SYS_LEO:
sprintf(id, "L%02d", prn - MINPRNLEO + 1); std::snprintf(id, sizeof(id_aux), "L%02d", prn - MINPRNLEO + 1);
return; return;
case SYS_SBS: case SYS_SBS:
sprintf(id, "%03d", prn); std::snprintf(id, sizeof(id_aux), "%03d", prn);
return; return;
} }
std::strncpy(id, "", 1);
} }
@ -1448,7 +1448,7 @@ void matsprint(const double A[], int n, int m, int p, int q, std::string &buffer
for (j = 0; j < m; j++) for (j = 0; j < m; j++)
{ {
char buf_[256]; char buf_[256];
sprintf(buf_, " %*.*f", p, q, A[i + j * n]); std::snprintf(buf_, sizeof(buf_), " %*.*f", p, q, A[i + j * n]);
std::string s(buf_); std::string s(buf_);
buffer += s; buffer += s;
} }
@ -1584,11 +1584,11 @@ void time2epoch(gtime_t t, double *ep)
break; break;
} }
} }
ep[0] = 1970 + days / 1461 * 4 + mon / 12; ep[0] = 1970 + static_cast<int>(days / 1461) * 4 + static_cast<int>(mon / 12);
ep[1] = mon % 12 + 1; ep[1] = mon % 12 + 1;
ep[2] = day + 1; ep[2] = day + 1;
ep[3] = sec / 3600; ep[3] = static_cast<int>(sec / 3600);
ep[4] = sec % 3600 / 60; ep[4] = static_cast<int>(sec % 3600 / 60);
ep[5] = sec % 60 + t.sec; ep[5] = sec % 60 + t.sec;
} }
@ -2073,7 +2073,7 @@ void time2str(gtime_t t, char *s, int n)
t.sec = 0.0; t.sec = 0.0;
}; };
time2epoch(t, ep); time2epoch(t, ep);
sprintf(s, "%04.0f/%02.0f/%02.0f %02.0f:%02.0f:%0*.*f", ep[0], ep[1], ep[2], std::snprintf(s, MAXSTATMSG, "%04.0f/%02.0f/%02.0f %02.0f:%02.0f:%0*.*f", ep[0], ep[1], ep[2],
ep[3], ep[4], n <= 0 ? 2 : n + 3, n <= 0 ? 0 : n, ep[5]); ep[3], ep[4], n <= 0 ? 2 : n + 3, n <= 0 ? 0 : n, ep[5]);
} }
@ -4147,7 +4147,7 @@ int repstr(char *str, const char *pat, const char *rep)
} }
strncpy(r, p, q - p); strncpy(r, p, q - p);
r += q - p; r += q - p;
r += sprintf(r, "%s", rep); r += std::snprintf(r, sizeof(buff), "%s", rep);
} }
if (p <= str) if (p <= str)
{ {
@ -4227,35 +4227,35 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov,
ep0[0] = ep[0]; ep0[0] = ep[0];
dow = static_cast<int>(floor(time2gpst(time, &week) / 86400.0)); dow = static_cast<int>(floor(time2gpst(time, &week) / 86400.0));
doy = static_cast<int>(floor(timediff(time, epoch2time(ep0)) / 86400.0)) + 1; doy = static_cast<int>(floor(timediff(time, epoch2time(ep0)) / 86400.0)) + 1;
sprintf(rep, "%02d", (static_cast<int>(ep[3]) / 3) * 3); std::snprintf(rep, sizeof(rep), "%02d", (static_cast<int>(ep[3]) / 3) * 3);
stat |= repstr(rpath, "%ha", rep); stat |= repstr(rpath, "%ha", rep);
sprintf(rep, "%02d", (static_cast<int>(ep[3]) / 6) * 6); std::snprintf(rep, sizeof(rep), "%02d", (static_cast<int>(ep[3]) / 6) * 6);
stat |= repstr(rpath, "%hb", rep); stat |= repstr(rpath, "%hb", rep);
sprintf(rep, "%02d", (static_cast<int>(ep[3]) / 12) * 12); std::snprintf(rep, sizeof(rep), "%02d", (static_cast<int>(ep[3]) / 12) * 12);
stat |= repstr(rpath, "%hc", rep); stat |= repstr(rpath, "%hc", rep);
sprintf(rep, "%04.0f", ep[0]); std::snprintf(rep, sizeof(rep), "%04.0f", ep[0]);
stat |= repstr(rpath, "%Y", rep); stat |= repstr(rpath, "%Y", rep);
sprintf(rep, "%02.0f", fmod(ep[0], 100.0)); std::snprintf(rep, sizeof(rep), "%02.0f", fmod(ep[0], 100.0));
stat |= repstr(rpath, "%y", rep); stat |= repstr(rpath, "%y", rep);
sprintf(rep, "%02.0f", ep[1]); std::snprintf(rep, sizeof(rep), "%02.0f", ep[1]);
stat |= repstr(rpath, "%m", rep); stat |= repstr(rpath, "%m", rep);
sprintf(rep, "%02.0f", ep[2]); std::snprintf(rep, sizeof(rep), "%02.0f", ep[2]);
stat |= repstr(rpath, "%d", rep); stat |= repstr(rpath, "%d", rep);
sprintf(rep, "%02.0f", ep[3]); std::snprintf(rep, sizeof(rep), "%02.0f", ep[3]);
stat |= repstr(rpath, "%h", rep); stat |= repstr(rpath, "%h", rep);
sprintf(rep, "%02.0f", ep[4]); std::snprintf(rep, sizeof(rep), "%02.0f", ep[4]);
stat |= repstr(rpath, "%M", rep); stat |= repstr(rpath, "%M", rep);
sprintf(rep, "%02.0f", floor(ep[5])); std::snprintf(rep, sizeof(rep), "%02.0f", floor(ep[5]));
stat |= repstr(rpath, "%S", rep); stat |= repstr(rpath, "%S", rep);
sprintf(rep, "%03d", doy); std::snprintf(rep, sizeof(rep), "%03d", doy);
stat |= repstr(rpath, "%n", rep); stat |= repstr(rpath, "%n", rep);
sprintf(rep, "%04d", week); std::snprintf(rep, sizeof(rep), "%04d", week);
stat |= repstr(rpath, "%W", rep); stat |= repstr(rpath, "%W", rep);
sprintf(rep, "%d", dow); std::snprintf(rep, sizeof(rep), "%d", dow);
stat |= repstr(rpath, "%D", rep); stat |= repstr(rpath, "%D", rep);
sprintf(rep, "%c", 'a' + static_cast<int>(ep[3])); std::snprintf(rep, sizeof(rep), "%c", 'a' + static_cast<int>(ep[3]));
stat |= repstr(rpath, "%H", rep); stat |= repstr(rpath, "%H", rep);
sprintf(rep, "%02d", (static_cast<int>(ep[4]) / 15) * 15); std::snprintf(rep, sizeof(rep), "%02d", (static_cast<int>(ep[4]) / 15) * 15);
stat |= repstr(rpath, "%t", rep); stat |= repstr(rpath, "%t", rep);
} }
else if (strstr(rpath, "%ha") || strstr(rpath, "%hb") || strstr(rpath, "%hc") || else if (strstr(rpath, "%ha") || strstr(rpath, "%hb") || strstr(rpath, "%hc") ||
@ -5114,7 +5114,7 @@ int rtk_uncompress(const char *file, char *uncfile)
{ {
std::strncpy(uncfile, tmpfile, 1024); std::strncpy(uncfile, tmpfile, 1024);
uncfile[p - tmpfile] = '\0'; uncfile[p - tmpfile] = '\0';
sprintf(cmd, R"(gzip -f -d -c "%s" > "%s")", tmpfile, uncfile); std::snprintf(cmd, sizeof(cmd), R"(gzip -f -d -c "%s" > "%s")", tmpfile, uncfile);
if (execcmd(cmd)) if (execcmd(cmd))
{ {
@ -5144,8 +5144,6 @@ int rtk_uncompress(const char *file, char *uncfile)
dir = fname; dir = fname;
fname = p + 1; fname = p + 1;
} }
// sprintf(cmd, "tar -C \"%s\" -xf \"%s\"", dir, tmpfile);
// NOTE: This sprintf triggers a format overflow warning. Replaced by:
std::ostringstream temp; std::ostringstream temp;
std::string s_aux1(dir); std::string s_aux1(dir);
std::string s_aux2(tmpfile); std::string s_aux2(tmpfile);
@ -5185,7 +5183,7 @@ int rtk_uncompress(const char *file, char *uncfile)
{ {
std::strncpy(uncfile, tmpfile, 1024); std::strncpy(uncfile, tmpfile, 1024);
uncfile[p - tmpfile + 3] = *(p + 3) == 'D' ? 'O' : 'o'; uncfile[p - tmpfile + 3] = *(p + 3) == 'D' ? 'O' : 'o';
sprintf(cmd, R"(crx2rnx < "%s" > "%s")", tmpfile, uncfile); std::snprintf(cmd, sizeof(cmd), R"(crx2rnx < "%s" > "%s")", tmpfile, uncfile);
if (execcmd(cmd)) if (execcmd(cmd))
{ {
@ -5256,8 +5254,8 @@ int expath(const char *path, char *paths[], int nmax)
{ {
continue; continue;
} }
sprintf(s1, "^%s$", d->d_name); std::snprintf(s1, sizeof(s1), "^%s$", d->d_name);
sprintf(s2, "^%s$", file); std::snprintf(s2, sizeof(s2), "^%s$", file);
for (p = s1; *p; p++) for (p = s1; *p; p++)
{ {
*p = static_cast<char>(tolower(static_cast<int>(*p))); *p = static_cast<char>(tolower(static_cast<int>(*p)));
@ -5280,7 +5278,7 @@ int expath(const char *path, char *paths[], int nmax)
} }
if (p && n < nmax) if (p && n < nmax)
{ {
sprintf(paths[n++], "%s%s", dir, d->d_name); std::snprintf(paths[n++], MAXSTRPATH + 255, "%s%s", dir, d->d_name);
} }
} }
closedir(dp); closedir(dp);

View File

@ -524,7 +524,7 @@ void errmsg(rtk_t *rtk, const char *format, ...)
int n; int n;
va_list ap; va_list ap;
time2str(rtk->sol.time, tstr, 2); time2str(rtk->sol.time, tstr, 2);
n = sprintf(buff, "%s: ", tstr + 11); n = std::snprintf(buff, sizeof(buff), "%s: ", tstr + 11);
va_start(ap, format); va_start(ap, format);
n += vsprintf(buff + n, format, ap); n += vsprintf(buff + n, format, ap);
va_end(ap); va_end(ap);

View File

@ -64,7 +64,7 @@
/* write solution header to output stream ------------------------------------*/ /* write solution header to output stream ------------------------------------*/
void writesolhead(stream_t *stream, const solopt_t *solopt) void writesolhead(stream_t *stream, const solopt_t *solopt)
{ {
unsigned char buff[1024]; unsigned char buff[MAXSOLMSG];
int n; int n;
n = outsolheads(buff, solopt); n = outsolheads(buff, solopt);
strwrite(stream, buff, n); strwrite(stream, buff, n);
@ -88,7 +88,7 @@ void saveoutbuf(rtksvr_t *svr, unsigned char *buff, int n, int index)
void writesol(rtksvr_t *svr, int index) void writesol(rtksvr_t *svr, int index)
{ {
solopt_t solopt = SOLOPT_DEFAULT; solopt_t solopt = SOLOPT_DEFAULT;
unsigned char buff[1024]; unsigned char buff[MAXSOLMSG];
int i; int i;
int n; int n;
@ -1247,7 +1247,7 @@ void rtksvrsstat(rtksvr_t *svr, int *sstat, char *msg)
sstat[i] = strstat(svr->stream + i, s); sstat[i] = strstat(svr->stream + i, s);
if (*s) if (*s)
{ {
p += sprintf(p, "(%d) %s ", i + 1, s); p += std::snprintf(p, MAXSTRMSG, "(%d) %s ", i + 1, s);
} }
} }
rtksvrunlock(svr); rtksvrunlock(svr);

View File

@ -61,6 +61,7 @@
#include "rtklib_sbas.h" #include "rtklib_sbas.h"
#include "rtklib_rtkcmn.h" #include "rtklib_rtkcmn.h"
#include <cmath> // for lround
#include <cstring> #include <cstring>
/* extract field from line ---------------------------------------------------*/ /* extract field from line ---------------------------------------------------*/
@ -727,7 +728,7 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te,
sbs->msgs = sbs_msgs; sbs->msgs = sbs_msgs;
} }
sbs->msgs[sbs->n].week = week; sbs->msgs[sbs->n].week = week;
sbs->msgs[sbs->n].tow = static_cast<int>(tow + 0.5); sbs->msgs[sbs->n].tow = static_cast<int>(std::lround(tow));
sbs->msgs[sbs->n].prn = prn; sbs->msgs[sbs->n].prn = prn;
for (i = 0; i < 29; i++) for (i = 0; i < 29; i++)
{ {
@ -782,7 +783,7 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te,
for (i = 0; i < MAXEXFILE; i++) for (i = 0; i < MAXEXFILE; i++)
{ {
if (!(efiles[i] = static_cast<char *>(malloc(1024)))) if (!(efiles[i] = static_cast<char *>(malloc(MAXSTRPATH + 255))))
{ {
for (i--; i >= 0; i--) for (i--; i >= 0; i--)
{ {

View File

@ -55,6 +55,7 @@
#include "rtklib_rtkcmn.h" #include "rtklib_rtkcmn.h"
#include "rtklib_rtksvr.h" #include "rtklib_rtksvr.h"
#include <cctype> #include <cctype>
#include <cmath>
#include <cstring> #include <cstring>
@ -1326,7 +1327,7 @@ int decode_solstat(char *buff, solstat_t *stat)
stat->resp = static_cast<float>(resp); stat->resp = static_cast<float>(resp);
stat->resc = static_cast<float>(resc); stat->resc = static_cast<float>(resc);
stat->flag = static_cast<unsigned char>((vsat << 5) + (slip << 3) + fix); stat->flag = static_cast<unsigned char>((vsat << 5) + (slip << 3) + fix);
stat->snr = static_cast<unsigned char>(snr * 4.0 + 0.5); stat->snr = static_cast<unsigned char>(std::lround(snr * 4.0));
stat->lock = static_cast<uint16_t>(lock); stat->lock = static_cast<uint16_t>(lock);
stat->outc = static_cast<uint16_t>(outc); stat->outc = static_cast<uint16_t>(outc);
stat->slipc = static_cast<uint16_t>(slipc); stat->slipc = static_cast<uint16_t>(slipc);
@ -1411,7 +1412,7 @@ int readsolstatt(char *files[], int nfile, gtime_t ts, gtime_t te,
for (i = 0; i < nfile; i++) for (i = 0; i < nfile; i++)
{ {
sprintf(path, "%s.stat", files[i]); std::snprintf(path, sizeof(path), "%s.stat", files[i]);
if (!(fp = fopen(path, "re"))) if (!(fp = fopen(path, "re")))
{ {
trace(1, "readsolstatt: file open error %s\n", path); trace(1, "readsolstatt: file open error %s\n", path);
@ -1447,7 +1448,7 @@ int outecef(unsigned char *buff, const char *s, const sol_t *sol,
trace(3, "outecef:\n"); trace(3, "outecef:\n");
p += snprintf(p, 255, "%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", p += std::snprintf(p, MAXSOLBUF, "%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n",
s, sep, sol->rr[0], sep, sol->rr[1], sep, sol->rr[2], sep, sol->stat, sep, s, sep, sol->rr[0], sep, sol->rr[1], sep, sol->rr[2], sep, sol->stat, sep,
sol->ns, sep, SQRT_SOL(sol->qr[0]), sep, SQRT_SOL(sol->qr[1]), sep, SQRT_SOL(sol->qr[2]), 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, sqvar(sol->qr[3]), sep, sqvar(sol->qr[4]), sep, sqvar(sol->qr[5]),
@ -1467,6 +1468,8 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol,
double Q[9]; double Q[9];
const char *sep = opt2sep(opt); const char *sep = opt2sep(opt);
char *p = reinterpret_cast<char *>(buff); char *p = reinterpret_cast<char *>(buff);
char *start;
start = p;
trace(3, "outpos :\n"); trace(3, "outpos :\n");
@ -1481,15 +1484,15 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol,
{ {
deg2dms(pos[0] * R2D, dms1); deg2dms(pos[0] * R2D, dms1);
deg2dms(pos[1] * R2D, dms2); deg2dms(pos[1] * R2D, dms2);
p += sprintf(p, "%s%s%4.0f%s%02.0f%s%08.5f%s%4.0f%s%02.0f%s%08.5f", s, sep, p += std::snprintf(p, MAXSOLMSG - (p - start), "%s%s%4.0f%s%02.0f%s%08.5f%s%4.0f%s%02.0f%s%08.5f", s, sep,
dms1[0], sep, dms1[1], sep, dms1[2], sep, dms2[0], sep, dms2[1], sep, dms1[0], sep, dms1[1], sep, dms1[2], sep, dms2[0], sep, dms2[1], sep,
dms2[2]); dms2[2]);
} }
else else
{ {
p += sprintf(p, "%s%s%14.9f%s%14.9f", s, sep, pos[0] * R2D, sep, pos[1] * R2D); p += std::snprintf(p, MAXSOLMSG - (p - start), "%s%s%14.9f%s%14.9f", s, sep, pos[0] * R2D, sep, pos[1] * R2D);
} }
p += sprintf(p, "%s%10.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", p += std::snprintf(p, MAXSOLMSG - (p - start), "%s%10.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n",
sep, pos[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[4]), sep, 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]), 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); sep, sqvar(Q[5]), sep, sol->age, sep, sol->ratio);
@ -1520,7 +1523,7 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol,
soltocov(sol, P); soltocov(sol, P);
covenu(pos, P, Q); covenu(pos, P, Q);
ecef2enu(pos, rr, enu); ecef2enu(pos, rr, enu);
p += sprintf(p, "%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", p += std::snprintf(p, MAXSOLMSG, "%s%s%14.4f%s%14.4f%s%14.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n",
s, sep, enu[0], sep, enu[1], sep, enu[2], sep, sol->stat, sep, sol->ns, sep, 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]), 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); sep, sqvar(Q[5]), sep, sqvar(Q[2]), sep, sol->age, sep, sol->ratio);
@ -1545,17 +1548,18 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol)
char *q; char *q;
char sum; char sum;
char *emag = const_cast<char *>("E"); char *emag = const_cast<char *>("E");
const int MSG_TAIL = 6;
trace(3, "outnmea_rmc:\n"); trace(3, "outnmea_rmc:\n");
if (sol->stat <= SOLQ_NONE) if (sol->stat <= SOLQ_NONE)
{ {
p += sprintf(p, "$GPRMC,,,,,,,,,,,,"); p += std::snprintf(p, MAXSOLBUF - MSG_TAIL, "$GPRMC,,,,,,,,,,,,");
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++)
{ {
sum ^= *q; sum ^= *q;
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - reinterpret_cast<char *>(buff); return p - reinterpret_cast<char *>(buff);
} }
time = gpst2utc(sol->time); time = gpst2utc(sol->time);
@ -1583,7 +1587,7 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol)
} }
deg2dms(fabs(pos[0]) * R2D, dms1); deg2dms(fabs(pos[0]) * R2D, dms1);
deg2dms(fabs(pos[1]) * R2D, dms2); deg2dms(fabs(pos[1]) * R2D, dms2);
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", p += std::snprintf(p, MAXSOLBUF - MSG_TAIL, "$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", 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, dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", vel / KNOT2M, dir,
ep[2], ep[1], static_cast<int>(ep[0]) % 100, amag, emag, ep[2], ep[1], static_cast<int>(ep[0]) % 100, amag, emag,
@ -1592,7 +1596,7 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol)
{ {
sum ^= *q; /* check-sum */ sum ^= *q; /* check-sum */
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - reinterpret_cast<char *>(buff); return p - reinterpret_cast<char *>(buff);
} }
@ -1611,17 +1615,18 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol)
char *p = reinterpret_cast<char *>(buff); char *p = reinterpret_cast<char *>(buff);
char *q; char *q;
char sum; char sum;
const int MSG_TAIL = 6;
trace(3, "outnmea_gga:\n"); trace(3, "outnmea_gga:\n");
if (sol->stat <= SOLQ_NONE) if (sol->stat <= SOLQ_NONE)
{ {
p += sprintf(p, "$GPGGA,,,,,,,,,,,,,,"); p += std::snprintf(p, MAXSOLBUF - MSG_TAIL, "$GPGGA,,,,,,,,,,,,,,");
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++)
{ {
sum ^= *q; sum ^= *q;
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - reinterpret_cast<char *>(buff); return p - reinterpret_cast<char *>(buff);
} }
for (solq = 0; solq < 8; solq++) for (solq = 0; solq < 8; solq++)
@ -1646,7 +1651,7 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol)
h = 0; // geoidh(pos); h = 0; // geoidh(pos);
deg2dms(fabs(pos[0]) * R2D, dms1); deg2dms(fabs(pos[0]) * R2D, dms1);
deg2dms(fabs(pos[1]) * R2D, dms2); deg2dms(fabs(pos[1]) * R2D, dms2);
p += sprintf(p, "$GPGGA,%02.0f%02.0f%05.2f,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%d,%02d,%.1f,%.3f,M,%.3f,M,%.1f,", p += std::snprintf(p, MAXSOLBUF - MSG_TAIL, "$GPGGA,%02.0f%02.0f%05.2f,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%d,%02d,%.1f,%.3f,M,%.3f,M,%.1f,",
ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "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", solq, dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", solq,
sol->ns, dop, pos[2] - h, h, sol->age); sol->ns, dop, pos[2] - h, h, sol->age);
@ -1654,7 +1659,7 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol)
{ {
sum ^= *q; /* check-sum */ sum ^= *q; /* check-sum */
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - reinterpret_cast<char *>(buff); return p - reinterpret_cast<char *>(buff);
} }
@ -1674,17 +1679,20 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol,
char *q; char *q;
char *s; char *s;
char sum; char sum;
const int MSG_TAIL = 6;
const int COMMA_LENGTH = 2;
const int MAX_LENGTH_INT = 10;
trace(3, "outnmea_gsa:\n"); trace(3, "outnmea_gsa:\n");
if (sol->stat <= SOLQ_NONE) if (sol->stat <= SOLQ_NONE)
{ {
p += sprintf(p, "$GPGSA,A,1,,,,,,,,,,,,,,,"); p += std::snprintf(p, MAXSOLBUF - MSG_TAIL, "$GPGSA,A,1,,,,,,,,,,,,,,,");
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++)
{ {
sum ^= *q; sum ^= *q;
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - reinterpret_cast<char *>(buff); return p - reinterpret_cast<char *>(buff);
} }
@ -1713,25 +1721,25 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol,
if (nsat > 0) if (nsat > 0)
{ {
s = p; s = p;
p += sprintf(p, "$GPGSA,A,%d", sol->stat <= 0 ? 1 : 3); p += std::snprintf(p, MAXSOLBUF, "$GPGSA,A,%d", sol->stat <= 0 ? 1 : 3);
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
{ {
if (i < nsat) if (i < nsat)
{ {
p += sprintf(p, ",%02d", prn[i]); p += std::snprintf(p, MAX_LENGTH_INT + 2, ",%02d", prn[i]);
} }
else else
{ {
p += sprintf(p, ","); p += std::snprintf(p, COMMA_LENGTH, ",");
} }
} }
dops(nsat, azel, 0.0, dop); dops(nsat, azel, 0.0, dop);
p += sprintf(p, ",%3.1f,%3.1f,%3.1f,1", dop[1], dop[2], dop[3]); p += std::snprintf(p, MAXSOLBUF - (p - s), ",%3.1f,%3.1f,%3.1f,1", dop[1], dop[2], dop[3]);
for (q = s + 1, sum = 0; *q; q++) for (q = s + 1, sum = 0; *q; q++)
{ {
sum ^= *q; /* check-sum */ sum ^= *q; /* check-sum */
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
} }
/* GLGSA: glonass */ /* GLGSA: glonass */
for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++)
@ -1753,25 +1761,26 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol,
if (nsat > 0) if (nsat > 0)
{ {
s = p; s = p;
p += sprintf(p, "$GLGSA,A,%d", sol->stat <= 0 ? 1 : 3); const int GLGSA_LENGTH = 11;
p += std::snprintf(p, GLGSA_LENGTH, "$GLGSA,A,%d", sol->stat <= 0 ? 1 : 3);
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
{ {
if (i < nsat) if (i < nsat)
{ {
p += sprintf(p, ",%02d", prn[i] + 64); p += std::snprintf(p, MAX_LENGTH_INT + 2, ",%02d", prn[i] + 64);
} }
else else
{ {
p += sprintf(p, ","); p += std::snprintf(p, COMMA_LENGTH, ",");
} }
} }
dops(nsat, azel, 0.0, dop); dops(nsat, azel, 0.0, dop);
p += sprintf(p, ",%3.1f,%3.1f,%3.1f,2", dop[1], dop[2], dop[3]); p += std::snprintf(p, MAXSOLBUF - (p - s), ",%3.1f,%3.1f,%3.1f,2", dop[1], dop[2], dop[3]);
for (q = s + 1, sum = 0; *q; q++) for (q = s + 1, sum = 0; *q; q++)
{ {
sum ^= *q; /* check-sum */ sum ^= *q; /* check-sum */
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
} }
/* GAGSA: galileo */ /* GAGSA: galileo */
for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++)
@ -1793,25 +1802,25 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol,
if (nsat > 0) if (nsat > 0)
{ {
s = p; s = p;
p += sprintf(p, "$GAGSA,A,%d", sol->stat <= 0 ? 1 : 3); p += std::snprintf(p, MAXSOLBUF, "$GAGSA,A,%d", sol->stat <= 0 ? 1 : 3);
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
{ {
if (i < nsat) if (i < nsat)
{ {
p += sprintf(p, ",%02d", prn[i]); p += std::snprintf(p, MAX_LENGTH_INT + 2, ",%02d", prn[i]);
} }
else else
{ {
p += sprintf(p, ","); p += std::snprintf(p, COMMA_LENGTH, ",");
} }
} }
dops(nsat, azel, 0.0, dop); dops(nsat, azel, 0.0, dop);
p += sprintf(p, ",%3.1f,%3.1f,%3.1f,3", dop[1], dop[2], dop[3]); p += std::snprintf(p, MAXSOLBUF - (p - s), ",%3.1f,%3.1f,%3.1f,3", dop[1], dop[2], dop[3]);
for (q = s + 1, sum = 0; *q; q++) for (q = s + 1, sum = 0; *q; q++)
{ {
sum ^= *q; /* check-sum */ sum ^= *q; /* check-sum */
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
} }
return p - reinterpret_cast<char *>(buff); return p - reinterpret_cast<char *>(buff);
} }
@ -1837,17 +1846,18 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
char *q; char *q;
char *s; char *s;
char sum; char sum;
const int MSG_TAIL = 6;
trace(3, "outnmea_gsv:\n"); trace(3, "outnmea_gsv:\n");
if (sol->stat <= SOLQ_NONE) if (sol->stat <= SOLQ_NONE)
{ {
p += sprintf(p, "$GPGSV,1,1,0,,,,,,,,,,,,,,,,"); p += std::snprintf(p, MAXSOLBUF, "$GPGSV,1,1,0,,,,,,,,,,,,,,,,");
for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++) for (q = reinterpret_cast<char *>(buff) + 1, sum = 0; *q; q++)
{ {
sum ^= *q; sum ^= *q;
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
return p - reinterpret_cast<char *>(buff); return p - reinterpret_cast<char *>(buff);
} }
/* GPGSV: gps/sbas */ /* GPGSV: gps/sbas */
@ -1868,7 +1878,7 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
for (i = k = 0; i < nmsg; i++) for (i = k = 0; i < nmsg; i++)
{ {
s = p; s = p;
p += sprintf(p, "$GPGSV,%d,%d,%02d", nmsg, i + 1, n); p += std::snprintf(p, MAXSOLBUF, "$GPGSV,%d,%d,%02d", nmsg, i + 1, n);
for (j = 0; j < 4; j++, k++) for (j = 0; j < 4; j++, k++)
{ {
@ -1885,19 +1895,19 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
} }
el = ssat[sats[k] - 1].azel[1] * R2D; el = ssat[sats[k] - 1].azel[1] * R2D;
snr = ssat[sats[k] - 1].snr[0] * 0.25; snr = ssat[sats[k] - 1].snr[0] * 0.25;
p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); p += std::snprintf(p, MAXSOLBUF - (s - p), ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr);
} }
else else
{ {
p += sprintf(p, ",,,,"); p += std::snprintf(p, MAXSOLBUF - (s - p), ",,,,");
} }
} }
p += sprintf(p, ",1"); /* L1C/A */ p += std::snprintf(p, MAXSOLBUF - (s - p), ",1"); /* L1C/A */
for (q = s + 1, sum = 0; *q; q++) for (q = s + 1, sum = 0; *q; q++)
{ {
sum ^= *q; /* check-sum */ sum ^= *q; /* check-sum */
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
} }
/* GLGSV: glonass */ /* GLGSV: glonass */
for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++)
@ -1916,7 +1926,7 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
for (i = k = 0; i < nmsg; i++) for (i = k = 0; i < nmsg; i++)
{ {
s = p; s = p;
p += sprintf(p, "$GLGSV,%d,%d,%02d", nmsg, i + 1, n); p += std::snprintf(p, MAXSOLBUF, "$GLGSV,%d,%d,%02d", nmsg, i + 1, n);
for (j = 0; j < 4; j++, k++) for (j = 0; j < 4; j++, k++)
{ {
@ -1931,19 +1941,19 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
} }
el = ssat[sats[k] - 1].azel[1] * R2D; el = ssat[sats[k] - 1].azel[1] * R2D;
snr = ssat[sats[k] - 1].snr[0] * 0.25; snr = ssat[sats[k] - 1].snr[0] * 0.25;
p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); p += std::snprintf(p, MAXSOLBUF - (s - p), ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr);
} }
else else
{ {
p += sprintf(p, ",,,,"); p += std::snprintf(p, MAXSOLBUF - (s - p), ",,,,");
} }
} }
p += sprintf(p, ",1"); /* L1C/A */ p += std::snprintf(p, MAXSOLBUF - (s - p), ",1"); /* L1C/A */
for (q = s + 1, sum = 0; *q; q++) for (q = s + 1, sum = 0; *q; q++)
{ {
sum ^= *q; /* check-sum */ sum ^= *q; /* check-sum */
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
} }
/* GAGSV: galileo */ /* GAGSV: galileo */
for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++)
@ -1962,7 +1972,7 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
for (i = k = 0; i < nmsg; i++) for (i = k = 0; i < nmsg; i++)
{ {
s = p; s = p;
p += sprintf(p, "$GAGSV,%d,%d,%02d", nmsg, i + 1, n); p += std::snprintf(p, MAXSOLBUF, "$GAGSV,%d,%d,%02d", nmsg, i + 1, n);
for (j = 0; j < 4; j++, k++) for (j = 0; j < 4; j++, k++)
{ {
@ -1976,19 +1986,19 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol,
} }
el = ssat[sats[k] - 1].azel[1] * R2D; el = ssat[sats[k] - 1].azel[1] * R2D;
snr = ssat[sats[k] - 1].snr[0] * 0.25; snr = ssat[sats[k] - 1].snr[0] * 0.25;
p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); p += std::snprintf(p, MAXSOLBUF - (s - p), ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr);
} }
else else
{ {
p += sprintf(p, ",,,,"); p += std::snprintf(p, MAXSOLBUF - (s - p), ",,,,");
} }
} }
p += sprintf(p, ",7"); /* L1BC */ p += std::snprintf(p, MAXSOLBUF - (s - p), ",7"); /* L1BC */
for (q = s + 1, sum = 0; *q; q++) for (q = s + 1, sum = 0; *q; q++)
{ {
sum ^= *q; /* check-sum */ sum ^= *q; /* check-sum */
} }
p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); p += std::snprintf(p, MSG_TAIL, "*%02X%c%c", sum, 0x0D, 0x0A);
} }
return p - reinterpret_cast<char *>(buff); return p - reinterpret_cast<char *>(buff);
} }
@ -2018,58 +2028,60 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt)
const char *s9[] = {"off", "on", "auto calib", "external calib", ""}; const char *s9[] = {"off", "on", "auto calib", "external calib", ""};
int i; int i;
char *p = reinterpret_cast<char *>(buff); char *p = reinterpret_cast<char *>(buff);
char *s;
s = p;
trace(3, "outprcopts:\n"); trace(3, "outprcopts:\n");
p += sprintf(p, "%s pos mode : %s\n", COMMENTH, s1[opt->mode]); p += std::snprintf(p, MAXSOLMSG, "%s pos mode : %s\n", COMMENTH, s1[opt->mode]);
if (PMODE_DGPS <= opt->mode && opt->mode <= PMODE_FIXED) if (PMODE_DGPS <= opt->mode && opt->mode <= PMODE_FIXED)
{ {
p += sprintf(p, "%s freqs : %s\n", COMMENTH, s2[opt->nf - 1]); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s freqs : %s\n", COMMENTH, s2[opt->nf - 1]);
} }
if (opt->mode > PMODE_SINGLE) if (opt->mode > PMODE_SINGLE)
{ {
p += sprintf(p, "%s solution : %s\n", COMMENTH, s3[opt->soltype]); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s solution : %s\n", COMMENTH, s3[opt->soltype]);
} }
p += sprintf(p, "%s elev mask : %.1f deg\n", COMMENTH, opt->elmin * R2D); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s elev mask : %.1f deg\n", COMMENTH, opt->elmin * R2D);
if (opt->mode > PMODE_SINGLE) if (opt->mode > PMODE_SINGLE)
{ {
p += sprintf(p, "%s dynamics : %s\n", COMMENTH, opt->dynamics ? "on" : "off"); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s dynamics : %s\n", COMMENTH, opt->dynamics ? "on" : "off");
p += sprintf(p, "%s tidecorr : %s\n", COMMENTH, opt->tidecorr ? "on" : "off"); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s tidecorr : %s\n", COMMENTH, opt->tidecorr ? "on" : "off");
} }
if (opt->mode <= PMODE_FIXED) if (opt->mode <= PMODE_FIXED)
{ {
p += sprintf(p, "%s ionos opt : %s\n", COMMENTH, s4[opt->ionoopt]); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s ionos opt : %s\n", COMMENTH, s4[opt->ionoopt]);
} }
p += sprintf(p, "%s tropo opt : %s\n", COMMENTH, s5[opt->tropopt]); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s tropo opt : %s\n", COMMENTH, s5[opt->tropopt]);
p += sprintf(p, "%s ephemeris : %s\n", COMMENTH, s6[opt->sateph]); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s ephemeris : %s\n", COMMENTH, s6[opt->sateph]);
if (opt->navsys != SYS_GPS) if (opt->navsys != SYS_GPS)
{ {
p += sprintf(p, "%s navi sys :", COMMENTH); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s navi sys :", COMMENTH);
for (i = 0; sys[i]; i++) for (i = 0; sys[i]; i++)
{ {
if (opt->navsys & sys[i]) if (opt->navsys & sys[i])
{ {
p += sprintf(p, " %s", s7[i]); p += std::snprintf(p, MAXSOLMSG - (p - s), " %s", s7[i]);
} }
} }
p += sprintf(p, "\n"); p += std::snprintf(p, MAXSOLMSG - (p - s), "\n");
} }
if (PMODE_KINEMA <= opt->mode && opt->mode <= PMODE_FIXED) if (PMODE_KINEMA <= opt->mode && opt->mode <= PMODE_FIXED)
{ {
p += sprintf(p, "%s amb res : %s\n", COMMENTH, s8[opt->modear]); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s amb res : %s\n", COMMENTH, s8[opt->modear]);
if (opt->navsys & SYS_GLO) if (opt->navsys & SYS_GLO)
{ {
p += sprintf(p, "%s amb glo : %s\n", COMMENTH, s9[opt->glomodear]); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s amb glo : %s\n", COMMENTH, s9[opt->glomodear]);
} }
if (opt->thresar[0] > 0.0) if (opt->thresar[0] > 0.0)
{ {
p += sprintf(p, "%s val thres : %.1f\n", COMMENTH, opt->thresar[0]); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s val thres : %.1f\n", COMMENTH, opt->thresar[0]);
} }
} }
if (opt->mode == PMODE_MOVEB && opt->baseline[0] > 0.0) if (opt->mode == PMODE_MOVEB && opt->baseline[0] > 0.0)
{ {
p += sprintf(p, "%s baseline : %.4f %.4f m\n", COMMENTH, p += std::snprintf(p, MAXSOLMSG - (p - s), "%s baseline : %.4f %.4f m\n", COMMENTH,
opt->baseline[0], opt->baseline[1]); opt->baseline[0], opt->baseline[1]);
} }
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
@ -2078,7 +2090,7 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt)
{ {
continue; continue;
} }
p += sprintf(p, "%s antenna%d : %-21s (%7.4f %7.4f %7.4f)\n", COMMENTH, p += std::snprintf(p, MAXSOLMSG - (p - s), "%s antenna%d : %-21s (%7.4f %7.4f %7.4f)\n", COMMENTH,
i + 1, opt->anttype[i], opt->antdel[i][0], opt->antdel[i][1], i + 1, opt->anttype[i], opt->antdel[i][0], opt->antdel[i][1],
opt->antdel[i][2]); opt->antdel[i][2]);
} }
@ -2100,6 +2112,8 @@ int outsolheads(unsigned char *buff, const solopt_t *opt)
const char *sep = opt2sep(opt); const char *sep = opt2sep(opt);
char *p = reinterpret_cast<char *>(buff); char *p = reinterpret_cast<char *>(buff);
int timeu = opt->timeu < 0 ? 0 : (opt->timeu > 20 ? 20 : opt->timeu); int timeu = opt->timeu < 0 ? 0 : (opt->timeu > 20 ? 20 : opt->timeu);
char *s;
s = p;
trace(3, "outsolheads:\n"); trace(3, "outsolheads:\n");
@ -2110,35 +2124,35 @@ int outsolheads(unsigned char *buff, const solopt_t *opt)
if (opt->outhead) if (opt->outhead)
{ {
p += sprintf(p, "%s (", COMMENTH); p += std::snprintf(p, MAXSOLMSG, "%s (", COMMENTH);
if (opt->posf == SOLF_XYZ) if (opt->posf == SOLF_XYZ)
{ {
p += sprintf(p, "x/y/z-ecef=WGS84"); p += std::snprintf(p, MAXSOLMSG - (p - s), "x/y/z-ecef=WGS84");
} }
else if (opt->posf == SOLF_ENU) else if (opt->posf == SOLF_ENU)
{ {
p += sprintf(p, "e/n/u-baseline=WGS84"); p += std::snprintf(p, MAXSOLMSG - (p - s), "e/n/u-baseline=WGS84");
} }
else else
{ {
p += sprintf(p, "lat/lon/height=%s/%s", s1[opt->datum], s2[opt->height]); p += std::snprintf(p, MAXSOLMSG - (p - s), "lat/lon/height=%s/%s", s1[opt->datum], s2[opt->height]);
} }
p += sprintf(p, ",Q=1:fix,2:float,3:sbas,4:dgps,5:single,6:ppp,ns=# of satellites)\n"); p += std::snprintf(p, MAXSOLMSG - (p - s), ",Q=1:fix,2:float,3:sbas,4:dgps,5:single,6:ppp,ns=# of satellites)\n");
} }
p += sprintf(p, "%s %-*s%s", COMMENTH, (opt->timef ? 16 : 8) + timeu + 1, s3[opt->times], sep); p += std::snprintf(p, MAXSOLMSG - (p - s), "%s %-*s%s", COMMENTH, (opt->timef ? 16 : 8) + timeu + 1, s3[opt->times], sep);
if (opt->posf == SOLF_LLH) if (opt->posf == SOLF_LLH)
{ /* lat/lon/hgt */ { /* lat/lon/hgt */
if (opt->degf) if (opt->degf)
{ {
p += sprintf(p, "%16s%s%16s%s%10s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", p += std::snprintf(p, MAXSOLMSG - (p - s), "%16s%s%16s%s%10s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n",
"latitude(d'\")", sep, "longitude(d'\")", sep, "height(m)", sep, "latitude(d'\")", sep, "longitude(d'\")", sep, "height(m)", sep,
"Q", sep, "ns", sep, "sdn(m)", sep, "sde(m)", sep, "sdu(m)", sep, "Q", sep, "ns", sep, "sdn(m)", sep, "sde(m)", sep, "sdu(m)", sep,
"sdne(m)", sep, "sdeu(m)", sep, "sdue(m)", sep, "age(s)", sep, "ratio"); "sdne(m)", sep, "sdeu(m)", sep, "sdue(m)", sep, "age(s)", sep, "ratio");
} }
else else
{ {
p += sprintf(p, "%14s%s%14s%s%10s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", p += std::snprintf(p, MAXSOLMSG - (p - s), "%14s%s%14s%s%10s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n",
"latitude(deg)", sep, "longitude(deg)", sep, "height(m)", sep, "latitude(deg)", sep, "longitude(deg)", sep, "height(m)", sep,
"Q", sep, "ns", sep, "sdn(m)", sep, "sde(m)", sep, "sdu(m)", sep, "Q", sep, "ns", sep, "sdn(m)", sep, "sde(m)", sep, "sdu(m)", sep,
"sdne(m)", sep, "sdeu(m)", sep, "sdun(m)", sep, "age(s)", sep, "ratio"); "sdne(m)", sep, "sdeu(m)", sep, "sdun(m)", sep, "age(s)", sep, "ratio");
@ -2146,14 +2160,14 @@ int outsolheads(unsigned char *buff, const solopt_t *opt)
} }
else if (opt->posf == SOLF_XYZ) else if (opt->posf == SOLF_XYZ)
{ /* x/y/z-ecef */ { /* x/y/z-ecef */
p += sprintf(p, "%14s%s%14s%s%14s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", p += std::snprintf(p, MAXSOLMSG - (p - s), "%14s%s%14s%s%14s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n",
"x-ecef(m)", sep, "y-ecef(m)", sep, "z-ecef(m)", sep, "Q", sep, "ns", sep, "x-ecef(m)", sep, "y-ecef(m)", sep, "z-ecef(m)", sep, "Q", sep, "ns", sep,
"sdx(m)", sep, "sdy(m)", sep, "sdz(m)", sep, "sdxy(m)", sep, "sdx(m)", sep, "sdy(m)", sep, "sdz(m)", sep, "sdxy(m)", sep,
"sdyz(m)", sep, "sdzx(m)", sep, "age(s)", sep, "ratio"); "sdyz(m)", sep, "sdzx(m)", sep, "age(s)", sep, "ratio");
} }
else if (opt->posf == SOLF_ENU) else if (opt->posf == SOLF_ENU)
{ /* e/n/u-baseline */ { /* e/n/u-baseline */
p += sprintf(p, "%14s%s%14s%s%14s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n", p += std::snprintf(p, MAXSOLMSG - (p - s), "%14s%s%14s%s%14s%s%3s%s%3s%s%8s%s%8s%s%8s%s%8s%s%8s%s%8s%s%6s%s%6s\n",
"e-baseline(m)", sep, "n-baseline(m)", sep, "u-baseline(m)", sep, "e-baseline(m)", sep, "n-baseline(m)", sep, "u-baseline(m)", sep,
"Q", sep, "ns", sep, "sde(m)", sep, "sdn(m)", sep, "sdu(m)", sep, "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"); "sden(m)", sep, "sdnu(m)", sep, "sdue(m)", sep, "age(s)", sep, "ratio");
@ -2223,7 +2237,7 @@ int outsols(unsigned char *buff, const sol_t *sol, const double *rb,
week++; week++;
gpst = 0.0; gpst = 0.0;
} }
snprintf(s, 255, "%4d%s%*.*f", week, sep, 6 + (timeu <= 0 ? 0 : timeu + 1), timeu, gpst); std::snprintf(s, sizeof(s), "%4d%s%*.*f", week, sep, 6 + (timeu <= 0 ? 0 : timeu + 1), timeu, gpst);
} }
switch (opt->posf) switch (opt->posf)
{ {

View File

@ -131,14 +131,13 @@ serial_t *openserial(const char *path, int mode, char *msg)
} }
if (i >= 11) if (i >= 11)
{ {
sprintf(msg, "bitrate error (%d)", brate); std::snprintf(msg, MAXSTRMSG, "bitrate error (%d)", brate);
tracet(1, "openserial: %s path=%s\n", msg, path); tracet(1, "openserial: %s path=%s\n", msg, path);
free(serial); free(serial);
return nullptr; return nullptr;
} }
parity = static_cast<char>(toupper(static_cast<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); std::string s_aux = "/dev/" + std::string(port);
s_aux.resize(128, '\0'); s_aux.resize(128, '\0');
int n = s_aux.length(); int n = s_aux.length();
@ -166,7 +165,7 @@ serial_t *openserial(const char *path, int mode, char *msg)
if ((serial->dev = open(dev, rw | O_NOCTTY | O_NONBLOCK)) < 0) if ((serial->dev = open(dev, rw | O_NOCTTY | O_NONBLOCK)) < 0)
{ {
sprintf(msg, "device open error (%d)", errno); std::snprintf(msg, MAXSTRMSG, "device open error (%d)", errno);
tracet(1, "openserial: %s dev=%s\n", msg, dev); tracet(1, "openserial: %s dev=%s\n", msg, dev);
free(serial); free(serial);
return nullptr; return nullptr;
@ -284,19 +283,19 @@ int openfile_(file_t *file, gtime_t time, char *msg)
if (!(file->fp = fopen(file->openpath, rw))) if (!(file->fp = fopen(file->openpath, rw)))
{ {
sprintf(msg, "file open error: %s", file->openpath); std::snprintf(msg, MAXSTRMSG, "file open error");
tracet(1, "openfile: %s\n", msg); tracet(1, "openfile: %s\n", msg);
return 0; return 0;
} }
tracet(4, "openfile_: open file %s (%s)\n", file->openpath, rw); tracet(4, "openfile_: open file %s (%s)\n", file->openpath, rw);
sprintf(tagpath, "%s.tag", file->openpath); std::snprintf(tagpath, MAXSTRPATH + 4, "%s.tag", file->openpath);
if (file->timetag) if (file->timetag)
{ /* output/sync time-tag */ { /* output/sync time-tag */
if (!(file->fp_tag = fopen(tagpath, rw))) if (!(file->fp_tag = fopen(tagpath, rw)))
{ {
sprintf(msg, "tag open error: %s", tagpath); std::snprintf(msg, MAXSTRMSG, "tag open error");
tracet(1, "openfile: %s\n", msg); tracet(1, "openfile: %s\n", msg);
fclose(file->fp); fclose(file->fp);
return 0; return 0;
@ -319,7 +318,7 @@ int openfile_(file_t *file, gtime_t time, char *msg)
} }
else else
{ {
sprintf(tagh, "TIMETAG RTKLIB %s", VER_RTKLIB); std::snprintf(tagh, TIMETAGH_LEN + 1, "TIMETAG RTKLIB %s", VER_RTKLIB);
memcpy(tagh + TIMETAGH_LEN - 4, &file->tick_f, sizeof(file->tick_f)); memcpy(tagh + TIMETAGH_LEN - 4, &file->tick_f, sizeof(file->tick_f));
fwrite(&tagh, 1, TIMETAGH_LEN, file->fp_tag); fwrite(&tagh, 1, TIMETAGH_LEN, file->fp_tag);
fwrite(&file->time, 1, sizeof(file->time), file->fp_tag); fwrite(&file->time, 1, sizeof(file->time), file->fp_tag);
@ -571,7 +570,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg)
{ {
trace(1, "fseek error"); trace(1, "fseek error");
} }
sprintf(msg, "end"); std::snprintf(msg, MAXSTRPATH, "end");
break; break;
} }
if (file->repmode || file->speed > 0.0) if (file->repmode || file->speed > 0.0)
@ -586,7 +585,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg)
tick_master = tick; tick_master = tick;
} }
sprintf(msg, "T%+.1fs", static_cast<int>(tick) < 0 ? 0.0 : static_cast<int>(tick) / 1000.0); std::snprintf(msg, MAXSTRPATH, "T%+.1fs", static_cast<int>(tick) < 0 ? 0.0 : static_cast<int>(tick) / 1000.0);
if (static_cast<int>(fpos - file->fpos) >= nmax) if (static_cast<int>(fpos - file->fpos) >= nmax)
{ {
@ -615,7 +614,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg)
file->fpos += nr; file->fpos += nr;
if (nr <= 0) if (nr <= 0)
{ {
sprintf(msg, "end"); std::snprintf(msg, MAXSTRPATH, "end");
} }
} }
tracet(5, "readfile: fp=%p \n nr=%d fpos=%u\n", file->fp, nr, file->fpos); tracet(5, "readfile: fp=%p \n nr=%d fpos=%u\n", file->fp, nr, file->fpos);
@ -829,7 +828,7 @@ int setsock(socket_t sock, char *msg)
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast<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) setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast<const char *>(&tv), sizeof(tv)) == -1)
{ {
sprintf(msg, "sockopt error: notimeo"); std::snprintf(msg, MAXSTRMSG, "sockopt error: notimeo");
tracet(1, "setsock: setsockopt error 1 sock=%d err=%d\n", sock, errsock()); tracet(1, "setsock: setsockopt error 1 sock=%d err=%d\n", sock, errsock());
closesocket(sock); closesocket(sock);
return 0; return 0;
@ -838,12 +837,12 @@ int setsock(socket_t sock, char *msg)
setsockopt(sock, SOL_SOCKET, SO_SNDBUF, 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); tracet(1, "setsock: setsockopt error 2 sock=%d err=%d bs=%d\n", sock, errsock(), bs);
sprintf(msg, "sockopt error: bufsiz"); std::snprintf(msg, MAXSTRMSG, "sockopt error: bufsiz");
} }
if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<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()); tracet(1, "setsock: setsockopt error 3 sock=%d err=%d\n", sock, errsock());
sprintf(msg, "sockopt error: nodelay"); std::snprintf(msg, MAXSTRMSG, "sockopt error: nodelay");
} }
return 1; return 1;
} }
@ -940,7 +939,7 @@ int gentcp(tcp_t *tcp, int type, char *msg)
/* generate socket */ /* generate socket */
if ((tcp->sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) if ((tcp->sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
{ {
sprintf(msg, "socket error (%d)", errsock()); std::snprintf(msg, MAXSTRMSG, "socket error (%d)", errsock());
tracet(1, "gentcp: socket error err=%d\n", errsock()); tracet(1, "gentcp: socket error err=%d\n", errsock());
tcp->state = -1; tcp->state = -1;
return 0; return 0;
@ -963,7 +962,7 @@ int gentcp(tcp_t *tcp, int type, char *msg)
#endif #endif
if (bind(tcp->sock, reinterpret_cast<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); std::snprintf(msg, MAXSTRMSG, "bind error (%d) : %d", errsock(), tcp->port);
tracet(1, "gentcp: bind error port=%d err=%d\n", tcp->port, errsock()); tracet(1, "gentcp: bind error port=%d err=%d\n", tcp->port, errsock());
closesocket(tcp->sock); closesocket(tcp->sock);
tcp->state = -1; tcp->state = -1;
@ -975,7 +974,7 @@ int gentcp(tcp_t *tcp, int type, char *msg)
{ /* client socket */ { /* client socket */
if (!(hp = gethostbyname(tcp->saddr))) if (!(hp = gethostbyname(tcp->saddr)))
{ {
sprintf(msg, "address error (%s)", tcp->saddr); std::snprintf(msg, MAXSTRMSG, "address error (%s)", tcp->saddr);
tracet(1, "gentcp: gethostbyname error addr=%s err=%d\n", tcp->saddr, errsock()); tracet(1, "gentcp: gethostbyname error addr=%s err=%d\n", tcp->saddr, errsock());
closesocket(tcp->sock); closesocket(tcp->sock);
tcp->state = 0; tcp->state = 0;
@ -1019,7 +1018,7 @@ tcpsvr_t *opentcpsvr(const char *path, char *msg)
decodetcppath(path, tcpsvr->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); decodetcppath(path, tcpsvr->svr.saddr, port, nullptr, nullptr, nullptr, nullptr);
if (sscanf(port, "%d", &tcpsvr->svr.port) < 1) if (sscanf(port, "%d", &tcpsvr->svr.port) < 1)
{ {
sprintf(msg, "port error: %s", port); std::snprintf(msg, MAXSTRMSG, "port error: %s", port);
tracet(1, "opentcpsvr: port error port=%s\n", port); tracet(1, "opentcpsvr: port error port=%s\n", port);
free(tcpsvr); free(tcpsvr);
return nullptr; return nullptr;
@ -1096,17 +1095,17 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg)
if (n == 0) if (n == 0)
{ {
tcpsvr->svr.state = 1; tcpsvr->svr.state = 1;
sprintf(msg, "waiting..."); std::snprintf(msg, MAXSTRMSG, "waiting...");
return; return;
} }
tcpsvr->svr.state = 2; tcpsvr->svr.state = 2;
if (n == 1) if (n == 1)
{ {
sprintf(msg, "%s", saddr); std::snprintf(msg, MAXSTRMSG, "%s", saddr);
} }
else else
{ {
sprintf(msg, "%d clients", n); std::snprintf(msg, MAXSTRMSG, "%d clients", n);
} }
} }
@ -1139,7 +1138,7 @@ int accsock(tcpsvr_t *tcpsvr, char *msg)
if ((sock = accept_nb(tcpsvr->svr.sock, reinterpret_cast<struct sockaddr *>(&addr), &len)) == -1) if ((sock = accept_nb(tcpsvr->svr.sock, reinterpret_cast<struct sockaddr *>(&addr), &len)) == -1)
{ {
err = errsock(); err = errsock();
sprintf(msg, "accept error (%d)", err); std::snprintf(msg, MAXSTRMSG, "accept error (%d)", err);
tracet(1, "accsock: accept error sock=%d err=%d\n", tcpsvr->svr.sock, err); tracet(1, "accsock: accept error sock=%d err=%d\n", tcpsvr->svr.sock, err);
closesocket(tcpsvr->svr.sock); closesocket(tcpsvr->svr.sock);
tcpsvr->svr.state = 0; tcpsvr->svr.state = 0;
@ -1161,7 +1160,7 @@ int accsock(tcpsvr_t *tcpsvr, char *msg)
std::strncpy(tcpsvr->cli[i].saddr, inet_ntoa(addr.sin_addr), 256); std::strncpy(tcpsvr->cli[i].saddr, inet_ntoa(addr.sin_addr), 256);
tcpsvr->cli[i].saddr[255] = '\0'; tcpsvr->cli[i].saddr[255] = '\0';
} }
sprintf(msg, "%s", tcpsvr->cli[i].saddr); std::snprintf(msg, MAXSTRMSG, "%s", tcpsvr->cli[i].saddr);
tracet(2, "accsock: connected sock=%d addr=%s\n", tcpsvr->cli[i].sock, tcpsvr->cli[i].saddr); tracet(2, "accsock: connected sock=%d addr=%s\n", tcpsvr->cli[i].sock, tcpsvr->cli[i].saddr);
tcpsvr->cli[i].state = 2; tcpsvr->cli[i].state = 2;
tcpsvr->cli[i].tact = tickget(); tcpsvr->cli[i].tact = tickget();
@ -1203,7 +1202,7 @@ int readtcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg)
{ {
err = errsock(); err = errsock();
tracet(1, "readtcpsvr: recv error sock=%d err=%d\n", tcpsvr->cli[0].sock, err); tracet(1, "readtcpsvr: recv error sock=%d err=%d\n", tcpsvr->cli[0].sock, err);
sprintf(msg, "recv error (%d)", err); std::snprintf(msg, MAXSTRMSG, "recv error (%d)", err);
discontcp(&tcpsvr->cli[0], ticonnect); discontcp(&tcpsvr->cli[0], ticonnect);
updatetcpsvr(tcpsvr, msg); updatetcpsvr(tcpsvr, msg);
return 0; return 0;
@ -1242,7 +1241,7 @@ int writetcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg)
{ {
err = errsock(); err = errsock();
tracet(1, "writetcpsvr: send error i=%d sock=%d err=%d\n", i, tcpsvr->cli[i].sock, err); tracet(1, "writetcpsvr: send error i=%d sock=%d err=%d\n", i, tcpsvr->cli[i].sock, err);
sprintf(msg, "send error (%d)", err); std::snprintf(msg, MAXSTRMSG, "send error (%d)", err);
discontcp(&tcpsvr->cli[i], ticonnect); discontcp(&tcpsvr->cli[i], ticonnect);
updatetcpsvr(tcpsvr, msg); updatetcpsvr(tcpsvr, msg);
return 0; return 0;
@ -1283,7 +1282,7 @@ int consock(tcpcli_t *tcpcli, char *msg)
sizeof(tcpcli->svr.addr))) == -1) sizeof(tcpcli->svr.addr))) == -1)
{ {
err = errsock(); err = errsock();
sprintf(msg, "connect error (%d)", err); std::snprintf(msg, MAXSTRMSG, "connect error (%d)", err);
tracet(1, "consock: connect error sock=%d err=%d\n", tcpcli->svr.sock, err); tracet(1, "consock: connect error sock=%d err=%d\n", tcpcli->svr.sock, err);
closesocket(tcpcli->svr.sock); closesocket(tcpcli->svr.sock);
tcpcli->svr.state = 0; tcpcli->svr.state = 0;
@ -1291,10 +1290,10 @@ int consock(tcpcli_t *tcpcli, char *msg)
} }
if (!stat) if (!stat)
{ /* not connect */ { /* not connect */
sprintf(msg, "connecting..."); std::snprintf(msg, MAXSTRMSG, "connecting...");
return 0; return 0;
} }
sprintf(msg, "%s", tcpcli->svr.saddr); std::snprintf(msg, MAXSTRMSG, "%s", tcpcli->svr.saddr);
tracet(2, "consock: connected sock=%d addr=%s\n", tcpcli->svr.sock, tcpcli->svr.saddr); tracet(2, "consock: connected sock=%d addr=%s\n", tcpcli->svr.sock, tcpcli->svr.saddr);
tcpcli->svr.state = 2; tcpcli->svr.state = 2;
tcpcli->svr.tact = tickget(); tcpcli->svr.tact = tickget();
@ -1319,7 +1318,7 @@ tcpcli_t *opentcpcli(const char *path, char *msg)
decodetcppath(path, tcpcli->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); decodetcppath(path, tcpcli->svr.saddr, port, nullptr, nullptr, nullptr, nullptr);
if (sscanf(port, "%d", &tcpcli->svr.port) < 1) if (sscanf(port, "%d", &tcpcli->svr.port) < 1)
{ {
sprintf(msg, "port error: %s", port); std::snprintf(msg, MAXSTRMSG, "port error: %s", port);
tracet(1, "opentcp: port error port=%s\n", port); tracet(1, "opentcp: port error port=%s\n", port);
free(tcpcli); free(tcpcli);
return nullptr; return nullptr;
@ -1369,7 +1368,7 @@ int waittcpcli(tcpcli_t *tcpcli, char *msg)
if (tcpcli->toinact > 0 && if (tcpcli->toinact > 0 &&
static_cast<int>(tickget() - tcpcli->svr.tact) > tcpcli->toinact) static_cast<int>(tickget() - tcpcli->svr.tact) > tcpcli->toinact)
{ {
sprintf(msg, "timeout"); std::snprintf(msg, MAXSTRMSG, "timeout");
tracet(2, "waittcpcli: inactive timeout sock=%d\n", tcpcli->svr.sock); tracet(2, "waittcpcli: inactive timeout sock=%d\n", tcpcli->svr.sock);
discontcp(&tcpcli->svr, tcpcli->tirecon); discontcp(&tcpcli->svr, tcpcli->tirecon);
return 0; return 0;
@ -1396,7 +1395,7 @@ int readtcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg)
{ {
err = errsock(); err = errsock();
tracet(1, "readtcpcli: recv error sock=%d err=%d\n", tcpcli->svr.sock, err); tracet(1, "readtcpcli: recv error sock=%d err=%d\n", tcpcli->svr.sock, err);
sprintf(msg, "recv error (%d)", err); std::snprintf(msg, MAXSTRMSG, "recv error (%d)", err);
discontcp(&tcpcli->svr, tcpcli->tirecon); discontcp(&tcpcli->svr, tcpcli->tirecon);
return 0; return 0;
} }
@ -1426,7 +1425,7 @@ int writetcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg)
{ {
err = errsock(); err = errsock();
tracet(1, "writetcp: send error sock=%d err=%d\n", tcpcli->svr.sock, err); tracet(1, "writetcp: send error sock=%d err=%d\n", tcpcli->svr.sock, err);
sprintf(msg, "send error (%d)", err); std::snprintf(msg, MAXSTRMSG, "send error (%d)", err);
discontcp(&tcpcli->svr, tcpcli->tirecon); discontcp(&tcpcli->svr, tcpcli->tirecon);
return 0; return 0;
} }
@ -1485,13 +1484,15 @@ int reqntrip_s(ntrip_t *ntrip, char *msg)
{ {
char buff[256 + NTRIP_MAXSTR]; char buff[256 + NTRIP_MAXSTR];
char *p = buff; char *p = buff;
char *s;
s = p;
tracet(3, "reqntrip_s: state=%d\n", ntrip->state); tracet(3, "reqntrip_s: state=%d\n", ntrip->state);
p += snprintf(p, 256 + NTRIP_MAXSTR, "SOURCE %s %s\r\n", ntrip->passwd, ntrip->mntpnt); p += std::snprintf(p, 256 + NTRIP_MAXSTR, "SOURCE %s %s\r\n", ntrip->passwd, ntrip->mntpnt);
p += sprintf(p, "Source-Agent: NTRIP %s\r\n", NTRIP_AGENT); p += std::snprintf(p, NTRIP_MAXSTR - (p - s), "Source-Agent: NTRIP %s\r\n", NTRIP_AGENT);
p += sprintf(p, "STR: %s\r\n", ntrip->str); p += std::snprintf(p, NTRIP_MAXSTR - (p - s), "STR: %s\r\n", ntrip->str);
p += sprintf(p, "\r\n"); p += std::snprintf(p, sizeof("\r\n") + 1, "\r\n");
if (writetcpcli(ntrip->tcp, reinterpret_cast<unsigned char *>(buff), p - buff, msg) != p - buff) if (writetcpcli(ntrip->tcp, reinterpret_cast<unsigned char *>(buff), p - buff, msg) != p - buff)
{ {
@ -1511,25 +1512,27 @@ int reqntrip_c(ntrip_t *ntrip, char *msg)
char buff[1024]; char buff[1024];
char user[512]; char user[512];
char *p = buff; char *p = buff;
char *s;
s = p;
tracet(3, "reqntrip_c: state=%d\n", ntrip->state); tracet(3, "reqntrip_c: state=%d\n", ntrip->state);
p += sprintf(p, "GET %s/%s HTTP/1.0\r\n", ntrip->url, ntrip->mntpnt); p += std::snprintf(p, NTRIP_MAXSTR, "GET %s/%s HTTP/1.0\r\n", ntrip->url, ntrip->mntpnt);
p += sprintf(p, "User-Agent: NTRIP %s\r\n", NTRIP_AGENT); p += std::snprintf(p, NTRIP_MAXSTR - (p - s), "User-Agent: NTRIP %s\r\n", NTRIP_AGENT);
if (!*ntrip->user) if (!*ntrip->user)
{ {
p += sprintf(p, "Accept: */*\r\n"); p += std::snprintf(p, NTRIP_MAXSTR - (p - s), "Accept: */*\r\n");
p += sprintf(p, "Connection: close\r\n"); p += std::snprintf(p, NTRIP_MAXSTR - (p - s), "Connection: close\r\n");
} }
else else
{ {
sprintf(user, "%s:%s", ntrip->user, ntrip->passwd); std::snprintf(user, sizeof(user), "%s:%s", ntrip->user, ntrip->passwd);
p += sprintf(p, "Authorization: Basic "); p += std::snprintf(p, NTRIP_MAXSTR - (p - s), "Authorization: Basic ");
p += encbase64(p, reinterpret_cast<unsigned char *>(user), strlen(user)); p += encbase64(p, reinterpret_cast<unsigned char *>(user), strlen(user));
p += sprintf(p, "\r\n"); p += std::snprintf(p, sizeof("\r\n") + 1, "\r\n");
} }
p += sprintf(p, "\r\n"); p += std::snprintf(p, sizeof("\r\n") + 1, "\r\n");
if (writetcpcli(ntrip->tcp, reinterpret_cast<unsigned char *>(buff), p - buff, msg) != p - buff) if (writetcpcli(ntrip->tcp, reinterpret_cast<unsigned char *>(buff), p - buff, msg) != p - buff)
{ {
@ -1565,7 +1568,7 @@ int rspntrip_s(ntrip_t *ntrip, char *msg)
*q++ = *p++; *q++ = *p++;
} }
ntrip->state = 2; ntrip->state = 2;
sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); std::snprintf(msg, MAXSTRMSG, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt);
tracet(2, "rspntrip_s: response ok nb=%d\n", ntrip->nb); tracet(2, "rspntrip_s: response ok nb=%d\n", ntrip->nb);
return 1; return 1;
} }
@ -1589,7 +1592,7 @@ int rspntrip_s(ntrip_t *ntrip, char *msg)
} }
else if (ntrip->nb >= NTRIP_MAXRSP) else if (ntrip->nb >= NTRIP_MAXRSP)
{ /* buffer overflow */ { /* buffer overflow */
sprintf(msg, "response overflow"); std::snprintf(msg, MAXSTRMSG, "response overflow");
tracet(1, "rspntrip_s: response overflow nb=%d\n", ntrip->nb); tracet(1, "rspntrip_s: response overflow nb=%d\n", ntrip->nb);
ntrip->nb = 0; ntrip->nb = 0;
ntrip->buff[0] = '\0'; ntrip->buff[0] = '\0';
@ -1622,7 +1625,7 @@ int rspntrip_c(ntrip_t *ntrip, char *msg)
*q++ = *p++; *q++ = *p++;
} }
ntrip->state = 2; ntrip->state = 2;
sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); std::snprintf(msg, MAXSTRMSG, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt);
tracet(2, "rspntrip_c: response ok nb=%d\n", ntrip->nb); tracet(2, "rspntrip_c: response ok nb=%d\n", ntrip->nb);
return 1; return 1;
} }
@ -1631,11 +1634,11 @@ int rspntrip_c(ntrip_t *ntrip, char *msg)
if (!*ntrip->mntpnt) if (!*ntrip->mntpnt)
{ /* source table request */ { /* source table request */
ntrip->state = 2; ntrip->state = 2;
sprintf(msg, "source table received"); std::snprintf(msg, MAXSTRMSG, "source table received");
tracet(2, "rspntrip_c: receive source table nb=%d\n", ntrip->nb); tracet(2, "rspntrip_c: receive source table nb=%d\n", ntrip->nb);
return 1; return 1;
} }
sprintf(msg, "no mountp. reconnect..."); std::snprintf(msg, MAXSTRMSG, "no mountp. reconnect...");
tracet(2, "rspntrip_c: no mount point nb=%d\n", ntrip->nb); tracet(2, "rspntrip_c: no mount point nb=%d\n", ntrip->nb);
ntrip->nb = 0; ntrip->nb = 0;
ntrip->buff[0] = '\0'; ntrip->buff[0] = '\0';
@ -1661,7 +1664,7 @@ int rspntrip_c(ntrip_t *ntrip, char *msg)
} }
else if (ntrip->nb >= NTRIP_MAXRSP) else if (ntrip->nb >= NTRIP_MAXRSP)
{ /* buffer overflow */ { /* buffer overflow */
sprintf(msg, "response overflow"); std::snprintf(msg, MAXSTRMSG, "response overflow");
tracet(1, "rspntrip_s: response overflow nb=%d\n", ntrip->nb); tracet(1, "rspntrip_s: response overflow nb=%d\n", ntrip->nb);
ntrip->nb = 0; ntrip->nb = 0;
ntrip->buff[0] = '\0'; ntrip->buff[0] = '\0';
@ -1750,14 +1753,13 @@ ntrip_t *openntrip(const char *path, int type, char *msg)
/* use default port if no port specified */ /* use default port if no port specified */
if (!*port) if (!*port)
{ {
sprintf(port, "%d", type ? NTRIP_CLI_PORT : NTRIP_SVR_PORT); std::snprintf(port, sizeof(port), "%d", type ? NTRIP_CLI_PORT : NTRIP_SVR_PORT);
} }
sprintf(tpath, "%s:%s", addr, port); std::snprintf(tpath, MAXSTRPATH, "%s:%s", addr, port);
/* ntrip access via proxy server */ /* ntrip access via proxy server */
if (*proxyaddr) if (*proxyaddr)
{ {
// sprintf(ntrip->url, "http://%s", tpath); This line triggers a warning. Replaced by:
std::string s_aux = "http://" + std::string(tpath); std::string s_aux = "http://" + std::string(tpath);
int n = s_aux.length(); int n = s_aux.length();
if (n < 256) if (n < 256)
@ -1978,7 +1980,6 @@ void *ftpthread(void *arg)
{ {
p = remote; p = remote;
} }
// sprintf(local, "%s%c%s", localdir, FILEPATHSEP, p); This line triggers a warning. Replaced by:
std::string s_aux = std::string(localdir) + std::to_string(FILEPATHSEP) + std::string(p); std::string s_aux = std::string(localdir) + std::to_string(FILEPATHSEP) + std::string(p);
int n = s_aux.length(); int n = s_aux.length();
if (n < 1024) if (n < 1024)
@ -1989,7 +1990,6 @@ void *ftpthread(void *arg)
} }
} }
// sprintf(errfile, "%s.err", local); This line triggers a warning. Replaced by:
std::string s_aux2 = std::string(local) + ".err"; std::string s_aux2 = std::string(local) + ".err";
n = s_aux2.length(); n = s_aux2.length();
if (n < 1024) if (n < 1024)
@ -2022,14 +2022,12 @@ void *ftpthread(void *arg)
if (*proxyaddr) if (*proxyaddr)
{ {
proto = ftp->proto ? const_cast<char *>("http") : const_cast<char *>("ftp"); proto = ftp->proto ? const_cast<char *>("http") : const_cast<char *>("ftp");
sprintf(env, "set %s_proxy=http://%s & ", proto, proxyaddr); std::snprintf(env, sizeof(env), "set %s_proxy=http://%s & ", proto, proxyaddr);
proxyopt = const_cast<char *>("--proxy=on "); proxyopt = const_cast<char *>("--proxy=on ");
} }
/* download command (ref [2]) */ /* download command (ref [2]) */
if (ftp->proto == 0) if (ftp->proto == 0)
{ /* ftp */ { /* ftp */
// sprintf(opt, "--ftp-user=%s --ftp-password=%s --glob=off --passive-ftp %s-t 1 -T %d -O \"%s\"",
// ftp->user, ftp->passwd, proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by:
std::string s_aux = "--ftp-user=" + std::string(ftp->user) + " --ftp-password=" + std::string(ftp->passwd) + std::string s_aux = "--ftp-user=" + std::string(ftp->user) + " --ftp-password=" + std::string(ftp->passwd) +
" --glob=off --passive-ftp " + std::string(proxyopt) + "s-t 1 -T " + std::to_string(FTP_TIMEOUT) + " --glob=off --passive-ftp " + std::string(proxyopt) + "s-t 1 -T " + std::to_string(FTP_TIMEOUT) +
" -O \"" + std::string(local) + "\""; " -O \"" + std::string(local) + "\"";
@ -2042,8 +2040,6 @@ void *ftpthread(void *arg)
} }
} }
// sprintf(cmd, "%s%s %s \"ftp://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr,
// remote, errfile); This line triggers a warning. Replaced by:
std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " +
"\"ftp://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; "\"ftp://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n";
k = s_aux2.length(); k = s_aux2.length();
@ -2054,7 +2050,6 @@ void *ftpthread(void *arg)
} }
else else
{ /* http */ { /* http */
// sprintf(opt, "%s-t 1 -T %d -O \"%s\"", proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by:
std::string s_aux = std::string(proxyopt) + " -t 1 -T " + std::to_string(FTP_TIMEOUT) + " -O \"" + std::string(local) + "\""; std::string s_aux = std::string(proxyopt) + " -t 1 -T " + std::to_string(FTP_TIMEOUT) + " -O \"" + std::string(local) + "\"";
int l = s_aux.length(); int l = s_aux.length();
for (int i = 0; (i < l) && (i < 1024); i++) for (int i = 0; (i < l) && (i < 1024); i++)
@ -2062,8 +2057,6 @@ void *ftpthread(void *arg)
opt[i] = s_aux[i]; opt[i] = s_aux[i];
} }
// sprintf(cmd, "%s%s %s \"http://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr,
// remote, errfile); This line triggers a warning. Replaced by:
std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " +
"\"http://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; "\"http://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n";
l = s_aux2.length(); l = s_aux2.length();
@ -2186,7 +2179,10 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg)
if (ftp->state <= 0) if (ftp->state <= 0)
{ /* ftp/http not executed? */ { /* ftp/http not executed? */
ftp->state = 1; ftp->state = 1;
sprintf(msg, "%s://%s", ftp->proto ? "http" : "ftp", ftp->addr); if (std::snprintf(msg, sizeof(ftp->addr), "%s://%s", ftp->proto ? "http" : "ftp", ftp->addr) < 0)
{
tracet(1, "readftp: ftp address truncation\n");
}
if (pthread_create(&ftp->thread, nullptr, ftpthread, ftp)) if (pthread_create(&ftp->thread, nullptr, ftpthread, ftp))
{ {
@ -2203,7 +2199,10 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg)
if (ftp->state == 3) if (ftp->state == 3)
{ /* ftp error */ { /* ftp error */
sprintf(msg, "%s error (%d)", ftp->proto ? "http" : "ftp", ftp->error); if (std::snprintf(msg, sizeof(ftp->addr), "%s error (%d)", ftp->proto ? "http" : "ftp", ftp->error) < 0)
{
tracet(1, "readftp: ftp address truncation\n");
}
/* set next retry time */ /* set next retry time */
ftp->tnext = nextdltime(ftp->topts, 0); ftp->tnext = nextdltime(ftp->topts, 0);
@ -2217,7 +2216,7 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg)
{ {
*p++ = *q++; *p++ = *q++;
} }
p += sprintf(reinterpret_cast<char *>(p), "\r\n"); p += std::snprintf(reinterpret_cast<char *>(p), sizeof("\r\n") + 1, "\r\n");
/* set next download time */ /* set next download time */
ftp->tnext = nextdltime(ftp->topts, 1); ftp->tnext = nextdltime(ftp->topts, 1);

View File

@ -339,6 +339,7 @@ install(FILES
${PROJECT_BINARY_DIR}/include/volk_gnsssdr/volk_gnsssdr_typedefs.h ${PROJECT_BINARY_DIR}/include/volk_gnsssdr/volk_gnsssdr_typedefs.h
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_malloc.h ${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_malloc.h
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_sine_table.h ${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/volk_gnsssdr_sine_table.h
${PROJECT_SOURCE_DIR}/include/volk_gnsssdr/constants.h
DESTINATION include/volk_gnsssdr DESTINATION include/volk_gnsssdr
COMPONENT "volk_gnsssdr_devel" COMPONENT "volk_gnsssdr_devel"
) )

View File

@ -0,0 +1,52 @@
#!/usr/bin/env python
# Copyright (C) 2010-2019 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
# GNSS-SDR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# GNSS-SDR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
# This script is used to compare the generic kernels to the highest performing kernel, for each operation
# Run:
# ./volk_gnsssdr_profile -j volk_gnsssdr_results.json
# Then run this script under python3
import matplotlib.pyplot as plt
import numpy as np
import json
filename = 'volk_gnsssdr_results.json'
operations = []
metrics = []
with open(filename) as json_file:
data = json.load(json_file)
for test in data['volk_gnsssdr_tests']:
if ('generic' in test['results']) or ('u_generic' in test['results']): # some dont have a generic kernel
operations.append(test['name'][13:]) # remove volk_gnsssdr_ prefix that they all have
extension_performance = []
for key, val in test['results'].items():
if key not in ['generic', 'u_generic']: # exclude generic results, when trying to find fastest time
extension_performance.append(val['time'])
try:
generic_time = test['results']['generic']['time']
except:
generic_time = test['results']['u_generic']['time']
metrics.append(extension_performance[np.argmin(extension_performance)]/generic_time)
plt.bar(np.arange(len(metrics)), metrics)
plt.hlines(1.0, -1, len(metrics), colors='r', linestyles='dashed')
plt.axis([-1, len(metrics), 0, 2])
plt.xticks(np.arange(len(operations)), operations, rotation=90)
plt.ylabel('Time taken of fastest kernel relative to generic kernel')
plt.show()

View File

@ -57,7 +57,7 @@ public:
class option_list class option_list
{ {
public: public:
option_list(std::string program_name); explicit option_list(std::string program_name);
void add(const option_t &opt); void add(const option_t &opt);

View File

@ -193,7 +193,7 @@ int main(int argc, char *argv[])
void read_results(std::vector<volk_gnsssdr_test_results_t> *results) void read_results(std::vector<volk_gnsssdr_test_results_t> *results)
{ {
char path[1024]; char path[1024];
volk_gnsssdr_get_config_path(path); volk_gnsssdr_get_config_path(path, true);
read_results(results, std::string(path)); read_results(results, std::string(path));
} }
@ -255,7 +255,7 @@ void read_results(std::vector<volk_gnsssdr_test_results_t> *results, std::string
void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool update_result) void write_results(const std::vector<volk_gnsssdr_test_results_t> *results, bool update_result)
{ {
char path[1024]; char path[1024];
volk_gnsssdr_get_config_path(path); volk_gnsssdr_get_config_path(path, false);
write_results(results, update_result, std::string(path)); write_results(results, update_result, std::string(path));
} }

View File

@ -0,0 +1,8 @@
########################################################################
# Toolchain file for building native on a ARM Cortex A72 w/ NEON
# Usage: cmake -DCMAKE_TOOLCHAIN_FILE=<this file> <source directory>
########################################################################
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_FLAGS "-march=armv8-a -mtune=cortex-a72 -mfpu=neon-fp-armv8 -mfloat-abi=hard" CACHE STRING "" FORCE)
set(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "" FORCE) #same flags for C sources

View File

@ -107,6 +107,7 @@
<param>12</param> <param>12</param>
</check> </check>
<flag compiler="gnu">-mfma</flag> <flag compiler="gnu">-mfma</flag>
<flag compiler="clang">-mfma</flag>
<flag compiler="msvc">/arch:AVX2</flag> <flag compiler="msvc">/arch:AVX2</flag>
<alignment>32</alignment> <alignment>32</alignment>
</arch> </arch>
@ -241,6 +242,7 @@
<!-- check to see that the OS has enabled AVX2 --> <!-- check to see that the OS has enabled AVX2 -->
<check name="get_avx2_enabled"></check> <check name="get_avx2_enabled"></check>
<flag compiler="gnu">-mavx2</flag> <flag compiler="gnu">-mavx2</flag>
<flag compiler="clang">-mavx2</flag>
<flag compiler="msvc">/arch:AVX2</flag> <flag compiler="msvc">/arch:AVX2</flag>
<alignment>32</alignment> <alignment>32</alignment>
</arch> </arch>

View File

@ -53,4 +53,47 @@ static inline float32x4_t vsqrtq_f32(float32x4_t q_x)
return vmulq_f32(q_x, q_step_2); return vmulq_f32(q_x, q_step_2);
} }
/* Magnitude squared for float32x4x2_t */
static inline float32x4_t _vmagnitudesquaredq_f32(float32x4x2_t cmplxValue)
{
float32x4_t iValue, qValue, result;
iValue = vmulq_f32(cmplxValue.val[0], cmplxValue.val[0]); // Square the values
qValue = vmulq_f32(cmplxValue.val[1], cmplxValue.val[1]); // Square the values
result = vaddq_f32(iValue, qValue); // Add the I2 and Q2 values
return result;
}
/* Inverse square root for float32x4_t */
static inline float32x4_t _vinvsqrtq_f32(float32x4_t x)
{
float32x4_t sqrt_reciprocal = vrsqrteq_f32(x);
sqrt_reciprocal = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x, sqrt_reciprocal), sqrt_reciprocal), sqrt_reciprocal);
sqrt_reciprocal = vmulq_f32(vrsqrtsq_f32(vmulq_f32(x, sqrt_reciprocal), sqrt_reciprocal), sqrt_reciprocal);
return sqrt_reciprocal;
}
/* Complex multiplication for float32x4x2_t */
static inline float32x4x2_t _vmultiply_complexq_f32(float32x4x2_t a_val, float32x4x2_t b_val)
{
float32x4x2_t tmp_real;
float32x4x2_t tmp_imag;
float32x4x2_t c_val;
// multiply the real*real and imag*imag to get real result
// a0r*b0r|a1r*b1r|a2r*b2r|a3r*b3r
tmp_real.val[0] = vmulq_f32(a_val.val[0], b_val.val[0]);
// a0i*b0i|a1i*b1i|a2i*b2i|a3i*b3i
tmp_real.val[1] = vmulq_f32(a_val.val[1], b_val.val[1]);
// Multiply cross terms to get the imaginary result
// a0r*b0i|a1r*b1i|a2r*b2i|a3r*b3i
tmp_imag.val[0] = vmulq_f32(a_val.val[0], b_val.val[1]);
// a0i*b0r|a1i*b1r|a2i*b2r|a3i*b3r
tmp_imag.val[1] = vmulq_f32(a_val.val[1], b_val.val[0]);
// combine the products
c_val.val[0] = vsubq_f32(tmp_real.val[0], tmp_real.val[1]);
c_val.val[1] = vaddq_f32(tmp_imag.val[0], tmp_imag.val[1]);
return c_val;
}
#endif /* INCLUDED_VOLK_GNSSSDR_NEON_INTRINSICS_H_ */ #endif /* INCLUDED_VOLK_GNSSSDR_NEON_INTRINSICS_H_ */

View File

@ -26,6 +26,7 @@
#define INCLUDED_VOLK_GNSSSDR_PREFS_H #define INCLUDED_VOLK_GNSSSDR_PREFS_H
#include <volk_gnsssdr/volk_gnsssdr_common.h> #include <volk_gnsssdr/volk_gnsssdr_common.h>
#include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
__VOLK_DECL_BEGIN __VOLK_DECL_BEGIN
@ -38,10 +39,11 @@ typedef struct volk_gnsssdr_arch_pref
} volk_gnsssdr_arch_pref_t; } volk_gnsssdr_arch_pref_t;
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// get path to volk_gnsssdr_config profiling info; // get path to volk_gnsssdr_config profiling info; second arguments specifies
// if config file should be tested on existence for reading.
// returns \0 in the argument on failure. // returns \0 in the argument on failure.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
VOLK_API void volk_gnsssdr_get_config_path(char *); VOLK_API void volk_gnsssdr_get_config_path(char *, bool);
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// load prefs into global prefs struct // load prefs into global prefs struct

View File

@ -16,6 +16,7 @@
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>. * along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
*/ */
#include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -29,7 +30,7 @@
#include <volk_gnsssdr/volk_gnsssdr_prefs.h> #include <volk_gnsssdr/volk_gnsssdr_prefs.h>
void volk_gnsssdr_get_config_path(char *path) void volk_gnsssdr_get_config_path(char *path, bool read)
{ {
if (!path) return; if (!path) return;
const char *suffix = "/.volk_gnsssdr/volk_gnsssdr_config"; const char *suffix = "/.volk_gnsssdr/volk_gnsssdr_config";
@ -42,8 +43,11 @@ void volk_gnsssdr_get_config_path(char *path)
{ {
strncpy(path, home, 512); strncpy(path, home, 512);
strcat(path, suffix2); strcat(path, suffix2);
if (!read || (access(path, F_OK) != -1))
{
return; return;
} }
}
// check for user-local config file // check for user-local config file
home = getenv("HOME"); home = getenv("HOME");
@ -51,7 +55,7 @@ void volk_gnsssdr_get_config_path(char *path)
{ {
strncpy(path, home, 512); strncpy(path, home, 512);
strcat(path, suffix); strcat(path, suffix);
if (access(path, F_OK) != -1) if (!read || (access(path, F_OK) != -1))
{ {
return; return;
} }
@ -63,7 +67,7 @@ void volk_gnsssdr_get_config_path(char *path)
{ {
strncpy(path, home, 512); strncpy(path, home, 512);
strcat(path, suffix); strcat(path, suffix);
if (access(path, F_OK) != -1) if (!read || (access(path, F_OK) != -1))
{ {
return; return;
} }
@ -99,7 +103,7 @@ size_t volk_gnsssdr_load_preferences(volk_gnsssdr_arch_pref_t **prefs_res)
volk_gnsssdr_arch_pref_t *prefs = NULL; volk_gnsssdr_arch_pref_t *prefs = NULL;
// get the config path // get the config path
volk_gnsssdr_get_config_path(path); volk_gnsssdr_get_config_path(path, true);
if (!path[0]) return n_arch_prefs; //no prefs found if (!path[0]) return n_arch_prefs; //no prefs found
config_file = fopen(path, "r"); config_file = fopen(path, "r");
if (!config_file) return n_arch_prefs; //no prefs found if (!config_file) return n_arch_prefs; //no prefs found

View File

@ -23,6 +23,7 @@ from __future__ import print_function
import sys import sys
import os import os
import exceptions
import re import re
from six.moves import configparser, input from six.moves import configparser, input

View File

@ -268,10 +268,10 @@ void rtl_tcp_signal_source_c::set_if_gain(int gain)
g += r.step; g += r.step;
} }
} }
for (unsigned stage = 1; stage <= gains.size(); stage++) for (size_t stage = 1; stage <= gains.size(); stage++)
{ {
int stage_gain = static_cast<int>(gains[stage] * 10); int stage_gain = static_cast<int>(gains[stage] * 10);
unsigned param = (stage << 16) | (stage_gain & 0xffff); size_t param = (stage << 16) | (stage_gain & 0xffff);
boost::system::error_code ec = rtl_tcp_command(RTL_TCP_SET_IF_GAIN, param, socket_); boost::system::error_code ec = rtl_tcp_command(RTL_TCP_SET_IF_GAIN, param, socket_);
if (ec) if (ec)
{ {

View File

@ -164,7 +164,7 @@ int unpack_2bit_samples::work(int noutput_items,
{ {
if (swap_endian_bytes_) if (swap_endian_bytes_)
{ {
for (unsigned int i = 0; i < ninput_bytes; ++i) for (size_t i = 0; i < ninput_bytes; ++i)
{ {
// Read packed input sample (1 byte = 4 samples) // Read packed input sample (1 byte = 4 samples)
raw_byte.byte = in[i]; raw_byte.byte = in[i];
@ -177,7 +177,7 @@ int unpack_2bit_samples::work(int noutput_items,
} }
else else
{ {
for (unsigned int i = 0; i < ninput_bytes; ++i) for (size_t i = 0; i < ninput_bytes; ++i)
{ {
// Read packed input sample (1 byte = 4 samples) // Read packed input sample (1 byte = 4 samples)
raw_byte.byte = in[i]; raw_byte.byte = in[i];
@ -193,7 +193,7 @@ int unpack_2bit_samples::work(int noutput_items,
{ {
if (swap_endian_bytes_) if (swap_endian_bytes_)
{ {
for (unsigned int i = 0; i < ninput_bytes; ++i) for (size_t i = 0; i < ninput_bytes; ++i)
{ {
// Read packed input sample (1 byte = 4 samples) // Read packed input sample (1 byte = 4 samples)
raw_byte.byte = in[i]; raw_byte.byte = in[i];
@ -206,7 +206,7 @@ int unpack_2bit_samples::work(int noutput_items,
} }
else else
{ {
for (unsigned int i = 0; i < ninput_bytes; ++i) for (size_t i = 0; i < ninput_bytes; ++i)
{ {
// Read packed input sample (1 byte = 4 samples) // Read packed input sample (1 byte = 4 samples)
raw_byte.byte = in[i]; raw_byte.byte = in[i];

View File

@ -48,7 +48,7 @@ public:
gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); gr_vector_const_void_star &input_items, gr_vector_void_star &output_items);
friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int adc_nbit); friend unpack_spir_gss6450_samples_sptr make_unpack_spir_gss6450_samples_sptr(unsigned int adc_nbit);
void decode_4bits_word(uint32_t input_uint32, gr_complex *out, int adc_bits); void decode_4bits_word(uint32_t input_uint32, gr_complex *out, int adc_bits);
unpack_spir_gss6450_samples(unsigned int adc_nbit); explicit unpack_spir_gss6450_samples(unsigned int adc_nbit);
~unpack_spir_gss6450_samples() = default; ~unpack_spir_gss6450_samples() = default;
private: private:

View File

@ -49,7 +49,7 @@ public:
/*! /*!
* \brief Constructor * \brief Constructor
*/ */
Fpga_Switch(const std::string& device_name); explicit Fpga_Switch(const std::string& device_name);
/*! /*!
* \brief Destructor * \brief Destructor

View File

@ -98,14 +98,14 @@ int Gnss_Sdr_Valve::work(int noutput_items,
return 0; return 0;
} }
// multichannel support // multichannel support
for (unsigned int ch = 0; ch < output_items.size(); ch++) for (size_t ch = 0; ch < output_items.size(); ch++)
{ {
memcpy(output_items[ch], input_items[ch], n * input_signature()->sizeof_stream_item(ch)); memcpy(output_items[ch], input_items[ch], n * input_signature()->sizeof_stream_item(ch));
} }
d_ncopied_items += n; d_ncopied_items += n;
return n; return n;
} }
for (unsigned int ch = 0; ch < output_items.size(); ch++) for (size_t ch = 0; ch < output_items.size(); ch++)
{ {
memcpy(output_items[ch], input_items[ch], noutput_items * input_signature()->sizeof_stream_item(ch)); memcpy(output_items[ch], input_items[ch], noutput_items * input_signature()->sizeof_stream_item(ch));
} }

View File

@ -138,7 +138,7 @@ bool sbas_l1_telemetry_decoder_gs::Sample_Aligner::get_symbols(const std::vector
VLOG(FLOW) << "get_symbols(): " VLOG(FLOW) << "get_symbols(): "
<< "d_past_sample=" << d_past_sample << "\tsamples size=" << samples.size(); << "d_past_sample=" << d_past_sample << "\tsamples size=" << samples.size();
for (uint32_t i_sym = 0; i_sym < samples.size() / sbas_l1_telemetry_decoder_gs::D_SAMPLES_PER_SYMBOL; i_sym++) for (size_t i_sym = 0; i_sym < samples.size() / sbas_l1_telemetry_decoder_gs::D_SAMPLES_PER_SYMBOL; i_sym++)
{ {
// get the next samples // get the next samples
for (int32_t i = 0; i < d_n_smpls_in_history; i++) for (int32_t i = 0; i < d_n_smpls_in_history; i++)

View File

@ -31,7 +31,7 @@
#include "viterbi_decoder.h" #include "viterbi_decoder.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <cstring> // for memset #include <algorithm> // for fill_n
#include <ostream> // for operator<<, basic_ostream, char_traits, endl #include <ostream> // for operator<<, basic_ostream, char_traits, endl
// logging // logging
@ -434,7 +434,6 @@ int Viterbi_Decoder::nsc_enc_bit(int state_out_p[], int input, int state_in,
length: The highest bit position in the symbol length: The highest bit position in the symbol
This function is used by nsc_enc_bit(), rsc_enc_bit(), and rsc_tail() */ This function is used by nsc_enc_bit(), rsc_enc_bit(), and rsc_tail() */
int Viterbi_Decoder::parity_counter(int symbol, int length) int Viterbi_Decoder::parity_counter(int symbol, int length)
{ {
int counter; int counter;
@ -453,14 +452,13 @@ Viterbi_Decoder::Prev::Prev(int states, int t)
{ {
this->t = t; this->t = t;
num_states = states; num_states = states;
state = new int[states]; state.reserve(num_states);
bit = new int[states]; bit.reserve(num_states);
metric = new float[states]; metric.reserve(num_states);
refcount = new int; refcount = 1;
*refcount = 1; std::fill_n(state.begin(), num_states, 0);
memset(state, 0, sizeof(int) * num_states); std::fill_n(bit.begin(), num_states, 0);
memset(bit, 0, sizeof(int) * num_states); std::fill_n(metric.begin(), num_states, 0.0F);
memset(metric, 0, sizeof(float) * num_states);
} }
@ -468,7 +466,7 @@ Viterbi_Decoder::Prev::Prev(int states, int t)
Viterbi_Decoder::Prev::Prev(const Prev& prev) Viterbi_Decoder::Prev::Prev(const Prev& prev)
{ {
refcount = prev.refcount; refcount = prev.refcount;
(*refcount)++; refcount++;
t = prev.t; t = prev.t;
state = prev.state; state = prev.state;
num_states = prev.num_states; num_states = prev.num_states;
@ -477,7 +475,7 @@ Viterbi_Decoder::Prev::Prev(const Prev& prev)
VLOG(LMORE) << "Prev(" VLOG(LMORE) << "Prev("
<< "?" << "?"
<< ", " << t << ")" << ", " << t << ")"
<< " copy, new refcount = " << *refcount; << " copy, new refcount = " << refcount;
} }
@ -491,21 +489,14 @@ Viterbi_Decoder::Prev& Viterbi_Decoder::Prev::operator=(const Prev& other)
} }
// handle old resources // handle old resources
if (*refcount == 1) if (refcount != 1)
{ // if they are not used anymore -> unallocate them
delete[] state;
delete[] bit;
delete[] metric;
delete refcount;
}
else
{ // this object is not anymore using them { // this object is not anymore using them
(*refcount)--; refcount--;
} }
// increase ref counter for this resource set // increase ref counter for this resource set
refcount = other.refcount; refcount = other.refcount;
(*refcount)++; refcount++;
// take over resources // take over resources
t = other.t; t = other.t;
@ -516,28 +507,20 @@ Viterbi_Decoder::Prev& Viterbi_Decoder::Prev::operator=(const Prev& other)
VLOG(LMORE) << "Prev(" VLOG(LMORE) << "Prev("
<< "?" << "?"
<< ", " << t << ")" << ", " << t << ")"
<< " assignment, new refcount = " << *refcount; << " assignment, new refcount = " << refcount;
return *this; return *this;
} }
Viterbi_Decoder::Prev::~Prev() Viterbi_Decoder::Prev::~Prev()
{ {
if (*refcount == 1) if (refcount != 1)
{ {
delete[] state; refcount--;
delete[] bit;
delete[] metric;
delete refcount;
// std::cout << "~Prev(" << "?" << ", " << t << ")" << " destructor with delete" << std::endl;
}
else
{
(*refcount)--;
VLOG(LMORE) << "~Prev(" VLOG(LMORE) << "~Prev("
<< "?" << "?"
<< ", " << t << ")" << ", " << t << ")"
<< " destructor after copy, new refcount = " << *refcount; << " destructor after copy, new refcount = " << refcount;
} }
} }

View File

@ -79,10 +79,10 @@ private:
private: private:
int t; int t;
int* state; std::vector<int> state;
int* bit; std::vector<int> bit;
float* metric; std::vector<float> metric;
int* refcount; int refcount;
}; };
// code properties // code properties

View File

@ -126,6 +126,10 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param.enable_fll_pull_in = enable_fll_pull_in; trk_param.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param.fll_bw_hz = fll_bw_hz; trk_param.fll_bw_hz = fll_bw_hz;
trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s); trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s);
@ -167,6 +171,13 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking(
trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail); trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail);
trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th); trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th);
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
// ################# MAKE TRACKING GNURadio object ################### // ################# MAKE TRACKING GNURadio object ###################
if (item_type == "gr_complex") if (item_type == "gr_complex")
{ {

View File

@ -126,6 +126,8 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param_fpga.enable_fll_pull_in = enable_fll_pull_in; trk_param_fpga.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param_fpga.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param_fpga.fll_bw_hz = fll_bw_hz; trk_param_fpga.fll_bw_hz = fll_bw_hz;
float pull_in_time_s = configuration->property(role + ".pull_in_time_s", 2.0); float pull_in_time_s = configuration->property(role + ".pull_in_time_s", 2.0);
@ -173,7 +175,7 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga(
std::string default_device_name = "/dev/uio"; std::string default_device_name = "/dev/uio";
std::string device_name = configuration->property(role + ".devicename", default_device_name); std::string device_name = configuration->property(role + ".devicename", default_device_name);
trk_param_fpga.device_name = device_name; trk_param_fpga.device_name = device_name;
uint32_t device_base = configuration->property(role + ".device_base", 15); int32_t device_base = configuration->property(role + ".device_base", 15);
trk_param_fpga.device_base = device_base; trk_param_fpga.device_base = device_base;
//################# PRE-COMPUTE ALL THE CODES ################# //################# PRE-COMPUTE ALL THE CODES #################
@ -252,6 +254,14 @@ GalileoE1DllPllVemlTrackingFpga::GalileoE1DllPllVemlTrackingFpga(
trk_param_fpga.extended_correlation_in_fpga = false; trk_param_fpga.extended_correlation_in_fpga = false;
trk_param_fpga.extend_fpga_integration_periods = 1; // (number of FPGA integrations that are combined in the SW) trk_param_fpga.extend_fpga_integration_periods = 1; // (number of FPGA integrations that are combined in the SW)
trk_param_fpga.fpga_integration_period = 1; // (number of symbols that are effectively integrated in the FPGA) trk_param_fpga.fpga_integration_period = 1; // (number of symbols that are effectively integrated in the FPGA)
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
//################# MAKE TRACKING GNURadio object ################### //################# MAKE TRACKING GNURadio object ###################
tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga);
channel_ = 0; channel_ = 0;

View File

@ -121,6 +121,8 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param.enable_fll_pull_in = enable_fll_pull_in; trk_param.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param.fll_bw_hz = fll_bw_hz; trk_param.fll_bw_hz = fll_bw_hz;
trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s); trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s);
@ -164,6 +166,13 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking(
trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail); trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail);
trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th); trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th);
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
// ################# MAKE TRACKING GNURadio object ################### // ################# MAKE TRACKING GNURadio object ###################
if (item_type == "gr_complex") if (item_type == "gr_complex")
{ {

View File

@ -117,6 +117,8 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param_fpga.enable_fll_pull_in = enable_fll_pull_in; trk_param_fpga.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param_fpga.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param_fpga.fll_bw_hz = fll_bw_hz; trk_param_fpga.fll_bw_hz = fll_bw_hz;
float pull_in_time_s = configuration->property(role + ".pull_in_time_s", 2.0); float pull_in_time_s = configuration->property(role + ".pull_in_time_s", 2.0);
@ -168,7 +170,7 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga(
std::string default_device_name = "/dev/uio"; std::string default_device_name = "/dev/uio";
std::string device_name = configuration->property(role + ".devicename", default_device_name); std::string device_name = configuration->property(role + ".devicename", default_device_name);
trk_param_fpga.device_name = device_name; trk_param_fpga.device_name = device_name;
uint32_t device_base = configuration->property(role + ".device_base", 27); int32_t device_base = configuration->property(role + ".device_base", 27);
trk_param_fpga.device_base = device_base; trk_param_fpga.device_base = device_base;
// ################# PRE-COMPUTE ALL THE CODES ################# // ################# PRE-COMPUTE ALL THE CODES #################
@ -260,6 +262,13 @@ GalileoE5aDllPllTrackingFpga::GalileoE5aDllPllTrackingFpga(
} }
} }
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
// ################# MAKE TRACKING GNURadio object ################### // ################# MAKE TRACKING GNURadio object ###################
tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga);
channel_ = 0; channel_ = 0;

View File

@ -127,6 +127,8 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param.enable_fll_pull_in = enable_fll_pull_in; trk_param.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param.fll_bw_hz = fll_bw_hz; trk_param.fll_bw_hz = fll_bw_hz;
trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s); trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s);
@ -170,6 +172,12 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking(
trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail); trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail);
trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th); trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th);
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
// ################# MAKE TRACKING GNURadio object ################### // ################# MAKE TRACKING GNURadio object ###################
if (item_type == "gr_complex") if (item_type == "gr_complex")
{ {

View File

@ -126,6 +126,8 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param_fpga.enable_fll_pull_in = enable_fll_pull_in; trk_param_fpga.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param_fpga.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param_fpga.fll_bw_hz = fll_bw_hz; trk_param_fpga.fll_bw_hz = fll_bw_hz;
float pull_in_time_s = configuration->property(role + ".pull_in_time_s", 2.0); float pull_in_time_s = configuration->property(role + ".pull_in_time_s", 2.0);
@ -174,7 +176,7 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga(
std::string default_device_name = "/dev/uio"; std::string default_device_name = "/dev/uio";
std::string device_name = configuration->property(role + ".devicename", default_device_name); std::string device_name = configuration->property(role + ".devicename", default_device_name);
trk_param_fpga.device_name = device_name; trk_param_fpga.device_name = device_name;
uint32_t device_base = configuration->property(role + ".device_base", 3); int32_t device_base = configuration->property(role + ".device_base", 3);
trk_param_fpga.device_base = device_base; trk_param_fpga.device_base = device_base;
// ################# PRE-COMPUTE ALL THE CODES ################# // ################# PRE-COMPUTE ALL THE CODES #################
@ -214,6 +216,13 @@ GpsL1CaDllPllTrackingFpga::GpsL1CaDllPllTrackingFpga(
} }
} }
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
// ################# MAKE TRACKING GNURadio object ################### // ################# MAKE TRACKING GNURadio object ###################
tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga);
channel_ = 0; channel_ = 0;

View File

@ -115,6 +115,8 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param.enable_fll_pull_in = enable_fll_pull_in; trk_param.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param.fll_bw_hz = fll_bw_hz; trk_param.fll_bw_hz = fll_bw_hz;
trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s); trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s);
@ -146,6 +148,13 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking(
trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail); trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail);
trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th); trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th);
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
// ################# MAKE TRACKING GNURadio object ################### // ################# MAKE TRACKING GNURadio object ###################
if (item_type == "gr_complex") if (item_type == "gr_complex")
{ {

View File

@ -128,6 +128,8 @@ GpsL5DllPllTracking::GpsL5DllPllTracking(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param.enable_fll_pull_in = enable_fll_pull_in; trk_param.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param.fll_bw_hz = fll_bw_hz; trk_param.fll_bw_hz = fll_bw_hz;
trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s); trk_param.pull_in_time_s = configuration->property(role + ".pull_in_time_s", trk_param.pull_in_time_s);
@ -166,6 +168,12 @@ GpsL5DllPllTracking::GpsL5DllPllTracking(
trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail); trk_param.max_carrier_lock_fail = configuration->property(role + ".max_carrier_lock_fail", trk_param.max_carrier_lock_fail);
trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th); trk_param.carrier_lock_th = configuration->property(role + ".carrier_lock_th", trk_param.carrier_lock_th);
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
// ################# MAKE TRACKING GNURadio object ################### // ################# MAKE TRACKING GNURadio object ###################
if (item_type == "gr_complex") if (item_type == "gr_complex")
{ {

View File

@ -130,6 +130,8 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga(
bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false); bool enable_fll_pull_in = configuration->property(role + ".enable_fll_pull_in", false);
trk_param_fpga.enable_fll_pull_in = enable_fll_pull_in; trk_param_fpga.enable_fll_pull_in = enable_fll_pull_in;
bool enable_fll_steady_state = configuration->property(role + ".enable_fll_steady_state", false);
trk_param_fpga.enable_fll_steady_state = enable_fll_steady_state;
float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0); float fll_bw_hz = configuration->property(role + ".fll_bw_hz", 35.0);
trk_param_fpga.fll_bw_hz = fll_bw_hz; trk_param_fpga.fll_bw_hz = fll_bw_hz;
float pull_in_time_s = configuration->property(role + ".pull_in_time_s", 2.0); float pull_in_time_s = configuration->property(role + ".pull_in_time_s", 2.0);
@ -173,7 +175,7 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga(
std::string default_device_name = "/dev/uio"; std::string default_device_name = "/dev/uio";
std::string device_name = configuration->property(role + ".devicename", default_device_name); std::string device_name = configuration->property(role + ".devicename", default_device_name);
trk_param_fpga.device_name = device_name; trk_param_fpga.device_name = device_name;
uint32_t device_base = configuration->property(role + ".device_base", 27); int32_t device_base = configuration->property(role + ".device_base", 27);
trk_param_fpga.device_base = device_base; trk_param_fpga.device_base = device_base;
// ################# PRE-COMPUTE ALL THE CODES ################# // ################# PRE-COMPUTE ALL THE CODES #################
@ -284,6 +286,13 @@ GpsL5DllPllTrackingFpga::GpsL5DllPllTrackingFpga(
} }
} }
//tracking lock tests smoother parameters
trk_param.cn0_smoother_samples = configuration->property(role + ".cn0_smoother_samples", trk_param.cn0_smoother_samples);
trk_param.cn0_smoother_alpha = configuration->property(role + ".cn0_smoother_alpha", trk_param.cn0_smoother_alpha);
trk_param.carrier_lock_test_smoother_samples = configuration->property(role + ".carrier_lock_test_smoother_samples", trk_param.carrier_lock_test_smoother_samples);
trk_param.carrier_lock_test_smoother_alpha = configuration->property(role + ".carrier_lock_test_smoother_alpha", trk_param.carrier_lock_test_smoother_alpha);
// ################# MAKE TRACKING GNURadio object ###################
tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga); tracking_fpga_sc = dll_pll_veml_make_tracking_fpga(trk_param_fpga);
channel_ = 0; channel_ = 0;
DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")"; DLOG(INFO) << "tracking(" << tracking_fpga_sc->unique_id() << ")";

View File

@ -445,16 +445,18 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl
d_carrier_lock_threshold = trk_parameters.carrier_lock_th; d_carrier_lock_threshold = trk_parameters.carrier_lock_th;
d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_cn0_smoother = Exponential_Smoother(); d_cn0_smoother = Exponential_Smoother();
d_cn0_smoother.set_alpha(trk_parameters.cn0_smoother_alpha);
if (d_code_period > 0.0) if (d_code_period > 0.0)
{ {
d_cn0_smoother.set_samples_for_initialization(200 / static_cast<int>(d_code_period * 1000.0)); d_cn0_smoother.set_samples_for_initialization(trk_parameters.cn0_smoother_samples / static_cast<int>(d_code_period * 1000.0));
} }
d_carrier_lock_test_smoother = Exponential_Smoother(); d_carrier_lock_test_smoother = Exponential_Smoother();
d_carrier_lock_test_smoother.set_alpha(0.002); d_carrier_lock_test_smoother.set_alpha(trk_parameters.carrier_lock_test_smoother_alpha);
d_carrier_lock_test_smoother.set_min_value(-1.0); d_carrier_lock_test_smoother.set_min_value(-1.0);
d_carrier_lock_test_smoother.set_offset(0.0); d_carrier_lock_test_smoother.set_offset(0.0);
d_carrier_lock_test_smoother.set_samples_for_initialization(25); d_carrier_lock_test_smoother.set_samples_for_initialization(trk_parameters.carrier_lock_test_smoother_samples);
d_acquisition_gnss_synchro = nullptr; d_acquisition_gnss_synchro = nullptr;
d_channel = 0; d_channel = 0;

View File

@ -77,7 +77,7 @@ public:
private: private:
friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_); friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_);
void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg); void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg);
dll_pll_veml_tracking(const Dll_Pll_Conf &conf_); explicit dll_pll_veml_tracking(const Dll_Pll_Conf &conf_);
bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool cn0_and_tracking_lock_status(double coh_integration_time_s);
bool acquire_secondary(); bool acquire_secondary();

View File

@ -375,16 +375,17 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &
d_carrier_lock_threshold = trk_parameters.carrier_lock_th; d_carrier_lock_threshold = trk_parameters.carrier_lock_th;
d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_Prompt_Data = static_cast<gr_complex *>(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment()));
d_cn0_smoother = Exponential_Smoother(); d_cn0_smoother = Exponential_Smoother();
d_cn0_smoother.set_alpha(trk_parameters.cn0_smoother_alpha);
if (d_code_period > 0.0) if (d_code_period > 0.0)
{ {
d_cn0_smoother.set_samples_for_initialization(200 / static_cast<int>(d_code_period * 1000.0)); d_cn0_smoother.set_samples_for_initialization(trk_parameters.cn0_smoother_samples / static_cast<int>(d_code_period * 1000.0));
} }
d_carrier_lock_test_smoother = Exponential_Smoother(); d_carrier_lock_test_smoother = Exponential_Smoother();
d_carrier_lock_test_smoother.set_alpha(0.002); d_carrier_lock_test_smoother.set_alpha(trk_parameters.carrier_lock_test_smoother_alpha);
d_carrier_lock_test_smoother.set_min_value(-1.0); d_carrier_lock_test_smoother.set_min_value(-1.0);
d_carrier_lock_test_smoother.set_offset(0.0); d_carrier_lock_test_smoother.set_offset(0.0);
d_carrier_lock_test_smoother.set_samples_for_initialization(25); d_carrier_lock_test_smoother.set_samples_for_initialization(trk_parameters.carrier_lock_test_smoother_samples);
d_acquisition_gnss_synchro = nullptr; d_acquisition_gnss_synchro = nullptr;
d_channel = 0; d_channel = 0;
@ -449,7 +450,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &
} }
// create multicorrelator class // create multicorrelator class
std::string device_name = trk_parameters.device_name; std::string device_name = trk_parameters.device_name;
uint32_t device_base = trk_parameters.device_base; int32_t device_base = trk_parameters.device_base;
int32_t *ca_codes = trk_parameters.ca_codes; int32_t *ca_codes = trk_parameters.ca_codes;
int32_t *data_codes = trk_parameters.data_codes; int32_t *data_codes = trk_parameters.data_codes;
multicorrelator_fpga = std::make_shared<Fpga_Multicorrelator_8sc>(d_n_correlator_taps, device_name, device_base, ca_codes, data_codes, d_code_length_chips, trk_parameters.track_pilot, d_code_samples_per_chip); multicorrelator_fpga = std::make_shared<Fpga_Multicorrelator_8sc>(d_n_correlator_taps, device_name, device_base, ca_codes, data_codes, d_code_length_chips, trk_parameters.track_pilot, d_code_samples_per_chip);

View File

@ -108,7 +108,7 @@ public:
private: private:
friend dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); friend dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_);
void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg); void msg_handler_telemetry_to_trk(const pmt::pmt_t &msg);
dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_); explicit dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_);
bool cn0_and_tracking_lock_status(double coh_integration_time_s); bool cn0_and_tracking_lock_status(double coh_integration_time_s);
bool acquire_secondary(); bool acquire_secondary();

View File

@ -124,7 +124,7 @@ void Bayesian_estimator::update_sequential(const arma::vec& data)
arma::vec mu_posterior = (kappa_prior * mu_prior + K * y_mean) / (kappa_prior + K); arma::vec mu_posterior = (kappa_prior * mu_prior + K * y_mean) / (kappa_prior + K);
int kappa_posterior = kappa_prior + K; int kappa_posterior = kappa_prior + K;
int nu_posterior = nu_prior + K; int nu_posterior = nu_prior + K;
arma::mat Psi_posterior = Psi_prior + Psi_N + (kappa_prior * K) / (kappa_prior + K) * (y_mean - mu_prior) * ((y_mean - mu_prior).t()); arma::mat Psi_posterior = Psi_prior + Psi_N + (kappa_prior * static_cast<float>(K)) / (kappa_prior + static_cast<float>(K)) * (y_mean - mu_prior) * ((y_mean - mu_prior).t());
mu_est = mu_posterior; mu_est = mu_posterior;
if ((nu_posterior - ny - 1) > 0) if ((nu_posterior - ny - 1) > 0)
@ -163,7 +163,7 @@ void Bayesian_estimator::update_sequential(const arma::vec& data, const arma::ve
arma::vec mu_posterior = (kappa_prior_0 * mu_prior_0 + K * y_mean) / (kappa_prior_0 + K); arma::vec mu_posterior = (kappa_prior_0 * mu_prior_0 + K * y_mean) / (kappa_prior_0 + K);
int kappa_posterior = kappa_prior_0 + K; int kappa_posterior = kappa_prior_0 + K;
int nu_posterior = nu_prior_0 + K; int nu_posterior = nu_prior_0 + K;
arma::mat Psi_posterior = Psi_prior_0 + Psi_N + (kappa_prior_0 * K) / (kappa_prior_0 + K) * (y_mean - mu_prior_0) * ((y_mean - mu_prior_0).t()); arma::mat Psi_posterior = Psi_prior_0 + Psi_N + (kappa_prior_0 * static_cast<float>(K)) / (kappa_prior_0 + static_cast<float>(K)) * (y_mean - mu_prior_0) * ((y_mean - mu_prior_0).t());
mu_est = mu_posterior; mu_est = mu_posterior;
if ((nu_posterior - ny - 1) > 0) if ((nu_posterior - ny - 1) > 0)

View File

@ -69,7 +69,7 @@ class Bayesian_estimator
{ {
public: public:
Bayesian_estimator(); Bayesian_estimator();
Bayesian_estimator(int ny); explicit Bayesian_estimator(int ny);
Bayesian_estimator(const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0); Bayesian_estimator(const arma::vec& mu_prior_0, int kappa_prior_0, int nu_prior_0, const arma::mat& Psi_prior_0);
~Bayesian_estimator() = default; ~Bayesian_estimator() = default;

View File

@ -63,7 +63,10 @@ Dll_Pll_Conf::Dll_Pll_Conf()
very_early_late_space_narrow_chips = 0.1; very_early_late_space_narrow_chips = 0.1;
extend_correlation_symbols = 5; extend_correlation_symbols = 5;
cn0_samples = FLAGS_cn0_samples; cn0_samples = FLAGS_cn0_samples;
carrier_lock_det_mav_samples = FLAGS_cn0_samples; cn0_smoother_samples=200;
cn0_smoother_alpha=0.002;
carrier_lock_test_smoother_alpha=0.002;
carrier_lock_test_smoother_samples=25;
cn0_min = FLAGS_cn0_min; cn0_min = FLAGS_cn0_min;
max_carrier_lock_fail = FLAGS_max_carrier_lock_fail; max_carrier_lock_fail = FLAGS_max_carrier_lock_fail;
max_code_lock_fail = FLAGS_max_lock_fail; max_code_lock_fail = FLAGS_max_lock_fail;

View File

@ -68,7 +68,11 @@ public:
int32_t extend_correlation_symbols; int32_t extend_correlation_symbols;
bool high_dyn; bool high_dyn;
int32_t cn0_samples; int32_t cn0_samples;
int32_t carrier_lock_det_mav_samples; int32_t cn0_smoother_samples;
float cn0_smoother_alpha;
int32_t carrier_lock_test_smoother_samples;
float carrier_lock_test_smoother_alpha;
//int32_t carrier_lock_det_mav_samples;
int32_t cn0_min; int32_t cn0_min;
int32_t max_code_lock_fail; int32_t max_code_lock_fail;
int32_t max_carrier_lock_fail; int32_t max_carrier_lock_fail;

View File

@ -65,6 +65,10 @@ Dll_Pll_Conf_Fpga::Dll_Pll_Conf_Fpga()
very_early_late_space_narrow_chips = 0.1; very_early_late_space_narrow_chips = 0.1;
extend_correlation_symbols = 5; extend_correlation_symbols = 5;
cn0_samples = FLAGS_cn0_samples; cn0_samples = FLAGS_cn0_samples;
cn0_smoother_samples=200;
cn0_smoother_alpha=0.002;
carrier_lock_test_smoother_alpha=0.002;
carrier_lock_test_smoother_samples=25;
cn0_min = FLAGS_cn0_min; cn0_min = FLAGS_cn0_min;
max_carrier_lock_fail = FLAGS_max_carrier_lock_fail; max_carrier_lock_fail = FLAGS_max_carrier_lock_fail;
max_code_lock_fail = FLAGS_max_lock_fail; max_code_lock_fail = FLAGS_max_lock_fail;
@ -77,7 +81,7 @@ Dll_Pll_Conf_Fpga::Dll_Pll_Conf_Fpga()
signal[1] = 'C'; signal[1] = 'C';
signal[2] = '\0'; signal[2] = '\0';
device_name = "/dev/uio"; device_name = "/dev/uio";
device_base = 1U; device_base = 1;
code_length_chips = 0U; code_length_chips = 0U;
code_samples_per_chip = 0U; code_samples_per_chip = 0U;
ca_codes = nullptr; ca_codes = nullptr;

View File

@ -73,6 +73,12 @@ public:
int32_t cn0_min; int32_t cn0_min;
int32_t max_code_lock_fail; int32_t max_code_lock_fail;
int32_t max_carrier_lock_fail; int32_t max_carrier_lock_fail;
int32_t cn0_smoother_samples;
float cn0_smoother_alpha;
int32_t carrier_lock_test_smoother_samples;
float carrier_lock_test_smoother_alpha;
// int32_t max_lock_fail; // int32_t max_lock_fail;
uint32_t smoother_length; uint32_t smoother_length;
double carrier_lock_th; double carrier_lock_th;
@ -81,7 +87,7 @@ public:
char system; char system;
char signal[3]; char signal[3];
std::string device_name; std::string device_name;
uint32_t device_base; int32_t device_base;
uint32_t code_length_chips; uint32_t code_length_chips;
uint32_t code_samples_per_chip; uint32_t code_samples_per_chip;
int32_t* ca_codes; int32_t* ca_codes;

View File

@ -61,7 +61,7 @@ const float PHASE_CARR_MAX_DIV_PI = 683565275.5764316; // 2^(31)/pi
const float TWO_PI = 6.283185307179586; const float TWO_PI = 6.283185307179586;
Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators, Fpga_Multicorrelator_8sc::Fpga_Multicorrelator_8sc(int32_t n_correlators,
std::string device_name, uint32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot, std::string device_name, int32_t device_base, int32_t *ca_codes, int32_t *data_codes, uint32_t code_length_chips, bool track_pilot,
uint32_t code_samples_per_chip) uint32_t code_samples_per_chip)
{ {

View File

@ -53,7 +53,7 @@ public:
*/ */
Fpga_Multicorrelator_8sc(int32_t n_correlators, Fpga_Multicorrelator_8sc(int32_t n_correlators,
std::string device_name, std::string device_name,
uint32_t device_base, int32_t device_base,
int32_t *ca_codes, int32_t *ca_codes,
int32_t *data_codes, int32_t *data_codes,
uint32_t code_length_chips, uint32_t code_length_chips,
@ -236,7 +236,7 @@ private:
// driver // driver
std::string d_device_name; std::string d_device_name;
uint32_t d_device_base; int32_t d_device_base;
// PRN codes // PRN codes
int32_t *d_ca_codes; int32_t *d_ca_codes;

View File

@ -108,7 +108,7 @@ void CubatureFilter::predict_sequential(const arma::vec& x_post, const arma::mat
arma::vec Xi_post; arma::vec Xi_post;
arma::vec Xi_pred; arma::vec Xi_pred;
for (uint8_t i = 0; i < np; i++) for (int i = 0; i < np; i++)
{ {
Xi_post = Sm_post * (std::sqrt(static_cast<float>(np) / 2.0) * gen_one.col(i)) + x_post; Xi_post = Sm_post * (std::sqrt(static_cast<float>(np) / 2.0) * gen_one.col(i)) + x_post;
Xi_pred = (*transition_fcn)(Xi_post); Xi_pred = (*transition_fcn)(Xi_post);
@ -151,7 +151,7 @@ void CubatureFilter::update_sequential(const arma::vec& z_upd, const arma::vec&
// Propagate and evaluate cubature points // Propagate and evaluate cubature points
arma::vec Xi_pred; arma::vec Xi_pred;
arma::vec Zi_pred; arma::vec Zi_pred;
for (uint8_t i = 0; i < np; i++) for (int i = 0; i < np; i++)
{ {
Xi_pred = Sm_pred * (std::sqrt(static_cast<float>(np) / 2.0) * gen_one.col(i)) + x_pred; Xi_pred = Sm_pred * (std::sqrt(static_cast<float>(np) / 2.0) * gen_one.col(i)) + x_pred;
Zi_pred = (*measurement_fcn)(Xi_pred); Zi_pred = (*measurement_fcn)(Xi_pred);
@ -270,7 +270,7 @@ void UnscentedFilter::predict_sequential(const arma::vec& x_post, const arma::ma
Xi_post.col(0) = x_post; Xi_post.col(0) = x_post;
Xi_pred.col(0) = (*transition_fcn)(Xi_post.col(0)); Xi_pred.col(0) = (*transition_fcn)(Xi_post.col(0));
for (uint8_t i = 1; i <= nx; i++) for (int i = 1; i <= nx; i++)
{ {
Xi_fact = std::sqrt(static_cast<float>(nx) + lambda) * arma::sqrtmat_sympd(P_x_post); Xi_fact = std::sqrt(static_cast<float>(nx) + lambda) * arma::sqrtmat_sympd(P_x_post);
Xi_post.col(i) = x_post + Xi_fact.col(i - 1); Xi_post.col(i) = x_post + Xi_fact.col(i - 1);
@ -285,7 +285,7 @@ void UnscentedFilter::predict_sequential(const arma::vec& x_post, const arma::ma
// Compute predicted error covariance // Compute predicted error covariance
arma::mat P_x_pred = W0_c * ((Xi_pred.col(0) - x_pred) * (Xi_pred.col(0).t() - x_pred.t())); arma::mat P_x_pred = W0_c * ((Xi_pred.col(0) - x_pred) * (Xi_pred.col(0).t() - x_pred.t()));
for (uint8_t i = 1; i < np; i++) for (int i = 1; i < np; i++)
{ {
P_x_pred = P_x_pred + Wi_m * ((Xi_pred.col(i) - x_pred) * (Xi_pred.col(i).t() - x_pred.t())); P_x_pred = P_x_pred + Wi_m * ((Xi_pred.col(i) - x_pred) * (Xi_pred.col(i).t() - x_pred.t()));
} }
@ -325,7 +325,7 @@ void UnscentedFilter::update_sequential(const arma::vec& z_upd, const arma::vec&
Xi_pred.col(0) = x_pred; Xi_pred.col(0) = x_pred;
Zi_pred.col(0) = (*measurement_fcn)(Xi_pred.col(0)); Zi_pred.col(0) = (*measurement_fcn)(Xi_pred.col(0));
for (uint8_t i = 1; i <= nx; i++) for (int i = 1; i <= nx; i++)
{ {
Xi_fact = std::sqrt(static_cast<float>(nx) + lambda) * arma::sqrtmat_sympd(P_x_pred); Xi_fact = std::sqrt(static_cast<float>(nx) + lambda) * arma::sqrtmat_sympd(P_x_pred);
Xi_pred.col(i) = x_pred + Xi_fact.col(i - 1); Xi_pred.col(i) = x_pred + Xi_fact.col(i - 1);
@ -341,7 +341,7 @@ void UnscentedFilter::update_sequential(const arma::vec& z_upd, const arma::vec&
// Compute measurement covariance and cross covariance // Compute measurement covariance and cross covariance
arma::mat P_zz_pred = W0_c * ((Zi_pred.col(0) - z_pred) * (Zi_pred.col(0).t() - z_pred.t())); arma::mat P_zz_pred = W0_c * ((Zi_pred.col(0) - z_pred) * (Zi_pred.col(0).t() - z_pred.t()));
arma::mat P_xz_pred = W0_c * ((Xi_pred.col(0) - x_pred) * (Zi_pred.col(0).t() - z_pred.t())); arma::mat P_xz_pred = W0_c * ((Xi_pred.col(0) - x_pred) * (Zi_pred.col(0).t() - z_pred.t()));
for (uint8_t i = 0; i < np; i++) for (int i = 0; i < np; i++)
{ {
P_zz_pred = P_zz_pred + Wi_m * ((Zi_pred.col(i) - z_pred) * (Zi_pred.col(i).t() - z_pred.t())); P_zz_pred = P_zz_pred + Wi_m * ((Zi_pred.col(i) - z_pred) * (Zi_pred.col(i).t() - z_pred.t()));
P_xz_pred = P_xz_pred + Wi_m * ((Xi_pred.col(i) - x_pred) * (Zi_pred.col(i).t() - z_pred.t())); P_xz_pred = P_xz_pred + Wi_m * ((Xi_pred.col(i) - x_pred) * (Zi_pred.col(i).t() - z_pred.t()));

View File

@ -64,7 +64,7 @@ class CubatureFilter
public: public:
// Constructors and destructors // Constructors and destructors
CubatureFilter(); CubatureFilter();
CubatureFilter(int nx); explicit CubatureFilter(int nx);
CubatureFilter(const arma::vec& x_pred_0, const arma::mat& P_x_pred_0); CubatureFilter(const arma::vec& x_pred_0, const arma::mat& P_x_pred_0);
~CubatureFilter() = default; ~CubatureFilter() = default;
@ -93,7 +93,7 @@ class UnscentedFilter
public: public:
// Constructors and destructors // Constructors and destructors
UnscentedFilter(); UnscentedFilter();
UnscentedFilter(int nx); explicit UnscentedFilter(int nx);
UnscentedFilter(const arma::vec& x_pred_0, const arma::mat& P_x_pred_0); UnscentedFilter(const arma::vec& x_pred_0, const arma::mat& P_x_pred_0);
~UnscentedFilter() = default; ~UnscentedFilter() = default;

View File

@ -52,7 +52,7 @@ public:
void set_pdi(float pdi_code); //!< Set Summation interval for code [s] void set_pdi(float pdi_code); //!< Set Summation interval for code [s]
void initialize(); //!< Start tracking with acquisition information void initialize(); //!< Start tracking with acquisition information
float get_code_nco(float DLL_discriminator); //!< Numerically controlled oscillator float get_code_nco(float DLL_discriminator); //!< Numerically controlled oscillator
Tracking_2nd_DLL_filter(float pdi_code); explicit Tracking_2nd_DLL_filter(float pdi_code);
Tracking_2nd_DLL_filter(); Tracking_2nd_DLL_filter();
~Tracking_2nd_DLL_filter() = default; ~Tracking_2nd_DLL_filter() = default;

View File

@ -51,7 +51,7 @@ public:
void set_pdi(float pdi_carr); //!< Set Summation interval for code [s] void set_pdi(float pdi_carr); //!< Set Summation interval for code [s]
void initialize(); void initialize();
float get_carrier_nco(float PLL_discriminator); float get_carrier_nco(float PLL_discriminator);
Tracking_2nd_PLL_filter(float pdi_carr); explicit Tracking_2nd_PLL_filter(float pdi_carr);
Tracking_2nd_PLL_filter(); Tracking_2nd_PLL_filter();
~Tracking_2nd_PLL_filter() = default; ~Tracking_2nd_PLL_filter() = default;

View File

@ -35,6 +35,7 @@
#include "tracking_loop_filter.h" #include "tracking_loop_filter.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <cmath> #include <cmath>
#include <cstddef>
const int MAX_LOOP_ORDER = 3; const int MAX_LOOP_ORDER = 3;
const int MAX_LOOP_HISTORY_LENGTH = 4; const int MAX_LOOP_HISTORY_LENGTH = 4;
@ -74,7 +75,7 @@ float Tracking_loop_filter::apply(float current_input)
float result = 0.0; float result = 0.0;
// Handle the old outputs first: // Handle the old outputs first:
for (unsigned int ii = 0; ii < d_output_coefficients.size(); ++ii) for (size_t ii = 0; ii < d_output_coefficients.size(); ++ii)
{ {
result += d_output_coefficients[ii] * d_outputs[(d_current_index + ii) % MAX_LOOP_HISTORY_LENGTH]; result += d_output_coefficients[ii] * d_outputs[(d_current_index + ii) % MAX_LOOP_HISTORY_LENGTH];
} }
@ -94,7 +95,7 @@ float Tracking_loop_filter::apply(float current_input)
d_inputs[d_current_index] = current_input; d_inputs[d_current_index] = current_input;
for (unsigned int ii = 0; ii < d_input_coefficients.size(); ++ii) for (size_t ii = 0; ii < d_input_coefficients.size(); ++ii)
{ {
result += d_input_coefficients[ii] * d_inputs[(d_current_index + ii) % MAX_LOOP_HISTORY_LENGTH]; result += d_input_coefficients[ii] * d_inputs[(d_current_index + ii) % MAX_LOOP_HISTORY_LENGTH];
} }

View File

@ -60,7 +60,7 @@ class INIReader
{ {
public: public:
//! Construct INIReader and parse given filename. See ini.h for more info about the parsing. //! Construct INIReader and parse given filename. See ini.h for more info about the parsing.
INIReader(const std::string& filename); explicit INIReader(const std::string& filename);
//! Return the result of ini_parse(), i.e., 0 on success, line number of first error on parse error, or -1 on file open error. //! Return the result of ini_parse(), i.e., 0 on success, line number of first error on parse error, or -1 on file open error.
int ParseError(); int ParseError();

View File

@ -99,7 +99,7 @@ static char* find_char_or_comment(char* s, char c)
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */ /* Version of strncpy that ensures dest (size bytes) is null-terminated. */
static char* strncpy0(char* dest, const char* src, size_t size) static char* strncpy0(char* dest, const char* src, size_t size)
{ {
for (unsigned int i = 0; i < size - 1; i++) for (size_t i = 0; i < size - 1; i++)
{ {
dest[i] = src[i]; dest[i] = src[i];
} }
@ -169,7 +169,7 @@ int ini_parse(const char* filename,
if (*end == ']') if (*end == ']')
{ {
*end = '\0'; *end = '\0';
strncpy0(section.data(), start + 1, sizeof(section)); strncpy0(section.data(), start + 1, section.size());
prev_name[MAX_NAME - 1] = '\0'; prev_name[MAX_NAME - 1] = '\0';
} }
else if (!error) else if (!error)
@ -195,7 +195,7 @@ int ini_parse(const char* filename,
rstrip(value); rstrip(value);
/* Valid name=value pair found, call handler */ /* Valid name=value pair found, call handler */
strncpy0(prev_name.data(), name, sizeof(prev_name)); strncpy0(prev_name.data(), name, prev_name.size());
if (!handler(user, section.data(), name, value) && !error) if (!handler(user, section.data(), name, value) && !error)
{ {
error = lineno; error = lineno;

View File

@ -1151,8 +1151,10 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(!epres) _ASN_DECODE_STARVED; if(!epres) _ASN_DECODE_STARVED;
/* Get the extensions map */ /* Get the extensions map */
if(per_get_many_bits(pd, epres, 0, bmlength)) if(per_get_many_bits(pd, epres, 0, bmlength)) {
FREEMEM(epres);
_ASN_DECODE_STARVED; _ASN_DECODE_STARVED;
}
memset(&epmd, 0, sizeof(epmd)); memset(&epmd, 0, sizeof(epmd));
epmd.buffer = epres; epmd.buffer = epres;

View File

@ -324,7 +324,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
size_t max_encoded_len = 1; size_t max_encoded_len = 1;
asn_enc_rval_t erval; asn_enc_rval_t erval;
int ret; int ret;
int edx; ssize_t edx;
ASN_DEBUG("Estimating size for SET OF %s", td->name); ASN_DEBUG("Estimating size for SET OF %s", td->name);
@ -919,7 +919,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(nelems < 0) _ASN_DECODE_STARVED; if(nelems < 0) _ASN_DECODE_STARVED;
} }
for(i = 0; i < nelems; i++) { for(ssize_t k = 0; k < nelems; k++) {
void *ptr = 0; void *ptr = 0;
ASN_DEBUG("SET OF %s decoding", elm->type->name); ASN_DEBUG("SET OF %s decoding", elm->type->name);
rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, rv = elm->type->uper_decoder(opt_codec_ctx, elm->type,

View File

@ -1151,9 +1151,10 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(!epres) _ASN_DECODE_STARVED; if(!epres) _ASN_DECODE_STARVED;
/* Get the extensions map */ /* Get the extensions map */
if(per_get_many_bits(pd, epres, 0, bmlength)) if(per_get_many_bits(pd, epres, 0, bmlength)) {
FREEMEM(epres);
_ASN_DECODE_STARVED; _ASN_DECODE_STARVED;
}
memset(&epmd, 0, sizeof(epmd)); memset(&epmd, 0, sizeof(epmd));
epmd.buffer = epres; epmd.buffer = epres;
epmd.nbits = bmlength; epmd.nbits = bmlength;

View File

@ -324,7 +324,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr,
size_t max_encoded_len = 1; size_t max_encoded_len = 1;
asn_enc_rval_t erval; asn_enc_rval_t erval;
int ret; int ret;
int edx; ssize_t edx;
ASN_DEBUG("Estimating size for SET OF %s", td->name); ASN_DEBUG("Estimating size for SET OF %s", td->name);
@ -919,7 +919,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
if(nelems < 0) _ASN_DECODE_STARVED; if(nelems < 0) _ASN_DECODE_STARVED;
} }
for(i = 0; i < nelems; i++) { for(ssize_t k = 0; k < nelems; k++) {
void *ptr = 0; void *ptr = 0;
ASN_DEBUG("SET OF %s decoding", elm->type->name); ASN_DEBUG("SET OF %s decoding", elm->type->name);
rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, rv = elm->type->uper_decoder(opt_codec_ctx, elm->type,

View File

@ -134,8 +134,8 @@ int EXPORT supl_ulp_send(supl_ctx_t *ctx, supl_ulp_t *pdu)
int EXPORT supl_ulp_recv(supl_ctx_t *ctx, supl_ulp_t *pdu) int EXPORT supl_ulp_recv(supl_ctx_t *ctx, supl_ulp_t *pdu)
{ {
int err; int64_t err;
int n; int64_t n;
asn_dec_rval_t rval; asn_dec_rval_t rval;
ULP_PDU_t *length; ULP_PDU_t *length;

View File

@ -77,7 +77,7 @@ public:
* *
* \param[in] configuration Pointer to a ConfigurationInterface * \param[in] configuration Pointer to a ConfigurationInterface
*/ */
ControlThread(std::shared_ptr<ConfigurationInterface> configuration); explicit ControlThread(std::shared_ptr<ConfigurationInterface> configuration);
/*! /*!
* \brief Destructor * \brief Destructor

View File

@ -57,7 +57,7 @@ class InMemoryConfiguration;
class FileConfiguration : public ConfigurationInterface class FileConfiguration : public ConfigurationInterface
{ {
public: public:
FileConfiguration(std::string filename); explicit FileConfiguration(std::string filename);
FileConfiguration(); FileConfiguration();
//! Virtual destructor //! Virtual destructor
~FileConfiguration(); ~FileConfiguration();

View File

@ -155,7 +155,7 @@ void GNSSFlowgraph::connect()
} }
// Signal Source > Signal conditioner > // Signal Source > Signal conditioner >
for (unsigned int i = 0; i < sig_conditioner_.size(); i++) for (size_t i = 0; i < sig_conditioner_.size(); i++)
{ {
if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false) if (configuration_->property(sig_conditioner_.at(i)->role() + ".enable_FPGA", false) == false)
{ {
@ -984,7 +984,7 @@ void GNSSFlowgraph::disconnect()
} }
// Signal Source > Signal conditioner > // Signal Source > Signal conditioner >
for (unsigned int i = 0; i < sig_conditioner_.size(); i++) for (size_t i = 0; i < sig_conditioner_.size(); i++)
{ {
try try
{ {

View File

@ -153,7 +153,7 @@ std::string TcpCmdInterface::status(const std::vector<std::string> &commandLine
struct tm tstruct = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr}; struct tm tstruct = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr};
std::array<char, 80> buf1{}; std::array<char, 80> buf1{};
tstruct = *gmtime(&UTC_time); tstruct = *gmtime(&UTC_time);
strftime(buf1.data(), sizeof(buf1), "%d/%m/%Y %H:%M:%S", &tstruct); strftime(buf1.data(), buf1.size(), "%d/%m/%Y %H:%M:%S", &tstruct);
std::string str_time = std::string(buf1.data()); std::string str_time = std::string(buf1.data());
str_stream << "- Receiver UTC Time: " << str_time << std::endl; str_stream << "- Receiver UTC Time: " << str_time << std::endl;
str_stream << std::setprecision(9); str_stream << std::setprecision(9);

View File

@ -924,13 +924,13 @@ double Beidou_Dnav_Navigation_Message::utc_time(const double beidoutime_correcte
} }
else // we are in the same week than the leap second event else // we are in the same week than the leap second event
{ {
if ((beidoutime_corrected - secondOfLeapSecondEvent) < (2 / 3) * 24 * 60 * 60) if ((beidoutime_corrected - secondOfLeapSecondEvent) < (static_cast<double>(2) / static_cast<double>(3)) * 24 * 60 * 60)
{ {
t_utc_daytime = fmod(beidoutime_corrected - Delta_t_UTC, 86400); t_utc_daytime = fmod(beidoutime_corrected - Delta_t_UTC, 86400);
} }
else else
{ {
if ((beidoutime_corrected - secondOfLeapSecondEvent) < (5 / 4) * 24 * 60 * 60) if ((beidoutime_corrected - secondOfLeapSecondEvent) < (static_cast<double>(5) / static_cast<double>(4)) * 24 * 60 * 60)
{ {
int32_t W = fmod(beidoutime_corrected - Delta_t_UTC - 43200, 86400) + 43200; int32_t W = fmod(beidoutime_corrected - Delta_t_UTC - 43200, 86400) + 43200;
t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS); t_utc_daytime = fmod(W, 86400 + d_DeltaT_LSF - d_DeltaT_LS);

View File

@ -34,6 +34,7 @@
#include "MATH_CONSTANTS.h" // for TWO_N20, TWO_N30, TWO_N14, TWO_N15, TWO_N18 #include "MATH_CONSTANTS.h" // for TWO_N20, TWO_N30, TWO_N14, TWO_N15, TWO_N18
#include "gnss_satellite.h" #include "gnss_satellite.h"
#include <glog/logging.h> #include <glog/logging.h>
#include <cstddef> // for size_t
#include <map> #include <map>
#include <ostream> // for operator<< #include <ostream> // for operator<<
@ -124,7 +125,7 @@ bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset<GLONASS_GNAV_STRING_B
std::vector<uint32_t> string_bits(GLONASS_GNAV_STRING_BITS); std::vector<uint32_t> string_bits(GLONASS_GNAV_STRING_BITS);
// Populate data and hamming code vectors // Populate data and hamming code vectors
for (uint32_t i = 0; i < string_bits.size(); i++) for (size_t i = 0; i < string_bits.size(); i++)
{ {
string_bits[i] = static_cast<uint32_t>(bits[i]); string_bits[i] = static_cast<uint32_t>(bits[i]);
} }

View File

@ -45,7 +45,7 @@ class Gnss_Signal
{ {
public: public:
Gnss_Signal(); Gnss_Signal();
Gnss_Signal(const std::string& signal_); explicit Gnss_Signal(const std::string& signal_);
Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& signal_); Gnss_Signal(const Gnss_Satellite& satellite_, const std::string& signal_);
~Gnss_Signal() = default; ~Gnss_Signal() = default;
std::string get_signal_str() const; //!< Get the satellite signal {"1C" for GPS L1 C/A, "2S" for GPS L2C (M), "L5" for GPS L5, "1G" for GLONASS L1 C/A, "1B" for Galileo E1B, "5X" for Galileo E5a. std::string get_signal_str() const; //!< Get the satellite signal {"1C" for GPS L1 C/A, "2S" for GPS L2C (M), "L5" for GPS L5, "1G" for GLONASS L1 C/A, "1B" for Galileo E1B, "5X" for Galileo E5a.

View File

@ -79,7 +79,7 @@ DEFINE_bool(show_plots, true, "Show plots on screen. Disable for non-interactive
class GnuplotException : public std::runtime_error class GnuplotException : public std::runtime_error
{ {
public: public:
GnuplotException(const std::string &msg) : std::runtime_error(msg) {} explicit GnuplotException(const std::string &msg) : std::runtime_error(msg) {}
}; };
@ -189,7 +189,7 @@ public:
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
//! set a style during construction //! set a style during construction
Gnuplot(const std::string &style = "points"); explicit Gnuplot(const std::string &style = "points");
// plot a single std::vector at one go // plot a single std::vector at one go
Gnuplot(const std::vector<double> &x, Gnuplot(const std::vector<double> &x,

View File

@ -369,7 +369,7 @@ int PositionSystemTest::run_receiver()
std::cout << "Failed to run command: " << argum2 << std::endl; std::cout << "Failed to run command: " << argum2 << std::endl;
return -1; return -1;
} }
while (fgets(buffer.data(), sizeof(buffer), fp) != nullptr) while (fgets(buffer.data(), buffer.size(), fp) != nullptr)
{ {
std::string aux = std::string(buffer.data()); std::string aux = std::string(buffer.data());
EXPECT_EQ(aux.empty(), false); EXPECT_EQ(aux.empty(), false);

View File

@ -120,7 +120,7 @@ class AcqPerfTest_msg_rx : public gr::block
private: private:
friend AcqPerfTest_msg_rx_sptr AcqPerfTest_msg_rx_make(Concurrent_Queue<int>& queue); friend AcqPerfTest_msg_rx_sptr AcqPerfTest_msg_rx_make(Concurrent_Queue<int>& queue);
void msg_handler_events(pmt::pmt_t msg); void msg_handler_events(pmt::pmt_t msg);
AcqPerfTest_msg_rx(Concurrent_Queue<int>& queue); explicit AcqPerfTest_msg_rx(Concurrent_Queue<int>& queue);
Concurrent_Queue<int>& channel_internal_queue; Concurrent_Queue<int>& channel_internal_queue;
public: public:

View File

@ -68,7 +68,7 @@ class GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx : public gr::block
private: private:
friend GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue<int>& queue); friend GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue<int>& queue);
void msg_handler_events(pmt::pmt_t msg); void msg_handler_events(pmt::pmt_t msg);
GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue<int>& queue); explicit GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue<int>& queue);
Concurrent_Queue<int>& channel_internal_queue; Concurrent_Queue<int>& channel_internal_queue;
public: public:

View File

@ -67,7 +67,7 @@ class GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx : public gr::block
private: private:
friend GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue<int>& queue); friend GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx_make(Concurrent_Queue<int>& queue);
void msg_handler_events(pmt::pmt_t msg); void msg_handler_events(pmt::pmt_t msg);
GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue<int>& queue); explicit GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx(Concurrent_Queue<int>& queue);
Concurrent_Queue<int>& channel_internal_queue; Concurrent_Queue<int>& channel_internal_queue;
public: public:

View File

@ -76,7 +76,7 @@ class GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx : public gr::block
private: private:
friend GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(Concurrent_Queue<int>& queue); friend GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_sptr GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx_make(Concurrent_Queue<int>& queue);
void msg_handler_events(pmt::pmt_t msg); void msg_handler_events(pmt::pmt_t msg);
GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(Concurrent_Queue<int>& queue); explicit GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx(Concurrent_Queue<int>& queue);
Concurrent_Queue<int>& channel_internal_queue; Concurrent_Queue<int>& channel_internal_queue;
public: public:

View File

@ -69,7 +69,7 @@ class GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx : public gr::block
private: private:
friend GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(Concurrent_Queue<int>& queue); friend GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_sptr GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx_make(Concurrent_Queue<int>& queue);
void msg_handler_events(pmt::pmt_t msg); void msg_handler_events(pmt::pmt_t msg);
GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(Concurrent_Queue<int>& queue); explicit GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx(Concurrent_Queue<int>& queue);
Concurrent_Queue<int>& channel_internal_queue; Concurrent_Queue<int>& channel_internal_queue;
public: public:

Some files were not shown because too many files have changed in this diff Show More