diff options
37 files changed, 495 insertions, 139 deletions
diff --git a/.gitignore b/.gitignore index 6300279f2b..a18599872b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ *.pyc *.pyo +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b7b1e05be..e31005b1f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -298,11 +298,23 @@ add_subdirectory(gr-fcd) add_subdirectory(gr-wavelet) add_subdirectory(gr-wxgui) -# Install our Cmake modules into ${GR_PKG_DATA_DIR}/cmake/Modules -file(GLOB cmake_modules "cmake/Modules/*.cmake") +# Install our Cmake modules into $prefix/lib/cmake/gnuradio +# See "Package Configuration Files" on page: +# http://www.cmake.org/Wiki/CMake/Tutorials/Packaging + +configure_file( + ${CMAKE_SOURCE_DIR}/cmake/Modules/GnuradioConfigVersion.cmake.in + ${CMAKE_BINARY_DIR}/cmake/Modules/GnuradioConfigVersion.cmake +@ONLY) + +SET(cmake_configs + ${CMAKE_SOURCE_DIR}/cmake/Modules/GnuradioConfig.cmake + ${CMAKE_BINARY_DIR}/cmake/Modules/GnuradioConfigVersion.cmake +) + install( - FILES ${cmake_modules} - DESTINATION ${GR_PKG_DATA_DIR}/cmake/Modules + FILES ${cmake_configs} + DESTINATION lib/cmake/gnuradio COMPONENT "runtime_devel" ) diff --git a/README.hacking b/README.hacking index 58b2698872..1f1083bb62 100644 --- a/README.hacking +++ b/README.hacking @@ -29,11 +29,6 @@ aren't done differently, etc, etc, Until boost 1.35 or later is common in distributions, you'll need to build boost from source yourself. See README.building-boost. -Also, when running make distcheck you'll need to provide the -DISTCHECK_CONFIGURE_FLAGS. E.g., - - $ make distcheck DISTCHECK_CONFIGURE_FLAGS=--with-boost=/opt/boost_1_36_0 - * C++ and Python @@ -175,38 +170,6 @@ library and into the program. I haven't tested out this idea. We use the standard unittest package for unit testing of Python code. -* Subversion line ending styles - -All text files in the tree should have the subversion property -'svn:eol-style' set to 'native', with the following exceptions: - -config/*.m4 -configure.ac -gr-howto-write-a-block/config/*.m4 -gr-howto-write-a-block/configure.ac - -The easiest way to ensure this is to add or edit the following lines in -your svn client configuration file (~/.subversion/config): - -enable-auto-props=yes - -[auto-props] -*.c = svn:eol-style=native -*.cc = svn:eol-style=native -*.i = svn:eol-style=native -*.h = svn:eol-style=native -*.am = svn:eol-style=native -*.py = svn:eol-style=native -*.ac = svn:eol-style=LF -*.m4 = svn:eol-style=LF - -* Misc tips - -ccache, a compiler cache, can really speed up your builds. -See http://ccache.samba.org/ - -Be sure to create links for gcc and g++ - * Standard command line options diff --git a/cmake/Modules/FindGnuradio.cmake b/cmake/Modules/FindGnuradio.cmake index bd45a95819..80be72dc8c 100644 --- a/cmake/Modules/FindGnuradio.cmake +++ b/cmake/Modules/FindGnuradio.cmake @@ -6,7 +6,7 @@ INCLUDE(FindPackageHandleStandardArgs) # if GR_REQUIRED_MODULES is not defined, it will be set to the following list (all of them)
if(NOT GR_REQUIRED_MODULES)
- set(GR_REQUIRED_MODULES RUNTIME ANALOG ATSC AUDIO BLOCKS CHANNELS DIGITAL FEC FFT FILTER NOAA PAGER QTGUI TRELLIS UHD VOCODER WAVELET)
+ set(GR_REQUIRED_MODULES RUNTIME ANALOG ATSC AUDIO BLOCKS CHANNELS DIGITAL FEC FFT FILTER NOAA PAGER QTGUI TRELLIS UHD VOCODER WAVELET PMT)
endif()
set(GNURADIO_ALL_LIBRARIES "")
@@ -103,4 +103,6 @@ GR_MODULE(TRELLIS gnuradio-trellis trellis/fsm.h gnuradio-trellis) GR_MODULE(UHD gnuradio-uhd gr_uhd/usrp_sink.h gnuradio-uhd)
GR_MODULE(VOCODER gnuradio-vocoder vocoder/alaw_encode_sb.h gnuradio-vocoder)
GR_MODULE(WAVELET gnuradio-wavelet wavelet/wavelet_ff.h gnuradio-wavelet)
+GR_MODULE(PMT gnuradio-pmt pmt/pmt.h gnuradio-pmt)
+
diff --git a/cmake/Modules/GnuradioConfig.cmake b/cmake/Modules/GnuradioConfig.cmake new file mode 100644 index 0000000000..06cf1a4722 --- /dev/null +++ b/cmake/Modules/GnuradioConfig.cmake @@ -0,0 +1,122 @@ +# Copyright 2013 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GNU Radio is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. + +INCLUDE(FindPkgConfig) +INCLUDE(FindPackageHandleStandardArgs) + +# if GR_REQUIRED_COMPONENTS is not defined, it will be set to the following list (all of them) +if(NOT GR_REQUIRED_COMPONENTS) + set(GR_REQUIRED_COMPONENTS RUNTIME ANALOG ATSC AUDIO BLOCKS CHANNELS DIGITAL FCD FEC FFT FILTER NOAA PAGER QTGUI TRELLIS UHD VOCODER WAVELET WXGUI) +endif() + +set(GNURADIO_ALL_LIBRARIES "") +set(GNURADIO_ALL_INCLUDE_DIRS "") + +MACRO(LIST_CONTAINS var value) + SET(${var}) + FOREACH(value2 ${ARGN}) + IF (${value} STREQUAL ${value2}) + SET(${var} TRUE) + ENDIF(${value} STREQUAL ${value2}) + ENDFOREACH(value2) +ENDMACRO(LIST_CONTAINS) + +function(GR_MODULE EXTVAR PCNAME INCFILE LIBFILE) + + LIST_CONTAINS(REQUIRED_MODULE ${EXTVAR} ${GR_REQUIRED_COMPONENTS}) + if(NOT REQUIRED_MODULE) + #message("Ignoring GNU Radio Module ${EXTVAR}") + return() + endif() + + message("Checking for GNU Radio Module: ${EXTVAR}") + + # check for .pc hints + PKG_CHECK_MODULES(PC_GNURADIO_${EXTVAR} ${PCNAME}) + + set(INCVAR_NAME "GNURADIO_${EXTVAR}_INCLUDE_DIRS") + set(LIBVAR_NAME "GNURADIO_${EXTVAR}_LIBRARIES") + set(PC_INCDIR ${PC_GNURADIO_${EXTVAR}_INCLUDEDIR}) + set(PC_LIBDIR ${PC_GNURADIO_${EXTVAR}_LIBDIR}) + + # look for include files + FIND_PATH( + ${INCVAR_NAME} + NAMES ${INCFILE} + HINTS $ENV{GNURADIO_RUNTIME_DIR}/include/gnuradio + ${PC_INCDIR}/gnuradio/ + ${CMAKE_INSTALL_PREFIX}/include/gnuradio + PATHS /usr/local/include/gnuradio + /usr/include/gnuradio + ) + + # look for libs + FIND_LIBRARY( + ${LIBVAR_NAME} + NAMES ${LIBFILE} + HINTS $ENV{GNURADIO_RUNTIME_DIR}/lib + ${PC_LIBDIR} + ${CMAKE_INSTALL_PREFIX}/lib/ + ${CMAKE_INSTALL_PREFIX}/lib64/ + PATHS /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 + ) + + # show results + message(" * INCLUDES=${GNURADIO_${EXTVAR}_INCLUDE_DIRS}") + message(" * LIBS=${GNURADIO_${EXTVAR}_LIBRARIES}") + + # append to all includes and libs list + LIST(APPEND GNURADIO_ALL_INCLUDE_DIRS ${GNURADIO_${EXTVAR}_INCLUDE_DIRS}) + LIST(APPEND GNURADIO_ALL_LIBRARIES ${GNURADIO_${EXTVAR}_LIBRARIES}) + + FIND_PACKAGE_HANDLE_STANDARD_ARGS(GNURADIO_${EXTVAR} DEFAULT_MSG GNURADIO_${EXTVAR}_LIBRARIES GNURADIO_${EXTVAR}_INCLUDE_DIRS) + message("GNURADIO_${EXTVAR}_FOUND = ${GNURADIO_${EXTVAR}_FOUND}") + set(GNURADIO_${EXTVAR}_FOUND ${GNURADIO_${EXTVAR}_FOUND} PARENT_SCOPE) + + # generate an error if the module is missing + if(NOT GNURADIO_${EXTVAR}_FOUND) + message(FATAL_ERROR "Required GNU Radio Component: ${EXTVAR} missing!") + endif() + + MARK_AS_ADVANCED(GNURADIO_${EXTVAR}_LIBRARIES GNURADIO_${EXTVAR}_INCLUDE_DIRS) + +endfunction() + +GR_MODULE(RUNTIME gnuradio-runtime gr_top_block.h gnuradio-runtime) +GR_MODULE(ANALOG gnuradio-analog analog/api.h gnuradio-analog) +GR_MODULE(ATSC gnuradio-atsc atsc/api.h gnuradio-atsc) +GR_MODULE(AUDIO gnuradio-audio audio/api.h gnuradio-audio) +GR_MODULE(BLOCKS gnuradio-blocks blocks/api.h gnuradio-blocks) +GR_MODULE(CHANNELS gnuradio-channels channels/api.h gnuradio-channels) +GR_MODULE(DIGITAL gnuradio-digital digital/api.h gnuradio-digital) +GR_MODULE(FCD gnuradio-fcd fcd_api.h gnuradio-fcd) +GR_MODULE(FEC gnuradio-fec fec/api.h gnuradio-fec) +GR_MODULE(FFT gnuradio-fft fft/api.h gnuradio-fft) +GR_MODULE(FILTER gnuradio-filter filter/api.h gnuradio-filter) +GR_MODULE(NOAA gnuradio-noaa noaa/api.h gnuradio-noaa) +GR_MODULE(PAGER gnuradio-pager pager/api.h gnuradio-pager) +GR_MODULE(QTGUI gnuradio-qtgui qtgui/api.h gnuradio-qtgui) +GR_MODULE(TRELLIS gnuradio-trellis trellis/api.h gnuradio-trellis) +GR_MODULE(UHD gnuradio-uhd uhd/api.h gnuradio-uhd) +GR_MODULE(VOCODER gnuradio-vocoder vocoder/api.h gnuradio-vocoder) +GR_MODULE(WAVELET gnuradio-wavelet wavelet/api.h gnuradio-wavelet) +GR_MODULE(WXGUI gnuradio-wxgui wxgui/api.h gnuradio-wxgui) diff --git a/cmake/Modules/GnuradioConfigVersion.cmake.in b/cmake/Modules/GnuradioConfigVersion.cmake.in new file mode 100644 index 0000000000..a9717a7e5a --- /dev/null +++ b/cmake/Modules/GnuradioConfigVersion.cmake.in @@ -0,0 +1,35 @@ +# Copyright 2013 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+set(MAJOR_VERSION @VERSION_INFO_MAJOR_VERSION@)
+set(API_COMPAT @VERSION_INFO_API_COMPAT@)
+set(MINOR_VERSION @VERSION_INFO_MINOR_VERSION@)
+set(MAINT_VERSION @VERSION_INFO_MAINT_VERSION@)
+
+set(PACKAGE_VERSION
+ ${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}.${MAINT_VERSION})
+
+if(${PACKAGE_FIND_VERSION_MAJOR} EQUAL ${MAJOR_VERSION})
+ if(${PACKAGE_FIND_VERSION_MINOR} EQUAL ${API_COMPAT})
+ if(NOT ${PACKAGE_FIND_VERSION_PATCH} GREATER ${MINOR_VERSION})
+ set(PACKAGE_VERSION_EXACT 1) # exact match for API version
+ set(PACKAGE_VERSION_COMPATIBLE 1) # compat for minor/patch version
+ endif(NOT ${PACKAGE_FIND_VERSION_PATCH} GREATER ${MINOR_VERSION})
+ endif(${PACKAGE_FIND_VERSION_MINOR} EQUAL ${API_COMPAT})
+endif(${PACKAGE_FIND_VERSION_MAJOR} EQUAL ${MAJOR_VERSION})
\ No newline at end of file diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake index 69ff1f5ddc..3803fba0b1 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -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 <pthread.h> + 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 <sched.h> + 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/docs/doxygen/other/main_page.dox b/docs/doxygen/other/main_page.dox index 2f638dec84..397f15b776 100644 --- a/docs/doxygen/other/main_page.dox +++ b/docs/doxygen/other/main_page.dox @@ -406,4 +406,63 @@ configuration variable and the section and option names are in uppercase. The value is the same format that would be used in the config file itself. + + +\section oot_config_page Out-of-Tree Configuration + +New as of 3.6.5. + +Using gr_modtool, each package comes with the ability to easily locate +the gnuradio-core library using the 'find_package(GnuradioCore)' cmake +command. This only locates that the library and include directories +exist, which is enough for most simple projects. + +As projects become more complicated and start needing to rely on other +GNU Radio components like gnuradio-blocks or gnuradio-filter, for +example, and when they become dependent on certain API compatibility +versions of GNU Radio, we need something more. And so we have +introduced the GnuradioConfig.cmake file. + +When GNU Radio is installed, it also installs a GNU Radio-specific +cmake config file that we can use for more advanced compatibility +issues of our projects. This tool allows us to specific the API +compatible version and a set of components that are required. + +Taking the above example, say we have built against version 3.6.5 with +features that were introduced in this version and we need the blocks +and filter components as well as the main core library. We fist set a +cmake variable GR_REQUIRED_COMPONENTS to the components we need. We +then use the 'find_package' command and also set a minimum required +API compatible version. Since we are on the 3.6 API version, the +minimum required version is "3.6.5". The code in the CMakeLists.txt +file would look like this: + +\code + set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS FILTER) + find_package(Gnuradio 3.6.5) +\endcode + +Note that the capitalization is important on both lines. + +If the installed version of GNU Radio is 3.6.4 or some other API +version like 3.5 or 3.7, the Cmake configuration will fail with the +version error. Likewise, if libgnuradio-filter was not installed as +part of GNU Radio, the configuration will also fail. + +\subsection oot_config_path_page Install Path + +Cmake has to know where to find these configuration files. They are +installed into $prefix/lib/cmake/gnuradio. If $prefix is '/usr' or +'/usr/local', then everything should work fine. If the GNU Radio +install $prefix is something else, then Cmake must be told where to +find it. This can be done in two ways. If you are installing the +out-of-tree module into the same $prefix, then you would be setting +'-DCMAKE_INSTALL_PREFIX' on the configuration command line. This is +enough to tell Cmake where to look for the configuration files. + +The other way to do it is to set the CMAKE_PREFIX_PATH environmental +variable to $prefix. You can then install your component anywhere +you'd like and it will be able to find and configure against the +installed GNU Radio. + */ diff --git a/gnuradio-runtime/CMakeLists.txt b/gnuradio-runtime/CMakeLists.txt index abdc969690..4940f7e58c 100644 --- a/gnuradio-runtime/CMakeLists.txt +++ b/gnuradio-runtime/CMakeLists.txt @@ -27,6 +27,7 @@ include(GrPython) # Setup compatibility checks and defines ######################################################################## include(${CMAKE_CURRENT_SOURCE_DIR}/ConfigChecks.cmake) +GR_CHECK_LINUX_SCHED_AVAIL() ######################################################################## # Register component diff --git a/gnuradio-runtime/include/gnuradio/block_detail.h b/gnuradio-runtime/include/gnuradio/block_detail.h index 0a8615a2b6..a76874a9be 100644 --- a/gnuradio-runtime/include/gnuradio/block_detail.h +++ b/gnuradio-runtime/include/gnuradio/block_detail.h @@ -114,13 +114,14 @@ namespace gr { /*! * \brief Removes a tag from the given input stream. * - * Calls gr::buffer::remove_item_tag(), which removes the tag from - * its deque. + * Calls gr::buffer::remove_item_tag(). + * The tag in question will then no longer appear on subsequent calls of get_tags_in_range(). * * \param which_input an integer of which input stream to remove the tag from * \param tag the tag object to add + * \param id The unique block ID (use gr::block::unique_id()) */ - void remove_item_tag(unsigned int which_input, const tag_t &tag); + void remove_item_tag(unsigned int which_input, const tag_t &tag, long id); /*! * \brief Given a [start,end), returns a vector of all tags in the range. @@ -135,11 +136,13 @@ namespace gr { * \param which_input an integer of which input stream to pull from * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest + * \param id Block ID */ void get_tags_in_range(std::vector<tag_t> &v, unsigned int which_input, uint64_t abs_start, - uint64_t abs_end); + uint64_t abs_end, + long id); /*! * \brief Given a [start,end), returns a vector of all tags in the @@ -158,12 +161,14 @@ namespace gr { * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest * \param key a PMT symbol to select only tags of this key + * \param id Block ID */ void get_tags_in_range(std::vector<tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, - const pmt::pmt_t &key); + const pmt::pmt_t &key, + long id); /*! * \brief Set core affinity of block to the cores in the vector diff --git a/gnuradio-runtime/include/gnuradio/buffer.h b/gnuradio-runtime/include/gnuradio/buffer.h index 490c8e0e9f..adf00d14ac 100644 --- a/gnuradio-runtime/include/gnuradio/buffer.h +++ b/gnuradio-runtime/include/gnuradio/buffer.h @@ -108,10 +108,15 @@ namespace gr { * \brief Removes an existing tag from the buffer. * * If no such tag is found, does nothing. + * Note: Doesn't actually physically delete the tag, but + * marks it as deleted. For the user, this has the same effect: + * Any subsequent calls to get_tags_in_range() will not return + * the tag. * * \param tag the tag that needs to be removed + * \param id the unique ID of the block calling this function */ - void remove_item_tag(const tag_t &tag); + void remove_item_tag(const tag_t &tag, long id); /*! * \brief Removes all tags before \p max_time from buffer @@ -273,10 +278,12 @@ namespace gr { * \param v a vector reference to return tags into * \param abs_start a uint64 count of the start of the range of interest * \param abs_end a uint64 count of the end of the range of interest + * \param id the unique ID of the block to make sure already deleted tags are not returned */ void get_tags_in_range(std::vector<tag_t> &v, uint64_t abs_start, - uint64_t abs_end); + uint64_t abs_end, + long id); // ------------------------------------------------------------------------- diff --git a/gnuradio-runtime/include/gnuradio/constants.h b/gnuradio-runtime/include/gnuradio/constants.h index 5ae924ca0d..beba6f2745 100644 --- a/gnuradio-runtime/include/gnuradio/constants.h +++ b/gnuradio-runtime/include/gnuradio/constants.h @@ -29,27 +29,27 @@ namespace gr { /*! - * \brief return ./configure --prefix argument. Typically /usr/local + * \brief return SYSCONFDIR. Typically ${CMAKE_INSTALL_PREFIX}/etc or /etc */ GR_RUNTIME_API const std::string prefix(); /*! - * \brief return ./configure --sysconfdir argument. Typically $prefix/etc or /etc + * \brief return SYSCONFDIR. Typically ${CMAKE_INSTALL_PREFIX}/etc or /etc */ GR_RUNTIME_API const std::string sysconfdir(); /*! - * \brief return preferences file directory. Typically $sysconfdir/etc/conf.d + * \brief return preferences file directory. Typically ${SYSCONFDIR}/etc/conf.d */ GR_RUNTIME_API const std::string prefsdir(); /*! - * \brief return date/time of build, as set when 'bootstrap' is run + * \brief return date/time of build, as set when 'cmake' is run */ GR_RUNTIME_API const std::string build_date(); /*! - * \brief return version string defined in configure.ac + * \brief return version string defined by cmake (GrVersion.cmake) */ GR_RUNTIME_API const std::string version(); diff --git a/gnuradio-runtime/include/gnuradio/tags.h b/gnuradio-runtime/include/gnuradio/tags.h index 5600601741..0bd7b8537f 100644 --- a/gnuradio-runtime/include/gnuradio/tags.h +++ b/gnuradio-runtime/include/gnuradio/tags.h @@ -42,6 +42,9 @@ namespace gr { //! the source ID of \p tag (as a PMT) pmt::pmt_t srcid; + //! Used by gr_buffer to mark a tagged as deleted by a specific block. You can usually ignore this. + std::vector<long> marked_deleted; + /*! * Comparison function to test which tag, \p x or \p y, came * first in time diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt index 3206e3c224..a87141cb92 100644 --- a/gnuradio-runtime/lib/CMakeLists.txt +++ b/gnuradio-runtime/lib/CMakeLists.txt @@ -69,8 +69,6 @@ GR_INCLUDE_SUBDIRECTORY(math) # Setup library ######################################################################## list(APPEND gnuradio_runtime_sources - complex_vec_test.cc - malloc16.c basic_block.cc block.cc block_detail.cc @@ -79,6 +77,7 @@ list(APPEND gnuradio_runtime_sources block_registry.cc buffer.cc circular_file.cc + complex_vec_test.cc feval.cc flat_flowgraph.cc flowgraph.cc @@ -87,6 +86,7 @@ list(APPEND gnuradio_runtime_sources io_signature.cc local_sighandler.cc logger.cc + malloc16.c message.cc misc.cc msg_accepter.cc @@ -94,10 +94,6 @@ list(APPEND gnuradio_runtime_sources msg_queue.cc pagesize.cc prefs.cc - tagged_stream_block.cc - test.cc - top_block.cc - top_block_impl.cc realtime.cc scheduler.cc scheduler_sts.cc @@ -108,6 +104,10 @@ list(APPEND gnuradio_runtime_sources sync_decimator.cc sync_interpolator.cc sys_paths.cc + tagged_stream_block.cc + test.cc + top_block.cc + top_block_impl.cc tpb_detail.cc tpb_thread_body.cc vmcircbuf.cc diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc index b38377e856..4246180d80 100644 --- a/gnuradio-runtime/lib/block.cc +++ b/gnuradio-runtime/lib/block.cc @@ -240,7 +240,7 @@ namespace gr { block::remove_item_tag(unsigned int which_input, const tag_t &tag) { - d_detail->remove_item_tag(which_input, tag); + d_detail->remove_item_tag(which_input, tag, unique_id()); } void @@ -248,7 +248,7 @@ namespace gr { unsigned int which_output, uint64_t start, uint64_t end) { - d_detail->get_tags_in_range(v, which_output, start, end); + d_detail->get_tags_in_range(v, which_output, start, end, unique_id()); } void @@ -257,7 +257,7 @@ namespace gr { uint64_t start, uint64_t end, const pmt::pmt_t &key) { - d_detail->get_tags_in_range(v, which_output, start, end, key); + d_detail->get_tags_in_range(v, which_output, start, end, key, unique_id()); } block::tag_propagation_policy_t diff --git a/gnuradio-runtime/lib/block_detail.cc b/gnuradio-runtime/lib/block_detail.cc index a3ab4b3f7b..293412f513 100644 --- a/gnuradio-runtime/lib/block_detail.cc +++ b/gnuradio-runtime/lib/block_detail.cc @@ -171,14 +171,14 @@ namespace gr { } void - block_detail::remove_item_tag(unsigned int which_input, const tag_t &tag) + block_detail::remove_item_tag(unsigned int which_input, const tag_t &tag, long id) { if(!pmt::is_symbol(tag.key)) { throw pmt::wrong_type("block_detail::add_item_tag key", tag.key); } else { // Add tag to gr_buffer's deque tags - d_input[which_input]->buffer()->remove_item_tag(tag); + d_input[which_input]->buffer()->remove_item_tag(tag, id); } } @@ -186,10 +186,11 @@ namespace gr { block_detail::get_tags_in_range(std::vector<tag_t> &v, unsigned int which_input, uint64_t abs_start, - uint64_t abs_end) + uint64_t abs_end, + long id) { // get from gr_buffer_reader's deque of tags - d_input[which_input]->get_tags_in_range(v, abs_start, abs_end); + d_input[which_input]->get_tags_in_range(v, abs_start, abs_end, id); } void @@ -197,14 +198,15 @@ namespace gr { unsigned int which_input, uint64_t abs_start, uint64_t abs_end, - const pmt::pmt_t &key) + const pmt::pmt_t &key, + long id) { std::vector<tag_t> found_items; v.resize(0); // get from gr_buffer_reader's deque of tags - d_input[which_input]->get_tags_in_range(found_items, abs_start, abs_end); + d_input[which_input]->get_tags_in_range(found_items, abs_start, abs_end, id); // Filter further by key name pmt::pmt_t itemkey; @@ -261,6 +263,7 @@ namespace gr { d_avg_noutput_items = noutput_items; d_var_noutput_items = 0; for(size_t i=0; i < d_input.size(); i++) { + gr::thread::scoped_lock guard(*d_output[i]->mutex()); float pfull = static_cast<float>(d_input[i]->items_available()) / static_cast<float>(d_input[i]->max_possible_items_available()); d_ins_input_buffers_full[i] = pfull; @@ -268,6 +271,7 @@ namespace gr { d_var_input_buffers_full[i] = 0; } for(size_t i=0; i < d_output.size(); i++) { + gr::thread::scoped_lock guard(*d_output[i]->mutex()); float pfull = 1.0f - static_cast<float>(d_output[i]->space_available()) / static_cast<float>(d_output[i]->bufsize()); d_ins_output_buffers_full[i] = pfull; diff --git a/gnuradio-runtime/lib/block_executor.cc b/gnuradio-runtime/lib/block_executor.cc index 8059ea2d5a..b0eb2eccee 100644 --- a/gnuradio-runtime/lib/block_executor.cc +++ b/gnuradio-runtime/lib/block_executor.cc @@ -93,7 +93,7 @@ namespace gr { static bool propagate_tags(block::tag_propagation_policy_t policy, block_detail *d, const std::vector<uint64_t> &start_nitems_read, double rrate, - std::vector<tag_t> &rtags) + std::vector<tag_t> &rtags, long block_id) { // Move tags downstream // if a sink, we don't need to move downstream @@ -109,7 +109,7 @@ namespace gr { // every tag on every input propogates to everyone downstream for(int i = 0; i < d->ninputs(); i++) { d->get_tags_in_range(rtags, i, start_nitems_read[i], - d->nitems_read(i)); + d->nitems_read(i), block_id); std::vector<tag_t>::iterator t; if(rrate == 1.0) { @@ -135,7 +135,7 @@ namespace gr { if(d->ninputs() == d->noutputs()) { for(int i = 0; i < d->ninputs(); i++) { d->get_tags_in_range(rtags, i, start_nitems_read[i], - d->nitems_read(i)); + d->nitems_read(i), block_id); std::vector<tag_t>::iterator t; for(t = rtags.begin(); t != rtags.end(); t++) { @@ -450,7 +450,7 @@ namespace gr { if(!propagate_tags(m->tag_propagation_policy(), d, d_start_nitems_read, m->relative_rate(), - d_returned_tags)) + d_returned_tags, m->unique_id())) goto were_done; if(n == block::WORK_DONE) diff --git a/gnuradio-runtime/lib/buffer.cc b/gnuradio-runtime/lib/buffer.cc index 1bcfc2a6e4..cd6feefe34 100644 --- a/gnuradio-runtime/lib/buffer.cc +++ b/gnuradio-runtime/lib/buffer.cc @@ -228,13 +228,12 @@ namespace gr { } void - buffer::remove_item_tag(const tag_t &tag) + buffer::remove_item_tag(const tag_t &tag, long id) { gr::thread::scoped_lock guard(*mutex()); for(std::deque<tag_t>::iterator it = d_item_tags.begin(); it != d_item_tags.end(); ++it) { if(*it == tag) { - d_item_tags.erase(it); - break; + (*it).marked_deleted.push_back(id); } } } @@ -315,7 +314,8 @@ namespace gr { void buffer_reader::get_tags_in_range(std::vector<tag_t> &v, uint64_t abs_start, - uint64_t abs_end) + uint64_t abs_end, + long id) { gr::thread::scoped_lock guard(*mutex()); @@ -327,9 +327,14 @@ namespace gr { item_time = (*itr).offset; if((item_time >= abs_start) && (item_time < abs_end)) { - v.push_back(*itr); + std::vector<long>::iterator id_itr; + id_itr = std::find(itr->marked_deleted.begin(), itr->marked_deleted.end(), id); + if (id_itr == itr->marked_deleted.end()) { // If id is not in the vector of marked blocks + v.push_back(*itr); + v.back().marked_deleted.clear(); + } } - + itr++; } } diff --git a/gnuradio-runtime/lib/controlport/frontend.ice b/gnuradio-runtime/lib/controlport/frontend.ice index b7474f37bf..50d056df72 100644 --- a/gnuradio-runtime/lib/controlport/frontend.ice +++ b/gnuradio-runtime/lib/controlport/frontend.ice @@ -98,15 +98,14 @@ module GNURadio { idempotent void setInfo(string k, string v) throws ReceiverFailure, NotSupported, InvalidSetting; }; - interface Channel { + interface Channel extends Tuner { void start(); void stop(); void destroyChannel() throws NotSupported; idempotent bool active(); - idempotent ChannelStatus status(); + idempotent ChannelStatus channelStat(); idempotent StreamInfo stream(); idempotent bool setComplex(bool complex) throws ReceiverFailure, NotSupported, InvalidSetting; - idempotent void setInfo(string k, string v) throws ReceiverFailure, NotSupported, InvalidSetting; idempotent void setStreamInfo(string k, string v) throws ReceiverFailure, NotSupported, InvalidSetting; }; diff --git a/gnuradio-runtime/lib/realtime.cc b/gnuradio-runtime/lib/realtime.cc index 81f92ae488..e3fea1c6a6 100644 --- a/gnuradio-runtime/lib/realtime.cc +++ b/gnuradio-runtime/lib/realtime.cc @@ -31,7 +31,7 @@ namespace gr { rt_status_t enable_realtime_scheduling() { - return enable_realtime_scheduling(); + return gr::enable_realtime_scheduling(); } } /* namespace gr */ diff --git a/gr-blocks/grc/blocks_interleaved_short_to_complex.xml b/gr-blocks/grc/blocks_interleaved_short_to_complex.xml index e44113e745..712ba3a7ad 100644 --- a/gr-blocks/grc/blocks_interleaved_short_to_complex.xml +++ b/gr-blocks/grc/blocks_interleaved_short_to_complex.xml @@ -8,10 +8,27 @@ <name>IShort To Complex</name> <key>blocks_interleaved_short_to_complex</key> <import>from gnuradio import blocks</import> - <make>blocks.interleaved_short_to_complex()</make> + <make>blocks.interleaved_short_to_complex($vector_input)</make> + <param> + <name>Vector Input</name> + <key>vector_input</key> + <value>False</value> + <type>enum</type> + <option> + <name>No</name> + <key>False</key> + <opt>vlen:1</opt> + </option> + <option> + <name>Yes</name> + <key>True</key> + <opt>vlen:2</opt> + </option> + </param> <sink> <name>in</name> <type>short</type> + <vlen>$vector_input.vlen</vlen> </sink> <source> <name>out</name> diff --git a/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h b/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h index 9fe0ec4147..38caaf7ffa 100644 --- a/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h +++ b/gr-blocks/include/gnuradio/blocks/interleaved_short_to_complex.h @@ -42,7 +42,7 @@ namespace gr { /*! * Build an interleaved short to complex block. */ - static sptr make(); + static sptr make(bool vector_input=false); }; } /* namespace blocks */ diff --git a/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h b/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h index ed051a9744..c594966e6e 100644 --- a/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h +++ b/gr-blocks/include/gnuradio/blocks/repack_bits_bb.h @@ -30,7 +30,7 @@ namespace gr { namespace blocks { /*! - * \brief Pack \p k bits from the input stream onto \p k bits of the output stream. + * \brief Pack \p k bits from the input stream onto \p l bits of the output stream. * \ingroup byte_operators_blk * * \details diff --git a/gr-blocks/lib/interleaved_short_array_to_complex.cc b/gr-blocks/lib/interleaved_short_array_to_complex.cc index eb6431b7a5..4aac6208a1 100644 --- a/gr-blocks/lib/interleaved_short_array_to_complex.cc +++ b/gr-blocks/lib/interleaved_short_array_to_complex.cc @@ -26,14 +26,12 @@ #include "interleaved_short_array_to_complex.h" #include <assert.h> +#include <volk/volk.h> void interleaved_short_array_to_complex (const short *in, gr_complex *out, int nsamples) { assert (nsamples % 2 == 0); - - for (int i = 0; i < nsamples/2; i++){ - out[i] = gr_complex (in[i*2 + 0], in[i*2 + 1]); - } + volk_16i_s32f_convert_32f_u( (float*)out, (const int16_t*) in, 1, nsamples ); } diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.cc b/gr-blocks/lib/interleaved_short_to_complex_impl.cc index 62823c2ee5..962b29b37c 100644 --- a/gr-blocks/lib/interleaved_short_to_complex_impl.cc +++ b/gr-blocks/lib/interleaved_short_to_complex_impl.cc @@ -31,16 +31,17 @@ namespace gr { namespace blocks { - interleaved_short_to_complex::sptr interleaved_short_to_complex::make() + interleaved_short_to_complex::sptr interleaved_short_to_complex::make(bool vector_input) { - return gnuradio::get_initial_sptr(new interleaved_short_to_complex_impl()); + return gnuradio::get_initial_sptr(new interleaved_short_to_complex_impl(vector_input)); } - interleaved_short_to_complex_impl::interleaved_short_to_complex_impl() + interleaved_short_to_complex_impl::interleaved_short_to_complex_impl(bool vector_input) : sync_decimator("interleaved_short_to_complex", - io_signature::make (1, 1, sizeof(short)), - io_signature::make (1, 1, sizeof(gr_complex)), - 2) + gr::io_signature::make (1, 1, (vector_input?2:1)*sizeof(short)), + gr::io_signature::make (1, 1, sizeof(gr_complex)), + vector_input?1:2), + d_vector_input(vector_input) { } diff --git a/gr-blocks/lib/interleaved_short_to_complex_impl.h b/gr-blocks/lib/interleaved_short_to_complex_impl.h index adb8ae8a8f..3280f894fd 100644 --- a/gr-blocks/lib/interleaved_short_to_complex_impl.h +++ b/gr-blocks/lib/interleaved_short_to_complex_impl.h @@ -30,8 +30,10 @@ namespace gr { class BLOCKS_API interleaved_short_to_complex_impl : public interleaved_short_to_complex { + private: + bool d_vector_input; public: - interleaved_short_to_complex_impl(); + interleaved_short_to_complex_impl(bool vector_input=false); int work(int noutput_items, gr_vector_const_void_star &input_items, diff --git a/gr-digital/include/gnuradio/digital/ofdm_frame_equalizer_vcvc.h b/gr-digital/include/gnuradio/digital/ofdm_frame_equalizer_vcvc.h index 0cdafe7a98..afc8b0ff6e 100644 --- a/gr-digital/include/gnuradio/digital/ofdm_frame_equalizer_vcvc.h +++ b/gr-digital/include/gnuradio/digital/ofdm_frame_equalizer_vcvc.h @@ -48,6 +48,8 @@ namespace gr { * \param len_tag_key Length tag key * \param propagate_channel_state If true, the channel state after the last symbol * will be added to the first symbol as a tag + * \param fixed_frame_len Set if the frame length is fixed throughout, + * helps with book keeping. */ static sptr make( ofdm_equalizer_base::sptr equalizer, diff --git a/gr-digital/include/gnuradio/digital/packet_header_ofdm.h b/gr-digital/include/gnuradio/digital/packet_header_ofdm.h index f3b85038b5..4603450915 100644 --- a/gr-digital/include/gnuradio/digital/packet_header_ofdm.h +++ b/gr-digital/include/gnuradio/digital/packet_header_ofdm.h @@ -69,6 +69,7 @@ namespace gr { * \param frame_len_tag_key The tag key used for the frame length (number of * OFDM symbols, this is the tag key required for the * frame equalizer etc.) + * \param num_tag_key The tag key used for packet numbering. * \param bits_per_header_sym Bits per complex symbol in the header, e.g. 1 if * the header is BPSK modulated, 2 if it's QPSK * modulated etc. diff --git a/gr-uhd/examples/python/usrp_spectrum_sense.py b/gr-uhd/examples/python/usrp_spectrum_sense.py index fe97e21cbd..3ad0f332a5 100755 --- a/gr-uhd/examples/python/usrp_spectrum_sense.py +++ b/gr-uhd/examples/python/usrp_spectrum_sense.py @@ -32,6 +32,7 @@ import sys import math import struct import threading +from datetime import datetime sys.stderr.write("Warning: this may have issues on some machines+Python version combinations to seg fault due to the callback in bin_statitics.\n\n") @@ -67,6 +68,12 @@ class tune(gr.feval_dd): # message on stderr. Not exactly helpful ;) new_freq = self.tb.set_next_freq() + + # wait until msgq is empty before continuing + while(self.tb.msgq.full_p()): + #print "msgq full, holding.." + time.sleep(0.1) + return new_freq except Exception, e: @@ -103,16 +110,22 @@ class my_top_block(gr.top_block): parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("", "--tune-delay", type="eng_float", - default=1e-3, metavar="SECS", + default=0.25, metavar="SECS", help="time to delay (in seconds) after changing frequency [default=%default]") parser.add_option("", "--dwell-delay", type="eng_float", - default=10e-3, metavar="SECS", + default=0.25, metavar="SECS", help="time to dwell (in seconds) at a given frequency [default=%default]") - parser.add_option("", "--channel-bandwidth", type="eng_float", - default=12.5e3, metavar="Hz", + parser.add_option("-b", "--channel-bandwidth", type="eng_float", + default=6.25e3, metavar="Hz", help="channel bandwidth of fft bins in Hz [default=%default]") - parser.add_option("-F", "--fft-size", type="int", default=256, - help="specify number of FFT bins [default=%default]") + parser.add_option("-l", "--lo-offset", type="eng_float", + default=0, metavar="Hz", + help="lo_offset in Hz [default=%default]") + parser.add_option("-q", "--squelch-threshold", type="eng_float", + default=None, metavar="dB", + help="squelch threshold in dB [default=%default]") + parser.add_option("-F", "--fft-size", type="int", default=None, + help="specify number of FFT bins [default=samp_rate/channel_bw]") parser.add_option("", "--real-time", action="store_true", default=False, help="Attempt to enable real-time scheduling") @@ -121,6 +134,8 @@ class my_top_block(gr.top_block): parser.print_help() sys.exit(1) + self.channel_bandwidth = options.channel_bandwidth + self.min_freq = eng_notation.str_to_num(args[0]) self.max_freq = eng_notation.str_to_num(args[1]) @@ -128,9 +143,6 @@ class my_top_block(gr.top_block): # swap them self.min_freq, self.max_freq = self.max_freq, self.min_freq - self.fft_size = options.fft_size - self.channel_bandwidth = options.channel_bandwidth - if not options.real_time: realtime = False else: @@ -153,11 +165,19 @@ class my_top_block(gr.top_block): # Set the antenna if(options.antenna): self.u.set_antenna(options.antenna, 0) + + self.u.set_samp_rate(options.samp_rate) + self.usrp_rate = usrp_rate = self.u.get_samp_rate() + + self.lo_offset = options.lo_offset - self.usrp_rate = usrp_rate = options.samp_rate - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - + if options.fft_size is None: + self.fft_size = int(self.usrp_rate/self.channel_bandwidth) + else: + self.fft_size = options.fft_size + + self.squelch_threshold = options.squelch_threshold + s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) mywindow = filter.window.blackmanharris(self.fft_size) @@ -169,14 +189,14 @@ class my_top_block(gr.top_block): c2mag = blocks.complex_to_mag_squared(self.fft_size) # FIXME the log10 primitive is dog slow - log = blocks.nlog10_ff(10, self.fft_size, - -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) + #log = blocks.nlog10_ff(10, self.fft_size, + # -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) # Set the freq_step to 75% of the actual data throughput. # This allows us to discard the bins on both ends of the spectrum. - self.freq_step = 0.75 * usrp_rate - self.min_center_freq = self.min_freq + self.freq_step/2 + self.freq_step = self.nearest_freq((0.75 * self.usrp_rate), self.channel_bandwidth) + self.min_center_freq = self.min_freq + (self.freq_step/2) nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step) self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step) @@ -185,7 +205,7 @@ class my_top_block(gr.top_block): tune_delay = max(0, int(round(options.tune_delay * usrp_rate / self.fft_size))) # in fft_frames dwell_delay = max(1, int(round(options.dwell_delay * usrp_rate / self.fft_size))) # in fft_frames - self.msgq = gr.msg_queue(16) + self.msgq = gr.msg_queue(1) self._tune_callback = tune(self) # hang on to this to keep it from being GC'd stats = blocks.bin_statistics_f(self.fft_size, self.msgq, self._tune_callback, tune_delay, @@ -224,7 +244,8 @@ class my_top_block(gr.top_block): target_freq: frequency in Hz @rypte: bool """ - r = self.u.set_center_freq(target_freq) + + r = self.u.set_center_freq(uhd.tune_request(target_freq, rf_freq=(target_freq + self.lo_offset),rf_freq_policy=uhd.tune_request.POLICY_MANUAL)) if r: return True @@ -232,47 +253,45 @@ class my_top_block(gr.top_block): def set_gain(self, gain): self.u.set_gain(gain) - - -def main_loop(tb): - def nearest_freq(freq, channel_bandwidth): + def nearest_freq(self, freq, channel_bandwidth): freq = round(freq / channel_bandwidth, 0) * channel_bandwidth return freq +def main_loop(tb): + def bin_freq(i_bin, center_freq): - hz_per_bin = tb.usrp_rate / tb.fft_size - freq = center_freq - (tb.usrp_rate / 2) + (hz_per_bin * i_bin) - freq = nearest_freq(freq, tb.channel_bandwidth) + #hz_per_bin = tb.usrp_rate / tb.fft_size + freq = center_freq - (tb.usrp_rate / 2) + (tb.channel_bandwidth * i_bin) + #print "freq original:",freq + #freq = nearest_freq(freq, tb.channel_bandwidth) + #print "freq rounded:",freq return freq bin_start = int(tb.fft_size * ((1 - 0.75) / 2)) bin_stop = int(tb.fft_size - bin_start) - + while 1: # Get the next message sent from the C++ code (blocking call). # It contains the center frequency and the mag squared of the fft m = parse_msg(tb.msgq.delete_head()) - # Print center freq so we know that something is happening... - #print "m.center_freq:", m.center_freq - - # FIXME do something useful with the data... - - # m.data are the mag_squared of the fft output (they are in the - # standard order. I.e., bin 0 == DC.) - # You'll probably want to do the equivalent of "fftshift" on them + # m.center_freq is the center frequency at the time of capture + # m.data are the mag_squared of the fft output # m.raw_data is a string that contains the binary floats. # You could write this as binary to a file. for i_bin in range(bin_start, bin_stop): - # create signal object to find matching signals - freq = int(bin_freq(i_bin, m.center_freq)) - power = float(m.data[i_bin]) - - print freq, power + center_freq = m.center_freq + freq = bin_freq(i_bin, center_freq) + #noise_floor_db = -174 + 10*math.log10(tb.channel_bandwidth) + noise_floor_db = 10*math.log10(min(m.data)/tb.usrp_rate) + power_db = 10*math.log10(m.data[i_bin]/tb.usrp_rate) - noise_floor_db + + if (power_db > tb.squelch_threshold) and (freq >= tb.min_freq) and (freq <= tb.max_freq): + print datetime.now(), "center_freq", center_freq, "freq", freq, "power_db", power_db, "noise_floor_db", noise_floor_db if __name__ == '__main__': t = ThreadClass() diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py index 25b0a4c467..e392f6a606 100644 --- a/gr-uhd/grc/gen_uhd_usrp_blocks.py +++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py @@ -25,6 +25,7 @@ MAIN_TMPL = """\ <key>uhd_usrp_$(sourk)</key> <throttle>1</throttle> <import>from gnuradio import uhd</import> + <import>import time</import> <make>uhd.usrp_$(sourk)( device_addr=\$dev_addr, stream_args=uhd.stream_args( @@ -56,8 +57,10 @@ self.\$(id).set_subdev_spec(\$sd_spec$(m), $m) \#end if ######################################################################## #end for -\#if \$sync() +\#if \$sync() == 'sync' self.\$(id).set_time_unknown_pps(uhd.time_spec()) +\#elif \$sync() == 'pc_clock' +self.\$(id).set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) \#end if self.\$(id).set_samp_rate(\$samp_rate) #for $n in range($max_nchan) @@ -166,6 +169,10 @@ self.\$(id).set_bandwidth(\$bw$(n), $n) <key>sync</key> </option> <option> + <name>PC Clock</name> + <key>pc_clock</key> + </option> + <option> <name>don't sync</name> <key></key> </option> diff --git a/gr-uhd/include/gnuradio/uhd/usrp_sink.h b/gr-uhd/include/gnuradio/uhd/usrp_sink.h index 4306d1e739..6d21bbccdd 100644 --- a/gr-uhd/include/gnuradio/uhd/usrp_sink.h +++ b/gr-uhd/include/gnuradio/uhd/usrp_sink.h @@ -297,6 +297,20 @@ namespace gr { virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0; /*! + * Get the bandpass filter setting on the RF frontend. + * \param chan the channel index 0 to N-1 + * \return bandwidth of the filter in Hz + */ + virtual double get_bandwidth(size_t chan = 0) = 0; + + /*! + * Get the bandpass filter range of the RF frontend. + * \param chan the channel index 0 to N-1 + * \return the range of the filter bandwidth in Hz + */ + virtual ::uhd::freq_range_t get_bandwidth_range(size_t chan = 0) = 0; + + /*! * Set a constant DC offset value. * The value is complex to control both I and Q. * \param offset the dc offset (1.0 is full-scale) diff --git a/gr-uhd/include/gnuradio/uhd/usrp_source.h b/gr-uhd/include/gnuradio/uhd/usrp_source.h index 498fd32088..f330ee0901 100644 --- a/gr-uhd/include/gnuradio/uhd/usrp_source.h +++ b/gr-uhd/include/gnuradio/uhd/usrp_source.h @@ -309,6 +309,20 @@ namespace gr { virtual void set_bandwidth(double bandwidth, size_t chan = 0) = 0; /*! + * Get the bandpass filter setting on the RF frontend. + * \param chan the channel index 0 to N-1 + * \return bandwidth of the filter in Hz + */ + virtual double get_bandwidth(size_t chan = 0) = 0; + + /*! + * Get the bandpass filter range of the RF frontend. + * \param chan the channel index 0 to N-1 + * \return the range of the filter bandwidth in Hz + */ + virtual ::uhd::freq_range_t get_bandwidth_range(size_t chan = 0) = 0; + + /*! * Enable/disable the automatic DC offset correction. * The automatic correction subtracts out the long-run average. * diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc index 349271f720..d38ffc344d 100644 --- a/gr-uhd/lib/usrp_sink_impl.cc +++ b/gr-uhd/lib/usrp_sink_impl.cc @@ -214,6 +214,18 @@ namespace gr { return _dev->set_tx_bandwidth(bandwidth, chan); } + double + usrp_sink_impl::get_bandwidth(size_t chan) + { + return _dev->get_tx_bandwidth(chan); + } + + ::uhd::freq_range_t + usrp_sink_impl::get_bandwidth_range(size_t chan) + { + return _dev->get_tx_bandwidth_range(chan); + } + void usrp_sink_impl::set_dc_offset(const std::complex<double> &offset, size_t chan) diff --git a/gr-uhd/lib/usrp_sink_impl.h b/gr-uhd/lib/usrp_sink_impl.h index 4db67f2abb..c714eb53eb 100644 --- a/gr-uhd/lib/usrp_sink_impl.h +++ b/gr-uhd/lib/usrp_sink_impl.h @@ -93,6 +93,8 @@ namespace gr { void set_gain(double gain, const std::string &name, size_t chan); void set_antenna(const std::string &ant, size_t chan); void set_bandwidth(double bandwidth, size_t chan); + double get_bandwidth(size_t chan); + ::uhd::freq_range_t get_bandwidth_range(size_t chan); void set_dc_offset(const std::complex<double> &offset, size_t chan); void set_iq_balance(const std::complex<double> &correction, size_t chan); void set_clock_config(const ::uhd::clock_config_t &clock_config, size_t mboard); diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc index 813f707178..c5df60222a 100644 --- a/gr-uhd/lib/usrp_source_impl.cc +++ b/gr-uhd/lib/usrp_source_impl.cc @@ -220,6 +220,18 @@ namespace gr { return _dev->set_rx_bandwidth(bandwidth, chan); } + double + usrp_source_impl::get_bandwidth(size_t chan) + { + return _dev->get_rx_bandwidth(chan); + } + + ::uhd::freq_range_t + usrp_source_impl::get_bandwidth_range(size_t chan) + { + return _dev->get_rx_bandwidth_range(chan); + } + void usrp_source_impl::set_auto_dc_offset(const bool enable, size_t chan) { diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h index 347241a19e..58bb21551c 100644 --- a/gr-uhd/lib/usrp_source_impl.h +++ b/gr-uhd/lib/usrp_source_impl.h @@ -95,6 +95,8 @@ namespace gr { void set_gain(double gain, const std::string &name, size_t chan); void set_antenna(const std::string &ant, size_t chan); void set_bandwidth(double bandwidth, size_t chan); + double get_bandwidth(size_t chan); + ::uhd::freq_range_t get_bandwidth_range(size_t chan); void set_auto_dc_offset(const bool enable, size_t chan); void set_dc_offset(const std::complex<double> &offset, size_t chan); void set_iq_balance(const std::complex<double> &correction, size_t chan); diff --git a/gr-utils/python/modtool/gr-newmod/CMakeLists.txt b/gr-utils/python/modtool/gr-newmod/CMakeLists.txt index 33f67c0442..6f01385e84 100644 --- a/gr-utils/python/modtool/gr-newmod/CMakeLists.txt +++ b/gr-utils/python/modtool/gr-newmod/CMakeLists.txt @@ -86,10 +86,17 @@ set(GRC_BLOCKS_DIR ${GR_PKG_DATA_DIR}/grc/blocks) find_package(GnuradioRuntime) find_package(CppUnit) +# To run a more advanced search for GNU Radio and it's components and +# versions, use the following. Add any components required to the list +# of GR_REQUIRED_COMPONENTS (in all caps) and change "version" to the +# minimum API compatible version required. +# +# set(GR_REQUIRED_COMPONENTS RUNTIME BLOCKS FILTER ...) +# find_package(Gnuradio "version") + if(NOT GNURADIO_RUNTIME_FOUND) message(FATAL_ERROR "GnuRadio Runtime required to compile howto") endif() - if(NOT CPPUNIT_FOUND) message(FATAL_ERROR "CppUnit required to compile howto") endif() |