From 9b393098a6e79c3c9ab2eaf431ebb80939cb062f Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Fri, 16 Aug 2024 13:27:36 +0200 Subject: [PATCH 01/10] Bump version of google benchmark to 1.9.0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffa66cf5b..3696eede2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -361,7 +361,7 @@ set(GNSSSDR_PUGIXML_LOCAL_VERSION "1.14") set(GNSSSDR_GTEST_LOCAL_VERSION "1.15.2") set(GNSSSDR_GNSS_SIM_LOCAL_VERSION "origin/master") set(GNSSSDR_GNSSTK_LOCAL_VERSION "14.3.0") -set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.8.5") +set(GNSSSDR_BENCHMARK_LOCAL_VERSION "1.9.0") set(GNSSSDR_MATHJAX_EXTERNAL_VERSION "2.7.7") set(GNSSSDR_ABSL_LOCAL_VERSION "origin/master") # live at head (see https://abseil.io/about/releases) From 62cb96ae03a5f3ae14b6ba7062e93ffdf7e67e2e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 09:25:05 +0200 Subject: [PATCH 02/10] Create a CMake target for the ION dependency for consistency --- CMakeLists.txt | 68 +++++++++++++++---- .../signal_source/libs/CMakeLists.txt | 9 ++- 2 files changed, 57 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f70609a92..8b081522b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,7 @@ option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal option(ENABLE_ZMQ "Enable GNU Radio ZeroMQ Messaging, requires gr-zeromq" ON) -option(ENABLE_ION "Enable ION GNSS-SDR Metadata Standard signal source" ON) +option(ENABLE_ION "Enable ION GNSS-SDR Metadata Standard signal source" OFF) # Performance analysis tools option(ENABLE_GPERFTOOLS "Enable linking to Gperftools libraries (tcmalloc and profiler)" OFF) @@ -1424,20 +1424,6 @@ else() endif() -################################################################################ -# ION GNSS-SDR Metadata Standard -################################################################################ -include(FetchContent) -FetchContent_Declare( - gnss_metadata_standard - GIT_REPOSITORY https://github.com/IonMetadataWorkingGroup/GNSS-Metadata-Standard - GIT_TAG master - SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/gnss-metadata-standard - CMAKE_ARGS -DABSL_PROPAGATE_CXX_STD=ON -ABSL_BUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=${GNSSSDR_BINARY_DIR}/gnss-metadata-standard ${ABSEIL_TOOLCHAIN_FILE} - BINARY_DIR ${GNSSSDR_BINARY_DIR}/gnss-metadata-standard -) -FetchContent_MakeAvailable(gnss_metadata_standard) - ################################################################################ # Abseil C++ - https://abseil.io/docs/cpp/ ################################################################################ @@ -3371,6 +3357,57 @@ if(ENABLE_AD9361 OR ENABLE_FMCOMMS2) endif() +################################################################################ +# ION GNSS-SDR Metadata Standard https://sdr.ion.org/ (OPTIONAL) +################################################################################ +if(ENABLE_ION) + include(FetchContent) + set(CMAKE_POLICY_DEFAULT_CMP0063 NEW) + FetchContent_Declare( + gnss_metadata_standard + GIT_REPOSITORY https://github.com/IonMetadataWorkingGroup/GNSS-Metadata-Standard + GIT_TAG origin/master + SOURCE_DIR ${GNSSSDR_BINARY_DIR}/thirdparty/gnss-metadata-standard + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${GNSSSDR_BINARY_DIR}/gnss-metadata-standard + BINARY_DIR ${GNSSSDR_BINARY_DIR}/gnss-metadata-standard + ) + FetchContent_MakeAvailable(gnss_metadata_standard) + + if(NOT TARGET ION::ion) + add_library(ION::ion STATIC IMPORTED) + add_dependencies(ION::ion gnss_metadata_standard) + if(CMAKE_GENERATOR STREQUAL "Xcode") + set_target_properties(ION::ion PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION_DEBUG "${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_LOCATION_RELEASE "${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/Release/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_LOCATION_RELWITHDEBINFO "${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_LOCATION_MINSIZEREL "${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${GNSSSDR_BINARY_DIR}/thirdparty/gnss-metadata-standard/source/api/inc" + ) + set_property(TARGET ION::ion APPEND PROPERTY + INTERFACE_LINK_LIBRARIES + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/Release/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/Release/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/MinSizeRel/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/RelWithDebInfo/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + "$<$:${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/Debug/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}>" + ) + else() + set_target_properties(ION::ion PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX}" + INTERFACE_INCLUDE_DIRECTORIES "${GNSSSDR_BINARY_DIR}/thirdparty/gnss-metadata-standard/source/api/inc" + INTERFACE_LINK_LIBRARIES "${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/GnssMetadata/${CMAKE_FIND_LIBRARY_PREFIXES}api${CMAKE_STATIC_LIBRARY_SUFFIX};${GNSSSDR_BINARY_DIR}/gnss-metadata-standard/source/api/lib/tinyxml2/${CMAKE_FIND_LIBRARY_PREFIXES}xml${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + endif() + endif() +endif() + ##################################################################### # Check signal sources related to FPGA only. @@ -3684,6 +3721,7 @@ add_feature_info(ENABLE_RAW_UDP ENABLE_RAW_UDP "Enables Custom_UDP_Signal_Source add_feature_info(ENABLE_FLEXIBAND ENABLE_FLEXIBAND "Enables Flexiband_Signal_Source for using Teleorbit's Flexiband RF front-end. Requires gr-teleorbit.") add_feature_info(ENABLE_ARRAY ENABLE_ARRAY "Enables Raw_Array_Signal_Source and Array_Signal_Conditioner for using CTTC's antenna array. Requires gr-dbfcttc.") add_feature_info(ENABLE_ZMQ ENABLE_ZMQ "Enables ZMQ_Signal_Source for GNU Radio ZeroMQ messages. Requires gr-zeromq.") +add_feature_info(ENABLE_ION ENABLE_ION "Enables ION_GSMS_Signal_Source for the ION Metadata Standard.") add_feature_info(ENABLE_GPERFTOOLS ENABLE_GPERFTOOLS "Enables performance analysis. Requires Gperftools.") add_feature_info(ENABLE_GPROF ENABLE_GPROF "Enables performance analysis with 'gprof'.") add_feature_info(ENABLE_CLANG_TIDY ENABLE_CLANG_TIDY "Runs clang-tidy along with the compiler. Requires Clang.") diff --git a/src/algorithms/signal_source/libs/CMakeLists.txt b/src/algorithms/signal_source/libs/CMakeLists.txt index 36f327931..aa4fa8eea 100644 --- a/src/algorithms/signal_source/libs/CMakeLists.txt +++ b/src/algorithms/signal_source/libs/CMakeLists.txt @@ -142,6 +142,10 @@ if(ENABLE_FPGA OR ENABLE_AD9361) ) endif() +if(ENABLE_ION) + target_link_libraries(signal_source_libs PUBLIC ION::ion algorithms_libs) +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(signal_source_libs @@ -151,11 +155,6 @@ if(ENABLE_CLANG_TIDY) endif() endif() -if(ENABLE_ION) - target_include_directories(signal_source_libs PUBLIC ${GNSSSDR_BINARY_DIR}/thirdparty/gnss-metadata-standard/source/api/inc) - target_link_libraries(signal_source_libs PUBLIC api xml) -endif() - set_property(TARGET signal_source_libs APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES $ ) From da21ff4fd9747ec52c7122c370e652bc943e1850 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 09:26:21 +0200 Subject: [PATCH 03/10] Improve formatting, add missing include --- .../adapters/ion_gsms_signal_source.cc | 13 +++++++++++-- .../signal_source/adapters/ion_gsms_signal_source.h | 5 ++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/algorithms/signal_source/adapters/ion_gsms_signal_source.cc b/src/algorithms/signal_source/adapters/ion_gsms_signal_source.cc index b4edd615f..c0db26e71 100644 --- a/src/algorithms/signal_source/adapters/ion_gsms_signal_source.cc +++ b/src/algorithms/signal_source/adapters/ion_gsms_signal_source.cc @@ -8,7 +8,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -49,6 +49,7 @@ std::vector parse_comma_list(const std::string& str) return list; } + IONGSMSSignalSource::IONGSMSSignalSource(const ConfigurationInterface* configuration, const std::string& role, unsigned int in_streams, @@ -62,10 +63,14 @@ IONGSMSSignalSource::IONGSMSSignalSource(const ConfigurationInterface* configura in_streams_(in_streams), out_streams_(out_streams) { - if (in_streams > 0) + if (in_streams_ > 0) { LOG(ERROR) << "A signal source does not have an input stream"; } + if (out_streams_ <= 0) + { + LOG(ERROR) << "A signal source does not have an output stream"; + } sources_ = metadata_.make_stream_sources(configuration, role, stream_ids_); @@ -91,6 +96,7 @@ void IONGSMSSignalSource::connect(gr::top_block_sptr top_block) } } + void IONGSMSSignalSource::disconnect(gr::top_block_sptr top_block) { std::size_t cumulative_index = 0; @@ -103,6 +109,7 @@ void IONGSMSSignalSource::disconnect(gr::top_block_sptr top_block) } } + gr::basic_block_sptr IONGSMSSignalSource::get_left_block() { LOG(WARNING) << "Trying to get signal source left block."; @@ -110,11 +117,13 @@ gr::basic_block_sptr IONGSMSSignalSource::get_left_block() return IONGSMSFileSource::sptr(); } + gr::basic_block_sptr IONGSMSSignalSource::get_right_block() { return get_right_block(0); } + gr::basic_block_sptr IONGSMSSignalSource::get_right_block(int RF_channel) { return copy_blocks_[RF_channel]; diff --git a/src/algorithms/signal_source/adapters/ion_gsms_signal_source.h b/src/algorithms/signal_source/adapters/ion_gsms_signal_source.h index 5063b4e80..d724d101b 100644 --- a/src/algorithms/signal_source/adapters/ion_gsms_signal_source.h +++ b/src/algorithms/signal_source/adapters/ion_gsms_signal_source.h @@ -8,7 +8,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -22,6 +22,7 @@ #include "file_source_base.h" #include "gnss_sdr_timestamp.h" #include "ion_gsms.h" +#include #include #include @@ -44,8 +45,6 @@ public: ~IONGSMSSignalSource() override = default; protected: - // std::tuple itemTypeToSize() override; - // double packetsPerSample() const override; void connect(gr::top_block_sptr top_block) override; void disconnect(gr::top_block_sptr top_block) override; From e37855d43ee85d10c5ac2ac7e247349407ad6700 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 09:27:29 +0200 Subject: [PATCH 04/10] Fixes for C++ standards older than 20. Avoid C++20-specific lambda templates --- src/algorithms/signal_source/libs/ion_gsms.cc | 22 +++---- src/algorithms/signal_source/libs/ion_gsms.h | 18 +++--- .../signal_source/libs/ion_gsms_chunk_data.cc | 47 ++++++++------- .../signal_source/libs/ion_gsms_chunk_data.h | 57 +++++++++++++++---- .../libs/ion_gsms_chunk_unpacking_ctx.h | 16 +++--- .../libs/ion_gsms_metadata_handler.cc | 19 +++++-- .../libs/ion_gsms_metadata_handler.h | 21 +++---- .../libs/ion_gsms_stream_encodings.h | 14 +++-- 8 files changed, 132 insertions(+), 82 deletions(-) diff --git a/src/algorithms/signal_source/libs/ion_gsms.cc b/src/algorithms/signal_source/libs/ion_gsms.cc index 8389afd10..e44c0abab 100644 --- a/src/algorithms/signal_source/libs/ion_gsms.cc +++ b/src/algorithms/signal_source/libs/ion_gsms.cc @@ -8,7 +8,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -17,22 +17,14 @@ #include "ion_gsms.h" #include "gnuradio/block.h" #include -#include -#include - -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#include -#endif +#include using namespace std::string_literals; IONGSMSFileSource::IONGSMSFileSource( const ConfigurationInterface* configuration __attribute__((unused)), const std::string& role __attribute__((unused)), - const std::filesystem::path& metadata_filepath, + const fs::path& metadata_filepath, const GnssMetadata::File& file, const GnssMetadata::Block& block, const std::vector& stream_ids) @@ -40,13 +32,11 @@ IONGSMSFileSource::IONGSMSFileSource( "ion_gsms_file_source", gr::io_signature::make(0, 0, 0), make_output_signature(block, stream_ids)), - file_metadata_(file), - block_metadata_(block), io_buffer_offset_(0), maximum_item_rate_(0), chunk_cycle_length_(0) { - std::filesystem::path data_filepath = metadata_filepath.parent_path() / file.Url().Value(); + fs::path data_filepath = metadata_filepath.parent_path() / file.Url().Value(); fd_ = std::fopen(data_filepath.c_str(), "rb"); std::size_t block_offset = file.Offset(); std::fseek(fd_, file.Offset() + block_offset + block.SizeHeader(), SEEK_SET); @@ -67,11 +57,13 @@ IONGSMSFileSource::IONGSMSFileSource( output_stream_count_ = output_stream_offset; } + IONGSMSFileSource::~IONGSMSFileSource() { std::fclose(fd_); } + int IONGSMSFileSource::work( int noutput_items, gr_vector_const_void_star& input_items __attribute__((unused)), @@ -106,11 +98,13 @@ int IONGSMSFileSource::work( return WORK_CALLED_PRODUCE; } + std::size_t IONGSMSFileSource::output_stream_count() const { return output_stream_count_; } + std::size_t IONGSMSFileSource::output_stream_item_size(std::size_t stream_index) const { return output_stream_item_sizes_[stream_index]; diff --git a/src/algorithms/signal_source/libs/ion_gsms.h b/src/algorithms/signal_source/libs/ion_gsms.h index 5164e3581..054b1e9dd 100644 --- a/src/algorithms/signal_source/libs/ion_gsms.h +++ b/src/algorithms/signal_source/libs/ion_gsms.h @@ -8,7 +8,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -19,14 +19,20 @@ #include "configuration_interface.h" #include "gnss_block_interface.h" +#include "gnss_sdr_filesystem.h" #include "ion_gsms_chunk_data.h" #include #include -#include +#include +#include #include #include #include +/** \addtogroup Signal_Source + * \{ */ +/** \addtogroup Signal_Source_libs + * \{ */ class IONGSMSFileSource : public gr::sync_block { @@ -36,7 +42,7 @@ public: IONGSMSFileSource( const ConfigurationInterface* configuration, const std::string& role, - const std::filesystem::path& metadata_filepath, + const fs::path& metadata_filepath, const GnssMetadata::File& file, const GnssMetadata::Block& block, const std::vector& stream_ids); @@ -54,9 +60,6 @@ public: private: static gr::io_signature::sptr make_output_signature(const GnssMetadata::Block& block, const std::vector& stream_ids); -private: - const GnssMetadata::File& file_metadata_; - const GnssMetadata::Block& block_metadata_; FILE* fd_; std::vector io_buffer_; std::size_t io_buffer_offset_; @@ -70,5 +73,6 @@ private: #include "ion_gsms_metadata_handler.h" - +/** \} */ +/** \} */ #endif // GNSS_SDR_ION_GNSS_SDR_METADATA_STANDARD_H diff --git a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.cc b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.cc index f6d1b18b9..5a8cd823c 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.cc +++ b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.cc @@ -8,31 +8,30 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- */ #include "ion_gsms_chunk_data.h" -#include -#include -#include - +#include #if USE_GLOG_AND_GFLAGS #include #else #include #endif + IONGSMSChunkData::IONGSMSChunkData(const GnssMetadata::Chunk& chunk, const std::vector& stream_ids, std::size_t output_stream_offset) : chunk_(chunk), sizeword_(chunk_.SizeWord()), countwords_(chunk_.CountWords()) { - with_word_type(sizeword_, [&] { - buffer_ = new WordType[countwords_]; - }); + // Instantiate the Allocator functor + Allocator allocator(countwords_, buffer_); + // Call with_word_type with the Allocator functor + with_word_type(sizeword_, allocator); const std::size_t total_bitsize = sizeword_ * countwords_ * 8; std::size_t used_bitsize = 0; @@ -81,11 +80,11 @@ IONGSMSChunkData::IONGSMSChunkData(const GnssMetadata::Chunk& chunk, const std:: IONGSMSChunkData::~IONGSMSChunkData() { - with_word_type(sizeword_, [&] { - delete[] static_cast(buffer_); - }); + Deleter deleter(static_cast(buffer_)); + with_word_type(sizeword_, deleter); } + std::size_t IONGSMSChunkData::read_from_buffer(uint8_t* buffer, std::size_t offset) { memset(buffer_, 0, sizeword_ * countwords_); @@ -93,6 +92,7 @@ std::size_t IONGSMSChunkData::read_from_buffer(uint8_t* buffer, std::size_t offs return sizeword_ * countwords_; } + void IONGSMSChunkData::write_to_output(gr_vector_void_star& outputs, std::vector& output_items) { switch (sizeword_) @@ -121,11 +121,13 @@ std::size_t IONGSMSChunkData::output_stream_count() const return output_stream_count_; } + std::size_t IONGSMSChunkData::output_stream_item_size(std::size_t stream_index) const { return output_stream_item_size_[stream_index]; } + std::size_t IONGSMSChunkData::output_stream_item_rate(std::size_t stream_index) const { return output_stream_item_rate_[stream_index]; @@ -165,6 +167,7 @@ void IONGSMSChunkData::unpack_words(gr_vector_void_star& outputs, std::vector std::size_t IONGSMSChunkData::write_stream_samples( IONGSMSChunkUnpackingCtx& ctx, @@ -185,24 +188,25 @@ std::size_t IONGSMSChunkData::write_stream_samples( if (sample_bitsize <= 8) { - write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, (int8_t**)(out)); + write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, reinterpret_cast(out)); } else if (sample_bitsize <= 16) { - write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, (int16_t**)(out)); + write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, reinterpret_cast(out)); } else if (sample_bitsize <= 32) { - write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, (int32_t**)(out)); + write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, reinterpret_cast(out)); } else if (sample_bitsize <= 64) { - write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, (int64_t**)(out)); + write_n_samples(ctx, lump.Shift(), sample_bitsize, sample_count, stream_encoding, reinterpret_cast(out)); } return sample_count; } + template void IONGSMSChunkData::write_n_samples( IONGSMSChunkUnpackingCtx& ctx, @@ -241,22 +245,23 @@ void IONGSMSChunkData::write_n_samples( // Static utilities -void IONGSMSChunkData::decode_sample(const uint8_t sample_bitsize, auto* sample, const GnssMetadata::StreamEncoding encoding) +template +void IONGSMSChunkData::decode_sample(const uint8_t sample_bitsize, Sample* sample, const GnssMetadata::StreamEncoding encoding) { - using SampleType = std::remove_pointer_t; + // using SampleType = std::remove_pointer_t; switch (sample_bitsize) { case 2: - *sample = GnssMetadata::two_bit_look_up[encoding][*sample]; + *sample = GnssMetadata::two_bit_look_up[encoding][*sample]; break; case 3: - *sample = GnssMetadata::three_bit_look_up[encoding][*sample]; + *sample = GnssMetadata::three_bit_look_up[encoding][*sample]; break; case 4: - *sample = GnssMetadata::four_bit_look_up[encoding][*sample]; + *sample = GnssMetadata::four_bit_look_up[encoding][*sample]; break; case 5: - *sample = GnssMetadata::five_bit_look_up[encoding][*sample]; + *sample = GnssMetadata::five_bit_look_up[encoding][*sample]; break; default: // TODO - Is this an error that can happen? diff --git a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h index 881c431f6..5a6b98aba 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h +++ b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h @@ -8,7 +8,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -21,16 +21,14 @@ #include "ion_gsms_chunk_unpacking_ctx.h" #include "ion_gsms_stream_encodings.h" #include +#include +#include +#include #include #include -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif -inline std::size_t bits_to_item_size(const std::size_t bit_count) +inline std::size_t bits_to_item_size(std::size_t bit_count) { if (bit_count <= 8) { @@ -50,11 +48,46 @@ inline std::size_t bits_to_item_size(const std::size_t bit_count) } // You are asking too much of this humble processor - LOG(ERROR) << "Item size too large (" << std::to_string(bit_count) << "), returning nonsense."; + std::cerr << "Item size too large (" << std::to_string(bit_count) << "), returning nonsense.\n"; return 1; } -void with_word_type(const uint8_t word_size, auto&& callback) + +// Define a functor that has a templated operator() +struct Allocator +{ + size_t countwords_; + void*& buffer_; // Using void* to hold any type of pointer + + Allocator(size_t countwords, void*& buffer) + : countwords_(countwords), buffer_(buffer) {} + + template + void operator()() const + { + buffer_ = new WordType[countwords_]; + } +}; + + +// Define a functor to delete the allocated memory +struct Deleter +{ + void* buffer_; + + explicit Deleter(void* buffer) + : buffer_(buffer) {} + + template + void operator()() const + { + delete[] static_cast(buffer_); + } +}; + + +template +void with_word_type(uint8_t word_size, Callback callback) { switch (word_size) { @@ -71,7 +104,7 @@ void with_word_type(const uint8_t word_size, auto&& callback) callback.template operator()(); break; default: - LOG(ERROR) << "Unknown word size (" << std::to_string(word_size) << "), returning nonsense."; + std::cerr << "Unknown word size (" << std::to_string(word_size) << "), returning nonsense.\n"; break; } } @@ -118,9 +151,9 @@ private: GnssMetadata::StreamEncoding stream_encoding, OT** out); - static void decode_sample(uint8_t sample_bitsize, auto* sample, GnssMetadata::StreamEncoding encoding); + template + static void decode_sample(uint8_t sample_bitsize, Sample* sample, GnssMetadata::StreamEncoding encoding); -private: const GnssMetadata::Chunk& chunk_; uint8_t sizeword_; uint8_t countwords_; diff --git a/src/algorithms/signal_source/libs/ion_gsms_chunk_unpacking_ctx.h b/src/algorithms/signal_source/libs/ion_gsms_chunk_unpacking_ctx.h index 1dad11902..c4d839de1 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_chunk_unpacking_ctx.h +++ b/src/algorithms/signal_source/libs/ion_gsms_chunk_unpacking_ctx.h @@ -10,7 +10,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -21,12 +21,12 @@ #include "GnssMetadata.h" #include +#include -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif +/** \addtogroup Signal_Source + * \{ */ +/** \addtogroup Signal_Source_libs + * \{ */ template struct IONGSMSChunkUnpackingCtx @@ -118,7 +118,7 @@ struct IONGSMSChunkUnpackingCtx } template - void shift_sample(const uint8_t sample_bitsize, OT* output, uint8_t output_bit_offset = 0) + void shift_sample(uint8_t sample_bitsize, OT* output, uint8_t output_bit_offset = 0) { if (sample_bitsize % word_bitsize_ == 0) { @@ -176,4 +176,6 @@ struct IONGSMSChunkUnpackingCtx } }; +/** \} */ +/** \} */ #endif // ION_GSM_CHUNK_UNPACKING_CTX_H diff --git a/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.cc b/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.cc index 9a05e372d..eea6e9c5f 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.cc +++ b/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.cc @@ -8,14 +8,14 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- */ #include "ion_gsms.h" - +#include #if USE_GLOG_AND_GFLAGS #include #else @@ -40,16 +40,25 @@ void IONGSMSMetadataHandler::load_metadata() GnssMetadata::XmlProcessor xml_proc; if (!xml_proc.Load(metadata_filepath_.c_str(), false, metadata_)) { - LOG(ERROR) << "Could not load XML metadata file:"; + LOG(WARNING) << "Could not load XML metadata file " << metadata_filepath_; + std::cerr << "Could not load XML metadata file " << metadata_filepath_ << std::endl; + std::cout << "GNSS-SDR program ended.\n"; + exit(1); } } catch (GnssMetadata::ApiException& e) { - LOG(ERROR) << "API Exception while loading XML metadata file: " << std::to_string(e.Error()); + LOG(WARNING) << "API Exception while loading XML metadata file: " << std::to_string(e.Error()); + std::cerr << "Could not load XML metadata file " << metadata_filepath_ << " : " << std::to_string(e.Error()) << std::endl; + std::cout << "GNSS-SDR program ended.\n"; + exit(1); } catch (std::exception& e) { - LOG(ERROR) << "Exception while loading XML metadata file: " << e.what(); + LOG(WARNING) << "Exception while loading XML metadata file: " << e.what(); + std::cerr << "Could not load XML metadata file " << metadata_filepath_ << " : " << e.what() << std::endl; + std::cout << "GNSS-SDR program ended.\n"; + exit(1); } } diff --git a/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h b/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h index 710233d72..62077c82a 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h +++ b/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h @@ -8,7 +8,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -23,11 +23,11 @@ #include #include -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif +/** \addtogroup Signal_Source + * \{ */ +/** \addtogroup Signal_Source_libs + * \{ */ + class IONGSMSMetadataHandler { @@ -35,16 +35,17 @@ public: explicit IONGSMSMetadataHandler(const std::string& metadata_filepath); std::vector make_stream_sources(const ConfigurationInterface* configuration, const std::string& role, const std::vector& stream_ids) const; - -public: // Getters const std::string& metadata_filepath() const; -private: // Private methods +private: void load_metadata(); -private: // State + // State std::string metadata_filepath_; GnssMetadata::Metadata metadata_; }; + +/** \} */ +/** \} */ #endif // ION_GSMS_METADATA_HANDLER_H diff --git a/src/algorithms/signal_source/libs/ion_gsms_stream_encodings.h b/src/algorithms/signal_source/libs/ion_gsms_stream_encodings.h index 443a6e823..90ba15cac 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_stream_encodings.h +++ b/src/algorithms/signal_source/libs/ion_gsms_stream_encodings.h @@ -10,7 +10,7 @@ * GNSS-SDR is a Global Navigation Satellite System software-defined receiver. * This file is part of GNSS-SDR. * - * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2024 (see AUTHORS file for a list of contributors) * SPDX-License-Identifier: GPL-3.0-or-later * * ----------------------------------------------------------------------------- @@ -21,11 +21,10 @@ #include -#if USE_GLOG_AND_GFLAGS -#include -#else -#include -#endif +/** \addtogroup Signal_Source + * \{ */ +/** \addtogroup Signal_Source_libs + * \{ */ namespace GnssMetadata { @@ -165,4 +164,7 @@ inline T five_bit_look_up[11][32]{ } // namespace GnssMetadata + +/** \} */ +/** \} */ #endif // ION_GSM_STREAM_ENCODINGS_H From bc2a1e02b893be7fafcbf40baa384e41f2cb6d58 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 09:28:03 +0200 Subject: [PATCH 05/10] Update changelog --- docs/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 931e8988f..abdc04427 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -41,6 +41,11 @@ All notable changes to GNSS-SDR will be documented in this file. - `-DENABLE_DMA_PROXY`: Checks if the DMA proxy driver is installed for controlling the DMA in the FPGA and enables its usage. +- Add the `ION_GSMS_Signal_Source`, which is able to process raw data files + described with the + [ION GNSS Software Defined Receiver Metadata Standard](https://sdr.ion.org/). + It requires the `-DENABLE_ION=ON` building configuration option. + ### Improvements in Portability: - Fix building against google-glog 0.7.x. From fc5148bf44377e9062a697f4d1ae01b9d8276ae6 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 09:28:35 +0200 Subject: [PATCH 06/10] Add Victor to the list of authors --- AUTHORS | 1 + CITATION.cff | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/AUTHORS b/AUTHORS index ad0660662..d1251f1fc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -64,6 +64,7 @@ Marc Sales marcsales92@gmail.com Contributor Piyush Gupta piyush04111999@gmail.com Contributor Rodrigo Muñoz rodrigo.munoz@proteinlab.cl Contributor Stefan van der Linden spvdlinden@gmail.com Contributor +Victor Castillo-Agüero victorcastilloaguero@gmail.com Contributor Will Silberman wsilberm@google.com Contributor Carlos Paniego carpanie@hotmail.com Artwork diff --git a/CITATION.cff b/CITATION.cff index 0f11b55f1..2be1e1880 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -34,6 +34,11 @@ authors: email: mara.branzanti@gmail.com family-names: Branzanti given-names: Mara + - alias: castle055 + affiliation: "Instituto Nacional de Técnica Aeroespacial" + email: victorcastilloaguero@gmail.com + family-names: "Castillo-Agüero" + given-names: Victor - alias: acebrianjuan email: acebrianjuan@gmail.com family-names: "Cebrián-Juan" From c212bac26d856308bd01040625639b39a280c2af Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 09:58:33 +0200 Subject: [PATCH 07/10] Fix CMake error --- src/algorithms/signal_source/adapters/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index 9ff0ab434..d6491098f 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -171,7 +171,7 @@ target_include_directories(signal_source_adapters ${GNSSSDR_SOURCE_DIR}/src/core/interfaces ) -if(ENABLE_FPGA OR ENABLE_AD9361) +if(ENABLE_FPGA OR ENABLE_AD9361 OR ENABLE_ION) target_link_libraries(signal_source_adapters PUBLIC signal_source_libs From 614693ea0f34fed42aa35c5e4fa788c05a116478 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 10:21:51 +0200 Subject: [PATCH 08/10] Fix building error --- src/algorithms/signal_source/libs/ion_gsms_chunk_data.h | 2 +- .../signal_source/libs/ion_gsms_chunk_unpacking_ctx.h | 2 +- src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h index 5a6b98aba..1dd712351 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h +++ b/src/algorithms/signal_source/libs/ion_gsms_chunk_data.h @@ -17,10 +17,10 @@ #ifndef ION_GSM_CHUNK_DATA_H #define ION_GSM_CHUNK_DATA_H -#include "GnssMetadata.h" #include "ion_gsms_chunk_unpacking_ctx.h" #include "ion_gsms_stream_encodings.h" #include +#include #include #include #include diff --git a/src/algorithms/signal_source/libs/ion_gsms_chunk_unpacking_ctx.h b/src/algorithms/signal_source/libs/ion_gsms_chunk_unpacking_ctx.h index c4d839de1..44c125889 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_chunk_unpacking_ctx.h +++ b/src/algorithms/signal_source/libs/ion_gsms_chunk_unpacking_ctx.h @@ -19,8 +19,8 @@ #ifndef ION_GSM_CHUNK_UNPACKING_CTX_H #define ION_GSM_CHUNK_UNPACKING_CTX_H -#include "GnssMetadata.h" #include +#include #include /** \addtogroup Signal_Source diff --git a/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h b/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h index 62077c82a..2431fbec8 100644 --- a/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h +++ b/src/algorithms/signal_source/libs/ion_gsms_metadata_handler.h @@ -17,9 +17,9 @@ #ifndef ION_GSMS_METADATA_HANDLER_H #define ION_GSMS_METADATA_HANDLER_H -#include "GnssMetadata.h" #include "configuration_interface.h" #include +#include #include #include From f3ba1822b17d95bc1eb25d0ddd18481183aff238 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 10:24:48 +0200 Subject: [PATCH 09/10] Fix building --- src/algorithms/signal_source/adapters/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/algorithms/signal_source/adapters/CMakeLists.txt b/src/algorithms/signal_source/adapters/CMakeLists.txt index d6491098f..6b58e1abe 100644 --- a/src/algorithms/signal_source/adapters/CMakeLists.txt +++ b/src/algorithms/signal_source/adapters/CMakeLists.txt @@ -103,6 +103,11 @@ if(ENABLE_ZMQ) list(APPEND OPT_DRIVER_HEADERS zmq_signal_source.h) endif() +if(ENABLE_ION) + list(APPEND OPT_DRIVER_SOURCES ion_gsms_signal_source.cc) + list(APPEND OPT_DRIVER_HEADERS ion_gsms_signal_source.h) +endif() + set(SIGNAL_SOURCE_ADAPTER_SOURCES signal_source_base.cc file_source_base.cc @@ -119,7 +124,6 @@ set(SIGNAL_SOURCE_ADAPTER_SOURCES two_bit_packed_file_signal_source.cc four_bit_cpx_file_signal_source.cc file_timestamp_signal_source.cc - ion_gsms_signal_source.cc ${OPT_DRIVER_SOURCES} ) @@ -139,7 +143,6 @@ set(SIGNAL_SOURCE_ADAPTER_HEADERS two_bit_packed_file_signal_source.h four_bit_cpx_file_signal_source.h file_timestamp_signal_source.h - ion_gsms_signal_source.h ${OPT_DRIVER_HEADERS} ) From 45d31cb3b9a637b14adc4bb497fb1336c27cfd06 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 19 Aug 2024 10:29:48 +0200 Subject: [PATCH 10/10] Add -DENABLE_ION=ON to CI jobs --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 32dc29f9b..7bc294b0f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: libgnutls-openssl-dev libmatio-dev googletest protobuf-compiler libprotobuf-dev \ python3-mako liborc-0.4-dev - name: configure - run: cd build && cmake -GNinja .. + run: cd build && cmake -GNinja -DENABLE_ION=ON .. - name: build run: cd build && ninja - name: check @@ -60,7 +60,7 @@ jobs: brew install ninja hdf5 automake armadillo lapack libmatio gnuradio openssl pugixml protobuf pip3 install mako - name: configure - run: cd build && cmake -GNinja .. + run: cd build && cmake -GNinja -DENABLE_ION=ON .. - name: build run: cd build && ninja - name: check @@ -92,7 +92,7 @@ jobs: brew install ninja pkg-config hdf5 automake armadillo lapack libmatio gnuradio openssl pugixml protobuf pip3 install mako - name: configure - run: cd build && cmake -GXcode .. + run: cd build && cmake -GXcode -DENABLE_ION=ON .. - name: build run: cd build && xcodebuild -configuration Release - name: check