File gnss-sdr-0.0.20-add-gnmax-support.patch of Package gnss-sdr

diff -up gnss-sdr-0.0.20/CMakeLists.txt.aaaa gnss-sdr-0.0.20/CMakeLists.txt
--- gnss-sdr-0.0.20/CMakeLists.txt.aaaa	2025-04-02 17:56:58.000000000 +0200
+++ gnss-sdr-0.0.20/CMakeLists.txt	2025-04-14 14:53:05.332302523 +0200
@@ -52,6 +52,8 @@ option(ENABLE_RAW_UDP "Enable the use of
 
 option(ENABLE_FLEXIBAND "Enable the use of the signal source adater for the Teleorbit Flexiband GNU Radio driver" OFF)
 
+option(ENABLE_GNMAX "Enable the use of the gnMAX2769 dongle as signal source (experimental)" OFF)
+
 option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF)
 
 option(ENABLE_ZMQ "Enable GNU Radio ZeroMQ Messaging, requires gr-zeromq" ON)
@@ -3513,6 +3515,33 @@ if(ENABLE_FLEXIBAND)
 endif()
 
 
+######################
+# GNMAX - OPTIONAL
+######################
+if(DEFINED ENV{GNMAX_DRIVER})
+    message(STATUS "GNMAX_DRIVER environment variable found.")
+    set(ENABLE_GNMAX ON)
+endif()
+
+if(GNMAX_DRIVER)
+    set(ENABLE_GNMAX ON)
+endif()
+
+find_package(GRGNMAX)
+set_package_properties(GRGNMAX PROPERTIES
+    URL "https://github.com/wkazubski/gr-gnMAX2769"
+    DESCRIPTION "The MAX2769 front-end GNU Radio block."
+    PURPOSE "Used for communication with the gnMAX2769 front-end."
+    TYPE OPTIONAL
+)
+if(ENABLE_GNMAX)
+    message(STATUS "The gnMAX2769 driver will be compiled.")
+    message(STATUS " You can disable it with 'cmake -DENABLE_GNMAX=OFF ..'")
+else()
+    message(STATUS "The (optional and experimental) gnMAX2769 driver is not enabled.")
+    message(STATUS " Enable it with 'cmake -DENABLE_GNMAX=ON ..' to add support for the gnMAX2769 dongle.")
+endif()
+
 
 #######################################################
 # CTTC's digital array beamformer prototype - OPTIONAL
@@ -3696,6 +3725,7 @@ add_feature_info(ENABLE_MAX2771 ENABLE_M
 add_feature_info(ENABLE_DMA_PROXY ENABLE_DMA_PROXY "Enables DMA_Signal_Source_FPGA for file post-processing in FPGA SoC devices. Requires the DMA Proxy driver and -DENABLE_FPGA=ON.")
 add_feature_info(ENABLE_RAW_UDP ENABLE_RAW_UDP "Enables Custom_UDP_Signal_Source for custom UDP packet sample source. Requires libpcap.")
 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_GNMAX ENABLE_GNMAX "Enables GNMAX_Signal_Source for using the gnMAX2769 dongle. Requires gr-gnMAX2769.")
 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.")
diff -up gnss-sdr-0.0.20/cmake/Modules/FindGRGNMAX.cmake.aaaa gnss-sdr-0.0.20/cmake/Modules/FindGRGNMAX.cmake
--- gnss-sdr-0.0.20/cmake/Modules/FindGRGNMAX.cmake.aaaa	2025-04-14 14:53:05.332599682 +0200
+++ gnss-sdr-0.0.20/cmake/Modules/FindGRGNMAX.cmake	2025-04-14 14:53:05.332599682 +0200
@@ -0,0 +1,63 @@
+# Copyright (C) 2011-2020  (see AUTHORS file for a list of contributors)
+#
+# GNSS-SDR is a software-defined Global Navigation Satellite Systems receiver
+#
+# This file is part of GNSS-SDR.
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+########################################################################
+# Find  GR-GN3S Module
+########################################################################
+
+#
+# Provides the following imported target:
+# Gnuradio::gnmax
+#
+
+include(FindPkgConfig)
+pkg_check_modules(PC_GR_GNMAX gr-gnmax)
+
+find_path(
+    GR_GNMAX_INCLUDE_DIRS
+    NAMES gnMAX2769/api.h
+    HINTS $ENV{GR_GNMAX_DIR}/include
+          ${PC_GR_GNMAX_INCLUDEDIR}
+    PATHS ${CMAKE_INSTALL_PREFIX}/include
+          /usr/local/include
+          /usr/include
+          ${GRGNMAX_ROOT}/include
+          $ENV{GRGNMAX_ROOT}/include
+)
+
+find_library(
+    GR_GNMAX_LIBRARIES
+    NAMES gnuradio-gnMAX2769
+    HINTS $ENV{GR_GNMAX_DIR}/lib
+          ${PC_GR_GNMAX_LIBDIR}
+    PATHS ${CMAKE_INSTALL_PREFIX}/lib
+          ${CMAKE_INSTALL_PREFIX}/lib64
+          /usr/local/lib
+          /usr/local/lib64
+          /usr/lib
+          /usr/lib64
+          ${GRGNMAX_ROOT}/lib
+          $ENV{GRGNMAX_ROOT}/lib
+          ${GRGNMAX_ROOT}/lib64
+          $ENV{GRGNMAX_ROOT}/lib64
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GRGNMAX DEFAULT_MSG GR_GNMAX_LIBRARIES GR_GNMAX_INCLUDE_DIRS)
+
+if(GRGNMAX_FOUND AND NOT TARGET Gnuradio::gnmax)
+    add_library(Gnuradio::gnmax SHARED IMPORTED)
+    set_target_properties(Gnuradio::gnmax PROPERTIES
+        IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
+        IMPORTED_LOCATION "${GR_GNMAX_LIBRARIES}"
+        INTERFACE_INCLUDE_DIRECTORIES "${GR_GNMAX_INCLUDE_DIRS}"
+        INTERFACE_LINK_LIBRARIES "${GR_GNMAX_LIBRARIES}"
+    )
+endif()
+
+mark_as_advanced(GR_GNMAX_LIBRARIES GR_GNMAX_INCLUDE_DIRS)
diff -up gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/CMakeLists.txt.aaaa gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/CMakeLists.txt
--- gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/CMakeLists.txt.aaaa	2025-04-02 17:56:58.000000000 +0200
+++ gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/CMakeLists.txt	2025-04-14 14:53:05.332706272 +0200
@@ -33,6 +33,14 @@ if(ENABLE_AD936X_SDR AND NOT ENABLE_PLUT
     set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} ad936x_custom_signal_source.h)
 endif()
 
+if(ENABLE_GNMAX)
+    ##############################################
+    # gnMAX2769 (USB dongle)
+    ##############################################
+    set(OPT_DRIVER_SOURCES ${OPT_DRIVER_SOURCES} gnmax_signal_source.cc)
+    set(OPT_DRIVER_HEADERS ${OPT_DRIVER_HEADERS} gnmax_signal_source.h)
+endif()
+
 if(ENABLE_FMCOMMS2)
     ###############################################
     # FMCOMMS2 based SDR Hardware
@@ -276,6 +284,13 @@ if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND)
     )
 endif()
 
+if(ENABLE_GNMAX AND GRGNMAX_FOUND)
+    target_link_libraries(signal_source_adapters
+        PRIVATE
+            Gnuradio::gnmax
+    )
+endif()
+
 if(ENABLE_ARRAY AND GRDBFCTTC_FOUND)
     target_link_libraries(signal_source_adapters
         PRIVATE
diff -up gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/gnmax_signal_source.cc.aaaa gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/gnmax_signal_source.cc
--- gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/gnmax_signal_source.cc.aaaa	2025-04-14 14:53:05.332779640 +0200
+++ gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/gnmax_signal_source.cc	2025-04-14 14:54:45.719883746 +0200
@@ -0,0 +1,193 @@
+/*!
+ * \file gnmax_signal_source.cc
+ * \brief gnMAX2769 USB dongle GPS RF front-end signal sampler driver
+ * \author Wojciech Kazubski, wk(at)ire.pw.edu.pl
+ * \author Javier Arribas, jarribas(at)cttc.es
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2020  (see AUTHORS file for a list of contributors)
+ *
+ * GNSS-SDR is a software defined Global Navigation
+ *          Satellite Systems receiver
+ *
+ * This file is part of GNSS-SDR.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ * -----------------------------------------------------------------------------
+ */
+
+#include "gnmax_signal_source.h"
+#include "GPS_L1_CA.h"
+#include "configuration_interface.h"
+#include "gnss_sdr_string_literals.h"
+#include "gnss_sdr_valve.h"
+#include <gnuradio/blocks/file_sink.h>
+#include <gnMAX2769/gnmax_source_cc.h>
+
+#if USE_GLOG_AND_GFLAGS
+#include <glog/logging.h>
+#else
+#include <absl/log/log.h>
+#endif
+
+
+using namespace std::string_literals;
+
+
+GnMaxSignalSource::GnMaxSignalSource(const ConfigurationInterface* configuration,
+    const std::string& role,
+    unsigned int in_stream,
+    unsigned int out_stream,
+    Concurrent_Queue<pmt::pmt_t>* queue)
+    : SignalSourceBase(configuration, role, "GnMax_Signal_Source"s),
+      item_type_(configuration->property(role + ".item_type", std::string("gr_complex"))),
+      dump_filename_(configuration->property(role + ".dump_filename", std::string("./data/signal_source.dat"))),
+      bias_(configuration->property(role + ".antenna_bias", true)),
+      ant_(configuration->property(role + ".antenna", 3)),
+      freq_(configuration->property(role + ".freq", GPS_L1_FREQ_HZ)),
+      bw_(configuration->property(role + ".if_bandwidth", 1)),
+      zeroif_(configuration->property(role + ".zero_if", false)),
+      in_stream_(in_stream),
+      out_stream_(out_stream),
+      dump_(configuration->property(role + ".dump", false))
+{
+    if (bias_)
+        bias__ = 1;
+    else
+        bias__ = 0;
+
+    freq__ = static_cast<float>(freq_);
+
+    if (bw_ <= 2.501E6)
+        bw__ = 0;
+    else
+        {
+            if (bw_ <= 4.201E6)
+                bw__ = 1;
+            else
+                {
+                    if (bw_ <= 8.001E6)
+                        bw__ = 2;
+                    else
+                        bw__ = 3;
+                }
+        }
+
+    if (zeroif_)
+        zeroif__ = 1;
+    else
+        zeroif__ = 0;
+
+    if (item_type_.compare("gr_complex") == 0)
+        {
+            item_size_ = sizeof(gr_complex);
+            gnmax_source_ = gr::gnMAX2769::gnmax_source_cc::make(bias__, ant_, freq__, bw__, zeroif__);
+            DLOG(INFO) << "Item size " << item_size_;
+            DLOG(INFO) << "gnmax_source(" << gnmax_source_->unique_id() << ")";
+        }
+    //    else if (item_type_.compare("short") == 0)
+    //        {
+    //            item_size_ = sizeof(short);
+    //            resampler_ = direct_resampler_make_conditioner_ss(sample_freq_in_,
+    //                    sample_freq_out_);
+    //        }
+    else
+        {
+            LOG(WARNING) << item_type_
+                         << " unrecognized item type for resampler";
+            item_size_ = sizeof(short);
+        }
+
+    if (samples_ != 0)
+        {
+            DLOG(INFO) << "Send STOP signal after " << samples_ << " samples";
+            valve_ = gnss_sdr_make_valve(item_size_, samples_, queue);
+            DLOG(INFO) << "valve(" << valve_->unique_id() << ")";
+        }
+
+    if (dump_)
+        {
+            DLOG(INFO) << "Dumping output into file " << dump_filename_;
+            file_sink_ = gr::blocks::file_sink::make(item_size_, dump_filename_.c_str());
+            DLOG(INFO) << "file_sink(" << file_sink_->unique_id() << ")";
+        }
+
+    if (in_stream_ > 0)
+        {
+            LOG(ERROR) << "A signal source does not have an input stream";
+        }
+    if (out_stream_ > 1)
+        {
+            LOG(ERROR) << "This implementation only supports one output stream";
+        }
+}
+
+
+GnMaxSignalSource::~GnMaxSignalSource()
+{
+}
+
+
+void GnMaxSignalSource::connect(gr::top_block_sptr top_block)
+{
+    if (samples_ != 0)
+        {
+            top_block->connect(gnmax_source_, 0, valve_, 0);
+            DLOG(INFO) << "connected limesdr source to valve";
+            if (dump_)
+                {
+                    top_block->connect(valve_, 0, file_sink_, 0);
+                    DLOG(INFO) << "connected valve to file sink";
+                }
+        }
+    else
+        {
+            if (dump_)
+                {
+                    top_block->connect(gnmax_source_, 0, file_sink_, 0);
+                    DLOG(INFO) << "connected limesdr source to file sink";
+                }
+        }
+}
+
+
+void GnMaxSignalSource::disconnect(gr::top_block_sptr top_block)
+{
+    if (samples_ != 0)
+        {
+            top_block->disconnect(gnmax_source_, 0, valve_, 0);
+            if (dump_)
+                {
+                    top_block->disconnect(valve_, 0, file_sink_, 0);
+                }
+        }
+    else
+        {
+            if (dump_)
+                {
+                    top_block->disconnect(gnmax_source_, 0, file_sink_, 0);
+                }
+        }
+}
+
+
+gr::basic_block_sptr GnMaxSignalSource::get_left_block()
+{
+    LOG(WARNING) << "Left block of a signal source should not be retrieved";
+    return gr::block_sptr();
+}
+
+
+gr::basic_block_sptr GnMaxSignalSource::get_right_block()
+{
+    if (samples_ != 0)
+        {
+            return valve_;
+        }
+    else
+        {
+            return gnmax_source_;
+        }
+}
diff -up gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/gnmax_signal_source.h.aaaa gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/gnmax_signal_source.h
--- gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/gnmax_signal_source.h.aaaa	2025-04-14 14:53:05.332889938 +0200
+++ gnss-sdr-0.0.20/src/algorithms/signal_source/adapters/gnmax_signal_source.h	2025-04-14 14:53:05.332889938 +0200
@@ -0,0 +1,94 @@
+/*!
+ * \file gnmax_signal_source.h
+ * \brief gnMAX2769 USB dongle GPS RF front-end signal sampler driver
+ * \author Wojciech Kazubski, wk(at)ire.pw.edu.pl
+ * \author Javier Arribas, jarribas(at)cttc.es
+ *
+ * -----------------------------------------------------------------------------
+ *
+ * Copyright (C) 2010-2020  (see AUTHORS file for a list of contributors)
+ *
+ * GNSS-SDR is a software defined Global Navigation
+ *          Satellite Systems receiver
+ *
+ * This file is part of GNSS-SDR.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ *
+ * -----------------------------------------------------------------------------
+ */
+
+#ifndef GNSS_SDR_GNMAX_SIGNAL_SOURCE_H_
+#define GNSS_SDR_GNMAX_SIGNAL_SOURCE_H_
+
+#include "concurrent_queue.h"
+#include "signal_source_base.h"
+#include <gnuradio/blocks/file_sink.h>
+#include <pmt/pmt.h>
+#include <cstdint>
+#include <memory>
+#include <stdexcept>
+#include <string>
+
+/** \addtogroup Signal_Source
+ * \{ */
+/** \addtogroup Signal_Source_adapters
+ * \{ */
+
+
+class ConfigurationInterface;
+
+/*!
+ * \brief This class reads samples from a gnMAX2769 USB dongle, a RF front-end signal sampler
+ */
+class GnMaxSignalSource : public SignalSourceBase
+{
+public:
+    GnMaxSignalSource(const ConfigurationInterface* configuration,
+        const std::string& role, unsigned int in_stream,
+        unsigned int out_stream, Concurrent_Queue<pmt::pmt_t>* queue);
+
+    virtual ~GnMaxSignalSource();
+
+    inline size_t item_size() override
+    {
+        return item_size_;
+    }
+
+    void connect(gr::top_block_sptr top_block) override;
+    void disconnect(gr::top_block_sptr top_block) override;
+    gr::basic_block_sptr get_left_block() override;
+    gr::basic_block_sptr get_right_block() override;
+
+private:
+    gr::block_sptr gnmax_source_;
+    gnss_shared_ptr<gr::block> valve_;
+    gr::blocks::file_sink::sptr file_sink_;
+
+    std::string item_type_;
+    std::string dump_filename_;
+
+    // Front-end settings
+    bool bias_;
+    int bias__;
+    int ant_;
+    unsigned long freq_;  // frequency of local oscilator
+    float freq__;
+    unsigned long bw_;
+    int bw__;
+    bool zeroif_;
+    int zeroif__;
+
+    size_t item_size_;
+    int64_t samples_;
+
+    unsigned int in_stream_;
+    unsigned int out_stream_;
+
+    bool dump_;
+};
+
+
+/** \} */
+/** \} */
+#endif /*GNSS_SDR_GNMAX_SIGNAL_SOURCE_H_*/
diff -up gnss-sdr-0.0.20/src/core/receiver/CMakeLists.txt.aaaa gnss-sdr-0.0.20/src/core/receiver/CMakeLists.txt
--- gnss-sdr-0.0.20/src/core/receiver/CMakeLists.txt.aaaa	2025-04-02 17:56:58.000000000 +0200
+++ gnss-sdr-0.0.20/src/core/receiver/CMakeLists.txt	2025-04-14 14:53:05.333044945 +0200
@@ -124,6 +124,10 @@ if(ENABLE_LIMESDR)
     target_compile_definitions(core_receiver PRIVATE -DLIMESDR_DRIVER=1)
 endif()
 
+if(ENABLE_GNMAX)
+    target_compile_definitions(core_receiver PRIVATE -DGNMAX_DRIVER=1)
+endif()
+
 if(ENABLE_ARRAY)
     target_compile_definitions(core_receiver PRIVATE -DRAW_ARRAY_DRIVER=1)
 endif()
@@ -268,6 +272,13 @@ if(ENABLE_FLEXIBAND AND TELEORBIT_FOUND)
     )
 endif()
 
