From 800d2eaeaf840261471ba11ad4c920b1e6353d4a Mon Sep 17 00:00:00 2001 From: Clayton Smith Date: Sun, 31 May 2020 03:43:18 +0000 Subject: [PATCH] fcd: restore support for FUNcube Dongle and Pro+ 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 now. Signed-off-by: Eric Wild XXX --- CMakeLists.txt | 1 + cmake/Modules/FindGnuradioFCDPP.cmake | 27 +++++++++++++++++++++++++++ lib/CMakeLists.txt | 8 ++++++++ lib/fcd/CMakeLists.txt | 22 ++++------------------ lib/fcd/fcd_source_c.cc | 18 +----------------- lib/fcd/fcd_source_c.h | 13 ++----------- 6 files changed, 43 insertions(+), 46 deletions(-) create mode 100644 cmake/Modules/FindGnuradioFCDPP.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index cf24991..e89f584 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,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 0000000..f81fe8a --- /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 f8c9db7..d7b2457 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 80f88d3..f5d4aa5 100644 --- a/lib/fcd/CMakeLists.txt +++ b/lib/fcd/CMakeLists.txt @@ -23,26 +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} - ) - - list(APPEND gr_osmosdr_libs - ${Gnuradio-fcd_LIBRARIES} - ) -endif(ENABLE_FCD) - -if(ENABLE_FCDPP) - target_include_directories(gnuradio-osmosdr PRIVATE - ${Gnuradio-fcdpp_INCLUDE_DIRS} - ) - list(APPEND gr_osmosdr_libs - ${Gnuradio-fcdpp_LIBRARIES} - ) -endif(ENABLE_FCDPP) +list(APPEND gr_osmosdr_libs + ${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 885d514..744fa69 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 70239f8..2b02eb1 100644 --- a/lib/fcd/fcd_source_c.h +++ b/lib/fcd/fcd_source_c.h @@ -22,13 +22,8 @@ #include -#ifdef HAVE_FCD -#include -#endif - -#ifdef HAVE_FCDPP +#include #include -#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; };