diff options
author | Ben Reynwar <ben@reynwar.net> | 2013-05-10 01:17:21 -0700 |
---|---|---|
committer | Ben Reynwar <ben@reynwar.net> | 2013-05-10 01:17:21 -0700 |
commit | af76f9509ae97f04ef6b77a3f63e2650dc2b66c8 (patch) | |
tree | 2b5ad689efd3cb2f387dfc61d81c8f6364b92b38 | |
parent | 72948e9a4031f8d779a70f73e6e6a0014d1de326 (diff) | |
parent | 3e052d303874a07237c4e0c31eef3f7f7a192835 (diff) |
Merge branch 'next' into next_docs
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 20 | ||||
-rw-r--r-- | README.hacking | 37 | ||||
-rw-r--r-- | cmake/Modules/GnuradioConfig.cmake | 122 | ||||
-rw-r--r-- | cmake/Modules/GnuradioConfigVersion.cmake.in | 35 | ||||
-rw-r--r-- | cmake/Modules/GrMiscUtils.cmake | 28 | ||||
-rw-r--r-- | docs/doxygen/other/main_page.dox | 59 | ||||
-rw-r--r-- | gnuradio-runtime/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-runtime/include/gr_buffer.h | 2 | ||||
-rw-r--r-- | gnuradio-runtime/include/gr_constants.h | 10 | ||||
-rw-r--r-- | gnuradio-runtime/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-runtime/lib/gr_block_detail.cc | 2 | ||||
-rw-r--r-- | gnuradio-runtime/lib/gr_realtime.cc | 3 | ||||
-rw-r--r-- | gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h | 2 | ||||
-rw-r--r-- | gr-digital/include/digital/packet_header_ofdm.h | 1 | ||||
-rwxr-xr-x | gr-uhd/examples/python/usrp_spectrum_sense.py | 99 | ||||
-rw-r--r-- | gr-utils/python/modtool/gr-newmod/CMakeLists.txt | 9 |
17 files changed, 344 insertions, 88 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/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 3ad9e68021..498e2f5803 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/gr_buffer.h b/gnuradio-runtime/include/gr_buffer.h index 9b9f75604a..cc6a7a61fe 100644 --- a/gnuradio-runtime/include/gr_buffer.h +++ b/gnuradio-runtime/include/gr_buffer.h @@ -112,6 +112,7 @@ class GR_RUNTIME_API gr_buffer { * 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 gr_tag_t &tag, long id); @@ -283,6 +284,7 @@ class GR_RUNTIME_API gr_buffer_reader { * \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<gr_tag_t> &v, uint64_t abs_start, diff --git a/gnuradio-runtime/include/gr_constants.h b/gnuradio-runtime/include/gr_constants.h index 3534166bc0..38ad858b20 100644 --- a/gnuradio-runtime/include/gr_constants.h +++ b/gnuradio-runtime/include/gr_constants.h @@ -26,27 +26,27 @@ #include <string> /*! - * \brief return ./configure --prefix argument. Typically /usr/local + * \brief return CMAKE_INSTALL_PREFIX. Typically /usr/local */ GR_RUNTIME_API const std::string gr_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 gr_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 gr_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 gr_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 gr_version(); diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt index 98db673f5d..1cde8ce323 100644 --- a/gnuradio-runtime/lib/CMakeLists.txt +++ b/gnuradio-runtime/lib/CMakeLists.txt @@ -123,6 +123,7 @@ list(APPEND gnuradio_runtime_sources gr_vmcircbuf_mmap_tmpfile.cc gr_vmcircbuf_sysv_shm.cc malloc16.c + realtime.cc runtime_block_gateway.cc ) diff --git a/gnuradio-runtime/lib/gr_block_detail.cc b/gnuradio-runtime/lib/gr_block_detail.cc index 7d850138c4..0b12b1728b 100644 --- a/gnuradio-runtime/lib/gr_block_detail.cc +++ b/gnuradio-runtime/lib/gr_block_detail.cc @@ -270,6 +270,7 @@ gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) 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; @@ -304,6 +305,7 @@ gr_block_detail::stop_perf_counters(int noutput_items, int nproduced) } 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()); diff --git a/gnuradio-runtime/lib/gr_realtime.cc b/gnuradio-runtime/lib/gr_realtime.cc index d7a7eab5ba..9977718a5d 100644 --- a/gnuradio-runtime/lib/gr_realtime.cc +++ b/gnuradio-runtime/lib/gr_realtime.cc @@ -25,9 +25,10 @@ #endif #include <gr_realtime.h> +#include <realtime.h> gr_rt_status_t gr_enable_realtime_scheduling() { - return gr_enable_realtime_scheduling(); + return gr::enable_realtime_scheduling(); } diff --git a/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h b/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h index f8e15fb577..3be014d455 100644 --- a/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h +++ b/gr-digital/include/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/digital/packet_header_ofdm.h b/gr-digital/include/digital/packet_header_ofdm.h index 30d6a953cd..3a477580ce 100644 --- a/gr-digital/include/digital/packet_header_ofdm.h +++ b/gr-digital/include/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-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() |