[PATCH] fcd: restore support for FUNcube Dongle and Pro+

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.

argilo at gmail.com argilo at gmail.com
Sun May 31 03:43:18 UTC 2020


From: Clayton Smith <argilo at gmail.com>

Support for the original FUNcube Dongle used to live in GNU Radio's
gr-fcd module, which was removed in version 3.8. As a result, gr-osmosdr
lost support for both FUNcube Dongle and FUNcube Dongle Pro+.

The gr-fcdproplus out-of-tree module subsequently added support for the
original FUNcube Dongle, meaning that it now supports both types. As a
result, FUNcube support can easily be restored in gr-osmosdr. The
#ifdefs are no longer required, since everything is in a single module
now.
---
 CMakeLists.txt                        |  1 +
 cmake/Modules/FindGnuradioFCDPP.cmake | 27 +++++++++++++++++++++++++++
 lib/CMakeLists.txt                    |  8 ++++++++
 lib/fcd/CMakeLists.txt                | 21 ++++-----------------
 lib/fcd/fcd_source_c.cc               | 18 +-----------------
 lib/fcd/fcd_source_c.h                | 13 ++-----------
 6 files changed, 43 insertions(+), 45 deletions(-)
 create mode 100644 cmake/Modules/FindGnuradioFCDPP.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7a2cf9df3d..14a9ddda7f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -176,6 +176,7 @@ find_package(LibHackRF)
 find_package(LibAIRSPY)
 find_package(LibAIRSPYHF)
 find_package(LibbladeRF)
+find_package(GnuradioFCDPP)
 find_package(SoapySDR NO_MODULE)
 find_package(LibFreeSRP)
 find_package(Doxygen)
diff --git a/cmake/Modules/FindGnuradioFCDPP.cmake b/cmake/Modules/FindGnuradioFCDPP.cmake
new file mode 100644
index 0000000000..f81fe8aa41
--- /dev/null
+++ b/cmake/Modules/FindGnuradioFCDPP.cmake
@@ -0,0 +1,27 @@
+if(NOT GNURADIO_FCDPP_FOUND)
+  pkg_check_modules (GNURADIO_FCDPP_PKG libgnuradio-fcdproplus)
+  find_path(GNURADIO_FCDPP_INCLUDE_DIRS NAMES fcdproplus/api.h
+    PATHS
+    ${GNURADIO_FCDPP_PKG_INCLUDE_DIRS}
+    /usr/include
+    /usr/local/include
+  )
+
+  find_library(GNURADIO_FCDPP_LIBRARIES NAMES gnuradio-fcdproplus
+    PATHS
+    ${GNURADIO_FCDPP_PKG_LIBRARY_DIRS}
+    /usr/lib
+    /usr/local/lib
+  )
+
+if(GNURADIO_FCDPP_INCLUDE_DIRS AND GNURADIO_FCDPP_LIBRARIES)
+  set(GNURADIO_FCDPP_FOUND TRUE CACHE INTERNAL "gnuradio-fcdproplus found")
+  message(STATUS "Found gnuradio-fcdproplus: ${GNURADIO_FCDPP_INCLUDE_DIRS}, ${GNURADIO_FCDPP_LIBRARIES}")
+else(GNURADIO_FCDPP_INCLUDE_DIRS AND GNURADIO_FCDPP_LIBRARIES)
+  set(GNURADIO_FCDPP_FOUND FALSE CACHE INTERNAL "gnuradio-fcdproplus found")
+  message(STATUS "gnuradio-fcdproplus not found.")
+endif(GNURADIO_FCDPP_INCLUDE_DIRS AND GNURADIO_FCDPP_LIBRARIES)
+
+mark_as_advanced(GNURADIO_FCDPP_LIBRARIES GNURADIO_FCDPP_INCLUDE_DIRS)
+
+endif(NOT GNURADIO_FCDPP_FOUND)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index d04cb1d402..3199ef3d79 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -135,6 +135,14 @@ if(ENABLE_OSMOSDR)
     add_subdirectory(osmosdr)
 endif(ENABLE_OSMOSDR)
 
+########################################################################
+# Setup FCD component
+########################################################################
+GR_REGISTER_COMPONENT("FUNcube Dongle" ENABLE_FCD GNURADIO_FCDPP_FOUND)
+if(ENABLE_FCD)
+    add_subdirectory(fcd)
+endif(ENABLE_FCD)
+
 ########################################################################
 # Setup File component
 ########################################################################
diff --git a/lib/fcd/CMakeLists.txt b/lib/fcd/CMakeLists.txt
index 146191f7ac..7a515c71fc 100644
--- a/lib/fcd/CMakeLists.txt
+++ b/lib/fcd/CMakeLists.txt
@@ -23,25 +23,12 @@
 
 target_include_directories(gnuradio-osmosdr PRIVATE
     ${CMAKE_CURRENT_SOURCE_DIR}
+    ${GNURADIO_FCDPP_INCLUDE_DIRS}
 )
 
-if(ENABLE_FCD)
-    target_include_directories(gnuradio-osmosdr PRIVATE
-        ${Gnuradio-fcd_INCLUDE_DIRS}
-    )
-    target_link_libraries(gnuradio-osmosdr PRIVATE
-        ${Gnuradio-fcd_LIBRARIES}
-    )
-endif(ENABLE_FCD)
-
-if(ENABLE_FCDPP)
-    target_include_directories(gnuradio-osmosdr PRIVATE
-        ${Gnuradio-fcdpp_INCLUDE_DIRS}
-    )
-    target_link_libraries(gnuradio-osmosdr PRIVATE
-        ${Gnuradio-fcdpp_LIBRARIES}
-    )
-endif(ENABLE_FCDPP)
+target_link_libraries(gnuradio-osmosdr
+    ${GNURADIO_FCDPP_LIBRARIES}
+)
 
 list(APPEND gr_osmosdr_srcs
     ${CMAKE_CURRENT_SOURCE_DIR}/fcd_source_c.cc
diff --git a/lib/fcd/fcd_source_c.cc b/lib/fcd/fcd_source_c.cc
index 885d514787..744fa69553 100644
--- a/lib/fcd/fcd_source_c.cc
+++ b/lib/fcd/fcd_source_c.cc
@@ -142,18 +142,15 @@ fcd_source_c::fcd_source_c(const std::string &args) :
 
   std::cerr << "Using " << name() << " (" << dev_name << ")" << std::endl;
 
-#ifdef HAVE_FCD
   if ( FUNCUBE_V1 == _type )
   {
-    _src_v1 = gr::fcd::source_c::make( dev_name );
+    _src_v1 = gr::fcdproplus::fcd::make( dev_name );
     connect( _src_v1, 0, self(), 0 );
 
     set_gain( 20, "LNA" );
     set_gain( 12, "MIX" );
   }
-#endif
 
-#ifdef HAVE_FCDPP
   if ( FUNCUBE_V2 == _type )
   {
     _src_v2 = gr::fcdproplus::fcdproplus::make( dev_name );
@@ -163,7 +160,6 @@ fcd_source_c::fcd_source_c(const std::string &args) :
     set_gain( 1, "MIX" );
     set_gain( 15, "BB" );
   }
-#endif
 }
 
 fcd_source_c::~fcd_source_c()
@@ -241,15 +237,11 @@ osmosdr::freq_range_t fcd_source_c::get_freq_range( size_t chan )
 
 double fcd_source_c::set_center_freq( double freq, size_t chan )
 {
-#ifdef HAVE_FCD
   if ( FUNCUBE_V1 == _type )
     _src_v1->set_freq( float(freq) );
-#endif
 
-#ifdef HAVE_FCDPP
   if ( FUNCUBE_V2 == _type )
     _src_v2->set_freq( float(freq) );
-#endif
 
   _freq = freq;
 
@@ -263,15 +255,11 @@ double fcd_source_c::get_center_freq( size_t chan )
 
 double fcd_source_c::set_freq_corr( double ppm, size_t chan )
 {
-#ifdef HAVE_FCD
   if ( FUNCUBE_V1 == _type )
     _src_v1->set_freq_corr( ppm );
-#endif
 
-#ifdef HAVE_FCDPP
   if ( FUNCUBE_V2 == _type )
     _src_v2->set_freq_corr( ppm );
-#endif
 
   _correct = ppm;
 
@@ -343,7 +331,6 @@ double fcd_source_c::set_gain( double gain, size_t chan )
 
 double fcd_source_c::set_gain( double gain, const std::string & name, size_t chan )
 {
-#ifdef HAVE_FCD
   if ( FUNCUBE_V1 == _type )
   {
     if ( "LNA" == name )
@@ -357,9 +344,7 @@ double fcd_source_c::set_gain( double gain, const std::string & name, size_t cha
       _src_v1->set_mixer_gain(_mix_gain);
     }
   }
-#endif
 
-#ifdef HAVE_FCDPP
   if ( FUNCUBE_V2 == _type )
   {
     if ( "LNA" == name )
@@ -378,7 +363,6 @@ double fcd_source_c::set_gain( double gain, const std::string & name, size_t cha
       _src_v2->set_if_gain(_bb_gain);
     }
   }
-#endif
 
   return get_gain( name, chan );
 }
diff --git a/lib/fcd/fcd_source_c.h b/lib/fcd/fcd_source_c.h
index 70239f8533..2b02eb1052 100644
--- a/lib/fcd/fcd_source_c.h
+++ b/lib/fcd/fcd_source_c.h
@@ -22,13 +22,8 @@
 
 #include <gnuradio/hier_block2.h>
 
-#ifdef HAVE_FCD
-#include <gnuradio/fcd/source_c.h>
-#endif
-
-#ifdef HAVE_FCDPP
+#include <fcdproplus/fcd.h>
 #include <fcdproplus/fcdproplus.h>
-#endif
 
 #include "source_iface.h"
 
@@ -86,12 +81,8 @@ public:
 
 private:
   dongle_type _type;
-#ifdef HAVE_FCD
-  gr::fcd::source_c::sptr _src_v1;
-#endif
-#ifdef HAVE_FCDPP
+  gr::fcdproplus::fcd::sptr _src_v1;
   gr::fcdproplus::fcdproplus::sptr _src_v2;
-#endif
   double _lna_gain, _mix_gain, _bb_gain, _freq;
   int _correct;
 };
-- 
2.25.1




More information about the osmocom-sdr mailing list