+if(ENABLE_GNMAX AND GRGNMAX_FOUND)
+    target_link_libraries(core_receiver
+        PRIVATE
+            Gnuradio::gnmax
+    )
+endif()
+
 if(ENABLE_ARRAY AND GRDBFCTTC_FOUND)
     target_link_libraries(core_receiver
         PRIVATE
diff -up gnss-sdr-0.0.20/src/core/receiver/gnss_block_factory.cc.aaaa gnss-sdr-0.0.20/src/core/receiver/gnss_block_factory.cc
--- gnss-sdr-0.0.20/src/core/receiver/gnss_block_factory.cc.aaaa	2025-04-02 17:56:58.000000000 +0200
+++ gnss-sdr-0.0.20/src/core/receiver/gnss_block_factory.cc	2025-04-14 14:53:05.333223277 +0200
@@ -147,6 +147,10 @@
 #include "gps_l1_ca_pcps_opencl_acquisition.h"
 #endif
 
+#if GNMAX_DRIVER
+#include "gnmax_signal_source.h"
+#endif
+
 #if RAW_ARRAY_DRIVER
 #include "raw_array_signal_source.h"
 #endif
@@ -777,6 +781,16 @@ std::unique_ptr<GNSSBlockInterface> GNSS
                     block = std::move(block_);
                 }
 #endif
+
+#if GNMAX_DRIVER
+            else if (implementation == "GNMAX_Signal_Source")
+                {
+                    std::unique_ptr<GNSSBlockInterface> block_ = std::make_unique<GnMaxSignalSource>(configuration, role, in_streams,
+                        out_streams, queue);
+                    block = std::move(block_);
+                }
+#endif
+ 
 #if RAW_ARRAY_DRIVER
             else if (implementation == "Raw_Array_Signal_Source")
                 {
openSUSE Build Service is sponsored by