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

Move files (#24)

* Bump local version of GoogleTest to 1.15.2 and Protocol Buffers to 27.3

* Avoid code duplication in CMake modules

* Update clang-tidy job

* Clang Tidy fixes

* Improve efficiency of Concurrent_Map and Concurrent_Queue classes

* Fix segmentation fault if the SignalSource implementation is not available

* Moved decimation factor count variable to the class

* Avoid possible runtime error when PVT.enable_rx_clock_correction=true

* Fix formatting

* Fix clang-tidy job

* Move receiver-related classes to src/core/libs

* Uniformize cmake module names

* Fix formatting

* Make clang-tidy happy

* Fix crypto benchmarks

* Fixes for old systems

* Instantiate sources only once

---------

Co-authored-by: cesaaargm <cesare.martinez@proton.me>
Co-authored-by: Xavier Guerrero-Pau <xguerrero@cttc.es>
This commit is contained in:
Carles Fernandez 2024-08-10 11:31:15 +02:00 committed by GitHub
parent 98f1cdfb6b
commit 79da7787ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 260 additions and 232 deletions

10
.gitignore vendored
View File

@ -15,11 +15,17 @@ src/utils/nav-listener/build
.cproject
.idea
cmake-build-debug/
cmake-build-release/
/install
.DS_Store
.pydevproject
.vscode/
.vs/
Testing/
/build/*
/cmake-build-release/*
GSDR*
PVT_*
HAS_*
gnss_sdr_pvt.nmea
build-debug/
build-release/

View File

@ -2215,7 +2215,7 @@ endif()
################################################################################
# OpenSSL https://www.openssl.org/ or GnuTLS - https://www.gnutls.org/
################################################################################
include(GnssSdrCrypto)
include(GnsssdrCrypto)

View File

@ -366,8 +366,10 @@ if(GNURADIO_RUNTIME_INCLUDE_DIRS)
)
if(CMAKE_VERSION VERSION_GREATER 3.13)
target_link_libraries(Gnuradio::filter INTERFACE Log4cpp::log4cpp)
target_link_libraries(Gnuradio::runtime INTERFACE Log4cpp::log4cpp)
else()
set_target_properties(Gnuradio::filter PROPERTIES INTERFACE_LINK_LIBRARIES Log4cpp::log4cpp)
set_target_properties(Gnuradio::runtime PROPERTIES INTERFACE_LINK_LIBRARIES Log4cpp::log4cpp)
endif()
endif()
if(${_uses_spdlog})

View File

@ -2228,7 +2228,7 @@ int rtklib_pvt_gs::work(int noutput_items, gr_vector_const_void_star& input_item
d_gnss_observables_map_t1 = d_gnss_observables_map;
// ### select the rx_time and interpolate observables at that time
if (!d_gnss_observables_map_t0.empty())
if (!d_gnss_observables_map_t0.empty() && !d_gnss_observables_map_t1.empty())
{
const auto t0_int_ms = static_cast<uint32_t>(d_gnss_observables_map_t0.cbegin()->second.RX_time * 1000.0);
const uint32_t adjust_next_obs_interval_ms = d_observable_interval_ms - t0_int_ms % d_observable_interval_ms;

View File

@ -13,6 +13,7 @@
* -----------------------------------------------------------------------------
*/
#include "ad936x_iio_custom.h"
#include "display.h"
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <chrono>
@ -44,6 +45,7 @@ ad936x_iio_custom::ad936x_iio_custom(int debug_level_, int log_level_)
n_channels = 0;
}
ad936x_iio_custom::~ad936x_iio_custom()
{
// disable TX
@ -59,11 +61,13 @@ void ad936x_iio_custom::set_gnsstime_queue(std::shared_ptr<Concurrent_Queue<Gnss
GnssTime_queue = std::move(queue);
}
void ad936x_iio_custom::set_pps_samplestamp_queue(std::shared_ptr<Concurrent_Queue<PpsSamplestamp>> queue)
{
Pps_queue = std::move(queue);
}
bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::string board_type)
{
// Find devices
@ -125,7 +129,6 @@ bool ad936x_iio_custom::initialize_device(std::string pluto_device_uri, std::str
return false;
}
phy = iio_context_find_device(ctx, "ad9361-phy");
if (phy == NULL)
@ -328,7 +331,6 @@ bool ad936x_iio_custom::config_ad9361_dds(uint64_t freq_rf_tx_hz_,
configure_params(dds_dev, params_dds);
}
return true;
}
@ -345,6 +347,7 @@ bool ad936x_iio_custom::check_device()
}
}
bool ad936x_iio_custom::get_iio_param(iio_device *dev, const std::string &param, std::string &value)
{
struct iio_channel *chn = 0;
@ -386,6 +389,7 @@ bool ad936x_iio_custom::get_iio_param(iio_device *dev, const std::string &param,
}
}
bool ad936x_iio_custom::read_die_temp(double &temp_c)
{
std::string temp_mC_str;
@ -410,6 +414,8 @@ bool ad936x_iio_custom::read_die_temp(double &temp_c)
return false;
}
}
bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
long long sample_rate_,
long long freq_,
@ -425,7 +431,6 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
double lo_attenuation_db_,
bool high_side_lo_,
int tx_lo_channel_)
{
if (check_device() == false) return false;
@ -610,14 +615,12 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
std::cerr << "Warning: rf_port_select write returned: " << ret << "\n";
no_errors = false;
}
// ret = iio_channel_attr_write_longlong(phy_ch, "rf_bandwidth", bandwidth_);
// if (ret < 0)
// {
// std::cerr << "Warning: rf_bandwidth write returned: " << ret << "\n";
// no_errors = false;
// }
long long set_rf_bw;
ret = iio_channel_attr_read_longlong(phy_ch, "rf_bandwidth", &set_rf_bw);
if (ret < 0)
@ -630,7 +633,6 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
std::cerr << "Info: rf_bandwidth read returned: " << set_rf_bw << " Hz \n";
}
if (setRXGain(0, gain_mode_rx0_, rf_gain_rx0_) == false)
{
std::cerr << "Info: setRXGain read returned false \n";
@ -662,14 +664,12 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
std::cerr << "Warning: rf_port_select write returned: " << ret << "\n";
no_errors = false;
}
// ret = iio_channel_attr_write_longlong(phy_ch, "rf_bandwidth", bandwidth_);
// if (ret < 0)
// {
// std::cerr << "Warning: rf_bandwidth write returned: " << ret << "\n";
// no_errors = false;
// }
long long set_rf_bw;
ret = iio_channel_attr_read_longlong(phy_ch, "rf_bandwidth", &set_rf_bw);
if (ret < 0)
@ -702,6 +702,7 @@ bool ad936x_iio_custom::init_config_ad9361_rx(long long bandwidth_,
return no_errors;
}
bool ad936x_iio_custom::set_rx_frequency(long long freq_hz)
{
if (check_device() == false) return false;
@ -747,6 +748,7 @@ bool ad936x_iio_custom::get_rx_frequency(long long &freq_hz)
return true;
}
bool ad936x_iio_custom::setRXGain(int ch_num, std::string gain_mode, double gain_dB)
{
if (check_device() == false) return false;
@ -779,6 +781,7 @@ bool ad936x_iio_custom::setRXGain(int ch_num, std::string gain_mode, double gain
}
}
double ad936x_iio_custom::get_rx_gain(int ch_num)
{
if (check_device() == false) return -1;
@ -817,6 +820,7 @@ bool ad936x_iio_custom::calibrate([[maybe_unused]] int ch, [[maybe_unused]] doub
return true;
}
void ad936x_iio_custom::monitor_thread_fn()
{
uint32_t val;
@ -849,11 +853,12 @@ void ad936x_iio_custom::monitor_thread_fn()
// } else {
if (val & 4)
{
std::cout << "WARNING: IIO status register reported overflow!\n";
LOG(INFO) << "WARNING: IIO status register reported overflow!";
std::cout
<< TEXT_BOLD_RED
<< "WARNING: IIO status register reported overflow!\n";
LOG(WARNING) << "WARNING: IIO status register reported overflow!";
}
/* Clear bits */
if (val)
{
@ -867,6 +872,7 @@ void ad936x_iio_custom::monitor_thread_fn()
return;
}
void ad936x_iio_custom::stop_record()
{
receive_samples = false;
@ -915,6 +921,7 @@ void ad936x_iio_custom::PlutoTxEnable(bool txon)
}
}
void ad936x_iio_custom::setPlutoGpo(int p)
{
char pins[11];
@ -953,7 +960,6 @@ bool ad936x_iio_custom::select_rf_filter(std::string rf_filter)
// 1 Enable
// X Enable Mask if Identifier=0xF
if (check_device() == false) return false;
// int plutoGpo = 0;
int ret;
@ -1006,6 +1012,8 @@ bool ad936x_iio_custom::select_rf_filter(std::string rf_filter)
return true;
}
void ad936x_iio_custom::get_PPS_timestamp()
{
GnssTime tow;
@ -1042,7 +1050,6 @@ void ad936x_iio_custom::get_PPS_timestamp()
// record pps rise samplestamp associated to the absolute sample counter
// PPS rising edge must be associated with the corresponding uBlox time message (tx once a second)
if (GnssTime_queue->timed_wait_and_pop(tow, 2000) == false)
{
if (receive_samples == true)
@ -1073,6 +1080,8 @@ void ad936x_iio_custom::get_PPS_timestamp()
}
}
}
bool ad936x_iio_custom::start_sample_rx(bool ppsmode)
{
// using queues of smart pointers to preallocated buffers
@ -1118,9 +1127,7 @@ bool ad936x_iio_custom::start_sample_rx(bool ppsmode)
// start sample overflow detector
overflow_monitor_thread = std::thread(&ad936x_iio_custom::monitor_thread_fn, this);
// start PPS and GNSS Time capture thread
if (ppsmode == true)
{
capture_time_thread = std::thread(&ad936x_iio_custom::get_PPS_timestamp, this);
@ -1128,16 +1135,19 @@ bool ad936x_iio_custom::start_sample_rx(bool ppsmode)
return true;
}
void ad936x_iio_custom::pop_sample_buffer(std::shared_ptr<ad936x_iio_samples> &current_buffer)
{
used_buffers.wait_and_pop(current_buffer);
}
void ad936x_iio_custom::push_sample_buffer(std::shared_ptr<ad936x_iio_samples> &current_buffer)
{
free_buffers.push(current_buffer);
}
void ad936x_iio_custom::capture(const std::vector<std::string> &channels)
{
if (check_device() == false) return;

View File

@ -9,36 +9,42 @@ protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${GNSSSDR_SOURCE_DIR}/docs/protobuf/
add_subdirectory(supl)
set(CORE_LIBS_SOURCES
ini.cc
INIReader.cc
string_converter.cc
gnss_sdr_supl_client.cc
gnss_sdr_sample_counter.cc
channel_status_msg_receiver.cc
channel_event.cc
channel_status_msg_receiver.cc
command_event.cc
galileo_e6_has_msg_receiver.cc
galileo_tow_map.cc
gnss_crypto.cc
gnss_sdr_sample_counter.cc
gnss_sdr_supl_client.cc
ini.cc
INIReader.cc
nav_message_monitor.cc
nav_message_udp_sink.cc
galileo_tow_map.cc
osnma_helper.cc
osnma_msg_receiver.cc
osnma_nav_data_manager.cc
string_converter.cc
)
set(CORE_LIBS_HEADERS
channel_event.h
channel_status_msg_receiver.h
command_event.h
galileo_tow_map.h
gnss_crypto.h
gnss_sdr_sample_counter.h
gnss_sdr_supl_client.h
ini.h
INIReader.h
string_converter.h
gnss_sdr_supl_client.h
gnss_sdr_sample_counter.h
channel_status_msg_receiver.h
channel_event.h
command_event.h
nav_message_monitor.h
nav_message_packet.h
nav_message_udp_sink.h
serdes_nav_message.h
nav_message_monitor.h
galileo_tow_map.h
osnma_helper.h
osnma_msg_receiver.h
osnma_nav_data_manager.h
serdes_nav_message.h
string_converter.h
)
if(ENABLE_FPGA)
@ -96,6 +102,7 @@ target_link_libraries(core_libs
PRIVATE
algorithms_libs
Boost::serialization
Boost::system
Pugixml::pugixml
)
@ -123,6 +130,10 @@ target_include_directories(core_libs
${GNSSSDR_SOURCE_DIR}/src/core/interfaces
)
# links to the appropriate library and defines
# USE_GNUTLS_FALLBACK, USE_OPENSSL_3, or USE_OPENSSL_111 accordingly.
link_to_crypto_dependencies(core_libs)
if(USE_GENERIC_LAMBDAS)
set(has_generic_lambdas HAS_GENERIC_LAMBDA=1)
set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0)

View File

@ -205,7 +205,7 @@ bool Gnss_Crypto::verify_signature_ecdsa_p256(const std::vector<uint8_t>& messag
{
if (!have_public_key())
{
LOG(WARNING) << "Galileo OSNMA KROOT verification error: Public key is not available";
LOG(WARNING) << "Signature verification error: Public key is not available";
return false;
}
std::vector<uint8_t> digest = this->compute_SHA_256(message);
@ -344,7 +344,7 @@ bool Gnss_Crypto::verify_signature_ecdsa_p521(const std::vector<uint8_t>& messag
{
if (!have_public_key())
{
LOG(WARNING) << "Galileo OSNMA KROOT verification error: Public key is not available";
LOG(WARNING) << "Signature verification error: Public key is not available";
return false;
}
@ -797,7 +797,7 @@ std::string Gnss_Crypto::get_public_key_type() const
{
if (d_PublicKeyType.empty())
{
return std::string("Unknown");
return {"Unknown"};
}
return d_PublicKeyType;
}

View File

@ -31,7 +31,7 @@
/** \addtogroup Core
* \{ */
/** \addtogroup System_Parameters
/** \addtogroup Core_Receiver_Library
* \{ */
/*!

View File

@ -25,7 +25,7 @@
/** \addtogroup Core
* \{ */
/** \addtogroup System_Parameters
/** \addtogroup Core_Receiver_Library
* \{ */
class Osnma_Helper

View File

@ -1,23 +1,22 @@
/*!
* \file osnma_nav_data_manager.cc
* \brief Class for Galileo OSNMA navigation data management
* \author Cesare Ghionoiu-Martinez, 2020-2023 cesare.martinez(at)proton.me
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
* \file osnma_nav_data_manager.cc
* \brief Class for Galileo OSNMA navigation data management
* \author Cesare Ghionoiu-Martinez, 2020-2023 cesare.martinez(at)proton.me
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#include "osnma_nav_data_manager.h"
#if USE_GLOG_AND_GFLAGS
#include <glog/logging.h> // for DLOG
#include <vector>
#else
#include <absl/log/log.h>
#endif
@ -54,18 +53,20 @@ void OSNMA_nav_data_Manager::update_nav_data(const std::multimap<uint32_t, Tag>&
if (have_PRNd_nav_data(tag.second.PRN_d))
{
std::map<uint32_t, OSNMA_NavData> tow_map = _satellite_nav_data.find(tag.second.PRN_d)->second;
for (auto & tow_it : tow_map) // note: starts with smallest (i.e. oldest) navigation dataset
for (auto& tow_it : tow_map) // note: starts with smallest (i.e. oldest) navigation dataset
{
std::string nav_data;
if (tag.second.ADKD == 0 || tag.second.ADKD == 12)
{
nav_data = tow_it.second.get_ephemeris_data();
}
else if (tag.second.ADKD == 4){
else if (tag.second.ADKD == 4)
{
nav_data = tow_it.second.get_utc_data();
}
// find associated OSNMA_NavData
if (tag.second.nav_data == nav_data){
if (tag.second.nav_data == nav_data)
{
_satellite_nav_data[tag.second.PRN_d][tow_it.first].verified_bits += tag_size;
}
}
@ -138,13 +139,14 @@ bool OSNMA_nav_data_Manager::have_nav_data(uint32_t PRNd, uint32_t TOW, uint8_t
std::string OSNMA_nav_data_Manager::get_navigation_data(const Tag& tag)
{
auto prn_it = _satellite_nav_data.find(tag.PRN_d);
if (prn_it == _satellite_nav_data.end()){
if (prn_it == _satellite_nav_data.end())
{
return "";
}
// satellite was found, check if TOW exists in inner map
std::map<uint32_t, OSNMA_NavData> tow_map = prn_it->second;
for (auto & tow_it : tow_map) // note: starts with smallest (i.e. oldest) navigation dataset
for (auto& tow_it : tow_map) // note: starts with smallest (i.e. oldest) navigation dataset
{
// Check if current key (TOW) fulfills condition
if ((tag.TOW - 30 * tag.cop) <= tow_it.first && tow_it.first <= tag.TOW - 30)
@ -156,9 +158,8 @@ std::string OSNMA_nav_data_Manager::get_navigation_data(const Tag& tag)
return tow_it.second.get_ephemeris_data();
}
}
else if(tag.ADKD == 4)
else if (tag.ADKD == 4)
{
if (!tow_it.second.get_utc_data().empty())
{
return tow_it.second.get_utc_data();
@ -179,17 +180,22 @@ std::string OSNMA_nav_data_Manager::get_navigation_data(const Tag& tag)
*/
bool OSNMA_nav_data_Manager::have_nav_data(const std::string& nav_bits, uint32_t PRNd, uint32_t TOW)
{
if (_satellite_nav_data.find(PRNd) != _satellite_nav_data.end()){
if (_satellite_nav_data.find(PRNd) != _satellite_nav_data.end())
{
for (auto& data_timestamp : _satellite_nav_data[PRNd])
{
if (nav_bits.size() == EPH_SIZE){
if (data_timestamp.second.get_ephemeris_data() == nav_bits){
if (nav_bits.size() == EPH_SIZE)
{
if (data_timestamp.second.get_ephemeris_data() == nav_bits)
{
data_timestamp.second.update_last_received_timestamp(TOW);
return true;
}
}
else if (nav_bits.size() == UTC_SIZE){
if (data_timestamp.second.get_utc_data() == nav_bits){
else if (nav_bits.size() == UTC_SIZE)
{
if (data_timestamp.second.get_utc_data() == nav_bits)
{
data_timestamp.second.update_last_received_timestamp(TOW);
return true;
}
@ -208,12 +214,13 @@ bool OSNMA_nav_data_Manager::have_nav_data(const std::string& nav_bits, uint32_t
bool OSNMA_nav_data_Manager::have_nav_data(const Tag& t) const
{
auto prn_it = _satellite_nav_data.find(t.PRN_d);
if (prn_it == _satellite_nav_data.end()){
if (prn_it == _satellite_nav_data.end())
{
return false;
}
// satellite was found, check if TOW exists in inner map
std::map<uint32_t, OSNMA_NavData> tow_map = prn_it->second;
for (auto & tow_it : tow_map) // note: starts with smallest (i.e. oldest) navigation dataset
for (auto& tow_it : tow_map) // note: starts with smallest (i.e. oldest) navigation dataset
{
// Check if current key (TOW) fulfills condition
if (t.TOW - 30 * t.cop <= tow_it.first && tow_it.first <= t.TOW - 30)
@ -240,10 +247,12 @@ bool OSNMA_nav_data_Manager::have_nav_data(const Tag& t) const
void OSNMA_nav_data_Manager::print_status()
{
for (const auto& satellite : _satellite_nav_data){
for (const auto& satellite : _satellite_nav_data)
{
LOG(INFO) << "Galileo OSNMA: NavData status :: SVID=" << satellite.first;
const auto& tow_data = satellite.second;
for (const auto& nav_data : tow_data) {
for (const auto& nav_data : tow_data)
{
LOG(INFO) << "Galileo OSNMA: IOD_nav=0b" << std::uppercase
<< std::bitset<10>(nav_data.second.IOD_nav)
<< ", TOW_start="

View File

@ -1,18 +1,18 @@
/*!
* \file osnma_nav_data_manager.h
* \brief Class for Galileo OSNMA navigation data management
* \author Cesare Ghionoiu-Martinez, 2020-2023 cesare.martinez(at)proton.me
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
* \file osnma_nav_data_manager.h
* \brief Class for Galileo OSNMA navigation data management
* \author Cesare Ghionoiu-Martinez, 2020-2023 cesare.martinez(at)proton.me
*
* -----------------------------------------------------------------------------
*
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
* This file is part of GNSS-SDR.
*
* Copyright (C) 2010-2023 (see AUTHORS file for a list of contributors)
* SPDX-License-Identifier: GPL-3.0-or-later
*
* -----------------------------------------------------------------------------
*/
#ifndef GNSS_SDR_OSNMA_NAV_DATA_MANAGER_H
#define GNSS_SDR_OSNMA_NAV_DATA_MANAGER_H
@ -20,8 +20,13 @@
#include "osnma_data.h" // NavData
#include <cstdint> // uint32_t
#include <map>
#include <vector>
#include <string>
#include <vector>
/** \addtogroup Core
* \{ */
/** \addtogroup Core_Receiver_Library
* \{ */
/**
* @class OSNMA_nav_data_Manager
@ -29,7 +34,8 @@
* @details It does good stuff
* @remarks throw it whatever, it will improve it. Does good stuff
*/
class OSNMA_nav_data_Manager{
class OSNMA_nav_data_Manager
{
public:
OSNMA_nav_data_Manager() = default;
bool have_nav_data(const std::string& nav_bits, uint32_t PRNd, uint32_t TOW);
@ -41,6 +47,7 @@ public:
void update_nav_data(const std::multimap<uint32_t, Tag>& tags_verified, const uint8_t tag_size);
std::vector<OSNMA_NavData> get_verified_data();
void print_status();
private:
bool have_PRNd_nav_data(uint32_t PRNd);
@ -50,4 +57,7 @@ private:
const uint16_t UTC_SIZE{141};
const uint16_t MAX_ALLOWED_SIZE{150}; // arbitrary maximum for the navigation data container
};
/** \} */
/** \} */
#endif // GNSS_SDR_OSNMA_NAV_DATA_MANAGER_H

View File

@ -46,6 +46,7 @@ gnss_synchro_monitor::gnss_synchro_monitor(int n_channels,
: gr::block("gnss_synchro_monitor",
gr::io_signature::make(n_channels, n_channels, sizeof(Gnss_Synchro)),
gr::io_signature::make(0, 0, 0)),
count(0),
d_nchannels(n_channels),
d_decimation_factor(decimation_factor)
{
@ -73,7 +74,6 @@ int gnss_synchro_monitor::general_work(int noutput_items __attribute__((unused))
for (int channel_index = 0; channel_index < d_nchannels; channel_index++)
{
// Loop through each item in each input stream channel
int count = 0;
for (int item_index = 0; item_index < ninput_items[channel_index]; item_index++)
{
// Use the count variable to limit how many items are sent per channel

View File

@ -71,9 +71,10 @@ private:
const std::vector<std::string>& udp_addresses,
bool enable_protobuf);
std::unique_ptr<Gnss_Synchro_Udp_Sink> udp_sink_ptr;
int count;
int d_nchannels;
int d_decimation_factor;
std::unique_ptr<Gnss_Synchro_Udp_Sink> udp_sink_ptr;
};

View File

@ -36,52 +36,48 @@ template <typename Data>
*/
class Concurrent_Map
{
typedef typename std::map<int, Data>::iterator Data_iterator; // iterator is scope dependent
public:
void write(int key, Data const& data)
{
std::unique_lock<std::mutex> lock(the_mutex);
Data_iterator data_iter;
data_iter = the_map.find(key);
std::lock_guard<std::mutex> lock(the_mutex);
auto data_iter = the_map.find(key);
if (data_iter != the_map.end())
{
data_iter->second = data; // update
}
else
{
the_map.insert(std::pair<int, Data>(key, data)); // insert SILENTLY fails if the item already exists in the map!
the_map.insert(std::pair<int, Data>(key, data)); // insert does not overwrite if the item already exists in the map!
}
lock.unlock();
}
std::map<int, Data> get_map_copy()
std::map<int, Data> get_map_copy() const&
{
std::unique_lock<std::mutex> lock(the_mutex);
std::map<int, Data> map_aux = the_map;
lock.unlock();
return map_aux;
std::lock_guard<std::mutex> lock(the_mutex);
return the_map; // This implicitly creates a copy
}
size_t size()
std::map<int, Data> get_map_copy() &&
{
std::unique_lock<std::mutex> lock(the_mutex);
size_t size_ = the_map.size();
lock.unlock();
return size_;
std::lock_guard<std::mutex> lock(the_mutex);
return std::move(the_map);
}
bool read(int key, Data& p_data)
size_t size() const
{
std::unique_lock<std::mutex> lock(the_mutex);
Data_iterator data_iter;
data_iter = the_map.find(key);
std::lock_guard<std::mutex> lock(the_mutex);
return the_map.size();
}
bool read(int key, Data& p_data) const
{
std::lock_guard<std::mutex> lock(the_mutex);
auto data_iter = the_map.find(key);
if (data_iter != the_map.end())
{
p_data = data_iter->second;
lock.unlock();
return true;
}
lock.unlock();
return false;
}

View File

@ -19,9 +19,10 @@
#include <chrono>
#include <condition_variable>
#include <cstddef>
#include <mutex>
#include <queue>
#include <thread>
#include <utility>
/** \addtogroup Core
* \{ */
@ -33,48 +34,53 @@ template <typename Data>
/*!
* \brief This class implements a thread-safe std::queue
*
* Thread-safe object queue which uses the library
* boost_thread to perform MUTEX based on the code available at
* https://www.justsoftwaresolutions.co.uk/threading/implementing-a-thread-safe-queue-using-condition-variables.html
*/
class Concurrent_Queue
{
public:
void push(Data const& data)
void push(const Data& data)
{
std::unique_lock<std::mutex> lock(the_mutex);
{
std::lock_guard<std::mutex> lock(the_mutex);
the_queue.push(data);
lock.unlock();
}
the_condition_variable.notify_one();
}
bool empty() const
void push(Data&& data)
{
std::unique_lock<std::mutex> lock(the_mutex);
return the_queue.empty();
{
std::lock_guard<std::mutex> lock(the_mutex);
the_queue.push(std::move(data));
}
the_condition_variable.notify_one();
}
size_t size() const
bool empty() const noexcept
{
std::unique_lock<std::mutex> lock(the_mutex);
return size() == 0;
}
size_t size() const noexcept
{
std::lock_guard<std::mutex> lock(the_mutex);
return the_queue.size();
}
void clear()
{
std::unique_lock<std::mutex> lock(the_mutex);
the_queue = std::queue<Data>();
std::lock_guard<std::mutex> lock(the_mutex);
std::queue<Data>().swap(the_queue);
}
bool try_pop(Data& popped_value)
{
std::unique_lock<std::mutex> lock(the_mutex);
std::lock_guard<std::mutex> lock(the_mutex);
if (the_queue.empty())
{
return false;
}
popped_value = the_queue.front();
popped_value = std::move(the_queue.front());
the_queue.pop();
return true;
}
@ -82,26 +88,21 @@ public:
void wait_and_pop(Data& popped_value)
{
std::unique_lock<std::mutex> lock(the_mutex);
while (the_queue.empty())
{
the_condition_variable.wait(lock);
}
popped_value = the_queue.front();
the_condition_variable.wait(lock, [this] { return !the_queue.empty(); });
popped_value = std::move(the_queue.front());
the_queue.pop();
}
bool timed_wait_and_pop(Data& popped_value, int wait_ms)
{
std::unique_lock<std::mutex> lock(the_mutex);
if (the_queue.empty())
{
the_condition_variable.wait_for(lock, std::chrono::milliseconds(wait_ms));
if (the_queue.empty())
if (!the_condition_variable.wait_for(lock,
std::chrono::milliseconds(wait_ms),
[this] { return !the_queue.empty(); }))
{
return false;
}
}
popped_value = the_queue.front();
popped_value = std::move(the_queue.front());
the_queue.pop();
return true;
}

View File

@ -113,6 +113,7 @@
#include "tracking_interface.h"
#include "two_bit_cpx_file_signal_source.h"
#include "two_bit_packed_file_signal_source.h"
#include <cstdlib> // for exit
#include <exception> // for exception
#include <iostream> // for cerr
#include <utility> // for move

View File

@ -49,6 +49,7 @@
#include <algorithm> // for transform, sort, unique
#include <cmath> // for floor
#include <cstddef> // for size_t
#include <cstdlib> // for exit
#include <exception> // for exception
#include <iostream> // for operator<<
#include <iterator> // for insert_iterator, inserter
@ -144,9 +145,9 @@ void GNSSFlowgraph::init()
sources_count_ = configuration_->property("GNSS-SDR.num_sources", sources_count_deprecated);
// Avoid segmentation fault caused by wrong configuration
if (sources_count_ == 2 && block_factory->GetSignalSource(configuration_.get(), queue_.get(), 0)->implementation() == "Multichannel_File_Signal_Source")
if (sources_count_ == 2 && configuration_->property("SignalSource.implementation", std::string("")) == "Multichannel_File_Signal_Source")
{
std::cout << " * Please set GNSS-SDR.num_sources=1 in your configuraiion file\n";
std::cout << " * Please set GNSS-SDR.num_sources=1 in your configuration file\n";
std::cout << " if you are using the Multichannel_File_Signal_Source implementation.\n";
sources_count_ = 1;
}
@ -156,7 +157,13 @@ void GNSSFlowgraph::init()
for (int i = 0; i < sources_count_; i++)
{
DLOG(INFO) << "Creating source " << i;
sig_source_.push_back(block_factory->GetSignalSource(configuration_.get(), queue_.get(), i));
auto check_not_nullptr = block_factory->GetSignalSource(configuration_.get(), queue_.get(), i);
if (!check_not_nullptr)
{
std::cout << "GNSS-SDR program ended.\n";
exit(1);
}
sig_source_.push_back(std::move(check_not_nullptr));
if (enable_fpga_offloading_ == false)
{
auto& src = sig_source_.back();

View File

@ -7,7 +7,6 @@
set(SYSTEM_PARAMETERS_SOURCES
gnss_almanac.cc
gnss_crypto.cc
gnss_ephemeris.cc
gnss_satellite.cc
gnss_signal.cc
@ -31,13 +30,10 @@ set(SYSTEM_PARAMETERS_SOURCES
reed_solomon.cc
osnma_data.cc
osnma_dsm_reader.cc
osnma_helper.cc
osnma_nav_data_manager.cc
)
set(SYSTEM_PARAMETERS_HEADERS
gnss_almanac.h
gnss_crypto.h
gnss_ephemeris.h
gnss_satellite.h
gnss_signal.h
@ -98,8 +94,6 @@ set(SYSTEM_PARAMETERS_HEADERS
Galileo_OSNMA.h
osnma_data.h
osnma_dsm_reader.h
osnma_helper.h
osnma_nav_data_manager.h
)
list(SORT SYSTEM_PARAMETERS_HEADERS)
@ -142,10 +136,6 @@ target_include_directories(core_system_parameters
${GNSSSDR_SOURCE_DIR}/src/algorithms/libs
)
# links to the appropriate library and defines
# USE_GNUTLS_FALLBACK, USE_OPENSSL_3, or USE_OPENSSL_111 accordingly.
link_to_crypto_dependencies(core_system_parameters)
if(ENABLE_CLANG_TIDY)
if(CLANG_TIDY_EXE)
set_target_properties(core_system_parameters

View File

@ -40,6 +40,7 @@ public:
bool reserved{};
};
class DSM_dsm_header
{
public:
@ -48,6 +49,7 @@ public:
uint8_t dsm_block_id{};
};
class MACK_header
{
public:
@ -57,6 +59,7 @@ public:
uint8_t cop{};
};
class MACK_tag_info
{
public:
@ -66,6 +69,7 @@ public:
uint8_t cop{};
};
class MACK_tag_and_info
{
public:
@ -75,6 +79,7 @@ public:
uint32_t counter; // CTR
};
class DSM_PKR_message
{
public:
@ -89,6 +94,7 @@ public:
uint8_t npktid{};
};
class DSM_KROOT_message
{
public:
@ -112,6 +118,7 @@ public:
uint8_t towh_k{};
};
class MACK_message
{
public:
@ -124,33 +131,38 @@ public:
uint32_t PRNa;
};
class OSNMA_NavData
{
public:
OSNMA_NavData(): nav_data_id(id_counter++){}
bool have_this_bits(std::string nav_data);
bool add_nav_data(const std::string& nav_data);
void update_last_received_timestamp(uint32_t TOW);
const uint32_t nav_data_id;
uint32_t verified_bits{0};
uint32_t get_tow_sf0() const {return TOW_sf0;}
void set_tow_sf0(int value) {TOW_sf0 = value;}
uint32_t last_received_TOW{0};
uint32_t IOD_nav{0};
OSNMA_NavData() : nav_data_id(id_counter++) {}
std::string get_utc_data() const;
std::string get_ephemeris_data() const;
void set_ephemeris_data(std::string value) {d_ephemeris_iono = value;}
void set_utc_data(std::string value) {d_utc = value;}
uint32_t get_tow_sf0() const { return TOW_sf0; }
const uint32_t nav_data_id;
bool have_this_bits(std::string nav_data);
bool add_nav_data(const std::string& nav_data);
bool verified{false};
void update_last_received_timestamp(uint32_t TOW);
void set_tow_sf0(int value) { TOW_sf0 = value; }
void set_ephemeris_data(std::string value) { d_ephemeris_iono = value; }
void set_utc_data(std::string value) { d_utc = value; }
uint32_t verified_bits{0};
uint32_t last_received_TOW{0};
uint32_t IOD_nav{0};
uint32_t PRNd{0};
uint32_t ADKD{};
private:
std::string d_ephemeris_iono{""};
std::string d_utc{""};
uint32_t TOW_sf0{0};
uint32_t static id_counter;
static uint32_t id_counter;
};
/*!
@ -224,6 +236,8 @@ public:
uint32_t skipped;
std::string nav_data;
};
/** \} */
/** \} */
#endif // GNSS_SDR_OSNMA_DATA_H

View File

@ -111,7 +111,7 @@ endif()
add_benchmark(benchmark_atan2 Gnuradio::runtime)
add_benchmark(benchmark_copy)
add_benchmark(benchmark_crypto core_system_parameters ${EXTRA_BENCHMARK_DEPENDENCIES})
add_benchmark(benchmark_crypto core_libs Boost::headers ${EXTRA_BENCHMARK_DEPENDENCIES})
add_benchmark(benchmark_detector core_system_parameters ${EXTRA_BENCHMARK_DEPENDENCIES})
add_benchmark(benchmark_preamble core_system_parameters ${EXTRA_BENCHMARK_DEPENDENCIES})
add_benchmark(benchmark_reed_solomon core_system_parameters ${EXTRA_BENCHMARK_DEPENDENCIES})

View File

@ -106,26 +106,12 @@ void bm_verify_ecdsa_p256(benchmark::State& state)
0x6B, 0xFF, 0x70, 0x06, 0xE0, 0xC4, 0x51, 0xEE, 0x3F, 0x87,
0x28, 0xC1, 0x77, 0xFB};
// PEM format
// compressed ECDSA P-256 format
std::vector<uint8_t> publicKey = {
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E,
0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, 0x45,
0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A, 0x4D, 0x46, 0x6B,
0x77, 0x45, 0x77, 0x59, 0x48, 0x4B, 0x6F, 0x5A, 0x49, 0x7A,
0x6A, 0x30, 0x43, 0x41, 0x51, 0x59, 0x49, 0x4B, 0x6F, 0x5A,
0x49, 0x7A, 0x6A, 0x30, 0x44, 0x41, 0x51, 0x63, 0x44, 0x51,
0x67, 0x41, 0x45, 0x41, 0x37, 0x4C, 0x4F, 0x5A, 0x4C, 0x77,
0x67, 0x65, 0x39, 0x32, 0x4C, 0x78, 0x4E, 0x2B, 0x46, 0x6B,
0x59, 0x66, 0x38, 0x74, 0x6F, 0x59, 0x79, 0x44, 0x57, 0x50,
0x2F, 0x0A, 0x6F, 0x4A, 0x46, 0x42, 0x44, 0x38, 0x46, 0x59,
0x2B, 0x37, 0x64, 0x35, 0x67, 0x4F, 0x71, 0x49, 0x61, 0x45,
0x32, 0x52, 0x6A, 0x50, 0x41, 0x6E, 0x4B, 0x49, 0x36, 0x38,
0x73, 0x2F, 0x4F, 0x4B, 0x2F, 0x48, 0x50, 0x67, 0x6F, 0x4C,
0x6B, 0x4F, 0x32, 0x69, 0x6A, 0x51, 0x38, 0x78, 0x41, 0x5A,
0x79, 0x44, 0x64, 0x50, 0x42, 0x31, 0x64, 0x48, 0x53, 0x51,
0x3D, 0x3D, 0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x45, 0x4E,
0x44, 0x20, 0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B,
0x45, 0x59, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A};
0x03, 0x03, 0xB2, 0xCE, 0x64, 0xBC, 0x20, 0x7B, 0xDD, 0x8B,
0xC4, 0xDF, 0x85, 0x91, 0x87, 0xFC, 0xB6, 0x86, 0x32, 0x0D,
0x63, 0xFF, 0xA0, 0x91, 0x41, 0x0F, 0xC1, 0x58, 0xFB, 0xB7,
0x79, 0x80, 0xEA};
d_crypto->set_public_key(publicKey);
@ -146,50 +132,34 @@ void bm_verify_ecdsa_p521(benchmark::State& state)
// Message to be verified
std::vector<uint8_t> message = {
0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F, 0x72, 0x6C, 0x64};
0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x77, 0x6F, 0x72, 0x6C, 0x64, 0x0A}; // "Hello world\n"
// Public key in PEM format
// Public key in compressed X format
std::vector<uint8_t> publicKey = {
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x42, 0x45, 0x47, 0x49, 0x4E, 0x20, 0x50,
0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D, 0x2D,
0x2D, 0x2D, 0x0A, 0x4D, 0x49, 0x47, 0x62, 0x4D, 0x42, 0x41, 0x47, 0x42,
0x79, 0x71, 0x47, 0x53, 0x4D, 0x34, 0x39, 0x41, 0x67, 0x45, 0x47, 0x42,
0x53, 0x75, 0x42, 0x42, 0x41, 0x41, 0x6A, 0x41, 0x34, 0x47, 0x47, 0x41,
0x41, 0x51, 0x41, 0x6F, 0x35, 0x76, 0x77, 0x66, 0x6E, 0x47, 0x57, 0x47,
0x33, 0x44, 0x63, 0x59, 0x75, 0x2B, 0x2F, 0x61, 0x58, 0x47, 0x32, 0x7A,
0x74, 0x65, 0x41, 0x46, 0x50, 0x54, 0x33, 0x0A, 0x48, 0x36, 0x4C, 0x76,
0x4F, 0x4C, 0x76, 0x49, 0x51, 0x6A, 0x61, 0x2B, 0x6A, 0x74, 0x57, 0x73,
0x70, 0x4F, 0x38, 0x37, 0x6F, 0x50, 0x32, 0x4E, 0x6D, 0x72, 0x34, 0x6E,
0x50, 0x68, 0x76, 0x62, 0x53, 0x58, 0x52, 0x4D, 0x37, 0x6A, 0x49, 0x69,
0x46, 0x38, 0x47, 0x70, 0x6B, 0x75, 0x58, 0x6A, 0x75, 0x4E, 0x7A, 0x34,
0x72, 0x61, 0x56, 0x4F, 0x65, 0x49, 0x4D, 0x42, 0x77, 0x45, 0x2B, 0x61,
0x0A, 0x30, 0x4C, 0x76, 0x7A, 0x37, 0x69, 0x54, 0x4D, 0x5A, 0x46, 0x41,
0x41, 0x51, 0x64, 0x2B, 0x70, 0x47, 0x72, 0x56, 0x54, 0x47, 0x77, 0x66,
0x53, 0x48, 0x49, 0x72, 0x49, 0x49, 0x45, 0x78, 0x74, 0x5A, 0x35, 0x77,
0x30, 0x38, 0x51, 0x4F, 0x43, 0x58, 0x2F, 0x75, 0x46, 0x65, 0x2B, 0x30,
0x78, 0x52, 0x78, 0x4C, 0x64, 0x2F, 0x33, 0x36, 0x42, 0x4E, 0x74, 0x63,
0x74, 0x69, 0x2F, 0x45, 0x4C, 0x0A, 0x4B, 0x31, 0x35, 0x67, 0x2B, 0x4B,
0x32, 0x71, 0x67, 0x2F, 0x6C, 0x39, 0x46, 0x42, 0x47, 0x67, 0x4D, 0x2B,
0x51, 0x3D, 0x0A, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x45, 0x4E, 0x44, 0x20,
0x50, 0x55, 0x42, 0x4C, 0x49, 0x43, 0x20, 0x4B, 0x45, 0x59, 0x2D, 0x2D,
0x2D, 0x2D, 0x2D, 0x0A};
0x03, 0x00, 0x28, 0x35, 0xBB, 0xE9, 0x24, 0x59, 0x4E, 0xF0,
0xE3, 0xA2, 0xDB, 0xC0, 0x49, 0x30, 0x60, 0x7C, 0x61, 0x90,
0xE4, 0x03, 0xE0, 0xC7, 0xB8, 0xC2, 0x62, 0x37, 0xF7, 0x58,
0x56, 0xBE, 0x63, 0x5C, 0x97, 0xF7, 0x53, 0x64, 0x7E, 0xE1,
0x0C, 0x07, 0xD3, 0x97, 0x8D, 0x58, 0x46, 0xFD, 0x6E, 0x06,
0x44, 0x01, 0xA7, 0xAA, 0xC4, 0x95, 0x13, 0x5D, 0xC9, 0x77,
0x26, 0xE9, 0xF8, 0x72, 0x0C, 0xD3, 0x88};
// ECDSA P-521 signature, raw format
std::vector<uint8_t> signature = {
0x01, 0x7B, 0x59, 0xAC, 0x3A, 0x03, 0x5C, 0xB4, 0x07, 0xCD,
0xC1, 0xEB, 0xBE, 0xE5, 0xA6, 0xCB, 0xDA, 0x0A, 0xFF, 0x4D,
0x38, 0x61, 0x16, 0x0F, 0xB3, 0x77, 0xE5, 0x8A, 0xDC, 0xF3,
0xFD, 0x79, 0x38, 0x1E, 0xE8, 0x08, 0x3D, 0x5D, 0xBC, 0xC2,
0x80, 0x6E, 0xE9, 0x2B, 0xC3, 0xEF, 0x07, 0x3D, 0x0C, 0x82,
0x4C, 0x9B, 0x7A, 0x5C, 0x2E, 0xD5, 0x46, 0xBD, 0x22, 0x21,
0x13, 0x8A, 0xB2, 0xCA, 0x96, 0x3D, 0x01, 0xBA, 0x2A, 0xC4,
0x3F, 0xDB, 0x66, 0x3C, 0x40, 0x26, 0xD9, 0xBC, 0x26, 0xD5,
0x57, 0xD4, 0xBD, 0x15, 0x16, 0x88, 0x21, 0x3B, 0xAA, 0x07,
0x89, 0xEF, 0x29, 0x8F, 0x2F, 0x85, 0x76, 0x58, 0x9D, 0xCA,
0x00, 0xCC, 0xC8, 0x30, 0x88, 0x31, 0x99, 0xC1, 0x94, 0xB9,
0xAF, 0x91, 0xDC, 0xC4, 0x6F, 0x19, 0x2B, 0x12, 0xA2, 0x82,
0xA5, 0x66, 0x5E, 0x4B, 0xBB, 0xDF, 0x65, 0x81, 0x52, 0x14,
0x01, 0xD7};
0x01, 0x5C, 0x23, 0xC0, 0xBE, 0xAD, 0x1E, 0x44, 0x60, 0xD4,
0xE0, 0x81, 0x38, 0xF2, 0xBA, 0xF5, 0xB5, 0x37, 0x5A, 0x34,
0xB5, 0xCA, 0x6B, 0xC8, 0x0F, 0xCD, 0x75, 0x1D, 0x5E, 0xC0,
0x8A, 0xD3, 0xD7, 0x79, 0xA7, 0xC1, 0xB8, 0xA2, 0xC6, 0xEA,
0x5A, 0x7D, 0x60, 0x66, 0x50, 0x97, 0x37, 0x6C, 0xF9, 0x0A,
0xF6, 0x3D, 0x77, 0x9A, 0xE2, 0x19, 0xF7, 0xF9, 0xDD, 0x52,
0xC4, 0x0F, 0x98, 0xAA, 0xA2, 0xA4, 0x01, 0xC9, 0x41, 0x0B,
0xD0, 0x25, 0xDD, 0xC9, 0x7C, 0x3F, 0x70, 0x32, 0x23, 0xCF,
0xFE, 0x37, 0x67, 0x3A, 0xBC, 0x0B, 0x76, 0x16, 0x82, 0x83,
0x27, 0x3D, 0x1D, 0x19, 0x15, 0x78, 0x08, 0x2B, 0xD4, 0xA7,
0xC2, 0x0F, 0x11, 0xF4, 0xDD, 0xE5, 0x5A, 0x5D, 0x04, 0x8D,
0x6D, 0x5E, 0xC4, 0x1F, 0x54, 0x44, 0xA9, 0x13, 0x34, 0x71,
0x0F, 0xF7, 0x57, 0x9A, 0x9F, 0x2E, 0xF4, 0x97, 0x7D, 0xAE,
0x28, 0xEF};
d_crypto->set_public_key(publicKey);