From 3e6a24e5d9e81878ac57281e7a9d3b23d3dbc6e8 Mon Sep 17 00:00:00 2001 From: Dimitri Stolnikov Date: Wed, 29 May 2013 22:34:40 +0200 Subject: [PATCH] convert to gnuradio 3.7 interface --- CMakeLists.txt | 18 ++++------- README | 2 +- cmake/Modules/FindGnuradioAudio.cmake | 26 ---------------- cmake/Modules/FindGnuradioCore.cmake | 29 ----------------- cmake/Modules/FindGnuradioFCD.cmake | 2 +- cmake/Modules/FindGnuradioIQBalance.cmake | 10 +++--- cmake/Modules/FindGnuradioUHD.cmake | 2 +- cmake/Modules/FindGruel.cmake | 29 ----------------- cmake/Modules/GrMiscUtils.cmake | 38 ++++++++++++++++++++--- cmake/Modules/GrSwig.cmake | 22 ++++++++++--- gnuradio-osmosdr.pc.in | 2 +- grc/gen_osmosdr_blocks.py | 2 +- include/osmosdr/osmosdr_api.h | 2 +- include/osmosdr/osmosdr_sink_c.h | 8 ++--- include/osmosdr/osmosdr_source_c.h | 8 ++--- lib/CMakeLists.txt | 8 ++--- lib/fcd/fcd_source.cc | 14 ++++----- lib/fcd/fcd_source.h | 8 ++--- lib/file/CMakeLists.txt | 2 +- lib/file/file_source_c.cc | 23 +++++++------- lib/file/file_source_c.h | 4 +-- lib/hackrf/hackrf_sink_c.cc | 12 +++---- lib/hackrf/hackrf_sink_c.h | 10 +++--- lib/hackrf/hackrf_source_c.cc | 14 ++++----- lib/hackrf/hackrf_source_c.h | 10 +++--- lib/miri/miri_source_c.cc | 14 ++++----- lib/miri/miri_source_c.h | 10 +++--- lib/osmosdr/osmosdr_src_c.cc | 10 +++--- lib/osmosdr/osmosdr_src_c.h | 12 +++---- lib/osmosdr_arg_helpers.h | 6 ++-- lib/osmosdr_sink_c_impl.cc | 27 +++++++++------- lib/osmosdr_snk_iface.h | 2 +- lib/osmosdr_source_c_impl.cc | 34 ++++++++++---------- lib/osmosdr_src_iface.h | 2 +- lib/rtl/rtl_source_c.cc | 14 ++++----- lib/rtl/rtl_source_c.h | 10 +++--- lib/rtl_tcp/CMakeLists.txt | 2 +- lib/rtl_tcp/rtl_tcp_source_c.cc | 20 ++++++------ lib/rtl_tcp/rtl_tcp_source_c.h | 4 +-- lib/rtl_tcp/rtl_tcp_source_f.cc | 8 ++--- lib/rtl_tcp/rtl_tcp_source_f.h | 6 ++-- lib/uhd/uhd_sink_c.cc | 10 +++--- lib/uhd/uhd_sink_c.h | 8 ++--- lib/uhd/uhd_source_c.cc | 10 +++--- lib/uhd/uhd_source_c.h | 8 ++--- swig/CMakeLists.txt | 6 ++-- swig/osmosdr_swig.i | 18 +++++------ 47 files changed, 253 insertions(+), 293 deletions(-) delete mode 100644 cmake/Modules/FindGnuradioAudio.cmake delete mode 100644 cmake/Modules/FindGnuradioCore.cmake delete mode 100644 cmake/Modules/FindGruel.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fedb27..ee27cf0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,8 +143,8 @@ set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) ######################################################################## # Find build dependencies ######################################################################## -find_package(Gruel) -find_package(GnuradioCore) +set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS) +find_package(Gnuradio "3.7.0") find_package(GnuradioIQBalance) find_package(UHD) find_package(GnuradioUHD) @@ -155,12 +155,8 @@ find_package(LibMiriSDR) find_package(LibHackRF) find_package(Doxygen) -if(NOT GRUEL_FOUND) - message(FATAL_ERROR "Gruel required to build " ${CMAKE_PROJECT_NAME}) -endif() - -if(NOT GNURADIO_CORE_FOUND) - message(FATAL_ERROR "GnuRadio Core required to build " ${CMAKE_PROJECT_NAME}) +if(NOT GNURADIO_RUNTIME_FOUND) + message(FATAL_ERROR "GnuRadio Runtime required to build " ${CMAKE_PROJECT_NAME}) endif() ######################################################################## @@ -170,14 +166,12 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/lib ${Boost_INCLUDE_DIRS} - ${GRUEL_INCLUDE_DIRS} - ${GNURADIO_CORE_INCLUDE_DIRS} + ${GNURADIO_RUNTIME_INCLUDE_DIRS} ) link_directories( ${Boost_LIBRARY_DIRS} - ${GRUEL_LIBRARY_DIRS} - ${GNURADIO_CORE_LIBRARY_DIRS} + ${GNURADIO_RUNTIME_LIBRARY_DIRS} ) # Set component parameters diff --git a/README b/README index 543c2bb..8003665 100644 --- a/README +++ b/README @@ -7,7 +7,7 @@ While primarily being developed for the OsmoSDR hardware, this block as well sup * RTL2832U based DVB-T dongles through librtlsdr * RTL-TCP spectrum server (see librtlsdr project) * MSi2500 based DVB-T dongles through libmirisdr - * gnuradio .cfile input through libgnuradio-core + * gnuradio .cfile input through libgnuradio-blocks By using the OsmoSDR block you can take advantage of a common software api in your application(s) independent of the underlying radio hardware. diff --git a/cmake/Modules/FindGnuradioAudio.cmake b/cmake/Modules/FindGnuradioAudio.cmake deleted file mode 100644 index 246568f..0000000 --- a/cmake/Modules/FindGnuradioAudio.cmake +++ /dev/null @@ -1,26 +0,0 @@ -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_GNURADIO_AUDIO gnuradio-audio) - -FIND_PATH( - GNURADIO_AUDIO_INCLUDE_DIRS - NAMES gnuradio/gr_audio_api.h - HINTS $ENV{GNURADIO_AUDIO_DIR}/include - ${PC_GNURADIO_AUDIO_INCLUDEDIR} - PATHS /usr/local/include - /usr/include -) - -FIND_LIBRARY( - GNURADIO_AUDIO_LIBRARIES - NAMES gnuradio-audio - HINTS $ENV{GNURADIO_AUDIO_DIR}/lib - ${PC_GNURADIO_AUDIO_LIBDIR} - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_AUDIO DEFAULT_MSG GNURADIO_AUDIO_LIBRARIES GNURADIO_AUDIO_INCLUDE_DIRS) -MARK_AS_ADVANCED(GNURADIO_AUDIO_LIBRARIES GNURADIO_AUDIO_INCLUDE_DIRS) diff --git a/cmake/Modules/FindGnuradioCore.cmake b/cmake/Modules/FindGnuradioCore.cmake deleted file mode 100644 index 6b4386e..0000000 --- a/cmake/Modules/FindGnuradioCore.cmake +++ /dev/null @@ -1,29 +0,0 @@ -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_GNURADIO_CORE gnuradio-core) - -FIND_PATH( - GNURADIO_CORE_INCLUDE_DIRS - NAMES gr_core_api.h - HINTS $ENV{GNURADIO_CORE_DIR}/include/gnuradio - ${PC_GNURADIO_CORE_INCLUDEDIR} - ${CMAKE_INSTALL_PREFIX}/include/gnuradio - PATHS /usr/local/include/gnuradio - /usr/include/gnuradio -) - -FIND_LIBRARY( - GNURADIO_CORE_LIBRARIES - NAMES gnuradio-core - HINTS $ENV{GNURADIO_CORE_DIR}/lib - ${PC_GNURADIO_CORE_LIBDIR} - ${CMAKE_INSTALL_PREFIX}/lib64 - ${CMAKE_INSTALL_PREFIX}/lib - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_CORE DEFAULT_MSG GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) -MARK_AS_ADVANCED(GNURADIO_CORE_LIBRARIES GNURADIO_CORE_INCLUDE_DIRS) diff --git a/cmake/Modules/FindGnuradioFCD.cmake b/cmake/Modules/FindGnuradioFCD.cmake index bbde835..e7d7670 100644 --- a/cmake/Modules/FindGnuradioFCD.cmake +++ b/cmake/Modules/FindGnuradioFCD.cmake @@ -3,7 +3,7 @@ PKG_CHECK_MODULES(PC_GNURADIO_FCD gnuradio-fcd) FIND_PATH( GNURADIO_FCD_INCLUDE_DIRS - NAMES gnuradio/fcd_api.h + NAMES gnuradio/fcd/api.h HINTS $ENV{GNURADIO_FCD_DIR}/include ${PC_GNURADIO_FCD_INCLUDEDIR} PATHS /usr/local/include diff --git a/cmake/Modules/FindGnuradioIQBalance.cmake b/cmake/Modules/FindGnuradioIQBalance.cmake index 642ee3f..30cc20c 100644 --- a/cmake/Modules/FindGnuradioIQBalance.cmake +++ b/cmake/Modules/FindGnuradioIQBalance.cmake @@ -3,12 +3,12 @@ PKG_CHECK_MODULES(PC_GNURADIO_IQBALANCE gnuradio-iqbalance) FIND_PATH( GNURADIO_IQBALANCE_INCLUDE_DIRS - NAMES iqbalance_api.h - HINTS $ENV{GNURADIO_IQBALANCE_DIR}/include/iqbalance + NAMES iqbalance/api.h + HINTS $ENV{GNURADIO_IQBALANCE_DIR}/include ${PC_GNURADIO_IQBALANCE_INCLUDEDIR} - ${CMAKE_INSTALL_PREFIX}/include/iqbalance - PATHS /usr/local/include/iqbalance - /usr/include/iqbalance + ${CMAKE_INSTALL_PREFIX}/include + PATHS /usr/local/include + /usr/include ) FIND_LIBRARY( diff --git a/cmake/Modules/FindGnuradioUHD.cmake b/cmake/Modules/FindGnuradioUHD.cmake index 33c437d..f99daf0 100644 --- a/cmake/Modules/FindGnuradioUHD.cmake +++ b/cmake/Modules/FindGnuradioUHD.cmake @@ -3,7 +3,7 @@ PKG_CHECK_MODULES(PC_GNURADIO_UHD gnuradio-uhd) FIND_PATH( GNURADIO_UHD_INCLUDE_DIRS - NAMES gnuradio/gr_uhd_api.h + NAMES gnuradio/uhd/api.h HINTS $ENV{GNURADIO_UHD_DIR}/include ${PC_GNURADIO_UHD_INCLUDEDIR} PATHS /usr/local/include diff --git a/cmake/Modules/FindGruel.cmake b/cmake/Modules/FindGruel.cmake deleted file mode 100644 index 1d044ee..0000000 --- a/cmake/Modules/FindGruel.cmake +++ /dev/null @@ -1,29 +0,0 @@ -INCLUDE(FindPkgConfig) -PKG_CHECK_MODULES(PC_GRUEL gruel) - -FIND_PATH( - GRUEL_INCLUDE_DIRS - NAMES gruel/attributes.h - HINTS $ENV{GRUEL_DIR}/include - ${PC_GRUEL_INCLUDEDIR} - ${CMAKE_INSTALL_PREFIX}/include - PATHS /usr/local/include - /usr/include -) - -FIND_LIBRARY( - GRUEL_LIBRARIES - NAMES gruel - HINTS $ENV{GRUEL_DIR}/lib - ${PC_GRUEL_LIBDIR} - ${CMAKE_INSTALL_PREFIX}/lib - ${CMAKE_INSTALL_PREFIX}/lib64 - PATHS /usr/local/lib - /usr/local/lib64 - /usr/lib - /usr/lib64 -) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GRUEL DEFAULT_MSG GRUEL_LIBRARIES GRUEL_INCLUDE_DIRS) -MARK_AS_ADVANCED(GRUEL_LIBRARIES GRUEL_INCLUDE_DIRS) diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake index 69ff1f5..3d9a5f5 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -268,15 +268,15 @@ function(GRCC) set(filenames ${ARGV}) file(MAKE_DIRECTORY ${directory}) - SET(GRCC_COMMAND ${CMAKE_SOURCE_DIR}/gr-utils/src/python/grcc) + SET(GRCC_COMMAND ${CMAKE_SOURCE_DIR}/gr-utils/python/grcc) - # GRCC uses some stuff in grc and gnuradio-core, so we force + # GRCC uses some stuff in grc and gnuradio-runtime, so we force # the known paths here list(APPEND PYTHONPATHS ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/gnuradio-core/src/python - ${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/swig - ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig + ${CMAKE_SOURCE_DIR}/gnuradio-runtime/python + ${CMAKE_SOURCE_DIR}/gnuradio-runtime/lib/swig + ${CMAKE_BINARY_DIR}/gnuradio-runtime/lib/swig ) if(WIN32) @@ -317,3 +317,31 @@ function(GRCC) set(PYFILES ${pyfiles} PARENT_SCOPE) endfunction(GRCC) + +######################################################################## +# Check if HAVE_PTHREAD_SETSCHEDPARAM and HAVE_SCHED_SETSCHEDULER +# should be defined +######################################################################## +macro(GR_CHECK_LINUX_SCHED_AVAIL) +set(CMAKE_REQUIRED_LIBRARIES -lpthread) + CHECK_CXX_SOURCE_COMPILES(" + #include + int main(){ + pthread_t pthread; + pthread_setschedparam(pthread, 0, 0); + return 0; + } " HAVE_PTHREAD_SETSCHEDPARAM + ) + GR_ADD_COND_DEF(HAVE_PTHREAD_SETSCHEDPARAM) + + CHECK_CXX_SOURCE_COMPILES(" + #include + int main(){ + pid_t pid; + sched_setscheduler(pid, 0, 0); + return 0; + } " HAVE_SCHED_SETSCHEDULER + ) + GR_ADD_COND_DEF(HAVE_SCHED_SETSCHEDULER) +endmacro(GR_CHECK_LINUX_SCHED_AVAIL) + diff --git a/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake index b9bf0bb..8cf1265 100644 --- a/cmake/Modules/GrSwig.cmake +++ b/cmake/Modules/GrSwig.cmake @@ -105,21 +105,35 @@ endfunction(GR_SWIG_MAKE_DOCS) macro(GR_SWIG_MAKE name) set(ifiles ${ARGN}) + # Shimming this in here to take care of a SWIG bug with handling + # vector and vector (on 32-bit machines) and + # vector (on 64-bit machines). Use this to test + # the size of size_t, then set SIZE_T_32 if it's a 32-bit machine + # or not if it's 64-bit. The logic in gr_type.i handles the rest. + INCLUDE (CheckTypeSize) + CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T) + CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT) + if(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) + list(APPEND GR_SWIG_FLAGS -DSIZE_T_32) + endif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) + #do swig doc generation if specified if (GR_SWIG_DOC_FILE) set(GR_SWIG_DOCS_SOURCE_DEPS ${GR_SWIG_SOURCE_DEPS}) - set(GR_SWIG_DOCS_TARGET_DEPS ${GR_SWIG_TARGET_DEPS}) + list(APPEND GR_SWIG_DOCS_TARGET_DEPS ${GR_SWIG_TARGET_DEPS}) GR_SWIG_MAKE_DOCS(${GR_SWIG_DOC_FILE} ${GR_SWIG_DOC_DIRS}) add_custom_target(${name}_swig_doc DEPENDS ${GR_SWIG_DOC_FILE}) - list(APPEND GR_SWIG_TARGET_DEPS ${name}_swig_doc) + list(APPEND GR_SWIG_TARGET_DEPS ${name}_swig_doc ${GR_RUNTIME_SWIG_DOC_FILE}) endif() #append additional include directories find_package(PythonLibs) list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_PATH}) #deprecated name (now dirs) list(APPEND GR_SWIG_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}) + + #prepend local swig directories + list(INSERT GR_SWIG_INCLUDE_DIRS 0 ${CMAKE_CURRENT_SOURCE_DIR}) + list(INSERT GR_SWIG_INCLUDE_DIRS 0 ${CMAKE_CURRENT_BINARY_DIR}) #determine include dependencies for swig file execute_process( diff --git a/gnuradio-osmosdr.pc.in b/gnuradio-osmosdr.pc.in index 2cdfc28..c428cfa 100644 --- a/gnuradio-osmosdr.pc.in +++ b/gnuradio-osmosdr.pc.in @@ -7,7 +7,7 @@ Name: @CPACK_PACKAGE_NAME@ Description: @CPACK_PACKAGE_DESCRIPTION_SUMMARY@ URL: http://sdr.osmocom.org/trac/ Version: @CPACK_PACKAGE_VERSION@ -Requires: gnuradio-core +Requires: gnuradio-runtime gnuradio-blocks Requires.private: @GR_OSMOSDR_PC_REQUIRES@ Conflicts: Cflags: -I${includedir} @GR_OSMOSDR_PC_CFLAGS@ diff --git a/grc/gen_osmosdr_blocks.py b/grc/gen_osmosdr_blocks.py index bb21f5f..7b97d1b 100644 --- a/grc/gen_osmosdr_blocks.py +++ b/grc/gen_osmosdr_blocks.py @@ -115,7 +115,7 @@ While primarily being developed for the OsmoSDR hardware, this block as well sup * RTL2832U based DVB-T dongles through librtlsdr * RTL-TCP spectrum server (see librtlsdr project) * MSi2500 based DVB-T dongles through libmirisdr - * gnuradio .cfile input through libgnuradio-core + * gnuradio .cfile input through libgnuradio-blocks By using the OsmoSDR block you can take advantage of a common software api in your application(s) independent of the underlying radio hardware. diff --git a/include/osmosdr/osmosdr_api.h b/include/osmosdr/osmosdr_api.h index d8a1c4c..d3adbf0 100644 --- a/include/osmosdr/osmosdr_api.h +++ b/include/osmosdr/osmosdr_api.h @@ -22,7 +22,7 @@ #ifndef INCLUDED_OSMOSDR_API_H #define INCLUDED_OSMOSDR_API_H -#include +#include #ifdef gnuradio_osmosdr_EXPORTS # define OSMOSDR_API __GR_ATTR_EXPORT diff --git a/include/osmosdr/osmosdr_sink_c.h b/include/osmosdr/osmosdr_sink_c.h index d3911e1..fa03300 100644 --- a/include/osmosdr/osmosdr_sink_c.h +++ b/include/osmosdr/osmosdr_sink_c.h @@ -22,13 +22,13 @@ #include #include -#include +#include class osmosdr_sink_c; /* * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets + * to gr::blocks (and many other data structures). The shared_ptr gets * us transparent reference counting, which greatly simplifies storage * management issues. This is especially helpful in our hybrid * C++ / Python system. @@ -52,9 +52,9 @@ OSMOSDR_API osmosdr_sink_c_sptr osmosdr_make_sink_c ( const std::string & args = * \brief Takes a stream of complex samples. * \ingroup block * - * This uses the preferred technique: subclassing gr_hier_block2. + * This uses the preferred technique: subclassing gr::hier_block2. */ -class OSMOSDR_API osmosdr_sink_c : virtual public gr_hier_block2 +class OSMOSDR_API osmosdr_sink_c : virtual public gr::hier_block2 { public: /*! diff --git a/include/osmosdr/osmosdr_source_c.h b/include/osmosdr/osmosdr_source_c.h index 8ffdb90..9b506df 100644 --- a/include/osmosdr/osmosdr_source_c.h +++ b/include/osmosdr/osmosdr_source_c.h @@ -22,13 +22,13 @@ #include #include -#include +#include class osmosdr_source_c; /* * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets + * to gr::blocks (and many other data structures). The shared_ptr gets * us transparent reference counting, which greatly simplifies storage * management issues. This is especially helpful in our hybrid * C++ / Python system. @@ -52,9 +52,9 @@ OSMOSDR_API osmosdr_source_c_sptr osmosdr_make_source_c ( const std::string & ar * \brief Provides a stream of complex samples. * \ingroup block * - * This uses the preferred technique: subclassing gr_hier_block2. + * This uses the preferred technique: subclassing gr::hier_block2. */ -class OSMOSDR_API osmosdr_source_c : virtual public gr_hier_block2 +class OSMOSDR_API osmosdr_source_c : virtual public gr::hier_block2 { public: /*! diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 850a660..e4d764b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -44,8 +44,8 @@ GR_OSMOSDR_APPEND_SRCS( GR_OSMOSDR_APPEND_LIBS( ${Boost_LIBRARIES} - ${GRUEL_LIBRARIES} - ${GNURADIO_CORE_LIBRARIES} + ${GNURADIO_RUNTIME_LIBRARIES} + ${GNURADIO_BLOCKS_LIBRARIES} ) ######################################################################## @@ -77,7 +77,7 @@ endif(ENABLE_FCD) ######################################################################## # Setup File component ######################################################################## -GR_REGISTER_COMPONENT("IQ File Source" ENABLE_FILE GNURADIO_CORE_FOUND) +GR_REGISTER_COMPONENT("IQ File Source" ENABLE_FILE GNURADIO_BLOCKS_FOUND) if(ENABLE_FILE) GR_INCLUDE_SUBDIRECTORY(file) endif(ENABLE_FILE) @@ -93,7 +93,7 @@ endif(ENABLE_RTL) ######################################################################## # Setup RTL_TCP component ######################################################################## -GR_REGISTER_COMPONENT("RTLSDR TCP Client" ENABLE_RTL_TCP GNURADIO_CORE_FOUND) +GR_REGISTER_COMPONENT("RTLSDR TCP Client" ENABLE_RTL_TCP GNURADIO_BLOCKS_FOUND) if(ENABLE_RTL_TCP) GR_INCLUDE_SUBDIRECTORY(rtl_tcp) endif(ENABLE_RTL_TCP) diff --git a/lib/fcd/fcd_source.cc b/lib/fcd/fcd_source.cc index e75616b..8b53c64 100644 --- a/lib/fcd/fcd_source.cc +++ b/lib/fcd/fcd_source.cc @@ -25,11 +25,11 @@ #include #include -#include +#include -#include +#include "fcd_source.h" -#include +#include "osmosdr_arg_helpers.h" using namespace boost::assign; @@ -74,9 +74,9 @@ static std::vector< std::string > _get_devices() } fcd_source::fcd_source(const std::string &args) : - gr_hier_block2("fcd_source", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (gr_complex))) + gr::hier_block2("fcd_source", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(1, 1, sizeof (gr_complex))) { std::string dev_name; unsigned int dev_index = 0; @@ -93,7 +93,7 @@ fcd_source::fcd_source(const std::string &args) : else throw std::runtime_error("No FunCube Dongle found."); - _src = fcd_make_source_c( dev_name ); + _src = gr::fcd::source_c::make( dev_name ); connect( _src, 0, self(), 0 ); } diff --git a/lib/fcd/fcd_source.h b/lib/fcd/fcd_source.h index 6c175d1..ce84946 100644 --- a/lib/fcd/fcd_source.h +++ b/lib/fcd/fcd_source.h @@ -20,9 +20,9 @@ #ifndef FCD_SOURCE_H #define FCD_SOURCE_H -#include +#include -#include +#include #include "osmosdr_src_iface.h" @@ -33,7 +33,7 @@ typedef boost::shared_ptr< fcd_source > fcd_source_sptr; fcd_source_sptr make_fcd_source( const std::string & args = "" ); class fcd_source : - public gr_hier_block2, + public gr::hier_block2, public osmosdr_src_iface { private: @@ -73,7 +73,7 @@ public: std::string get_antenna( size_t chan = 0 ); private: - fcd_source_c_sptr _src; + gr::fcd::source_c::sptr _src; double _gain, _freq; int32_t _correct; }; diff --git a/lib/file/CMakeLists.txt b/lib/file/CMakeLists.txt index 0ef8e43..917b423 100644 --- a/lib/file/CMakeLists.txt +++ b/lib/file/CMakeLists.txt @@ -33,5 +33,5 @@ set(file_srcs # Append gnuradio-osmosdr library sources ######################################################################## list(APPEND gr_osmosdr_srcs ${file_srcs}) -list(APPEND gr_osmosdr_libs ${GNURADIO_CORE_LIBRARIES}) +list(APPEND gr_osmosdr_libs ${GNURADIO_BLOCKS_LIBRARIES}) diff --git a/lib/file/file_source_c.cc b/lib/file/file_source_c.cc index 1b83fdf..dc2587d 100644 --- a/lib/file/file_source_c.cc +++ b/lib/file/file_source_c.cc @@ -24,13 +24,13 @@ #include -#include -#include -#include +#include +#include +#include #include "file_source_c.h" -#include +#include "osmosdr_arg_helpers.h" using namespace boost::assign; @@ -40,9 +40,9 @@ file_source_c_sptr make_file_source_c(const std::string &args) } file_source_c::file_source_c(const std::string &args) : - gr_hier_block2("file_source_c", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (gr_complex))) + gr::hier_block2("file_source_c", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(1, 1, sizeof (gr_complex))) { std::string filename; bool repeat = true; @@ -76,12 +76,13 @@ file_source_c::file_source_c(const std::string &args) : if (0 == _rate) throw std::runtime_error("Parameter 'rate' is missing in arguments."); - gr_file_source_sptr src = gr_make_file_source( sizeof(gr_complex), - filename.c_str(), - repeat ); + gr::blocks::file_source::sptr src = \ + gr::blocks::file_source::make( sizeof(gr_complex), + filename.c_str(), + repeat ); if (throttle) { - gr_throttle::sptr throttle = gr_make_throttle( sizeof(gr_complex), _rate ); + gr::blocks::throttle::sptr throttle = gr::blocks::throttle::make( sizeof(gr_complex), _rate ); connect( src, 0, throttle, 0 ); connect( throttle, 0, self(), 0 ); diff --git a/lib/file/file_source_c.h b/lib/file/file_source_c.h index 94d2c0a..29fafa1 100644 --- a/lib/file/file_source_c.h +++ b/lib/file/file_source_c.h @@ -20,7 +20,7 @@ #ifndef FILE_SOURCE_C_H #define FILE_SOURCE_C_H -#include +#include #include "osmosdr_src_iface.h" @@ -31,7 +31,7 @@ typedef boost::shared_ptr< file_source_c > file_source_c_sptr; file_source_c_sptr make_file_source_c( const std::string & args = "" ); class file_source_c : - public gr_hier_block2, + public gr::hier_block2, public osmosdr_src_iface { private: diff --git a/lib/hackrf/hackrf_sink_c.cc b/lib/hackrf/hackrf_sink_c.cc index 635159d..af0c963 100644 --- a/lib/hackrf/hackrf_sink_c.cc +++ b/lib/hackrf/hackrf_sink_c.cc @@ -42,7 +42,7 @@ #include #include -#include +#include #include "hackrf_sink_c.h" @@ -126,7 +126,7 @@ hackrf_sink_c_sptr make_hackrf_sink_c (const std::string & args) /* * Specify constraints on number of input and output streams. * This info is used to construct the input and output signatures - * (2nd & 3rd args to gr_block's constructor). The input and + * (2nd & 3rd args to gr::block's constructor). The input and * output signatures are used by the runtime system to * check that a valid number and type of inputs and outputs * are connected to this block. In this case, we accept @@ -141,9 +141,9 @@ static const int MAX_OUT = 0; // maximum number of output streams * The private constructor */ hackrf_sink_c::hackrf_sink_c (const std::string &args) - : gr_sync_block ("hackrf_sink_c", - gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)), - gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex))), + : gr::sync_block ("hackrf_sink_c", + gr::io_signature::make(MIN_IN, MAX_IN, sizeof (gr_complex)), + gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof (gr_complex))), _dev(NULL), _buf(NULL), _sample_rate(0), @@ -219,7 +219,7 @@ hackrf_sink_c::hackrf_sink_c (const std::string &args) cb_init( &_cbuf, _buf_num, BUF_LEN ); -// _thread = gruel::thread(_hackrf_wait, this); +// _thread = gr::thread::thread(_hackrf_wait, this); } /* diff --git a/lib/hackrf/hackrf_sink_c.h b/lib/hackrf/hackrf_sink_c.h index 665121b..c1c5598 100644 --- a/lib/hackrf/hackrf_sink_c.h +++ b/lib/hackrf/hackrf_sink_c.h @@ -20,8 +20,8 @@ #ifndef INCLUDED_HACKRF_SINK_C_H #define INCLUDED_HACKRF_SINK_C_H -#include -#include +#include +#include #include #include @@ -45,7 +45,7 @@ typedef struct circular_buffer /* * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets + * to gr::blocks (and many other data structures). The shared_ptr gets * us transparent reference counting, which greatly simplifies storage * management issues. This is especially helpful in our hybrid * C++ / Python system. @@ -66,7 +66,7 @@ typedef boost::shared_ptr hackrf_sink_c_sptr; hackrf_sink_c_sptr make_hackrf_sink_c (const std::string & args = ""); class hackrf_sink_c : - public gr_sync_block, + public gr::sync_block, public osmosdr_snk_iface { private: @@ -131,7 +131,7 @@ private: static boost::mutex _usage_mutex; hackrf_device *_dev; -// gruel::thread _thread; +// gr::thread::thread _thread; circular_buffer_t _cbuf; unsigned char *_buf; diff --git a/lib/hackrf/hackrf_source_c.cc b/lib/hackrf/hackrf_source_c.cc index 5049eeb..48eabb1 100644 --- a/lib/hackrf/hackrf_source_c.cc +++ b/lib/hackrf/hackrf_source_c.cc @@ -28,7 +28,7 @@ #endif #include "hackrf_source_c.h" -#include +#include #include #include @@ -39,7 +39,7 @@ #include #include -#include +#include "osmosdr_arg_helpers.h" using namespace boost::assign; @@ -59,7 +59,7 @@ hackrf_source_c_sptr make_hackrf_source_c (const std::string & args) /* * Specify constraints on number of input and output streams. * This info is used to construct the input and output signatures - * (2nd & 3rd args to gr_block's constructor). The input and + * (2nd & 3rd args to gr::block's constructor). The input and * output signatures are used by the runtime system to * check that a valid number and type of inputs and outputs * are connected to this block. In this case, we accept @@ -74,9 +74,9 @@ static const int MAX_OUT = 1; // maximum number of output streams * The private constructor */ hackrf_source_c::hackrf_source_c (const std::string &args) - : gr_sync_block ("hackrf_source_c", - gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)), - gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex))), + : gr::sync_block ("hackrf_source_c", + gr::io_signature::make(MIN_IN, MAX_IN, sizeof (gr_complex)), + gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof (gr_complex))), _dev(NULL), _buf(NULL), _sample_rate(0), @@ -177,7 +177,7 @@ hackrf_source_c::hackrf_source_c (const std::string &args) _buf[i] = (unsigned short *) malloc(_buf_len); } -// _thread = gruel::thread(_hackrf_wait, this); +// _thread = gr::thread::thread(_hackrf_wait, this); } /* diff --git a/lib/hackrf/hackrf_source_c.h b/lib/hackrf/hackrf_source_c.h index ccd6201..658bcea 100644 --- a/lib/hackrf/hackrf_source_c.h +++ b/lib/hackrf/hackrf_source_c.h @@ -22,8 +22,8 @@ #ifndef INCLUDED_HACKRF_SOURCE_C_H #define INCLUDED_HACKRF_SOURCE_C_H -#include -#include +#include +#include #include #include @@ -36,7 +36,7 @@ class hackrf_source_c; /* * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets + * to gr::blocks (and many other data structures). The shared_ptr gets * us transparent reference counting, which greatly simplifies storage * management issues. This is especially helpful in our hybrid * C++ / Python system. @@ -61,7 +61,7 @@ hackrf_source_c_sptr make_hackrf_source_c (const std::string & args = ""); * \ingroup block */ class hackrf_source_c : - public gr_sync_block, + public gr::sync_block, public osmosdr_src_iface { private: @@ -132,7 +132,7 @@ private: std::vector _lut; hackrf_device *_dev; - gruel::thread _thread; + gr::thread::thread _thread; unsigned short **_buf; unsigned int _buf_num; unsigned int _buf_len; diff --git a/lib/miri/miri_source_c.cc b/lib/miri/miri_source_c.cc index e36328e..5fe3c55 100644 --- a/lib/miri/miri_source_c.cc +++ b/lib/miri/miri_source_c.cc @@ -29,7 +29,7 @@ #endif #include "miri_source_c.h" -#include +#include #include #include @@ -40,7 +40,7 @@ #include -#include +#include "osmosdr_arg_helpers.h" using namespace boost::assign; @@ -64,7 +64,7 @@ make_miri_source_c (const std::string &args) /* * Specify constraints on number of input and output streams. * This info is used to construct the input and output signatures - * (2nd & 3rd args to gr_block's constructor). The input and + * (2nd & 3rd args to gr::block's constructor). The input and * output signatures are used by the runtime system to * check that a valid number and type of inputs and outputs * are connected to this block. In this case, we accept @@ -79,9 +79,9 @@ static const int MAX_OUT = 1; // maximum number of output streams * The private constructor */ miri_source_c::miri_source_c (const std::string &args) - : gr_sync_block ("miri_source_c", - gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)), - gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex))), + : gr::sync_block ("miri_source_c", + gr::io_signature::make(MIN_IN, MAX_IN, sizeof (gr_complex)), + gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof (gr_complex))), _running(true), _auto_gain(false), _skipped(0) @@ -140,7 +140,7 @@ miri_source_c::miri_source_c (const std::string &args) _buf[i] = (unsigned short *) malloc(BUF_SIZE); } - _thread = gruel::thread(_mirisdr_wait, this); + _thread = gr::thread::thread(_mirisdr_wait, this); } /* diff --git a/lib/miri/miri_source_c.h b/lib/miri/miri_source_c.h index 168c23a..a418617 100644 --- a/lib/miri/miri_source_c.h +++ b/lib/miri/miri_source_c.h @@ -20,9 +20,9 @@ #ifndef INCLUDED_MIRI_SOURCE_C_H #define INCLUDED_MIRI_SOURCE_C_H -#include +#include -#include +#include #include #include @@ -33,7 +33,7 @@ typedef struct mirisdr_dev mirisdr_dev_t; /* * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets + * to gr::blocks (and many other data structures). The shared_ptr gets * us transparent reference counting, which greatly simplifies storage * management issues. This is especially helpful in our hybrid * C++ / Python system. @@ -58,7 +58,7 @@ miri_source_c_sptr make_miri_source_c (const std::string & args = ""); * \ingroup block */ class miri_source_c : - public gr_sync_block, + public gr::sync_block, public osmosdr_src_iface { private: @@ -114,7 +114,7 @@ private: void mirisdr_wait(); mirisdr_dev_t *_dev; - gruel::thread _thread; + gr::thread::thread _thread; unsigned short **_buf; unsigned int *_buf_lens; unsigned int _buf_num; diff --git a/lib/osmosdr/osmosdr_src_c.cc b/lib/osmosdr/osmosdr_src_c.cc index 98ae080..7995002 100644 --- a/lib/osmosdr/osmosdr_src_c.cc +++ b/lib/osmosdr/osmosdr_src_c.cc @@ -28,7 +28,7 @@ #endif #include "osmosdr_src_c.h" -#include +#include #include #include @@ -39,7 +39,7 @@ #include -#include +#include "osmosdr_arg_helpers.h" using namespace boost::assign; @@ -63,8 +63,8 @@ osmosdr_make_src_c (const std::string &args) * The private constructor */ osmosdr_src_c::osmosdr_src_c (const std::string &args) - : gr_sync_block ("osmosdr_src_c", - gr_make_io_signature (0, 0, sizeof (gr_complex)), + : gr::sync_block ("osmosdr_src_c", + gr::io_signature::make(0, 0, sizeof (gr_complex)), args_to_io_signature(args)), _dev(NULL), _buf(NULL), @@ -139,7 +139,7 @@ osmosdr_src_c::osmosdr_src_c (const std::string &args) _buf[i] = (unsigned short *) malloc(_buf_len); } - _thread = gruel::thread(_osmosdr_wait, this); + _thread = gr::thread::thread(_osmosdr_wait, this); } /* diff --git a/lib/osmosdr/osmosdr_src_c.h b/lib/osmosdr/osmosdr_src_c.h index c9ebf2d..9ff5030 100644 --- a/lib/osmosdr/osmosdr_src_c.h +++ b/lib/osmosdr/osmosdr_src_c.h @@ -20,9 +20,9 @@ #ifndef INCLUDED_OSMOSDR_SRC_C_H #define INCLUDED_OSMOSDR_SRC_C_H -#include +#include -#include +#include #include #include @@ -33,7 +33,7 @@ typedef struct osmosdr_dev osmosdr_dev_t; /* * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets + * to gr::blocks (and many other data structures). The shared_ptr gets * us transparent reference counting, which greatly simplifies storage * management issues. This is especially helpful in our hybrid * C++ / Python system. @@ -57,10 +57,10 @@ osmosdr_src_c_sptr osmosdr_make_src_c (const std::string & args = ""); * \brief Provides a stream of complex samples. * \ingroup block * - * \sa osmosdr_sink_c for a version that subclasses gr_hier_block2. + * \sa osmosdr_sink_c for a version that subclasses gr::hier_block2. */ class osmosdr_src_c : - public gr_sync_block, + public gr::sync_block, public osmosdr_src_iface { private: @@ -118,7 +118,7 @@ private: void osmosdr_wait(); osmosdr_dev_t *_dev; - gruel::thread _thread; + gr::thread::thread _thread; unsigned short **_buf; unsigned int _buf_num; unsigned int _buf_len; diff --git a/lib/osmosdr_arg_helpers.h b/lib/osmosdr_arg_helpers.h index 2261524..c1a4fb3 100644 --- a/lib/osmosdr_arg_helpers.h +++ b/lib/osmosdr_arg_helpers.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -106,7 +106,7 @@ struct is_nchan_argument } }; -inline gr_io_signature_sptr args_to_io_signature( const std::string &args ) +inline gr::io_signature::sptr args_to_io_signature( const std::string &args ) { size_t max_nchan = 0; size_t dev_nchan = 0; @@ -147,7 +147,7 @@ inline gr_io_signature_sptr args_to_io_signature( const std::string &args ) throw std::runtime_error("Wrong device arguments specified. Missing nchan?"); const size_t nchan = std::max(dev_nchan, 1); // assume at least one - return gr_make_io_signature(nchan, nchan, sizeof(gr_complex)); + return gr::io_signature::make(nchan, nchan, sizeof(gr_complex)); } #endif // OSMOSDR_ARG_HELPERS_H diff --git a/lib/osmosdr_sink_c_impl.cc b/lib/osmosdr_sink_c_impl.cc index 8e08444..13494ee 100644 --- a/lib/osmosdr_sink_c_impl.cc +++ b/lib/osmosdr_sink_c_impl.cc @@ -27,10 +27,10 @@ #include "config.h" #endif -#include -#include -#include -#include +#include +#include +#include +#include #include "osmosdr_sink_c_impl.h" @@ -43,7 +43,7 @@ #include "osmosdr_arg_helpers.h" -/* This avoids throws in ctor of gr_hier_block2, as gnuradio is unable to deal +/* This avoids throws in ctor of gr::hier_block2, as gnuradio is unable to deal with this behavior in a clean way. The GR maintainer Rondeau has been informed. */ #define WORKAROUND_GR_HIER_BLOCK2_BUG @@ -61,9 +61,9 @@ osmosdr_make_sink_c (const std::string &args) * The private constructor */ osmosdr_sink_c_impl::osmosdr_sink_c_impl (const std::string &args) - : gr_hier_block2 ("osmosdr_sink_c_impl", + : gr::hier_block2 ("osmosdr_sink_c_impl", args_to_io_signature(args), - gr_make_io_signature (0, 0, 0)) + gr::io_signature::make(0, 0, 0)) { size_t channel = 0; bool device_specified = false; @@ -81,7 +81,7 @@ osmosdr_sink_c_impl::osmosdr_sink_c_impl (const std::string &args) std::cerr << "gr-osmosdr " << GR_OSMOSDR_VERSION " (" GR_OSMOSDR_LIBVER ") " - << "gnuradio " << gr_version() << std::endl; + << "gnuradio " << gr::version() << std::endl; std::cerr << "built-in sink types: "; BOOST_FOREACH(std::string dev_type, dev_types) std::cerr << dev_type << " "; @@ -128,7 +128,7 @@ osmosdr_sink_c_impl::osmosdr_sink_c_impl (const std::string &args) // std::cerr << "'" << entry.first << "' = '" << entry.second << "'" << std::endl; osmosdr_snk_iface *iface = NULL; - gr_basic_block_sptr block; + gr::basic_block_sptr block; #ifdef ENABLE_UHD if ( dict.count("uhd") ) { @@ -163,7 +163,7 @@ osmosdr_sink_c_impl::osmosdr_sink_c_impl (const std::string &args) size_t missing_chans = output_signature()->max_streams() - channel; std::cerr << "Trying to fill up " << missing_chans - << " missing channel(s) with null sinks.\n" + << " missing channel(s) with null sink(s).\n" << "This is being done to prevent the application from crashing\n" << "due to a gnuradio bug. The maintainers have been informed.\n" << std::endl; @@ -171,9 +171,12 @@ osmosdr_sink_c_impl::osmosdr_sink_c_impl (const std::string &args) for (size_t i = 0; i < missing_chans; i++) { /* we try to prevent the whole application from crashing by faking * the missing hardware (channels) with a null sink */ - gr_null_sink_sptr null_sink = gr_make_null_sink( sizeof(gr_complex) ); - gr_throttle::sptr throttle = gr_make_throttle(sizeof(gr_complex), 1e6); + gr::blocks::null_sink::sptr null_sink = \ + gr::blocks::null_sink::make( sizeof(gr_complex) ); + + gr::blocks::throttle::sptr throttle = \ + gr::blocks::throttle::make( sizeof(gr_complex), 1e5 ); connect(self(), channel++, throttle, 0); connect(throttle, 0, null_sink, 0); diff --git a/lib/osmosdr_snk_iface.h b/lib/osmosdr_snk_iface.h index bd952d8..a0b2e73 100644 --- a/lib/osmosdr_snk_iface.h +++ b/lib/osmosdr_snk_iface.h @@ -22,7 +22,7 @@ #define OSMOSDR_SNK_IFACE_H #include -#include +#include class osmosdr_snk_iface; diff --git a/lib/osmosdr_source_c_impl.cc b/lib/osmosdr_source_c_impl.cc index 09f29cb..2c3e0a4 100644 --- a/lib/osmosdr_source_c_impl.cc +++ b/lib/osmosdr_source_c_impl.cc @@ -28,10 +28,10 @@ #endif #include -#include -#include -#include -#include +#include +#include +#include +#include #ifdef ENABLE_OSMOSDR #include @@ -65,9 +65,9 @@ #include #endif -#include +#include "osmosdr_arg_helpers.h" -/* This avoids throws in ctor of gr_hier_block2, as gnuradio is unable to deal +/* This avoids throws in ctor of gr::hier_block2, as gnuradio is unable to deal with this behavior in a clean way. The GR maintainer Rondeau has been informed. */ #define WORKAROUND_GR_HIER_BLOCK2_BUG @@ -85,8 +85,8 @@ osmosdr_make_source_c (const std::string &args) * The private constructor */ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args) - : gr_hier_block2 ("osmosdr_source_c_impl", - gr_make_io_signature (0, 0, 0), + : gr::hier_block2 ("osmosdr_source_c_impl", + gr::io_signature::make(0, 0, 0), args_to_io_signature(args)) { size_t channel = 0; @@ -123,7 +123,7 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args) std::cerr << "gr-osmosdr " << GR_OSMOSDR_VERSION " (" GR_OSMOSDR_LIBVER ") " - << "gnuradio " << gr_version() << std::endl; + << "gnuradio " << gr::version() << std::endl; std::cerr << "built-in source types: "; BOOST_FOREACH(std::string dev_type, dev_types) std::cerr << dev_type << " "; @@ -186,7 +186,7 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args) // std::cerr << "'" << entry.first << "' = '" << entry.second << "'" << std::endl; osmosdr_src_iface *iface = NULL; - gr_basic_block_sptr block; + gr::basic_block_sptr block; #ifdef ENABLE_OSMOSDR if ( dict.count("osmosdr") ) { @@ -276,18 +276,20 @@ osmosdr_source_c_impl::osmosdr_source_c_impl (const std::string &args) std::cerr << std::endl << "FATAL: " << ex.what() << std::endl << std::endl; /* we try to prevent the whole application from crashing by faking - * the missing hardware (channels) with a gaussian noise source */ - gr_noise_source_c_sptr noise_source = \ - gr_make_noise_source_c( GR_GAUSSIAN, 10 ); + * the missing hardware (channels) with null sourc(e) */ - gr_throttle::sptr throttle = gr_make_throttle(sizeof(gr_complex), 1e6); + gr::blocks::null_source::sptr null_source = \ + gr::blocks::null_source::make( sizeof(gr_complex) ); - connect(noise_source, 0, throttle, 0); + gr::blocks::throttle::sptr throttle = \ + gr::blocks::throttle::make( sizeof(gr_complex), 1e5 ); + + connect(null_source, 0, throttle, 0); size_t missing_chans = output_signature()->max_streams() - channel; std::cerr << "Trying to fill up " << missing_chans - << " missing channel(s) with gaussian noise.\n" + << " missing channel(s) with null source(s).\n" << "This is being done to prevent the application from crashing\n" << "due to a gnuradio bug. The maintainers have been informed.\n" << std::endl; diff --git a/lib/osmosdr_src_iface.h b/lib/osmosdr_src_iface.h index f7c2925..7e3f23a 100644 --- a/lib/osmosdr_src_iface.h +++ b/lib/osmosdr_src_iface.h @@ -22,7 +22,7 @@ #define OSMOSDR_SRC_IFACE_H #include -#include +#include class osmosdr_src_iface; diff --git a/lib/rtl/rtl_source_c.cc b/lib/rtl/rtl_source_c.cc index b78f5f8..43dd1ac 100644 --- a/lib/rtl/rtl_source_c.cc +++ b/lib/rtl/rtl_source_c.cc @@ -28,7 +28,7 @@ #endif #include "rtl_source_c.h" -#include +#include #include #include @@ -41,7 +41,7 @@ #include -#include +#include "osmosdr_arg_helpers.h" using namespace boost::assign; @@ -64,7 +64,7 @@ make_rtl_source_c (const std::string &args) /* * Specify constraints on number of input and output streams. * This info is used to construct the input and output signatures - * (2nd & 3rd args to gr_block's constructor). The input and + * (2nd & 3rd args to gr::block's constructor). The input and * output signatures are used by the runtime system to * check that a valid number and type of inputs and outputs * are connected to this block. In this case, we accept @@ -79,9 +79,9 @@ static const int MAX_OUT = 1; // maximum number of output streams * The private constructor */ rtl_source_c::rtl_source_c (const std::string &args) - : gr_sync_block ("rtl_source_c", - gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)), - gr_make_io_signature (MIN_OUT, MAX_OUT, sizeof (gr_complex))), + : gr::sync_block ("rtl_source_c", + gr::io_signature::make(MIN_IN, MAX_IN, sizeof (gr_complex)), + gr::io_signature::make(MIN_OUT, MAX_OUT, sizeof (gr_complex))), _dev(NULL), _buf(NULL), _running(true), @@ -233,7 +233,7 @@ rtl_source_c::rtl_source_c (const std::string &args) _buf[i] = (unsigned short *) malloc(_buf_len); } - _thread = gruel::thread(_rtlsdr_wait, this); + _thread = gr::thread::thread(_rtlsdr_wait, this); } /* diff --git a/lib/rtl/rtl_source_c.h b/lib/rtl/rtl_source_c.h index 86d6a39..6b65d41 100644 --- a/lib/rtl/rtl_source_c.h +++ b/lib/rtl/rtl_source_c.h @@ -22,9 +22,9 @@ #ifndef INCLUDED_RTLSDR_SOURCE_C_H #define INCLUDED_RTLSDR_SOURCE_C_H -#include +#include -#include +#include #include #include @@ -35,7 +35,7 @@ typedef struct rtlsdr_dev rtlsdr_dev_t; /* * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets + * to gr::blocks (and many other data structures). The shared_ptr gets * us transparent reference counting, which greatly simplifies storage * management issues. This is especially helpful in our hybrid * C++ / Python system. @@ -61,7 +61,7 @@ rtl_source_c_sptr make_rtl_source_c (const std::string & args = ""); * */ class rtl_source_c : - public gr_sync_block, + public gr::sync_block, public osmosdr_src_iface { private: @@ -121,7 +121,7 @@ private: std::vector _lut; rtlsdr_dev_t *_dev; - gruel::thread _thread; + gr::thread::thread _thread; unsigned short **_buf; unsigned int _buf_num; unsigned int _buf_len; diff --git a/lib/rtl_tcp/CMakeLists.txt b/lib/rtl_tcp/CMakeLists.txt index b5bd992..54eed08 100644 --- a/lib/rtl_tcp/CMakeLists.txt +++ b/lib/rtl_tcp/CMakeLists.txt @@ -34,5 +34,5 @@ set(rtl_tcp_srcs # Append gnuradio-osmosdr library sources ######################################################################## list(APPEND gr_osmosdr_srcs ${rtl_tcp_srcs}) -list(APPEND gr_osmosdr_libs ${GNURADIO_CORE_LIBRARIES}) +list(APPEND gr_osmosdr_libs ${GNURADIO_BLOCKS_LIBRARIES}) diff --git a/lib/rtl_tcp/rtl_tcp_source_c.cc b/lib/rtl_tcp/rtl_tcp_source_c.cc index 8caf6f0..cfa36a2 100644 --- a/lib/rtl_tcp/rtl_tcp_source_c.cc +++ b/lib/rtl_tcp/rtl_tcp_source_c.cc @@ -25,13 +25,13 @@ #include #include -#include -#include -#include +#include +#include +#include #include "rtl_tcp_source_c.h" -#include +#include "osmosdr_arg_helpers.h" using namespace boost::assign; @@ -57,9 +57,9 @@ rtl_tcp_source_c_sptr make_rtl_tcp_source_c(const std::string &args) } rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) : - gr_hier_block2("rtl_tcp_source_c", - gr_make_io_signature (0, 0, 0), - gr_make_io_signature (1, 1, sizeof (gr_complex))), + gr::hier_block2("rtl_tcp_source_c", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(1, 1, sizeof (gr_complex))), _no_tuner(false), _auto_gain(false), _if_gain(0) @@ -127,10 +127,12 @@ rtl_tcp_source_c::rtl_tcp_source_c(const std::string &args) : _src->set_offset_tuning(offset_tune); /* rtl tcp source provides a stream of interleaved IQ floats */ - gr_deinterleave_sptr deinterleave = gr_make_deinterleave(sizeof(float)); + gr::blocks::deinterleave::sptr deinterleave = \ + gr::blocks::deinterleave::make( sizeof(float) ); /* block to convert deinterleaved floats to a complex stream */ - gr_float_to_complex_sptr f2c = gr_make_float_to_complex(1); + gr::blocks::float_to_complex::sptr f2c = \ + gr::blocks::float_to_complex::make( 1 ); connect(_src, 0, deinterleave, 0); connect(deinterleave, 0, f2c, 0); /* I */ diff --git a/lib/rtl_tcp/rtl_tcp_source_c.h b/lib/rtl_tcp/rtl_tcp_source_c.h index b452e68..8143566 100644 --- a/lib/rtl_tcp/rtl_tcp_source_c.h +++ b/lib/rtl_tcp/rtl_tcp_source_c.h @@ -20,7 +20,7 @@ #ifndef RTL_TCP_SOURCE_C_H #define RTL_TCP_SOURCE_C_H -#include +#include #include "osmosdr_src_iface.h" @@ -33,7 +33,7 @@ typedef boost::shared_ptr< rtl_tcp_source_c > rtl_tcp_source_c_sptr; rtl_tcp_source_c_sptr make_rtl_tcp_source_c( const std::string & args = "" ); class rtl_tcp_source_c : - public gr_hier_block2, + public gr::hier_block2, public osmosdr_src_iface { private: diff --git a/lib/rtl_tcp/rtl_tcp_source_f.cc b/lib/rtl_tcp/rtl_tcp_source_f.cc index 304fb29..4d38ddb 100644 --- a/lib/rtl_tcp/rtl_tcp_source_f.cc +++ b/lib/rtl_tcp/rtl_tcp_source_f.cc @@ -22,7 +22,7 @@ #include -#include +#include #include #include #include @@ -88,9 +88,9 @@ rtl_tcp_source_f::rtl_tcp_source_f(size_t itemsize, int payload_size, bool eof, bool wait) - : gr_sync_block ("rtl_tcp_source_f", - gr_make_io_signature(0, 0, 0), - gr_make_io_signature(1, 1, sizeof(float))), + : gr::sync_block ("rtl_tcp_source_f", + gr::io_signature::make(0, 0, 0), + gr::io_signature::make(1, 1, sizeof(float))), d_itemsize(itemsize), d_payload_size(payload_size), d_eof(eof), diff --git a/lib/rtl_tcp/rtl_tcp_source_f.h b/lib/rtl_tcp/rtl_tcp_source_f.h index ceae709..0911be5 100644 --- a/lib/rtl_tcp/rtl_tcp_source_f.h +++ b/lib/rtl_tcp/rtl_tcp_source_f.h @@ -21,8 +21,8 @@ #ifndef RTL_TCP_SOURCE_F_H #define RTL_TCP_SOURCE_F_H -#include -#include +#include +#include #if defined(_WIN32) // if not posix, assume winsock @@ -65,7 +65,7 @@ rtl_tcp_source_f_sptr make_rtl_tcp_source_f ( bool eof = false, bool wait = false); -class rtl_tcp_source_f : public gr_sync_block +class rtl_tcp_source_f : public gr::sync_block { private: size_t d_itemsize; diff --git a/lib/uhd/uhd_sink_c.cc b/lib/uhd/uhd_sink_c.cc index 427087e..20644f8 100644 --- a/lib/uhd/uhd_sink_c.cc +++ b/lib/uhd/uhd_sink_c.cc @@ -36,9 +36,9 @@ uhd_sink_c_sptr make_uhd_sink_c(const std::string &args) } uhd_sink_c::uhd_sink_c(const std::string &args) : - gr_hier_block2("uhd_sink_c", + gr::hier_block2("uhd_sink_c", args_to_io_signature(args), - gr_make_io_signature (0, 0, 0)), + gr::io_signature::make(0, 0, 0)), _lo_offset(0.0f) { size_t nchan = 1; @@ -63,9 +63,9 @@ uhd_sink_c::uhd_sink_c(const std::string &args) : } } - _snk = uhd_make_usrp_sink( arguments, - uhd::io_type_t::COMPLEX_FLOAT32, - nchan ); + _snk = gr::uhd::usrp_sink::make( arguments, + uhd::io_type_t::COMPLEX_FLOAT32, + nchan ); if (dict.count("subdev")) { _snk->set_subdev_spec( dict["subdev"] ); diff --git a/lib/uhd/uhd_sink_c.h b/lib/uhd/uhd_sink_c.h index 704fb33..a4e87b9 100644 --- a/lib/uhd/uhd_sink_c.h +++ b/lib/uhd/uhd_sink_c.h @@ -20,8 +20,8 @@ #ifndef UHD_SINK_C_H #define UHD_SINK_C_H -#include -#include +#include +#include #include "osmosdr_snk_iface.h" @@ -32,7 +32,7 @@ typedef boost::shared_ptr< uhd_sink_c > uhd_sink_c_sptr; uhd_sink_c_sptr make_uhd_sink_c(const std::string &args = ""); class uhd_sink_c : - public gr_hier_block2, + public gr::hier_block2, public osmosdr_snk_iface { private: @@ -73,7 +73,7 @@ public: private: double _lo_offset; - boost::shared_ptr _snk; + gr::uhd::usrp_sink::sptr _snk; }; #endif // UHD_SINK_C_H diff --git a/lib/uhd/uhd_source_c.cc b/lib/uhd/uhd_source_c.cc index ec33610..ff9e871 100644 --- a/lib/uhd/uhd_source_c.cc +++ b/lib/uhd/uhd_source_c.cc @@ -36,8 +36,8 @@ uhd_source_c_sptr make_uhd_source_c(const std::string &args) } uhd_source_c::uhd_source_c(const std::string &args) : - gr_hier_block2("uhd_source_c", - gr_make_io_signature (0, 0, 0), + gr::hier_block2("uhd_source_c", + gr::io_signature::make(0, 0, 0), args_to_io_signature(args)), _lo_offset(0.0f) { @@ -63,9 +63,9 @@ uhd_source_c::uhd_source_c(const std::string &args) : } } - _src = uhd_make_usrp_source( arguments, - uhd::io_type_t::COMPLEX_FLOAT32, - nchan ); + _src = gr::uhd::usrp_source::make( arguments, + uhd::io_type_t::COMPLEX_FLOAT32, + nchan ); if (dict.count("subdev")) { _src->set_subdev_spec( dict["subdev"] ); diff --git a/lib/uhd/uhd_source_c.h b/lib/uhd/uhd_source_c.h index 84a7965..17970bf 100644 --- a/lib/uhd/uhd_source_c.h +++ b/lib/uhd/uhd_source_c.h @@ -20,8 +20,8 @@ #ifndef UHD_SOURCE_C_H #define UHD_SOURCE_C_H -#include -#include +#include +#include #include "osmosdr_src_iface.h" @@ -32,7 +32,7 @@ typedef boost::shared_ptr< uhd_source_c > uhd_source_c_sptr; uhd_source_c_sptr make_uhd_source_c(const std::string &args = ""); class uhd_source_c : - public gr_hier_block2, + public gr::hier_block2, public osmosdr_src_iface { private: @@ -73,7 +73,7 @@ public: private: double _lo_offset; - boost::shared_ptr _src; + gr::uhd::usrp_source::sptr _src; }; #endif // UHD_SOURCE_C_H diff --git a/swig/CMakeLists.txt b/swig/CMakeLists.txt index b92d674..e963206 100644 --- a/swig/CMakeLists.txt +++ b/swig/CMakeLists.txt @@ -31,12 +31,12 @@ include(GrPython) ######################################################################## # Setup swig generation ######################################################################## -foreach(incdir ${GNURADIO_CORE_INCLUDE_DIRS}) +foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/swig) endforeach(incdir) -foreach(incdir ${GRUEL_INCLUDE_DIRS}) - list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gruel/swig) +foreach(incdir ${GNURADIO_RUNTIME_INCLUDE_DIRS}) + list(APPEND GR_SWIG_INCLUDE_DIRS ${incdir}/gnuradio/swig) endforeach(incdir) set(GR_SWIG_LIBRARIES gnuradio-osmosdr) diff --git a/swig/osmosdr_swig.i b/swig/osmosdr_swig.i index 2135599..3f44af1 100644 --- a/swig/osmosdr_swig.i +++ b/swig/osmosdr_swig.i @@ -16,6 +16,15 @@ #include "osmosdr/osmosdr_sink_c.h" %} +// Workaround for a SWIG 2.0.4 bug with templates. Probably needs to be looked in to. +%{ +#if PY_VERSION_HEX >= 0x03020000 +# define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj)) +#else +# define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj)) +#endif +%} + %template(string_vector_t) std::vector; //%template(size_vector_t) std::vector; @@ -37,12 +46,3 @@ GR_SWIG_BLOCK_MAGIC(osmosdr,source_c); GR_SWIG_BLOCK_MAGIC(osmosdr,sink_c); %include "osmosdr/osmosdr_sink_c.h" -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-osmosdr_swig" "scm_init_gnuradio_osmosdr_swig_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif