diff options
1039 files changed, 41740 insertions, 1836 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 16e4ef378e..17c0ad367e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) # Set the version information here set(VERSION_INFO_MAJOR_VERSION 3) set(VERSION_INFO_API_COMPAT 6) -set(VERSION_INFO_MINOR_VERSION 4) -set(VERSION_INFO_MAINT_VERSION 1) +set(VERSION_INFO_MINOR_VERSION 5) +set(VERSION_INFO_MAINT_VERSION git) include(GrVersion) #setup version info # Append -O2 optimization flag for Debug builds @@ -96,6 +96,7 @@ if(MSVC) ) add_definitions(-DHAVE_CONFIG_H) add_definitions(/MP) #build with multiple processors + add_definitions(/bigobj) #allow for larger object files endif(MSVC) ######################################################################## @@ -120,8 +121,10 @@ set(GR_PREFSDIR ${SYSCONFDIR}/${CMAKE_PROJECT_NAME}/conf.d) OPTION(ENABLE_PERFORMANCE_COUNTERS "Enable block performance counters" OFF) if(ENABLE_PERFORMANCE_COUNTERS) message(STATUS "ADDING PERF COUNTERS") + SET(GR_PERFORMANCE_COUNTERS True) add_definitions(-DGR_PERFORMANCE_COUNTERS) else(ENABLE_PERFORMANCE_COUNTERS) + SET(GR_PERFORMANCE_COUNTERS False) message(STATUS "NO PERF COUNTERS") endif(ENABLE_PERFORMANCE_COUNTERS) @@ -226,6 +229,9 @@ CPACK_COMPONENT("volk_devel" add_subdirectory(volk) endif(ENABLE_VOLK) +# Handle gr_log enable/disable +GR_LOGGING() + ######################################################################## # Distribute the README file ######################################################################## @@ -253,7 +259,7 @@ add_subdirectory(docs) add_subdirectory(gruel) add_subdirectory(gnuradio-core) add_subdirectory(grc) - +add_subdirectory(gr-blocks) add_subdirectory(gr-fft) add_subdirectory(gr-filter) add_subdirectory(gr-atsc) @@ -273,7 +279,26 @@ add_subdirectory(gr-vocoder) add_subdirectory(gr-fcd) add_subdirectory(gr-wavelet) add_subdirectory(gr-wxgui) -add_subdirectory(gr-blocks) + +# 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_configs} + DESTINATION lib/cmake/gnuradio + COMPONENT "runtime_devel" +) #finalize cpack after subdirs processed include(GrPackage) @@ -285,3 +310,17 @@ CPACK_FINALIZE() GR_PRINT_COMPONENT_SUMMARY() message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}") message(STATUS "Building for version: ${VERSION} / ${LIBVER}") + +# Create a gr_config.h with some definitions to export to other projects. +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/gr_config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/gr_config.h +) + +# Install gr_config.h in include/gnuradio +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/gr_config.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio + COMPONENT "core_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/FindLog4cpp.cmake b/cmake/Modules/FindLog4cpp.cmake new file mode 100644 index 0000000000..fc314c61a5 --- /dev/null +++ b/cmake/Modules/FindLog4cpp.cmake @@ -0,0 +1,53 @@ +# - Find Log4cpp +# Find the native LOG4CPP includes and library +# +# LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc. +# LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP. +# LOG4CPP_FOUND - True if LOG4CPP found. + + +if (LOG4CPP_INCLUDE_DIR) + # Already in cache, be silent + set(LOG4CPP_FIND_QUIETLY TRUE) +endif () + +find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh + /opt/local/include + /usr/local/include + /usr/include +) + +set(LOG4CPP_NAMES log4cpp) +find_library(LOG4CPP_LIBRARY + NAMES ${LOG4CPP_NAMES} + PATHS /usr/lib /usr/local/lib /opt/local/lib +) + + +if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY) + set(LOG4CPP_FOUND TRUE) + set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIRS ${LOG4CPP_INCLUDE_DIR} CACHE INTERNAL "" FORCE) +else () + set(LOG4CPP_FOUND FALSE CACHE INTERNAL "" FORCE) + set(LOG4CPP_LIBRARY "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIR "" CACHE INTERNAL "" FORCE) + set(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) +endif () + +if (LOG4CPP_FOUND) + if (NOT LOG4CPP_FIND_QUIETLY) + message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}") + endif () +else () + if (LOG4CPP_FIND_REQUIRED) + message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.") + message(FATAL_ERROR "Could NOT find LOG4CPP library") + endif () +endif () + +mark_as_advanced( + LOG4CPP_LIBRARIES + LOG4CPP_INCLUDE_DIRS +) diff --git a/cmake/Modules/GnuradioConfig.cmake b/cmake/Modules/GnuradioConfig.cmake new file mode 100644 index 0000000000..c2786232ae --- /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 CORE RUNTIME ANALOG ATSC AUDIO BLOCKS DIGITAL FCD 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_CORE_DIR}/include/gnuradio
+ ${PC_INCDIR}
+ ${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_CORE_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(CORE gnuradio-core gr_top_block.h gnuradio-core)
+GR_MODULE(RUNTIME gnuradio-core gr_top_block.h gnuradio-core)
+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 gr_audio_api.h gnuradio-audio)
+GR_MODULE(BLOCKS gnuradio-blocks blocks/api.h gnuradio-blocks)
+GR_MODULE(DIGITAL gnuradio-digital digital/ofdm_frame_equalizer_vcvc.h gnuradio-digital)
+GR_MODULE(FCD gnuradio-fft fcd_api.h gnuradio-fft)
+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 gr_qtgui_api.h gnuradio-qtgui)
+GR_MODULE(TRELLIS gnuradio-trellis trellis_api.h gnuradio-trellis)
+GR_MODULE(UHD gnuradio-uhd gr_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)
+
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 3e80846d62..69ff1f5ddc 100644 --- a/cmake/Modules/GrMiscUtils.cmake +++ b/cmake/Modules/GrMiscUtils.cmake @@ -209,6 +209,48 @@ function(GR_GEN_TARGET_DEPS name var) endif() endfunction(GR_GEN_TARGET_DEPS) +######################################################################## +# Control use of gr_logger +# Usage: +# GR_LOGGING() +# +# Will set ENABLE_GR_LOG to 1 by default. +# Can manually set with -DENABLE_GR_LOG=0|1 +######################################################################## +function(GR_LOGGING) + find_package(Log4cpp) + + OPTION(ENABLE_GR_LOG "Use gr_logger" ON) + if(ENABLE_GR_LOG) + # If gr_logger is enabled, make it usable + add_definitions( -DENABLE_GR_LOG ) + + # also test LOG4CPP; if we have it, use this version of the logger + # otherwise, default to the stdout/stderr model. + if(LOG4CPP_FOUND) + SET(HAVE_LOG4CPP True CACHE INTERNAL "" FORCE) + add_definitions( -DHAVE_LOG4CPP ) + else(not LOG4CPP_FOUND) + SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE) + SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) + endif(LOG4CPP_FOUND) + + SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE) + + else(ENABLE_GR_LOG) + SET(HAVE_LOG4CPP False CACHE INTERNAL "" FORCE) + SET(LOG4CPP_INCLUDE_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CPP_LIBRARY_DIRS "" CACHE INTERNAL "" FORCE) + SET(LOG4CPP_LIBRARIES "" CACHE INTERNAL "" FORCE) + endif(ENABLE_GR_LOG) + + message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.") + message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.") + message(STATUS "LOG4CPP_LIBRARIES set to ${LOG4CPP_LIBRARIES}.") + +endfunction(GR_LOGGING) ######################################################################## # Run GRCC to compile .grc files into .py files. diff --git a/cmake/Modules/GrVersion.cmake b/cmake/Modules/GrVersion.cmake index 9199a702bb..bafd0a7326 100644 --- a/cmake/Modules/GrVersion.cmake +++ b/cmake/Modules/GrVersion.cmake @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -54,6 +54,8 @@ if("${MINOR_VERSION}" STREQUAL "git") set(VERSION "${GIT_DESCRIBE}") set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}${MINOR_VERSION}") + set(RC_MINOR_VERSION "0") + set(RC_MAINT_VERSION "0") elseif("${MAINT_VERSION}" STREQUAL "git") # VERSION: 3.3.1git-xxx-gxxxxxxxx # DOCVER: 3.3.1git @@ -61,6 +63,8 @@ elseif("${MAINT_VERSION}" STREQUAL "git") set(VERSION "${GIT_DESCRIBE}") set(DOCVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") set(LIBVER "${MAJOR_VERSION}.${API_COMPAT}.${MINOR_VERSION}${MAINT_VERSION}") + math(EXPR RC_MINOR_VERSION "${MINOR_VERSION} - 1") + set(RC_MAINT_VERSION "0") else() # This is a numbered release. # VERSION: 3.3.1{.x} @@ -73,4 +77,6 @@ else() endif() set(DOCVER "${VERSION}") set(LIBVER "${VERSION}") + set(RC_MINOR_VERSION ${MINOR_VERSION}) + set(RC_MAINT_VERSION ${MAINT_VERSION}) endif() diff --git a/docs/doxygen/CMakeLists.txt b/docs/doxygen/CMakeLists.txt index f328bd7a22..a59159a691 100644 --- a/docs/doxygen/CMakeLists.txt +++ b/docs/doxygen/CMakeLists.txt @@ -37,6 +37,34 @@ configure_file( set(BUILT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/xml ${CMAKE_CURRENT_BINARY_DIR}/html) +if(ENABLE_GRUEL) + list(APPEND GENERATED_DEPS pmt_generated) +endif(ENABLE_GRUEL) + +if(ENABLE_GR_CORE) + list(APPEND GENERATED_DEPS general_generated gengen_generated filter_generated) +endif(ENABLE_GR_CORE) + +if(ENABLE_GR_BLOCKS) + list(APPEND GENERATED_DEPS blocks_generated_includes) +endif(ENABLE_GR_BLOCKS) + +if(ENABLE_GR_ANALOG) + list(APPEND GENERATED_DEPS analog_generated_includes) +endif(ENABLE_GR_ANALOG) + +if(ENABLE_GR_DIGITAL) + list(APPEND GENERATED_DEPS digital_generated_includes) +endif(ENABLE_GR_DIGITAL) + +if(ENABLE_GR_FILTER) + list(APPEND GENERATED_DEPS filter_generated_includes) +endif(ENABLE_GR_FILTER) + +if(ENABLE_GR_TRELLIS) + list(APPEND GENERATED_DEPS trellis_generated_includes) +endif(ENABLE_GR_TRELLIS) + ######################################################################## # Make and install doxygen docs ######################################################################## @@ -44,6 +72,7 @@ add_custom_command( OUTPUT ${BUILT_DIRS} COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS ${GENERATED_DEPS} COMMENT "Generating documentation with doxygen" ) diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in index 536661996b..aa4fc3b0be 100644 --- a/docs/doxygen/Doxyfile.in +++ b/docs/doxygen/Doxyfile.in @@ -674,13 +674,11 @@ EXCLUDE_SYMBOLS = ad9862 \ *app_top_block* \ *am_rx_graph* \ *_queue_watcher_thread* \ - *parse* \ *MyFrame* \ *MyApp* \ *PyObject* \ *wfm_rx_block* \ *_sptr* \ - *debug* \ *wfm_rx_sca_block* \ *tv_rx_block* \ *wxapt_rx_block* \ diff --git a/docs/doxygen/other/extra_pages.dox b/docs/doxygen/other/extra_pages.dox index d40c692e03..94c741864d 100644 --- a/docs/doxygen/other/extra_pages.dox +++ b/docs/doxygen/other/extra_pages.dox @@ -79,6 +79,8 @@ audio-osx and audio-windows to be either satisfied or built. \subsection dep_gr_comedi gr-comedi: Comedi hardware interface \li comedilib (>= 0.8) http://www.comedi.org/ +\subsection dep_gr_log gr-log: Logging Tools (Optional) +\li log4cpp (>= 1.0) http://log4cpp.sourceforge.net/ \section build_gr_cmake Building GNU Radio diff --git a/docs/doxygen/other/group_defs.dox b/docs/doxygen/other/group_defs.dox index 4aee49ec85..1c96abf3dc 100644 --- a/docs/doxygen/other/group_defs.dox +++ b/docs/doxygen/other/group_defs.dox @@ -8,32 +8,46 @@ * @{ */ -/*! \defgroup container_blk Top Block and Hierarchical Block Base Classes */ -/*! \defgroup source_blk Signal Sources */ -/*! \defgroup sink_blk Signal Sinks */ -/*! \defgroup filter_blk Filters */ -/*! \defgroup math_blk Mathematics */ -/*! \defgroup modulation_blk Signal Modulation */ -/*! \defgroup demodulation_blk Signal Demodulation */ -/*! \defgroup coding_blk Information Coding and Decoding*/ -/*! \defgroup sync_blk Synchronization */ -/*! \defgroup eq_blk Equalization */ -/*! \defgroup converter_blk Type Conversions */ -/*! \defgroup level_blk Signal Level Control (AGC) */ -/*! \defgroup dft_blk Fourier Transform */ -/*! \defgroup wavelet_blk Wavelet Transform */ -/*! \defgroup ofdm_blk OFDM Blocks */ -/*! \defgroup pager_blk Pager Blocks */ -/*! \defgroup misc_blk Miscellaneous Blocks */ -/*! \defgroup slicedice_blk Slicing and Dicing Streams */ -/*! \defgroup vocoder_blk Voice Encoders and Decoders */ -/*! \defgroup digital Digital Modulation Blocks */ -/*! \defgroup analog Analog Communications Blocks */ -/*! \defgroup qtgui_blk QT Graphical Interfaces */ -/*! \defgroup uhd_blk UHD Interface */ -/*! \defgroup audio_blk Audio Interface */ -/*! \defgroup pfb_blk Polyphase Filterbank */ -/*! \defgroup snr_blk SNR estimators */ +/*! \defgroup container_blk Top Block and Hierarchical Block Base Classes */ +/*! \defgroup audio_blk Audio Signals */ +/*! \defgroup boolean_operators_blk Boolean Operators */ +/*! \defgroup byte_operators_blk Byte Operators */ +/*! \defgroup channel_models_blk Channel Models */ +/*! \defgroup channelizers_blk Channelizers */ +/*! \defgroup coding_blk Information Coding and Decoding */ +/*! \defgroup debug_tools_blk Debug Tools */ +/*! \defgroup deprecated_blk Deprecated */ +/*! \defgroup equalizers_blk Equalizers */ +/*! \defgroup error_coding_blk Error Coding and Decoding */ +/*! \defgroup fcd_blk FCD Interface */ +/*! \defgroup file_operators_blk File Operators */ +/*! \defgroup filter_blk Filters */ +/*! \defgroup fourier_analysis_blk Fourier Analysis */ +/*! \defgroup instrumentation_blk Instrumentation Tools */ +/*! \defgroup level_controllers_blk Level Controllers */ +/*! \defgroup math_operators_blk Math Operators */ +/*! \defgroup measurement_tools_blk Measurement Tools */ +/*! \defgroup message_tools_blk Message Tools */ +/*! \defgroup misc_blk Miscellaneous */ +/*! \defgroup modulators_blk Modulators and Demodulators */ +/*! \defgroup networking_tools_blk Netwroking Tools */ +/*! \defgroup noaa_blk NOAA Blocks */ +/*! \defgroup ofdm_blk OFDM Blocks */ +/*! \defgroup packet_operators_blk Packet/Frame Operators */ +/*! \defgroup peak_detectors_blk Peak Detectors */ +/*! \defgroup pager_blk Pager Blocks */ +/*! \defgroup qtgui_blk QT Graphical Interfaces */ +/*! \defgroup resamplers_blk Resamplers */ +/*! \defgroup stream_operators_blk Streams Operators */ +/*! \defgroup stream_tag_tools_blk Stream Tag Tools */ +/*! \defgroup symbol_coding_blk Symbol Coding */ +/*! \defgroup synchronizers_blk Synchronizers */ +/*! \defgroup trellis_coding_blk Trellis Coding */ +/*! \defgroup type_converters_blk Data Type Converters */ +/*! \defgroup uhd_blk UHD Interface */ +/*! \defgroup waveform_generators_blk Waveform Generators */ +/*! \defgroup wavelet_blk Wavelet Transforms */ +/*! \defgroup wxgui_blk WX Graphical Interfaces */ /*! * \defgroup base_blk Base classes for GR Blocks diff --git a/docs/doxygen/other/logger.dox b/docs/doxygen/other/logger.dox new file mode 100644 index 0000000000..22458051db --- /dev/null +++ b/docs/doxygen/other/logger.dox @@ -0,0 +1,205 @@ +/*! \page page_logger Logging + +\section logging Logging + +GNU Radio has a logging interface to enable various levels of logging +information to be printed to the console or a file. The logger derives +from log4cpp (http://log4cpp.sourceforge.net/) which is readily +available in most Linux distributions. This is an optional dependency +and GNU Radio will work without it. + +When configuring GNU Radio, the -DENABLE_GR_LOG=On|Off option to cmake +will allow the user to toggle use of the logger on and off. The logger +defaults to "on" and will use log4cpp if it is available. If log4cpp +is not found, the default logging will output to standard output or +standard error, depending on the level of the log message. + +Logging is useful for blocks to print out certain amounts of data at +different levels. These levels are: + +<pre> + DEBUG < INFO < WARN < TRACE < ERROR < ALERT < CRIT < FATAL < EMERG +</pre> + + +The order here determines the level of output. These levels are +hierarchical in that specifying any level also includes any level +above it. For example, when using the WARN level, all WARN and +higher messages are logged while DEBUG and INFO are ignored. + +\subsection configfile Logging Configuration + +The logging configuration can be found in the gnuradio-core.conf file +under the [LOG] section. This allows us fairly complete control over +the logging facilities. The main configuration functions are to set up +the level of the loggers and set the default output behavior of the +loggers. + +There are two default loggers that all gr_block's have access to: +d_logger and d_debug_logger. The first is a standard logger meant to +output simple information about the block while it is running. The +debug logger is meant for debugging purposes and is added to make it +convenient to use a secondary logger that outputs to a different +stream or file. + +The four main configure options are: + +<pre> + log_level = debug + debug_level = debug + log_file = stdout + debug_file = stderr +</pre> + +This establishes the two loggers as having access to all levels of +logging events (DEBUG through EMERG). They are also configured not to +use files but instead output to the console. The standard logger will +output to standard out while the debug logger outputs to standard +error. + +Changing these last two lines to another value will create files that +are used to store the log messages. All messages are appended to the +file. + +When using either standard error or standard out, the messages for the +two different loggers will look like: + +<pre> + gr::log :\<level\>: \<block alias\> - \<message\> + gr::debug :\<level\>: \<block alias\> - \<message\> +</pre> + +When using a file, the only difference in the format is that the +message prefix of "gr::log" or "gr::debug" is not used. Instead, the +time in milliseconds from the start of the program is inserted. + +Remember that a local "~/.gnuradio/config.conf" file can be used to +override any parameter in the global file (see \ref prefs for more +details). + +To use these loggers inside of a GNU Radio block, we use the protected +data members of d_logger and d_debug_logger of gr_block and pass them +to our pre-defined macros: + +\code + GR_LOG_<level>(<logger>, "<Message to print>"); +\endcode + +Where \<level\> is one of the levels as mentioned above, \<logger\> is +either d_logger or d_debug_logger, and \<Message to print\> is the +message we want to output. If we wanted to output an INFO level +message to the standard logger and a WARN level message to the debug +logger, it would look like this: + +\code + GR_LOG_INFO(d_logger, "Some info about the block"); + GR_LOG_WARN(d_debug_logger, "Some warning about the block"); +\endcode + +When this is printed to wherever you are directing the output of the +logger, it will look like: + +<pre> + gr::log :INFO: <block's alias> - Some info about the block + gr::debug :WARN: <block's alias> - Some warning about the block +</pre> + +This provides us information about where the message came from, the +level of the message, and the block that generated the message. We use +the concept of the block's alias which by default (i.e., unless +otherwise set by the user) includes the name of the block and a unique +ID to distinguish it from other blocks of the same type. + +The various logging macros are defined in gr_logger.h. Here are some +simple examples of using them: + +\code + GR_LOG_DEBUG(LOG, "DEBUG message"); + GR_LOG_INFO(LOG, "INFO message"); + GR_LOG_NOTICE(LOG, "NOTICE message"); + GR_LOG_WARN(LOG, "WARNING message"); + GR_LOG_ERROR(LOG, "ERROR message"); + GR_LOG_CRIT(LOG, "CRIT message"); + GR_LOG_ALERT(LOG, "ALERT message"); + GR_LOG_FATAL(LOG, "FATAL message"); + GR_LOG_EMERG(LOG, "EMERG message"); +\endcode + +If the logger is not enabled, then these macros become nops and do +nothing (and d_logger and d_debug_logger are NULL pointers). If +logging is enabled but the log4cpp library is not found, then TRACE, +INFO, and NOTICE levels go to stdout and the rest to stderr. + + +\subsection adv_config Advanced Configuration Options + +If not using the simplified settings discussed above, where we can +direct the logger messages to either a file or one of the standard +outputs, we must use a more complicated configuration file. We do this +by specifying the "log_config" option in the [LOG] section. The +log4cpp documentation will provide more information on how +configuration works and looks. Mostly, a default configuration script +provided with GNU Radio can be used. After installation, the default +configuration script is located at: + +<pre> + $prefix/etc/gnuradio/gr_log_default.xml +</pre> + +For the following examples, we will assume that our local +"~/.gnuradio/config.conf" looks like this: + +\code +[LOG] +log_config = /opt/gr/etc/gnuadio/gr_log_default.xml +log_level = debug +debug_level = Off +\endcode + +Inside of the XML default configuration file, we define the parameters +for the two logger's, the standard logger the separate debug logger. + +If the levels of the two loggers are specified in our configuration +file, as in the above example, these levels override any levels +specified in the XML file. Here, we have turned on the standard logger +(d_logger) to all levels and turned off the debug logger +(d_debug_logger). So even if the debug logger is used in the code, it +will not actually output any information. Conversely, any level of +output passed to the standard logger will output because we have +turned this value to the lowest level "debug." + +If both an XML configuration file is set and the "log_file" or +"debug_file" options are set at the same time, both systems are +actually used. So you can configure file access and the pattern +through the XML file while also still outputting to stdout or stderr. + + +\section advlog Advanced Usage + +The description above for using the logging facilities is specific to +GNU Radio blocks. We have put the code necessary to access the +debugger into the gr_block parent class to simplify access and make +sure all blocks have the ability to quickly and easily use the logger. + +For non gr_block-based code, we have to get some information about the +logger in order to properly access it. Each logger only exists once as +a singleton in the system, but we need to get a pointer to the right +logger and then set it up for our local use. The following code +snippet shows how to do this to get access to the standard logger, +which has a root of "gr_log." (access to the debug logger is similar +except we would use "gr_log_debug." in the GR_LOG_GETLOGGER call): + +\code + gr_prefs *p = gr_prefs::singleton(); + std::string log_file = p->get_string("LOG", "log_config", ""); + std::string log_level = p->get_string("LOG", "log_level", "off"); + GR_CONFIG_LOGGER(log_file); + GR_LOG_GETLOGGER(LOG, "gr_log." + "my_logger_name"); + GR_LOG_SET_LEVEL(LOG, log_level); +\endcode + +This creates a pointer called LOG (which is instantiated as a +log4cpp:LoggerPtr in the macro) that we can now use locally as the +input to our logging macros like 'GR_LOG_INFO(LOG, "message")'. + +*/ diff --git a/docs/doxygen/other/main_page.dox b/docs/doxygen/other/main_page.dox index e7d4685f75..916ac9bdd1 100644 --- a/docs/doxygen/other/main_page.dox +++ b/docs/doxygen/other/main_page.dox @@ -39,11 +39,13 @@ More details on packages in GNU Radio: \li \ref page_vocoder More details on GNU Radio concepts: +\li \ref page_logger \li \ref page_pmt \li \ref page_msg_passing \li \ref page_metadata \li \ref volk_guide \li \ref page_pfb +\li \ref page_tagged_stream_blocks \section flowgraph Operating a Flowgraph @@ -402,4 +404,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/docs/doxygen/other/pfb_intro.dox b/docs/doxygen/other/pfb_intro.dox index 01d08b0fad..2d285f0027 100644 --- a/docs/doxygen/other/pfb_intro.dox +++ b/docs/doxygen/other/pfb_intro.dox @@ -5,8 +5,7 @@ Polyphase filterbanks (PFB) are a very powerful set of filtering tools that can efficiently perform many multi-rate signal processing tasks. GNU Radio has a set of polyphase filterbank blocks to be used -in all sorts of applications. These blocks and their documentation can -be found in \ref pfb_blk. +in all sorts of applications. \section Usage diff --git a/docs/doxygen/other/tagged_stream_blocks.dox b/docs/doxygen/other/tagged_stream_blocks.dox new file mode 100644 index 0000000000..33e2bf6437 --- /dev/null +++ b/docs/doxygen/other/tagged_stream_blocks.dox @@ -0,0 +1,271 @@ +/*! \page page_tagged_stream_blocks Tagged Stream Blocks + +\section intro Introduction + +A tagged stream block is a block that works on streamed, but packetized input data. +Think of packet data transmission: A data packet consists of N bytes. However, in +traditional GNU Radio blocks, if we stream N bytes into a block, there's no way of +knowing the packet boundary. This might be relevant: Perhaps the modulator has to +prepend a synchronisation word before every packet, or append a CRC. So while some +blocks don't care about packet boundaries, other blocks do: These are <em>tagged +stream blocks</em>. + +These blocks are different from all the other GNU Radio block types (gr_block, gr_sync_block etc.) in that they are driven by the input: The PDU length tag tells the block how to +operate, whereas other blocks are output-driven (the scheduler tries to fill up the output +buffer are much as possible). + +\subsection howtheywork How do they work? + +As the name implies, tagged stream blocks use tags to identify PDU boundaries. +On the first item of a streamed PDU, there \em must be a tag with a specific +key, which stores the length of the PDU as a pmt_integer. If anything else, or no tag, +is on this first item, this will cause the flow graph to crash! + +The scheduler then takes care of everything. When the work function is called, it +is guaranteed to contain exactly one complete PDU and enough space in the output buffer for +the output. + +\subsection relatestootherblocks How do they relate to other block types (e.g. sync blocks)? + +Tagged stream blocks and sync blocks are really orthogonal concepts, and a block could be +both (gr::digital::ofdm_frame_equalizer_vcvc is such a block). However, because the work +function is defined differently in these block types, there is no way to derive a block +from both gr_tagged_stream_block and gr_sync_block. + +If a block needs the tagged stream mechanism (i.e. knowing about PDU boundaries), it must be +derived from gr_tagged_stream_block. If it's also a sync block, it is still possible to +set gr_block::set_relative_rate(1.0) and/or the fixed rate functions. + +The way gr_tagged_stream_block works, it is still beneficial to specify a relative rate, +if possible. + + +\section creating Creating a tagged stream block + +To create a tagged stream block, the block must be derived from gr_tagged_stream_block. +Here's a minimal example of how the header file could look: +\code +#include <digital/api.h> +#include <gr_tagged_stream_block.h> + +namespace gr { + namespace digital { + + class DIGITAL_API crc32_bb : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<crc32_bb> sptr; + + static sptr make(bool check=false, const std::string& len_tag_key="packet_len"); + }; + + } // namespace digital +} // namespace gr + +\endcode + +It is very similar to any other block definition. Two things are stand out: First, +gr_tagged_stream_block.h is included to allow deriving from gr_tagged_stream_block. + +The other thing is in the make function: the second argument is a string containing +the key of the length tags. This is not necessary (the block could get this information +hard-coded), but the usual way is to allow the user to change this tag, but give a +default value (in this case, \p packet_len). + +The implementation header (*_impl.h) also looks a bit different (again this is cropped to the relevant parts): +\code +#include <digital/crc32_bb.h> +namespace gr { + namespace digital { + + class crc32_bb_impl : public crc32_bb + { + public: + crc32_bb_impl(bool check, const std::string& len_tag_key); + ~crc32_bb_impl(); + + int calculate_output_stream_length(const gr_vector_int &ninput_items); + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr +\endcode + +First, the \p work function signature is new. The argument list looks like that from +gr_block::general_work() (note: the arguments mean the same, too), but it's called +\p work like with the other derived block types (such as gr_sync_block). Also, there's a new +function: \p calculate_output_stream_length() is, in a sense, the opposite function to +gr_block::forecast(). Given a number of input items, it calculates the required number of +output items. Note how this relates to the fact that these blocks are input-driven. + +These two overrides (\p work() and \p calculate_output_stream_length() ) are what you need +for most tagged stream blocks. There are cases when you don't need to override the latter +because the default behaviour is enough, and other cases where you have to override more +than these two functions. These are discussed in \ref adv_usage. + +Finally, this is part of the actual block implementation (heavily cropped again, to highlight the relevant parts): +\code +#include <gr_io_signature.h> +#include "crc32_bb_impl.h" + +namespace gr { + namespace digital { + + crc32_bb::sptr crc32_bb::make(bool check, const std::string& len_tag_key) + { + return gnuradio::get_initial_sptr (new crc32_bb_impl(check, len_tag_key)); + } + + crc32_bb_impl::crc32_bb_impl(bool check, const std::string& len_tag_key) + : gr_tagged_stream_block("crc32_bb", + gr_make_io_signature(1, 1, sizeof (char)), + gr_make_io_signature(1, 1, sizeof (char)), + len_tag_key), + d_check(check) + { + } + + int + crc32_bb_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + if (d_check) { + return ninput_items[0] - 4; + } else { + return ninput_items[0] + 4; + } + } + + int + crc32_bb_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + + // Do all the signal processing... + // Don't call consume! + + return new_packet_length; + } + + } // namespace digital +} // namespace gr +\endcode + +The make function is not different to any other block. The constructor calls +gr_tagged_stream_block::gr_tagged_stream_block() as expected, but note that it passes the +key of the length tag to the parent constructor. + +The block in question is a CRC block, and it has two modes: It can check the CRC (which is +then dropped), or it can append a CRC to a sequence of bytes. The \p calculate_output_stream_length() function +is thus very simple: depending on how the block is configured, the output is either 4 bytes +longer or shorter than the input stream. + +The \p work() function looks very similar to any other work function. When writing the +signal processing code, the following things must be kept in mind: +- The work function is called for exactly one PDU, and no more (or less) may be processed +- \p ninput_items contains the exact number of items in this PDU (at every port). + These items \em will be consumed after \p work() exits. +- Don't call \p consume() or \p consume_each() yourself! gr_tagged_stream_block will do that + for you. +- You can call \p produce() or \p produce_each(), if you're doing something complicated. + Don't forget to return WORK_CALLED_PRODUCE in that case. + + +\subsection note_on_tp A note on tag propagation + +Despite using tags for a special purpose, all tags that are not the length tag are treated +exactly as before: use gr_block::set_tag_propagation_policy() in the constructor. + +In a lot of the cases, though, you will need to specify set_tag_propagation_policy(TPP_DONT) +and manually handle the tag propagation in \p work(). This is because the unknown length of +the PDUs at compile time prohibits us from setting a precise relative rate of the block, +which is a requirement for automatic tag propagation. +Only if the tagged stream block is also a sync block (including interpolators and decimators, +i.e. blocks with an integer rate change), can automatic tag propagation be reliably used. + +The CRC block seems to a very simple block, but it's already complicated enough to confuse +the automatic tag propagation. For example, what happens to tags which are on the CRC? Do +they get removed, or do they get moved to the last item before the CRC? Also, the input to +output rate is different for every PDU length. + +In this case, it is necessary for the developer to define a tag propagation policy and +implement it in \p work(). Also, it is good practice to specify that tag propagation policy +in the blocks documentation. + +The actual length tags \em are treated differently, though. Most importantly, you don't have +to write the new length tag yourself. The key for the output length tag is the same as that +on the input, if you don't want this, you must override gr_tagged_stream_block::update_length_tags(). + + +\section adv_usage Advanced Usage + +It is generally recommended to read the block documentation of gr_tagged_stream_block. + +A few special cases are described here: + +\subsection multiplelentags Multiple length tags + +In some cases, a single tag is not enough. One example is the OFDM receiver: one OFDM frame contains a certain number of OFDM symbols, and another number of bytes--these numbers are only +very loosely related, and one cannot be calculated from the other. + +gr::digital::ofdm_serializer_vcc is such a block. It is driven by the number of OFDM frames, +but the output is determined by the number of complex symbols. In order to use multiple length +tag keys, it overrides update_length_tags(). + +\subsection backtogrblock Falling back to gr_block behaviour + +If, at compile-time, it is uncertain whether or not a block should be a +gr_tagged_stream_block, there is the possibility of falling back to gr_block behaviour. + +To do this, simple don't pass an empty string as length tag key. Instead of crashing, +a tagged stream block will behave like a gr_block. + +This has some consequences: The work function must have all the elements of a +gr_block::general_work() function, including calls to consume(). Because such a block must +allow both modes of operation (PDUs with tags, and infinite-stream), the work function +must check which mode is currently relevant. Checking if +gr_tagged_stream_block::d_length_tag_key_str is empty is a good choice. + +gr::digital::ofdm_cyclic_prefixer implements this. + +\subsection otherwaysdetermineninput Other ways to determine the number of input items + +If the number of input items is not stored as a pmt::pmt_integer, but there is a way to determine +it, gr_tagged_stream_block::parse_length_tags() can be overridden to figure out the length +of the PDU. + +\section examples Examples + +\subsection CRC32 CRC32 + +Block: gr::digital::crc32_bb + +This is a very simple block, and a good example to start with. + +\subsection ofdmeq OFDM Frame Equalizer + +Block: gr::digital::ofdm_frame_equalizer_vcvc + +This block would be a sync block if tagged stream blocks didn't exist. It also uses more +than one tag to determine the output. + +\subsection muxer Tagged Stream Muxer + +Block: gr::blocks::tagged_stream_mux + +Use this to multiplex any number of tagged streams. + +\subsection ofdmprefixer Cyclic Prefixer (OFDM) + +Block: gr::digital::ofdm_cyclic_prefixer + +This block uses the gr_block behaviour fallback. + +*/ diff --git a/gnuradio-core/CMakeLists.txt b/gnuradio-core/CMakeLists.txt index b277103547..2bbb8570db 100644 --- a/gnuradio-core/CMakeLists.txt +++ b/gnuradio-core/CMakeLists.txt @@ -44,6 +44,7 @@ GR_REGISTER_COMPONENT("gnuradio-core" ENABLE_GR_CORE ) include(GrMiscUtils) + GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/runtime ${CMAKE_CURRENT_BINARY_DIR}/src/lib/general @@ -59,13 +60,17 @@ GR_SET_GLOBAL(GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/src/lib/swig ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/hier + ${CMAKE_BINARY_DIR} ) +list(APPEND GNURADIO_CORE_INCLUDE_DIRS ${CMAKE_BINARY_DIR}) + GR_SET_GLOBAL(GNURADIO_CORE_SWIG_INCLUDE_DIRS ${GNURADIO_CORE_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/swig ${CMAKE_SOURCE_DIR}/gruel/src/swig ${CMAKE_BINARY_DIR}/gruel/src/swig + ${CMAKE_BINARY_DIR} ) ######################################################################## @@ -107,12 +112,26 @@ CPACK_COMPONENT("core_swig" DEPENDS "gruel_swig;core_python;core_devel" ) +# Setup configure file +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-core.conf.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.conf +@ONLY) + install( - FILES gnuradio-core.conf + FILES ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.conf DESTINATION ${GR_PREFSDIR} COMPONENT "core_runtime" ) +if(ENABLE_GR_LOG AND HAVE_LOG4CPP) +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/gr_log_default.xml + DESTINATION ${GR_CONF_DIR}/gnuradio + COMPONENT "core_runtime" +) +endif(ENABLE_GR_LOG AND HAVE_LOG4CPP) + ######################################################################## # Add subdirectories ######################################################################## diff --git a/gnuradio-core/gnuradio-core.conf b/gnuradio-core/gnuradio-core.conf deleted file mode 100644 index d575d1dc8a..0000000000 --- a/gnuradio-core/gnuradio-core.conf +++ /dev/null @@ -1,14 +0,0 @@ -# This file contains system wide configuration data for GNU Radio. -# You may override any setting on a per-user basis by editing -# ~/.gnuradio/config.conf - -[DEFAULT] - -verbose = False - -# The maximum number of messages a block will store up before pruning -# the queue by popping messages from the front. -max_messages = 100 - -[PerfCounters] -on = False diff --git a/gnuradio-core/gnuradio-core.conf.in b/gnuradio-core/gnuradio-core.conf.in new file mode 100644 index 0000000000..25abedb253 --- /dev/null +++ b/gnuradio-core/gnuradio-core.conf.in @@ -0,0 +1,31 @@ +# This file contains system wide configuration data for GNU Radio. +# You may override any setting on a per-user basis by editing +# ~/.gnuradio/config.conf + +[DEFAULT] +verbose = False + +# The maximum number of messages a block will store up before pruning +# the queue by popping messages from the front. +max_messages = 100 + + +[LOG] +# Levels can be (case insensitive): +# DEBUG, INFO, WARN, TRACE, ERROR, ALERT, CRIT, FATAL, EMERG +log_level = debug +debug_level = emerg + +# These file names can either be 'stdout' to output to standard output +# or 'stderr' to output to standard error. Any other string will +# create a file in which to output the logging information. An empty +# string or no value here will ignore this level of configuration +# completely. +log_file = stdout +debug_file = stderr + +# Used for advanced configuration of the logger +#log_config = @CMAKE_INSTALL_PREFIX@/etc/gnuradio/gr_log_default.xml + +[PerfCounters] +on = False diff --git a/gnuradio-core/gr_log_default.xml b/gnuradio-core/gr_log_default.xml new file mode 100644 index 0000000000..13b854c7e8 --- /dev/null +++ b/gnuradio-core/gr_log_default.xml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + * Copyright 2006,2010,2011 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. + */ +--> + + <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> + + <appender name="RootConsoleAppender" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="Root :%p: %c{1} - %m%n"/> + </layout> + </appender> + + <!--Add appender to root to log ALL msgs in one place--> + <root> + <priority value="all" /> + </root> + + <appender name="errLogRootConsoleAppender" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="gr::log :%p: %c{1} - %m%n"/> + </layout> + </appender> + + <!-- Specify the level for some specific loggers--> + <category name="gr_log" > + <priority value ="all" /> + <appender-ref ref="errLogRootConsoleAppender"/> + </category> + + <appender name="errConsoleAppender" class="org.apache.log4j.ConsoleAppender"> + <param name="Target" value="System.out"/> + <layout class="org.apache.log4j.PatternLayout"> + <param name="ConversionPattern" value="gr::debug :%p: %c{1} - %m%n"/> + </layout> + </appender> + + <category name="gr_log_debug" > + <priority value ="DEBUG" /> + <appender-ref ref="errConsoleAppender"/> + </category> + + </log4j:configuration> + diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index 89a1bad88b..da6de8ed1b 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -39,6 +39,21 @@ list(APPEND gnuradio_core_sources bug_work_around_6.cc) list(APPEND test_gnuradio_core_sources bug_work_around_6.cc) ######################################################################## +# Set up Windows DLL resource files +######################################################################## + +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-core.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.rc + @ONLY) + + list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-core.rc) +ENDIF(MSVC) + +######################################################################## # Setup the include and linker paths ######################################################################## include_directories( @@ -54,13 +69,25 @@ link_directories( ${FFTW3F_LIBRARY_DIRS} ) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## + +# Only use if log4cpp is installed +# Define ENABLE_GR_LOG so .h and .cc files can turn actual +# logging and insert dummy functions. +#if(LOG4CPP_FOUND) +# add_definitions(-DENABLE_GR_LOG) +#endif(LOG4CPP_FOUND) + list(APPEND gnuradio_core_libs gruel ${Boost_LIBRARIES} ${FFTW3F_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) if(FFTW3F_THREADS_LIBRARIES) @@ -101,6 +128,6 @@ include_directories(${CPPUNIT_INCLUDE_DIRS}) link_directories(${CPPUNIT_LIBRARY_DIRS}) add_library(test-gnuradio-core SHARED ${test_gnuradio_core_sources}) -target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES}) +target_link_libraries(test-gnuradio-core gnuradio-core ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES}) endif(ENABLE_TESTING) diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h index d144c3eb46..27335702cb 100644 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h +++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccc.h @@ -28,7 +28,6 @@ /*! * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps - * \ingroup filter_blk */ class GR_CORE_API gr_adaptive_fir_ccc : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h index 7ec78099f8..13f4f9620c 100644 --- a/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_adaptive_fir_ccf.h @@ -28,7 +28,6 @@ /*! * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps - * \ingroup filter_blk */ class GR_CORE_API gr_adaptive_fir_ccf : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h index e4d89a775c..5312a9f779 100644 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h +++ b/gnuradio-core/src/lib/filter/gr_dc_blocker_cc.h @@ -48,11 +48,8 @@ typedef boost::shared_ptr<gr_dc_blocker_cc> gr_dc_blocker_cc_sptr; GR_CORE_API gr_dc_blocker_cc_sptr gr_make_dc_blocker_cc (int D=32, bool long_form=true); /*! - * \class gr_dc_blocker_cc * \brief a computationally efficient controllable DC blocker * - * \ingroup filter_blk - * * This block implements a computationally efficient DC blocker that produces * a tighter notch filter around DC for a smaller group delay than an * equivalent FIR filter or using a single pole IIR filter (though the IIR diff --git a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h index d69f24835b..5a60ddce99 100644 --- a/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h +++ b/gnuradio-core/src/lib/filter/gr_dc_blocker_ff.h @@ -49,11 +49,8 @@ typedef boost::shared_ptr<gr_dc_blocker_ff> gr_dc_blocker_ff_sptr; GR_CORE_API gr_dc_blocker_ff_sptr gr_make_dc_blocker_ff (int D=32, bool long_form=true); /*! - * \class gr_dc_blocker_ff * \brief a computationally efficient controllable DC blocker * - * \ingroup filter_blk - * * This block implements a computationally efficient DC blocker that produces * a tighter notch filter around DC for a smaller group delay than an * equivalent FIR filter or using a single pole IIR filter (though the IIR diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h index 4b478b65f7..5f648ee655 100644 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h +++ b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.h @@ -36,7 +36,6 @@ class gri_fft_filter_ccc_generic; /*! * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk */ class GR_CORE_API gr_fft_filter_ccc : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h index 309a551352..e2ca363d23 100644 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h +++ b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.h @@ -36,7 +36,6 @@ class gri_fft_filter_fff_generic; /*! * \brief Fast FFT filter with float input, float output and float taps - * \ingroup filter_blk */ class GR_CORE_API gr_fft_filter_fff : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h index fee11243a5..a80953c0b8 100644 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h +++ b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.h @@ -38,7 +38,6 @@ class gr_fir_fff; /*! * \brief Filter-Delay Combination Block. - * \ingroup filter_blk * * The block takes one or two float stream and outputs a complex * stream. If only one float stream is input, the real output is diff --git a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h b/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h index 3fc6c4855b..dceb6d64ee 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h +++ b/gnuradio-core/src/lib/filter/gr_fir_fcc_x86.h @@ -39,7 +39,7 @@ public: /*! * \brief SSE version of gr_fir_fcc - * \ingroup filter_blk + * \ingroup filter_primitive */ class GR_CORE_API gr_fir_fcc_sse : public gr_fir_fcc_simd { diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t index b32e04bd35..ed72e82cec 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.h.t @@ -39,7 +39,6 @@ class @FIR_TYPE@; /*! * \brief FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk */ class GR_CORE_API @NAME@ : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc index 97b8106994..95e17123c8 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc +++ b/gnuradio-core/src/lib/filter/gr_fir_sysconfig_x86.cc @@ -48,6 +48,7 @@ // #include <gr_fir_sss_mmx.h> // #include <gr_fir_sss_sse2.h> + #include <iostream> using std::cerr; @@ -207,7 +208,7 @@ gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps) if (gr_cpu::has_3dnow ()){ if (first){ - cerr << ">>> gr_fir_fcc: using 3DNow!\n"; + cerr << ">>> gr_fir_fcc: gr_fir_fcc: using 3DNow!\n"; first = false; } return make_gr_fir_fcc_3dnow (taps); @@ -215,7 +216,7 @@ gr_fir_sysconfig_x86::create_gr_fir_fcc (const std::vector<gr_complex> &taps) if (gr_cpu::has_sse ()){ if (first){ - cerr << ">>> gr_fir_fcc: using SSE\n"; + cerr << ">>> gr_fir_fcc: gr_fir_fcc: using SSE\n"; first = false; } return make_gr_fir_fcc_sse (taps); @@ -326,19 +327,26 @@ gr_fir_sysconfig_x86::create_gr_fir_sss (const std::vector<short> &taps) { // FIXME -- probably want to figure out best answer for Athlon and code // add code to select it here... + static bool first = true; if (gr_cpu::has_sse2 ()){ - cerr << ">>> gr_fir_sss: using SSE2\n"; - return make_gr_fir_sss_sse2 (taps); + if(first) { + cerr << ">>> gr_fir_sss: using SSE2\n"; + return make_gr_fir_sss_sse2 (taps); + } } if (gr_cpu::has_mmx ()){ - cerr << ">>> gr_fir_sss: using MMX\n"; - return make_gr_fir_sss_mmx (taps); + if(first) { + cerr << ">>> gr_fir_sss: using MMX\n"; + return make_gr_fir_sss_mmx (taps); + } } - cerr << ">>> gr_fir_sss: handing off to parent class\n"; - return gr_fir_sysconfig_generic::create_gr_fir_sss (taps); + if(first) { + cerr << ">>> gr_fir_sss: handing off to parent class\n"; + return gr_fir_sysconfig_generic::create_gr_fir_sss (taps); + } } #endif diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h index 29c67895a4..c09dafe8e7 100644 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h +++ b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.h @@ -36,7 +36,6 @@ GR_CORE_API gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_c /*! * \brief Interpolating mmse filter with gr_complex input, gr_complex output - * \ingroup filter_blk */ class GR_CORE_API gr_fractional_interpolator_cc : public gr_block { diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h index 7e000a6d1c..b9074baedc 100644 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h +++ b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.h @@ -36,7 +36,6 @@ GR_CORE_API gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_f /*! * \brief Interpolating mmse filter with float input, float output - * \ingroup filter_blk */ class GR_CORE_API gr_fractional_interpolator_ff : public gr_block { diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t index 97d20e04f5..f596f9bd9a 100644 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.h.t @@ -50,7 +50,6 @@ class @FIR_TYPE@; /*! * \brief FIR filter combined with frequency translation with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk * * This class efficiently combines a frequency translation * (typically "down conversion") with a FIR filter (typically low-pass) diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.h b/gnuradio-core/src/lib/filter/gr_goertzel_fc.h index 5fb6e0ee05..da3b44d662 100644 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.h +++ b/gnuradio-core/src/lib/filter/gr_goertzel_fc.h @@ -35,7 +35,6 @@ GR_CORE_API gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float fre /*! * \brief Goertzel single-bin DFT calculation. - * \ingroup dft_blk */ class GR_CORE_API gr_goertzel_fc : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.h b/gnuradio-core/src/lib/filter/gr_hilbert_fc.h index 2bb5ff9e37..a479c70bd2 100644 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.h +++ b/gnuradio-core/src/lib/filter/gr_hilbert_fc.h @@ -39,7 +39,6 @@ class gr_fir_fff; /*! * \brief Hilbert transformer. - * \ingroup filter_blk * * real output is input appropriately delayed. * imaginary output is hilbert filtered (90 degree phase shift) diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h index ab7065e921..e45bb9ca86 100644 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h +++ b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.h @@ -36,7 +36,6 @@ gr_make_iir_filter_ffd (const std::vector<double> &fftaps, /*! * \brief IIR filter with float input, float output and double taps - * \ingroup filter_blk * * This filter uses the Direct Form I implementation, where * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones. diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t index 83904dce21..fe0b9d92b2 100644 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.h.t @@ -39,7 +39,6 @@ class @FIR_TYPE@; /*! * \brief Interpolating FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk */ class GR_CORE_API @NAME@ : public gr_sync_interpolator { diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h index d92898a23e..1c3da10949 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.h @@ -36,14 +36,10 @@ GR_CORE_API gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float r class gr_fir_ccf; /*! - * \class gr_pfb_arb_resampler_ccf - * * \brief Polyphase filterbank arbitrary resampler with * gr_complex input, gr_complex output and float taps * - * \ingroup filter_blk - * \ingroup pfb_blk - * + * This block takes in a signal stream and performs arbitrary * resampling. The resampling rate can be any real * number <EM>r</EM>. The resampling is done by constructing diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h index d2e375210d..1aa55bc24e 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_fff.h @@ -36,14 +36,9 @@ GR_CORE_API gr_pfb_arb_resampler_fff_sptr gr_make_pfb_arb_resampler_fff (float r class gr_fir_fff; /*! - * \class gr_pfb_arb_resampler_fff - * * \brief Polyphase filterbank arbitrary resampler with * float input, float output and float taps * - * \ingroup filter_blk - * \ingroup pfb_blk - * * This block takes in a signal stream and performs arbitrary * resampling. The resampling rate can be any real * number <EM>r</EM>. The resampling is done by constructing diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h index 79ad322f9a..eaf06962a0 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h @@ -39,14 +39,9 @@ class gri_fft_complex; /*! - * \class gr_pfb_channelizer_ccf - * * \brief Polyphase filterbank channelizer with * gr_complex input, gr_complex output and float taps * - * \ingroup filter_blk - * \ingroup pfb_blk - * * This block takes in complex inputs and channelizes it to <EM>M</EM> * channels of equal bandwidth. Each of the resulting channels is * decimated to the new rate that is the input sampling rate diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h index 8715b4b106..01b5de77b8 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.h @@ -39,13 +39,8 @@ GR_CORE_API gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, f class gr_fir_ccf; /*! - * \class gr_pfb_clock_sync_ccf - * * \brief Timing synchronizer using polyphase filterbanks * - * \ingroup filter_blk - * \ingroup pfb_blk - * * This block performs timing synchronization for PAM signals by * minimizing the derivative of the filtered signal, which in turn * maximizes the SNR and minimizes ISI. diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h index 4909d556b9..6807f5761d 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.h @@ -38,13 +38,8 @@ GR_CORE_API gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, f class gr_fir_fff; /*! - * \class gr_pfb_clock_sync_fff - * * \brief Timing synchronizer using polyphase filterbanks * - * \ingroup filter_blk - * \ingroup pfb_blk - * * This block performs timing synchronization for PAM signals by * minimizing the derivative of the filtered signal, which in turn * maximizes the SNR and minimizes ISI. diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h index a2b347ae24..c882b21d9f 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.h @@ -37,13 +37,9 @@ class gr_fir_ccf; class gri_fft_complex; /*! - * \class gr_pfb_decimator_ccf * \brief Polyphase filterbank bandpass decimator with gr_complex * input, gr_complex output and float taps * - * \ingroup filter_blk - * \ingroup pfb_blk - * * This block takes in a signal stream and performs interger down- * sampling (decimation) with a polyphase filterbank. The first input * is the integer specifying how much to decimate by. The second diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h index aeae86e408..25322ecc0d 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.h @@ -35,13 +35,9 @@ GR_CORE_API gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned class gr_fir_ccf; /*! - * \class gr_pfb_interpolator_ccf * \brief Polyphase filterbank interpolator with gr_complex input, * gr_complex output and float taps * - * \ingroup filter_blk - * \ingroup pfb_blk - * * This block takes in a signal stream and performs interger up- * sampling (interpolation) with a polyphase filterbank. The first * input is the integer specifying how much to interpolate by. The diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h index 9e4f85497d..50c467cd31 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_synthesizer_ccf.h @@ -38,13 +38,8 @@ class gri_fft_complex; /*! - * \class gr_pfb_synthesizer_ccf - * * \brief Polyphase synthesis filterbank with * gr_complex input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk */ class GR_CORE_API gr_pfb_synthesizer_ccf : public gr_sync_interpolator diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t index 3eb85a9795..baa97e1ebf 100644 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t +++ b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.h.t @@ -43,7 +43,6 @@ class @FIR_TYPE@; /*! * \brief Rational Resampling Polyphase FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps - * \ingroup filter_blk */ class GR_CORE_API @NAME@ : public gr_block { diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h index 13c595826d..fdcd275ea9 100644 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h +++ b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.h @@ -37,7 +37,6 @@ gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen=1); /*! * \brief single pole IIR filter with complex input, complex output - * \ingroup filter_blk * * The input and output satisfy a difference equation of the form \htmlonly diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h index 8dcdad2c94..13918deb70 100644 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h +++ b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.h @@ -36,7 +36,6 @@ gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen=1); /*! * \brief single pole IIR filter with float input, float output - * \ingroup filter_blk * * The input and output satisfy a difference equation of the form \htmlonly diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h index 648c2b8c54..478cc77202 100644 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h +++ b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_generic.h @@ -31,7 +31,6 @@ class gri_fft_complex; /*! * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk */ class GR_CORE_API gri_fft_filter_ccc_generic { diff --git a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h index 64b8c0c153..7c6dcd18c8 100644 --- a/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h +++ b/gnuradio-core/src/lib/filter/gri_fft_filter_ccc_sse.h @@ -31,7 +31,6 @@ class gri_fft_complex; /*! * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk */ class GR_CORE_API gri_fft_filter_ccc_sse { diff --git a/gnuradio-core/src/lib/general/gr_add_ff.h b/gnuradio-core/src/lib/general/gr_add_ff.h index ff5604c97d..51d7aceae9 100644 --- a/gnuradio-core/src/lib/general/gr_add_ff.h +++ b/gnuradio-core/src/lib/general/gr_add_ff.h @@ -34,7 +34,6 @@ gr_make_add_ff (size_t vlen=1); /*! * \brief Add streams of complex values - * \ingroup math_blk */ class GR_CORE_API gr_add_ff : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h index 1c336306d6..5c2a68b5c9 100644 --- a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h +++ b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.h @@ -45,8 +45,6 @@ GR_CORE_API gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask * the LFSR. Optionally, after 'count' bits have been processed, the shift * register is reset to the seed value. This allows processing fixed length * vectors of samples. - * - * \ingroup coding_blk */ class GR_CORE_API gr_additive_scrambler_bb : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_agc2_cc.h b/gnuradio-core/src/lib/general/gr_agc2_cc.h index 54bae1aae9..ce251fb1d7 100644 --- a/gnuradio-core/src/lib/general/gr_agc2_cc.h +++ b/gnuradio-core/src/lib/general/gr_agc2_cc.h @@ -35,7 +35,6 @@ gr_make_agc2_cc (float attack_rate = 1e-1, float decay_rate = 1e-2, float refere float gain = 1.0, float max_gain = 0.0); /*! * \brief high performance Automatic Gain Control class - * \ingroup level_blk * * For Power the absolute value of the complex number is used. */ diff --git a/gnuradio-core/src/lib/general/gr_agc2_ff.h b/gnuradio-core/src/lib/general/gr_agc2_ff.h index 48529948c0..e4e830a1bc 100644 --- a/gnuradio-core/src/lib/general/gr_agc2_ff.h +++ b/gnuradio-core/src/lib/general/gr_agc2_ff.h @@ -35,7 +35,6 @@ gr_make_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float refere /*! * \brief high performance Automatic Gain Control class * - * \ingroup level_blk * Power is approximated by absolute value */ diff --git a/gnuradio-core/src/lib/general/gr_agc_cc.h b/gnuradio-core/src/lib/general/gr_agc_cc.h index 9f35350dbd..62a6ffb15b 100644 --- a/gnuradio-core/src/lib/general/gr_agc_cc.h +++ b/gnuradio-core/src/lib/general/gr_agc_cc.h @@ -34,7 +34,6 @@ gr_make_agc_cc (float rate = 1e-4, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); /*! * \brief high performance Automatic Gain Control class - * \ingroup level_blk * * For Power the absolute value of the complex number is used. */ diff --git a/gnuradio-core/src/lib/general/gr_agc_ff.h b/gnuradio-core/src/lib/general/gr_agc_ff.h index dc618213bb..14b418782d 100644 --- a/gnuradio-core/src/lib/general/gr_agc_ff.h +++ b/gnuradio-core/src/lib/general/gr_agc_ff.h @@ -35,7 +35,6 @@ gr_make_agc_ff (float rate = 1e-4, float reference = 1.0, /*! * \brief high performance Automatic Gain Control class - * \ingroup level_blk * * Power is approximated by absolute value */ diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h index 1b71a3f4bc..56a7aaa7f5 100644 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h +++ b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.h @@ -28,7 +28,6 @@ /*! * \brief align several complex short (interleaved short) input channels with corresponding unsigned 32 bit sample_counters (provided as interleaved 16 bit values) - * \ingroup misc * \param number of complex_short input channels (including the 32 bit counting channel) * \param align_interval is after how much samples (minimally) the sample-alignement is refreshed. Default is 128. * A bigger value means less processing power but also requests more buffer space, which has a maximum. @@ -37,7 +36,6 @@ * ninput_items_required = 32768 * max_possible_items_available = 16383 * If this is a filter, consider reducing the number of taps." - * \ingroup block * Pay attention on how you connect this block. * It expects a minimum of 2 usrp_source_s with nchan number of channels and FPGA_MODE_COUNTING_32BIT enabled. * This means that the first complex_short channel on every input is an interleaved 32 bit counter. diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.h b/gnuradio-core/src/lib/general/gr_bin_statistics_f.h index dd10759096..21401209cf 100644 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.h +++ b/gnuradio-core/src/lib/general/gr_bin_statistics_f.h @@ -43,7 +43,6 @@ gr_make_bin_statistics_f(unsigned int vlen, // vector length /*! * \brief control scanning and record frequency domain statistics - * \ingroup sink_blk */ class GR_CORE_API gr_bin_statistics_f : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_burst_tagger.h b/gnuradio-core/src/lib/general/gr_burst_tagger.h index 9a7898b043..c0307ff254 100644 --- a/gnuradio-core/src/lib/general/gr_burst_tagger.h +++ b/gnuradio-core/src/lib/general/gr_burst_tagger.h @@ -33,7 +33,6 @@ GR_CORE_API gr_burst_tagger_sptr gr_make_burst_tagger(size_t itemsize); /*! * \brief output[i] = input[i] - * \ingroup misc_blk * */ class GR_CORE_API gr_burst_tagger : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_bytes_to_syms.h b/gnuradio-core/src/lib/general/gr_bytes_to_syms.h index 23e5c6b91b..1dc928ae6c 100644 --- a/gnuradio-core/src/lib/general/gr_bytes_to_syms.h +++ b/gnuradio-core/src/lib/general/gr_bytes_to_syms.h @@ -32,7 +32,6 @@ GR_CORE_API gr_bytes_to_syms_sptr gr_make_bytes_to_syms (); /*! * \brief Convert stream of bytes to stream of +/- 1 symbols - * \ingroup converter_blk * * input: stream of bytes; output: stream of float * diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.h b/gnuradio-core/src/lib/general/gr_char_to_float.h index 5170c618c9..d216f3385c 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_float.h +++ b/gnuradio-core/src/lib/general/gr_char_to_float.h @@ -34,7 +34,6 @@ gr_make_char_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of chars to a stream of float - * \ingroup converter_blk * * \param vlen vector length of data streams. * \param scale a scalar divider to change the output signal scale. diff --git a/gnuradio-core/src/lib/general/gr_char_to_short.h b/gnuradio-core/src/lib/general/gr_char_to_short.h index 7ac5e97b93..be316b0fb6 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_short.h +++ b/gnuradio-core/src/lib/general/gr_char_to_short.h @@ -34,7 +34,6 @@ gr_make_char_to_short (size_t vlen=1); /*! * \brief Convert stream of chars to a stream of float - * \ingroup converter_blk * * \param vlen vector length of data streams. */ diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.h b/gnuradio-core/src/lib/general/gr_check_counting_s.h index 996fa3259f..c304f87d73 100644 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.h +++ b/gnuradio-core/src/lib/general/gr_check_counting_s.h @@ -33,7 +33,6 @@ GR_CORE_API gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit=fal /*! * \brief sink that checks if its input stream consists of a counting sequence. * \param do_32bit expect an interleaved 32 bit counter in stead of 16 bit counter (default false) - * \ingroup sink_blk * * This sink is typically used to test the USRP "Counting Mode" or "Counting mode 32 bit". */ diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h index 2f980b427b..fcaef9085f 100644 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h +++ b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.h @@ -34,7 +34,6 @@ GR_CORE_API gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s (); /*! * \brief sink that checks if its input stream consists of a lfsr_32k sequence. - * \ingroup sink_blk * * This sink is typically used along with gr_lfsr_32k_source_s to test * the USRP using its digital loopback mode. diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h index 66503413ff..5140f8d7af 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h +++ b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.h @@ -35,7 +35,6 @@ gr_make_complex_to_interleaved_short (); /*! * \brief Convert stream of complex to a stream of interleaved shorts - * \ingroup converter_blk */ class GR_CORE_API gr_complex_to_interleaved_short : public gr_sync_interpolator diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h index a2f06ea28c..450b94b069 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.h +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.h @@ -50,7 +50,6 @@ GR_CORE_API gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen=1); /*! * \brief convert a stream of gr_complex to 1 or 2 streams of float - * \ingroup converter_blk * \param vlen vector len (default 1) */ class GR_CORE_API gr_complex_to_float : public gr_sync_block @@ -68,7 +67,6 @@ class GR_CORE_API gr_complex_to_float : public gr_sync_block /*! * \brief complex in, real out (float) - * \ingroup converter_blk * \param vlen vector len (default 1) */ class GR_CORE_API gr_complex_to_real : public gr_sync_block @@ -86,7 +84,6 @@ class GR_CORE_API gr_complex_to_real : public gr_sync_block /*! * \brief complex in, imaginary out (float) - * \ingroup converter_blk * \param vlen vector len (default 1) */ class GR_CORE_API gr_complex_to_imag : public gr_sync_block @@ -104,7 +101,6 @@ class GR_CORE_API gr_complex_to_imag : public gr_sync_block /*! * \brief complex in, magnitude out (float) - * \ingroup converter_blk * \param vlen vector len (default 1) */ class GR_CORE_API gr_complex_to_mag : public gr_sync_block @@ -123,7 +119,6 @@ class GR_CORE_API gr_complex_to_mag : public gr_sync_block /*! * \brief complex in, magnitude squared out (float) - * \ingroup converter_blk * \param vlen vector len (default 1) */ class GR_CORE_API gr_complex_to_mag_squared : public gr_sync_block @@ -141,7 +136,6 @@ class GR_CORE_API gr_complex_to_mag_squared : public gr_sync_block /*! * \brief complex in, angle out (float) - * \ingroup converter_blk * \param vlen vector len (default 1) */ class GR_CORE_API gr_complex_to_arg : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.h b/gnuradio-core/src/lib/general/gr_conjugate_cc.h index e0a2af7164..11d521475f 100644 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.h +++ b/gnuradio-core/src/lib/general/gr_conjugate_cc.h @@ -35,7 +35,6 @@ GR_CORE_API gr_conjugate_cc_sptr gr_make_conjugate_cc (); /*! * \brief output = complex conjugate of input - * \ingroup math_blk */ class GR_CORE_API gr_conjugate_cc : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_constants.h b/gnuradio-core/src/lib/general/gr_constants.h index 00ed9463d8..77d8db0528 100644 --- a/gnuradio-core/src/lib/general/gr_constants.h +++ b/gnuradio-core/src/lib/general/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_CORE_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_CORE_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_CORE_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_CORE_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_CORE_API const std::string gr_version(); diff --git a/gnuradio-core/src/lib/general/gr_copy.h b/gnuradio-core/src/lib/general/gr_copy.h index b0769fa2b1..786ef8061b 100644 --- a/gnuradio-core/src/lib/general/gr_copy.h +++ b/gnuradio-core/src/lib/general/gr_copy.h @@ -33,7 +33,6 @@ GR_CORE_API gr_copy_sptr gr_make_copy(size_t itemsize); /*! * \brief output[i] = input[i] - * \ingroup misc_blk * * When enabled (default), this block copies its input to its output. * When disabled, this block drops its input on the floor. diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h index 345d3004a5..804cdcdefb 100644 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h +++ b/gnuradio-core/src/lib/general/gr_correlate_access_code_tag_bb.h @@ -41,7 +41,6 @@ gr_make_correlate_access_code_tag_bb (const std::string &access_code, int thresh /*! * \brief Examine input for specified access code, one bit at a time. - * \ingroup sync_blk * * input: stream of bits, 1 bit per input byte (data in LSB) * output: unaltered stream of bits (plus tags) diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.h b/gnuradio-core/src/lib/general/gr_cpfsk_bc.h index 6ad2774b3a..348c303e64 100644 --- a/gnuradio-core/src/lib/general/gr_cpfsk_bc.h +++ b/gnuradio-core/src/lib/general/gr_cpfsk_bc.h @@ -32,7 +32,6 @@ GR_CORE_API gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_p /*! * \brief Perform continuous phase 2-level frequency shift keying modulation * on an input stream of unpacked bits. - * \ingroup modulation_blk * * \param k modulation index * \param ampl output amplitude diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h index ef3d13ba7b..9d8a3ca8c4 100644 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h +++ b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.h @@ -35,7 +35,6 @@ gr_make_ctcss_squelch_ff(int rate, float freq, float level=0.01, int len=0, int /*! * \brief gate or zero output if ctcss tone not present - * \ingroup level_blk */ class GR_CORE_API gr_ctcss_squelch_ff : public gr_squelch_base_ff { diff --git a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h index df8e6f449d..15f0e6fff3 100644 --- a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h +++ b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.h @@ -34,7 +34,6 @@ typedef boost::shared_ptr<gr_decode_ccsds_27_fb> gr_decode_ccsds_27_fb_sptr; GR_CORE_API gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb(); /*! \brief A rate 1/2, k=7 convolutional decoder for the CCSDS standard - * \ingroup ecc * * This block performs soft-decision convolutional decoding using the Viterbi * algorithm. diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.h b/gnuradio-core/src/lib/general/gr_deinterleave.h index 0eecc44d13..3cc93b1a41 100644 --- a/gnuradio-core/src/lib/general/gr_deinterleave.h +++ b/gnuradio-core/src/lib/general/gr_deinterleave.h @@ -33,7 +33,6 @@ GR_CORE_API gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize); /*! * \brief deinterleave a single input into N outputs - * \ingroup slicedice_blk */ class GR_CORE_API gr_deinterleave : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/general/gr_delay.h b/gnuradio-core/src/lib/general/gr_delay.h index ed05c47f43..2572355cc0 100644 --- a/gnuradio-core/src/lib/general/gr_delay.h +++ b/gnuradio-core/src/lib/general/gr_delay.h @@ -34,7 +34,6 @@ GR_CORE_API gr_delay_sptr gr_make_delay (size_t itemsize, int delay); /*! * \brief delay the input by a certain number of samples - * \ingroup misc_blk */ class GR_CORE_API gr_delay : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_descrambler_bb.h b/gnuradio-core/src/lib/general/gr_descrambler_bb.h index 333593caaf..c0657f46e9 100644 --- a/gnuradio-core/src/lib/general/gr_descrambler_bb.h +++ b/gnuradio-core/src/lib/general/gr_descrambler_bb.h @@ -39,8 +39,6 @@ GR_CORE_API gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, in * \param mask Polynomial mask for LFSR * \param seed Initial shift register contents * \param len Shift register length - * - * \ingroup coding_blk */ class GR_CORE_API gr_descrambler_bb : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h index c4ebbc4765..d6d51b5dea 100644 --- a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h +++ b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.h @@ -33,7 +33,6 @@ GR_CORE_API gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulu /*! * \brief y[0] = (x[0] - x[-1]) % M - * \ingroup coding_blk * * Differential decoder */ diff --git a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h index e98876b700..556e9bdaf9 100644 --- a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h +++ b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.h @@ -33,7 +33,6 @@ GR_CORE_API gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulu /*! * \brief y[0] = (x[0] + y[-1]) % M - * \ingroup coding_blk * * Differential encoder */ diff --git a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h index 21c4f616d5..6f4632c952 100644 --- a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h +++ b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.h @@ -28,7 +28,6 @@ /*! * \brief Please fix my documentation! - * \ingroup misc */ class gr_diff_phasor_cc; typedef boost::shared_ptr<gr_diff_phasor_cc> gr_diff_phasor_cc_sptr; diff --git a/gnuradio-core/src/lib/general/gr_dpll_bb.h b/gnuradio-core/src/lib/general/gr_dpll_bb.h index a7df974fb4..4875600479 100644 --- a/gnuradio-core/src/lib/general/gr_dpll_bb.h +++ b/gnuradio-core/src/lib/general/gr_dpll_bb.h @@ -33,7 +33,6 @@ GR_CORE_API gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain); /*! * \brief Detect the peak of a signal - * \ingroup level_blk * * If a peak is detected, this block outputs a 1, * or it outputs 0's. diff --git a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h index 94e9c33f1b..a480c0828f 100644 --- a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h +++ b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.h @@ -30,7 +30,6 @@ typedef boost::shared_ptr<gr_encode_ccsds_27_bb> gr_encode_ccsds_27_bb_sptr; GR_CORE_API gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb(); /*! \brief A rate 1/2, k=7 convolutional encoder for the CCSDS standard - * \ingroup ecc * * This block performs convolutional encoding using the CCSDS standard * polynomial ("Voyager"). diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h index 45808752d3..33e5b9cc7b 100644 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h +++ b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.h @@ -34,7 +34,6 @@ gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen); /*! * \brief pad packet with alternating 1,0 pattern. - * \ingroup coding_blk * * input: stream of byte vectors; output: stream of byte vectors */ @@ -66,7 +65,6 @@ gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen); /*! * \brief remove fake padding from packet - * \ingroup coding_blk * * input: stream of byte vectors; output: stream of byte vectors */ diff --git a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h index 63e5e4c436..c76337a017 100644 --- a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h +++ b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.h @@ -34,7 +34,6 @@ gr_make_feedforward_agc_cc(int nsamples, float reference = 1.0); /*! * \brief Non-causal AGC which computes required gain based on max absolute value over nsamples - * \ingroup level_blk */ class GR_CORE_API gr_feedforward_agc_cc : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc.h b/gnuradio-core/src/lib/general/gr_fft_vcc.h index db5690d41d..472e4d5e7f 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vcc.h +++ b/gnuradio-core/src/lib/general/gr_fft_vcc.h @@ -36,7 +36,6 @@ gr_make_fft_vcc (int fft_size, bool forward, /*! * \brief Compute forward or reverse FFT. complex vector in / complex vector out. - * \ingroup dft_blk * * Abstract base class */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h index 967ceaefb6..d6f825fe5e 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h +++ b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.h @@ -35,7 +35,6 @@ gr_make_fft_vcc_fftw (int fft_size, bool forward, /*! * \brief Compute forward or reverse FFT. complex vector in / complex vector out. - * \ingroup dft_blk * * Concrete class that uses FFTW. */ diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.h b/gnuradio-core/src/lib/general/gr_fft_vfc.h index 35b95313d3..aba6e697a3 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.h +++ b/gnuradio-core/src/lib/general/gr_fft_vfc.h @@ -38,7 +38,6 @@ gr_make_fft_vfc (int fft_size, bool forward, /*! * \brief Compute forward FFT. float vector in / complex vector out. - * \ingroup dft_blk */ class GR_CORE_API gr_fft_vfc : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.h b/gnuradio-core/src/lib/general/gr_float_to_char.h index 2df50f18d5..92c828948d 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.h +++ b/gnuradio-core/src/lib/general/gr_float_to_char.h @@ -34,7 +34,6 @@ gr_make_float_to_char (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of char - * \ingroup converter_blk * * \param vlen vector length of data streams. * \param scale a scalar multiplier to change the output signal scale. diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.h b/gnuradio-core/src/lib/general/gr_float_to_complex.h index 628b4a954e..87c4954c29 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.h +++ b/gnuradio-core/src/lib/general/gr_float_to_complex.h @@ -35,7 +35,6 @@ gr_make_float_to_complex (size_t vlen = 1); /*! * \brief Convert 1 or 2 streams of float to a stream of gr_complex - * \ingroup converter_blk */ class GR_CORE_API gr_float_to_complex : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_float_to_int.h b/gnuradio-core/src/lib/general/gr_float_to_int.h index c10ea739d2..f4053a7682 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_int.h +++ b/gnuradio-core/src/lib/general/gr_float_to_int.h @@ -34,7 +34,6 @@ gr_make_float_to_int (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of short - * \ingroup converter_blk * * \param vlen vector length of data streams. * \param scale a scalar multiplier to change the output signal scale. diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.h b/gnuradio-core/src/lib/general/gr_float_to_short.h index 9e43804f54..968d5fbc7f 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.h +++ b/gnuradio-core/src/lib/general/gr_float_to_short.h @@ -34,7 +34,6 @@ gr_make_float_to_short (size_t vlen=1, float scale=1); /*! * \brief Convert stream of float to a stream of short - * \ingroup converter_blk * * \param vlen vector length of data streams. * \param scale a scalar multiplier to change the output signal scale. diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.h b/gnuradio-core/src/lib/general/gr_float_to_uchar.h index 7fd947048a..ca7e3cf1ca 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.h +++ b/gnuradio-core/src/lib/general/gr_float_to_uchar.h @@ -34,7 +34,6 @@ gr_make_float_to_uchar (); /*! * \brief Convert stream of float to a stream of unsigned char - * \ingroup converter_blk */ class GR_CORE_API gr_float_to_uchar : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_framer_sink_1.h b/gnuradio-core/src/lib/general/gr_framer_sink_1.h index 93e41745f3..796189bfc7 100644 --- a/gnuradio-core/src/lib/general/gr_framer_sink_1.h +++ b/gnuradio-core/src/lib/general/gr_framer_sink_1.h @@ -35,7 +35,6 @@ gr_make_framer_sink_1 (gr_msg_queue_sptr target_queue); /*! * \brief Given a stream of bits and access_code flags, assemble packets. - * \ingroup sink_blk * * input: stream of bytes from gr_correlate_access_code_bb * output: none. Pushes assembled packet into target queue diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h index c680e96480..441610644e 100644 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h +++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.h @@ -33,7 +33,6 @@ GR_CORE_API gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (doubl /*! * \brief Frequency modulator block - * \ingroup modulation_blk * * float input; complex baseband output */ diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_b.h b/gnuradio-core/src/lib/general/gr_glfsr_source_b.h index 7549a76b32..4ac63f44c1 100644 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_b.h +++ b/gnuradio-core/src/lib/general/gr_glfsr_source_b.h @@ -35,7 +35,6 @@ GR_CORE_API gr_glfsr_source_b_sptr gr_make_glfsr_source_b(int degree, bool repea /*! * \brief Galois LFSR pseudo-random source - * \ingroup source_blk */ class GR_CORE_API gr_glfsr_source_b : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_f.h b/gnuradio-core/src/lib/general/gr_glfsr_source_f.h index 3549e3e5df..2f0c003f1c 100644 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_f.h +++ b/gnuradio-core/src/lib/general/gr_glfsr_source_f.h @@ -35,7 +35,6 @@ GR_CORE_API gr_glfsr_source_f_sptr gr_make_glfsr_source_f(int degree, bool repea /*! * \brief Galois LFSR pseudo-random source generating float outputs -1.0 - 1.0 - * \ingroup source_blk */ class GR_CORE_API gr_glfsr_source_f : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h index 48415892dd..dd1b625d88 100644 --- a/gnuradio-core/src/lib/general/gr_head.h +++ b/gnuradio-core/src/lib/general/gr_head.h @@ -32,7 +32,6 @@ typedef boost::shared_ptr<gr_head> gr_head_sptr; /*! * \brief copies the first N items to the output then signals done - * \ingroup slicedice_blk * * Useful for building test cases */ diff --git a/gnuradio-core/src/lib/general/gr_int_to_float.h b/gnuradio-core/src/lib/general/gr_int_to_float.h index 6200c5be75..0b3be88a6e 100644 --- a/gnuradio-core/src/lib/general/gr_int_to_float.h +++ b/gnuradio-core/src/lib/general/gr_int_to_float.h @@ -34,7 +34,6 @@ gr_make_int_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of int to a stream of float - * \ingroup converter_blk * * \param vlen vector length of data streams. * \param scale a scalar divider to change the output signal scale. diff --git a/gnuradio-core/src/lib/general/gr_interleave.h b/gnuradio-core/src/lib/general/gr_interleave.h index 3b0202d008..c90a69ac45 100644 --- a/gnuradio-core/src/lib/general/gr_interleave.h +++ b/gnuradio-core/src/lib/general/gr_interleave.h @@ -33,7 +33,6 @@ GR_CORE_API gr_interleave_sptr gr_make_interleave (size_t itemsize); /*! * \brief interleave N inputs to a single output - * \ingroup slicedice_blk */ class GR_CORE_API gr_interleave : public gr_sync_interpolator { diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h index 159d107b33..f43b38ae11 100644 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h +++ b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.h @@ -35,7 +35,6 @@ gr_make_interleaved_short_to_complex (); /*! * \brief Convert stream of interleaved shorts to a stream of complex - * \ingroup converter_blk */ class GR_CORE_API gr_interleaved_short_to_complex : public gr_sync_decimator diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h b/gnuradio-core/src/lib/general/gr_iqcomp_cc.h index 2f5a44ebfb..21d57b0701 100644 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.h +++ b/gnuradio-core/src/lib/general/gr_iqcomp_cc.h @@ -34,7 +34,6 @@ GR_CORE_API gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu); /*! * \brief - * \ingroup misc_blk */ class GR_CORE_API gr_iqcomp_cc : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h index c6bf40ecf2..3e7482529d 100644 --- a/gnuradio-core/src/lib/general/gr_keep_m_in_n.h +++ b/gnuradio-core/src/lib/general/gr_keep_m_in_n.h @@ -35,7 +35,6 @@ gr_make_keep_m_in_n (size_t item_size, int m, int n, int offset); /*! * \brief decimate a stream, keeping one item out of every n. - * \ingroup slicedice_blk */ class GR_CORE_API gr_keep_m_in_n : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h index f37475204b..734716cfdf 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.h +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.h @@ -35,7 +35,6 @@ gr_make_keep_one_in_n (size_t item_size, int n); /*! * \brief decimate a stream, keeping one item out of every n. - * \ingroup slicedice_blk */ class GR_CORE_API gr_keep_one_in_n : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_kludge_copy.h b/gnuradio-core/src/lib/general/gr_kludge_copy.h index 0bcf144699..4e93e52408 100644 --- a/gnuradio-core/src/lib/general/gr_kludge_copy.h +++ b/gnuradio-core/src/lib/general/gr_kludge_copy.h @@ -33,7 +33,6 @@ GR_CORE_API gr_kludge_copy_sptr gr_make_kludge_copy(size_t itemsize); /*! * \brief output[i] = input[i] - * \ingroup misc_blk * * This is a short term kludge to work around a problem with the hierarchical block impl. */ diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h index db107652ad..cb5a4e9b5c 100644 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h +++ b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.h @@ -34,7 +34,6 @@ GR_CORE_API gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s (); /*! * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts) - * \ingroup source_blk * * This source is typically used along with gr_check_lfsr_32k_s to test * the USRP using its digital loopback mode. diff --git a/gnuradio-core/src/lib/general/gr_map_bb.h b/gnuradio-core/src/lib/general/gr_map_bb.h index 0a2f5a45f8..800ac1c851 100644 --- a/gnuradio-core/src/lib/general/gr_map_bb.h +++ b/gnuradio-core/src/lib/general/gr_map_bb.h @@ -32,7 +32,6 @@ GR_CORE_API gr_map_bb_sptr gr_make_map_bb(const std::vector<int> &map); /*! * \brief output[i] = map[input[i]] - * \ingroup coding_blk */ class GR_CORE_API gr_map_bb : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_message_strobe.h b/gnuradio-core/src/lib/general/gr_message_strobe.h index 89046ffc05..61cac50880 100644 --- a/gnuradio-core/src/lib/general/gr_message_strobe.h +++ b/gnuradio-core/src/lib/general/gr_message_strobe.h @@ -35,7 +35,6 @@ GR_CORE_API gr_message_strobe_sptr gr_make_message_strobe (pmt::pmt_t msg, float /*! * \brief Send message at defined interval - * \ingroup msg_blk */ class GR_CORE_API gr_message_strobe : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_multiply_cc.h b/gnuradio-core/src/lib/general/gr_multiply_cc.h index d25935b4ca..cff0c0713f 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_cc.h +++ b/gnuradio-core/src/lib/general/gr_multiply_cc.h @@ -34,7 +34,6 @@ gr_make_multiply_cc (size_t vlen=1); /*! * \brief Multiply streams of complex values - * \ingroup math_blk */ class GR_CORE_API gr_multiply_cc : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h index 826e287714..61c2677400 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h +++ b/gnuradio-core/src/lib/general/gr_multiply_conjugate_cc.h @@ -35,7 +35,6 @@ gr_make_multiply_conjugate_cc (size_t vlen=1); /*! * \brief Multiplies a stream by the conjugate of the second stream - * \ingroup math_blk */ class GR_CORE_API gr_multiply_conjugate_cc : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_cc.h b/gnuradio-core/src/lib/general/gr_multiply_const_cc.h index 97962abc70..2f960a920a 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_const_cc.h +++ b/gnuradio-core/src/lib/general/gr_multiply_const_cc.h @@ -34,7 +34,6 @@ gr_make_multiply_const_cc (gr_complex k, size_t vlen=1); /*! * \brief Multiply stream of complex values with a constant \p k - * \ingroup math_blk */ class GR_CORE_API gr_multiply_const_cc : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_multiply_const_ff.h b/gnuradio-core/src/lib/general/gr_multiply_const_ff.h index fac73f88a2..265a946df0 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_const_ff.h +++ b/gnuradio-core/src/lib/general/gr_multiply_const_ff.h @@ -34,7 +34,6 @@ gr_make_multiply_const_ff (float k, size_t vlen=1); /*! * \brief Multiply stream of float values with a constant \p k - * \ingroup math_blk */ class GR_CORE_API gr_multiply_const_ff : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_multiply_ff.h b/gnuradio-core/src/lib/general/gr_multiply_ff.h index ed628385ce..e7adde7218 100644 --- a/gnuradio-core/src/lib/general/gr_multiply_ff.h +++ b/gnuradio-core/src/lib/general/gr_multiply_ff.h @@ -34,7 +34,6 @@ gr_make_multiply_ff (size_t vlen=1); /*! * \brief Multiply streams of complex values - * \ingroup math_blk */ class GR_CORE_API gr_multiply_ff : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.h b/gnuradio-core/src/lib/general/gr_nlog10_ff.h index cfeba3feeb..34084f2a09 100644 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.h +++ b/gnuradio-core/src/lib/general/gr_nlog10_ff.h @@ -32,7 +32,6 @@ GR_CORE_API gr_nlog10_ff_sptr gr_make_nlog10_ff (float n=1.0, unsigned vlen=1, f /*! * \brief output = n*log10(input) + k - * \ingroup math_blk */ class GR_CORE_API gr_nlog10_ff : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_nop.h b/gnuradio-core/src/lib/general/gr_nop.h index e0d59280f9..9fd1d13813 100644 --- a/gnuradio-core/src/lib/general/gr_nop.h +++ b/gnuradio-core/src/lib/general/gr_nop.h @@ -35,7 +35,6 @@ gr_make_nop (size_t sizeof_stream_item); /*! * \brief Does nothing. Used for testing only. - * \ingroup misc_blk */ class GR_CORE_API gr_nop : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_null_sink.h b/gnuradio-core/src/lib/general/gr_null_sink.h index 7374293295..9f1e0f99fb 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.h +++ b/gnuradio-core/src/lib/general/gr_null_sink.h @@ -35,7 +35,6 @@ gr_make_null_sink (size_t sizeof_stream_item); /*! * \brief Bit bucket - * \ingroup sink_blk */ class GR_CORE_API gr_null_sink : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_null_source.h b/gnuradio-core/src/lib/general/gr_null_source.h index 1c64e8bd98..0059d0310b 100644 --- a/gnuradio-core/src/lib/general/gr_null_source.h +++ b/gnuradio-core/src/lib/general/gr_null_source.h @@ -34,7 +34,6 @@ gr_make_null_source (size_t sizeof_stream_item); /*! * \brief A source of zeros. - * \ingroup source_blk */ class GR_CORE_API gr_null_source : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h index a743e8c5a5..095316e07d 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h +++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink2.h @@ -39,8 +39,6 @@ gr_make_ofdm_frame_sink2 (gr_constellation_sptr constell, /*! * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs * them into packets, and sends to to a message queue sink. - * \ingroup sink_blk - * \ingroup ofdm_blk * * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually, * we want to be able to pass in a reference to an object to do the demapping and slicing diff --git a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h index 8e1508c78b..4b9c1c20aa 100644 --- a/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h +++ b/gnuradio-core/src/lib/general/gr_pack_k_bits_bb.h @@ -34,7 +34,6 @@ class gr_pack_k_bits_bb; /*! * \brief Converts a stream of bytes with 1 bit in the LSB to a byte with k relevent bits. - * \ingroup converter_blk */ class GR_CORE_API gr_pack_k_bits_bb : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/general/gr_packet_sink.h b/gnuradio-core/src/lib/general/gr_packet_sink.h index b4cb0b0f6e..cbb9b7715b 100644 --- a/gnuradio-core/src/lib/general/gr_packet_sink.h +++ b/gnuradio-core/src/lib/general/gr_packet_sink.h @@ -37,7 +37,6 @@ gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, ); /*! * \brief process received bits looking for packet sync, header, and process bits into packet - * \ingroup sink_blk */ class GR_CORE_API gr_packet_sink : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h index 665a6b882c..2a37de2c7b 100644 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h +++ b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.h @@ -35,7 +35,6 @@ GR_CORE_API gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold /*! * \brief Detect the peak of a signal - * \ingroup level_blk * * If a peak is detected, this block outputs a 1, * or it outputs 0's. A separate debug output may be connected, to diff --git a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h index 07f3b82d4c..999d0f0123 100644 --- a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h +++ b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.h @@ -33,7 +33,6 @@ GR_CORE_API gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensit /*! * \brief Phase modulator block - * \ingroup modulation_blk * output=complex(cos(in*sensitivity),sin(in*sensitivity)) */ class GR_CORE_API gr_phase_modulator_fc : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h index b3bc5ddd0c..abcd0052c0 100644 --- a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h +++ b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.h @@ -36,7 +36,6 @@ GR_CORE_API gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float /*! * \brief Implements a PLL which locks to the input frequency and outputs the * input signal mixed with that carrier. - * \ingroup sync_blk * * input: stream of complex; output: stream of complex * diff --git a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h index 3dfc8d7093..765e347fe4 100644 --- a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h +++ b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.h @@ -36,7 +36,6 @@ GR_CORE_API gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float loop_bw, /*! * \brief Implements a PLL which locks to the input frequency and outputs * an estimate of that frequency. Useful for FM Demod. - * \ingroup sync_blk * * input: stream of complex; output: stream of floats * diff --git a/gnuradio-core/src/lib/general/gr_pll_refout_cc.h b/gnuradio-core/src/lib/general/gr_pll_refout_cc.h index ef5cd31e27..01555b569a 100644 --- a/gnuradio-core/src/lib/general/gr_pll_refout_cc.h +++ b/gnuradio-core/src/lib/general/gr_pll_refout_cc.h @@ -34,7 +34,6 @@ GR_CORE_API gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float loop_bw, float max_freq, float min_freq); /*! * \brief Implements a PLL which locks to the input frequency and outputs a carrier - * \ingroup sync_blk * * input: stream of complex; output: stream of complex * diff --git a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h index 69bd2c502f..db67ae5266 100644 --- a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h +++ b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.h @@ -35,7 +35,6 @@ gr_make_pn_correlator_cc(int degree, int mask=0, int seed=1); /*! * \brief PN code sequential search correlator * - * \ingroup sync_blk * Receives complex baseband signal, outputs complex correlation against * reference PN code, one sample per PN code period */ diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h index 2811677cfc..c1264c0ab5 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.h @@ -34,7 +34,6 @@ gr_make_probe_avg_mag_sqrd_c (double threshold_db, double alpha = 0.0001); /*! * \brief compute avg magnitude squared. - * \ingroup sink_blk * * input: gr_complex * diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h index bb5d1ebf91..495f758c17 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.h @@ -34,7 +34,6 @@ gr_make_probe_avg_mag_sqrd_cf (double threshold_db, double alpha = 0.0001); /*! * \brief compute avg magnitude squared. - * \ingroup sink_blk * * input: gr_complex * output: gr_float diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h index b2efcc64eb..7eac0302db 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.h @@ -34,7 +34,6 @@ gr_make_probe_avg_mag_sqrd_f (double threshold_db, double alpha = 0.0001); /*! * \brief compute avg magnitude squared. - * \ingroup sink_blk * * input: float * diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h index b2b4624f58..b47acb9c37 100644 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h +++ b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.h @@ -36,7 +36,6 @@ gr_make_pwr_squelch_cc(double db, double alpha = 0.0001, int ramp=0, bool gate=f /*! * \brief gate or zero output when input power below threshold - * \ingroup level_blk */ class GR_CORE_API gr_pwr_squelch_cc : public gr_squelch_base_cc { diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h index d5148c4096..ab63f1b866 100644 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h +++ b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.h @@ -36,7 +36,6 @@ gr_make_pwr_squelch_ff(double db, double alpha = 0.0001, int ramp=0, bool gate=f /*! * \brief gate or zero output when input power below threshold - * \ingroup level_blk */ class GR_CORE_API gr_pwr_squelch_ff : public gr_squelch_base_ff { diff --git a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h index 9f5976c971..eb3f1cb980 100644 --- a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h +++ b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.h @@ -32,7 +32,6 @@ GR_CORE_API gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain) /*! * \brief quadrature demodulator: complex in, float out - * \ingroup demodulation_blk * * This can be used to demod FM, FSK, GMSK, etc. * The input is complex baseband. diff --git a/gnuradio-core/src/lib/general/gr_rail_ff.h b/gnuradio-core/src/lib/general/gr_rail_ff.h index 29db5b1fa1..b34194f936 100644 --- a/gnuradio-core/src/lib/general/gr_rail_ff.h +++ b/gnuradio-core/src/lib/general/gr_rail_ff.h @@ -28,7 +28,6 @@ /*! * \brief clips input values to min, max - * \ingroup misc */ class gr_rail_ff; diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.h b/gnuradio-core/src/lib/general/gr_random_pdu.h index e6457d21b6..8b8beb676f 100644 --- a/gnuradio-core/src/lib/general/gr_random_pdu.h +++ b/gnuradio-core/src/lib/general/gr_random_pdu.h @@ -38,7 +38,6 @@ GR_CORE_API gr_random_pdu_sptr gr_make_random_pdu (int mintime, int maxtime); /*! * \brief Send message at defined interval - * \ingroup msg_blk */ class GR_CORE_API gr_random_pdu : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.h b/gnuradio-core/src/lib/general/gr_regenerate_bb.h index e820db69e8..20b6edc2ee 100644 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.h +++ b/gnuradio-core/src/lib/general/gr_regenerate_bb.h @@ -33,7 +33,6 @@ GR_CORE_API gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned in /*! * \brief Detect the peak of a signal and repeat every period samples - * \ingroup level_blk * * If a peak is detected, this block outputs a 1 repeated every period samples * until reset by detection of another 1 on the input or stopped after max_regen diff --git a/gnuradio-core/src/lib/general/gr_repeat.h b/gnuradio-core/src/lib/general/gr_repeat.h index 548ca79f4d..f434eaf6d9 100644 --- a/gnuradio-core/src/lib/general/gr_repeat.h +++ b/gnuradio-core/src/lib/general/gr_repeat.h @@ -33,7 +33,6 @@ GR_CORE_API gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp); /*! * \brief Repeat a sample 'interp' times in output stream - * \ingroup misc_blk */ class GR_CORE_API gr_repeat : public gr_sync_interpolator diff --git a/gnuradio-core/src/lib/general/gr_rms_cf.h b/gnuradio-core/src/lib/general/gr_rms_cf.h index 9e701aa6a0..809d937998 100644 --- a/gnuradio-core/src/lib/general/gr_rms_cf.h +++ b/gnuradio-core/src/lib/general/gr_rms_cf.h @@ -34,7 +34,6 @@ gr_make_rms_cf (double alpha = 0.0001); /*! * \brief RMS average power - * \ingroup math_blk */ class GR_CORE_API gr_rms_cf : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_rms_ff.h b/gnuradio-core/src/lib/general/gr_rms_ff.h index 30cf7f9d9f..34c1a2f4a8 100644 --- a/gnuradio-core/src/lib/general/gr_rms_ff.h +++ b/gnuradio-core/src/lib/general/gr_rms_ff.h @@ -34,7 +34,6 @@ gr_make_rms_ff (double alpha = 0.0001); /*! * \brief RMS average power - * \ingroup math_blk */ class GR_CORE_API gr_rms_ff : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_scrambler_bb.h b/gnuradio-core/src/lib/general/gr_scrambler_bb.h index edb429e0a0..f302077d01 100644 --- a/gnuradio-core/src/lib/general/gr_scrambler_bb.h +++ b/gnuradio-core/src/lib/general/gr_scrambler_bb.h @@ -39,8 +39,6 @@ GR_CORE_API gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int le * \param mask Polynomial mask for LFSR * \param seed Initial shift register contents * \param len Shift register length - * - * \ingroup coding_blk */ class GR_CORE_API gr_scrambler_bb : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_short_to_char.h b/gnuradio-core/src/lib/general/gr_short_to_char.h index bf96211c7c..03b2dbfcfa 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_char.h +++ b/gnuradio-core/src/lib/general/gr_short_to_char.h @@ -34,7 +34,6 @@ gr_make_short_to_char (size_t vlen=1); /*! * \brief Convert stream of short to a stream of float - * \ingroup converter_blk * * \param vlen vector length of data streams. */ diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.h b/gnuradio-core/src/lib/general/gr_short_to_float.h index 362549e70a..78212fda49 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.h +++ b/gnuradio-core/src/lib/general/gr_short_to_float.h @@ -34,7 +34,6 @@ gr_make_short_to_float (size_t vlen=1, float scale=1); /*! * \brief Convert stream of short to a stream of float - * \ingroup converter_blk * * \param vlen vector length of data streams. * \param scale a scalar divider to change the output signal scale. diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.h b/gnuradio-core/src/lib/general/gr_simple_correlator.h index 37d00c125e..9909d58755 100644 --- a/gnuradio-core/src/lib/general/gr_simple_correlator.h +++ b/gnuradio-core/src/lib/general/gr_simple_correlator.h @@ -36,7 +36,6 @@ GR_CORE_API gr_simple_correlator_sptr gr_make_simple_correlator (int payload_byt /*! * \brief inverse of gr_simple_framer (more or less) - * \ingroup sync_blk */ class GR_CORE_API gr_simple_correlator : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_simple_framer.h b/gnuradio-core/src/lib/general/gr_simple_framer.h index 76a4b7baba..de7a96321d 100644 --- a/gnuradio-core/src/lib/general/gr_simple_framer.h +++ b/gnuradio-core/src/lib/general/gr_simple_framer.h @@ -33,7 +33,6 @@ GR_CORE_API gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize); /*! * \brief add sync field, seq number and command field to payload - * \ingroup sync_blk */ class GR_CORE_API gr_simple_framer : public gr_block { diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h index 4bf62c7ec6..a26f087a12 100644 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h +++ b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.h @@ -34,7 +34,6 @@ gr_make_simple_squelch_cc (double threshold_db, double alpha = 0.0001); /*! * \brief simple squelch block based on average signal power and threshold in dB. - * \ingroup level_blk */ class GR_CORE_API gr_simple_squelch_cc : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_skiphead.h b/gnuradio-core/src/lib/general/gr_skiphead.h index 899b40f27a..ff42a3eeda 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.h +++ b/gnuradio-core/src/lib/general/gr_skiphead.h @@ -36,7 +36,6 @@ gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); /*! * \brief skips the first N items, from then on copies items to the output - * \ingroup slicedice_blk * * Useful for building test cases and sources which have metadata or junk at the start */ diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.h b/gnuradio-core/src/lib/general/gr_stream_mux.h index 742bf082d1..fa1ee3e7ae 100644 --- a/gnuradio-core/src/lib/general/gr_stream_mux.h +++ b/gnuradio-core/src/lib/general/gr_stream_mux.h @@ -31,7 +31,6 @@ /*! * \brief Creates a stream muxing block to multiplex many streams into * one with a specified format. - * \ingroup converter_blk * * \param itemsize the item size of the stream * \param length a vector (list/tuple) specifying the number of diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.h b/gnuradio-core/src/lib/general/gr_stream_to_streams.h index 117f57bf5e..f1d3b26975 100644 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.h +++ b/gnuradio-core/src/lib/general/gr_stream_to_streams.h @@ -34,7 +34,6 @@ gr_make_stream_to_streams (size_t item_size, size_t nstreams); /*! * \brief convert a stream of items into a N streams of items - * \ingroup slicedice_blk * * Converts a stream of N items into N streams of 1 item. * Repeat ad infinitum. diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.h b/gnuradio-core/src/lib/general/gr_stream_to_vector.h index 362349965f..92d5e5a03e 100644 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.h +++ b/gnuradio-core/src/lib/general/gr_stream_to_vector.h @@ -35,7 +35,6 @@ gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block); /*! * \brief convert a stream of items into a stream of blocks containing nitems_per_block - * \ingroup slicedice_blk */ class GR_CORE_API gr_stream_to_vector : public gr_sync_decimator { diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.h b/gnuradio-core/src/lib/general/gr_streams_to_stream.h index f636837675..1af60ff53e 100644 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.h +++ b/gnuradio-core/src/lib/general/gr_streams_to_stream.h @@ -34,7 +34,6 @@ gr_make_streams_to_stream (size_t item_size, size_t nstreams); /*! * \brief Convert N streams of 1 item into a 1 stream of N items - * \ingroup slicedice_blk * * Convert N streams of 1 item into 1 stream of N items. * Repeat ad infinitum. diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.h b/gnuradio-core/src/lib/general/gr_streams_to_vector.h index 1df2890999..3f94bfd7c8 100644 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.h +++ b/gnuradio-core/src/lib/general/gr_streams_to_vector.h @@ -35,7 +35,6 @@ gr_make_streams_to_vector (size_t item_size, size_t nstreams); /*! * \brief convert N streams of items to 1 stream of vector length N - * \ingroup slicedice_blk */ class GR_CORE_API gr_streams_to_vector : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.h b/gnuradio-core/src/lib/general/gr_stretch_ff.h index f592c94a78..3578da8073 100644 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.h +++ b/gnuradio-core/src/lib/general/gr_stretch_ff.h @@ -30,7 +30,6 @@ * \brief adjust y-range of an input vector by mapping to range * (max-of-input, stipulated-min). Primarily for spectral signature * matching by normalizing spectrum dynamic ranges. - * \ingroup misc_blk */ diff --git a/gnuradio-core/src/lib/general/gr_tag_debug.h b/gnuradio-core/src/lib/general/gr_tag_debug.h index 57578884a8..f919acfc4f 100644 --- a/gnuradio-core/src/lib/general/gr_tag_debug.h +++ b/gnuradio-core/src/lib/general/gr_tag_debug.h @@ -36,7 +36,6 @@ gr_make_tag_debug(size_t sizeof_stream_item, const std::string &name); /*! * \brief Bit bucket that prints out any tag received. - * \ingroup sink_blk * * This block collects all tags sent to it on all input ports and * displays them to stdout in a formatted way. The \p name parameter diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.h b/gnuradio-core/src/lib/general/gr_threshold_ff.h index 678f8b1d2d..0b76a8c99a 100644 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.h +++ b/gnuradio-core/src/lib/general/gr_threshold_ff.h @@ -33,7 +33,6 @@ GR_CORE_API gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float /*! * \brief Please fix my documentation - * \ingroup misc_blk */ class GR_CORE_API gr_threshold_ff : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_throttle.h b/gnuradio-core/src/lib/general/gr_throttle.h index 876d6d8269..0a7566b355 100644 --- a/gnuradio-core/src/lib/general/gr_throttle.h +++ b/gnuradio-core/src/lib/general/gr_throttle.h @@ -27,7 +27,6 @@ /*! * \brief throttle flow of samples such that the average rate does not exceed samples_per_sec. - * \ingroup misc_blk * * input: one stream of itemsize; output: one stream of itemsize * diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.h b/gnuradio-core/src/lib/general/gr_uchar_to_float.h index c02601cca6..f7ea6134f7 100644 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.h +++ b/gnuradio-core/src/lib/general/gr_uchar_to_float.h @@ -34,7 +34,6 @@ gr_make_uchar_to_float (); /*! * \brief Convert stream of unsigned chars to a stream of float - * \ingroup converter_blk */ class GR_CORE_API gr_uchar_to_float : public gr_sync_block diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h index c3ea28d3fa..becd5d4cdb 100644 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h +++ b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.h @@ -34,7 +34,6 @@ class gr_unpack_k_bits_bb; /*! * \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB. - * \ingroup converter_blk */ class GR_CORE_API gr_unpack_k_bits_bb : public gr_sync_interpolator { diff --git a/gnuradio-core/src/lib/general/gr_vco_f.h b/gnuradio-core/src/lib/general/gr_vco_f.h index 83f6a9773e..d14318a9e5 100644 --- a/gnuradio-core/src/lib/general/gr_vco_f.h +++ b/gnuradio-core/src/lib/general/gr_vco_f.h @@ -28,7 +28,6 @@ /*! * \brief VCO - Voltage controlled oscillator - * \ingroup misc * * \param sampling_rate sampling rate (Hz) * \param sensitivity units are radians/sec/volt diff --git a/gnuradio-core/src/lib/general/gr_vector_map.h b/gnuradio-core/src/lib/general/gr_vector_map.h index f5492b1e3a..02f8dc72c8 100644 --- a/gnuradio-core/src/lib/general/gr_vector_map.h +++ b/gnuradio-core/src/lib/general/gr_vector_map.h @@ -55,8 +55,6 @@ gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens, * * \param mapping (vector of vectors of vectors of integers) how to * map elements from input to output vectors - * - * \ingroup slicedice_blk */ class GR_CORE_API gr_vector_map : public gr_sync_block { diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.h b/gnuradio-core/src/lib/general/gr_vector_to_stream.h index 9fc8030f5b..edcb063b5c 100644 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.h +++ b/gnuradio-core/src/lib/general/gr_vector_to_stream.h @@ -35,7 +35,6 @@ gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block); /*! * \brief convert a stream of blocks of nitems_per_block items into a stream of items - * \ingroup slicedice_blk */ class GR_CORE_API gr_vector_to_stream : public gr_sync_interpolator { diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.h b/gnuradio-core/src/lib/general/gr_vector_to_streams.h index 8db4230536..a3122dcef1 100644 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.h +++ b/gnuradio-core/src/lib/general/gr_vector_to_streams.h @@ -35,7 +35,6 @@ gr_make_vector_to_streams (size_t item_size, size_t nstreams); /*! * \brief Convert 1 stream of vectors of length N to N streams of items - * \ingroup slicedice_blk */ class GR_CORE_API gr_vector_to_streams : public gr_sync_block { diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t index 37678abe13..33563e14e2 100644 --- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t +++ b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.h.t @@ -36,7 +36,6 @@ GR_CORE_API @SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max /*! * \brief output is the moving sum of the last N samples, scaled by the scale factor - * \ingroup filter_blk * * max_iter limits how long we go without flushing the accumulator * This is necessary to avoid numerical instability for float and complex. diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t index a9e3a0a3ea..2b8207c027 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t @@ -28,6 +28,7 @@ #include <@NAME@.h> #include <algorithm> #include <gr_io_signature.h> +#include <iostream> @NAME@::@NAME@ (int vlen) @@ -46,7 +47,9 @@ int @TYPE@ *iptr = (@TYPE@ *) input_items[0]; for (int i = 0; i < noutput_items * d_vlen; i++) d_data.push_back (iptr[i]); - + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items); + d_tags.insert(d_tags.end(), tags.begin(), tags.end()); return noutput_items; } @@ -62,3 +65,9 @@ std::vector<@TYPE@> { return d_data; } + +std::vector<gr_tag_t> +@NAME@::tags () const +{ + return d_tags; +} diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t index b9126dc7b2..b7de1d101c 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.h.t @@ -43,6 +43,7 @@ gr_make_@BASE_NAME@ (int vlen = 1); class GR_CORE_API @NAME@ : public gr_sync_block { friend GR_CORE_API @NAME@_sptr gr_make_@BASE_NAME@ (int vlen); std::vector<@TYPE@> d_data; + std::vector<gr_tag_t> d_tags; int d_vlen; @NAME@ (int vlen); @@ -54,6 +55,7 @@ class GR_CORE_API @NAME@ : public gr_sync_block { void reset() {d_data.clear();} void clear() {reset(); } // deprecated std::vector<@TYPE@> data () const; + std::vector<gr_tag_t> tags () const; }; #endif diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t index d4a9409114..ee0ebf378b 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.i.t @@ -35,5 +35,6 @@ class @NAME@ : public gr_sync_block { void clear(); // deprecated void reset(); std::vector<@TYPE@> data () const; + std::vector<gr_tag_t> tags () const; }; diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t index 9f68f9cf14..19272ee24b 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t @@ -30,20 +30,39 @@ #include <gr_io_signature.h> #include <stdexcept> - -@NAME@::@NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen) +@NAME@::@NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags) : gr_sync_block ("@BASE_NAME@", gr_make_io_signature (0, 0, 0), gr_make_io_signature (1, 1, sizeof (@TYPE@) * vlen)), d_data (data), d_repeat (repeat), d_offset (0), - d_vlen (vlen) + d_vlen (vlen), + d_tags (tags), + d_tagpos (0) { + if (tags.size() == 0) { + d_settags = 0; + } else { + d_settags = 1; + set_output_multiple(data.size() / vlen); + } if ((data.size() % vlen) != 0) throw std::invalid_argument("data length must be a multiple of vlen"); } +void +@NAME@::set_data (const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags){ + d_data = data; + d_tags = tags; + rewind(); + if (tags.size() == 0) { + d_settags = false; + } else { + d_settags = true; + } +} + int @NAME@::work (int noutput_items, gr_vector_const_void_star &input_items, @@ -54,36 +73,52 @@ int if (d_repeat){ unsigned int size = d_data.size (); unsigned int offset = d_offset; - if (size == 0) return -1; - for (int i = 0; i < noutput_items*d_vlen; i++){ - optr[i] = d_data[offset++]; - if (offset >= size) - offset = 0; + if (d_settags) { + int n_outputitems_per_vector = d_data.size() / d_vlen; + for (int i = 0; i < noutput_items; i += n_outputitems_per_vector) { + // FIXME do proper vector copy + memcpy((void *) optr, (const void *) &d_data[0], size * sizeof (@TYPE@)); + optr += size; + for (unsigned t = 0; t < d_tags.size(); t++) { + add_item_tag(0, nitems_written(0)+i+d_tags[t].offset, d_tags[t].key, d_tags[t].value); + } + } + } else { + for (int i = 0; i < noutput_items*d_vlen; i++){ + optr[i] = d_data[offset++]; + if (offset >= size) { + offset = 0; + } + } } + + d_offset = offset; return noutput_items; - } - - else { + } else { if (d_offset >= d_data.size ()) return -1; // Done! unsigned n = std::min ((unsigned) d_data.size () - d_offset, - (unsigned) noutput_items*d_vlen); - for (unsigned i = 0; i < n; i++) + (unsigned) noutput_items*d_vlen); + for (unsigned i = 0; i < n; i++) { optr[i] = d_data[d_offset + i]; - + } + for (unsigned t = 0; t < d_tags.size(); t++) { + if ((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset+n)) + add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value); + } d_offset += n; return n/d_vlen; } } @NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen) +gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags) { - return gnuradio::get_initial_sptr(new @NAME@ (data, repeat, vlen)); + return gnuradio::get_initial_sptr(new @NAME@ (data, repeat, vlen, tags)); } diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t index fe02c1346f..041cc47a45 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.h.t @@ -38,24 +38,27 @@ typedef boost::shared_ptr<@NAME@> @NAME@_sptr; class @NAME@ : public gr_sync_block { friend GR_CORE_API @NAME@_sptr - gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen); + gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); std::vector<@TYPE@> d_data; bool d_repeat; unsigned int d_offset; int d_vlen; + bool d_settags; + std::vector<gr_tag_t> d_tags; + unsigned int d_tagpos; - @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen); + @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); public: void rewind() {d_offset=0;} virtual int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); - void set_data(const std::vector<@TYPE@> &data){ d_data = data; rewind(); } + void set_data(const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); }; GR_CORE_API @NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1); +gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); #endif diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t index 4986c68a35..1f1479f947 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.i.t @@ -25,13 +25,13 @@ GR_SWIG_BLOCK_MAGIC(gr,@BASE_NAME@); @NAME@_sptr -gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1) +gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat = false, int vlen = 1, const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()) throw(std::invalid_argument); class @NAME@ : public gr_sync_block { public: void rewind(); - void set_data(const std::vector<@TYPE@> &data); + void set_data(const std::vector<@TYPE@> &data, const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); private: - @NAME@ (const std::vector<@TYPE@> &data, int vlen); + @NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen, const std::vector<gr_tag_t> &tags); }; diff --git a/gnuradio-core/src/lib/gnuradio-core.rc.in b/gnuradio-core/src/lib/gnuradio-core.rc.in new file mode 100644 index 0000000000..a5579ce4ed --- /dev/null +++ b/gnuradio-core/src/lib/gnuradio-core.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-core" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-core.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-core.dll" + VALUE "ProductName", "gnuradio-core" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gnuradio-core/src/lib/hier/gr_channel_model.h b/gnuradio-core/src/lib/hier/gr_channel_model.h index 5796a6db24..c531b454e3 100644 --- a/gnuradio-core/src/lib/hier/gr_channel_model.h +++ b/gnuradio-core/src/lib/hier/gr_channel_model.h @@ -40,7 +40,6 @@ GR_CORE_API gr_channel_model_sptr gr_make_channel_model(double noise_voltage=0.0 /*! * \brief channel simulator - * \ingroup misc_blk */ class GR_CORE_API gr_channel_model : public gr_hier_block2 { diff --git a/gnuradio-core/src/lib/io/gr_message_sink.cc b/gnuradio-core/src/lib/io/gr_message_sink.cc index ae0b5c7649..3816f5da48 100644 --- a/gnuradio-core/src/lib/io/gr_message_sink.cc +++ b/gnuradio-core/src/lib/io/gr_message_sink.cc @@ -34,7 +34,6 @@ #include <stdexcept> #include <string.h> - // public constructor that returns a shared_ptr gr_message_sink_sptr @@ -42,12 +41,25 @@ gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) { return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block)); } +gr_message_sink_sptr +gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname) +{ + return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block, lengthtagname)); +} gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) : gr_sync_block("message_sink", gr_make_io_signature(1, 1, itemsize), gr_make_io_signature(0, 0, 0)), - d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block) + d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), d_tags(false), d_items_read(0) +{ +} + +gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname) + : gr_sync_block("message_sink", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(0, 0, 0)), + d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), d_tags(true), d_lengthtagname(lengthtagname), d_items_read(0) { } @@ -62,18 +74,46 @@ gr_message_sink::work(int noutput_items, { const char *in = (const char *) input_items[0]; - // if we'd block, drop the data on the floor and say everything is OK - if (d_dont_block && d_msgq->full_p()) - return noutput_items; + if (d_tags) { + long packet_length = 0; + std::vector<gr_tag_t> tags; + this->get_tags_in_range(tags, 0, d_items_read, d_items_read+1); + //const size_t ninput_items = noutput_items; //assumption for sync block, this can change + for (unsigned int i = 0; i < tags.size(); i++) { + if (pmt::pmt_symbol_to_string(tags[i].key) == d_lengthtagname) { + packet_length = pmt::pmt_to_long(tags[i].value); + } + } + assert(packet_length != 0); - // build a message to hold whatever we've got - gr_message_sptr msg = gr_make_message(0, // msg type - d_itemsize, // arg1 for other end - noutput_items, // arg2 for other end (redundant) - noutput_items * d_itemsize); // len of msg - memcpy(msg->msg(), in, noutput_items * d_itemsize); - - d_msgq->handle(msg); // send it - - return noutput_items; + // FIXME run this multiple times if input_items >= N * packet_length + if (noutput_items >= packet_length ) { + // If the message queue is full we drop the packet. + if (!d_msgq->full_p()) { + gr_message_sptr msg = gr_make_message(0, // msg type + d_itemsize, // arg1 for other end + packet_length, // arg2 for other end (redundant) + packet_length * d_itemsize); // len of msg + memcpy(msg->msg(), in, packet_length * d_itemsize); + d_msgq->handle(msg); // send it + } + d_items_read += packet_length; + return packet_length; + } else { + return 0; + } + } else { + // If the queue if full we drop all the data we got. + if (!d_msgq->full_p()) { + // build a message to hold whatever we've got + gr_message_sptr msg = gr_make_message(0, // msg type + d_itemsize, // arg1 for other end + noutput_items, // arg2 for other end (redundant) + noutput_items * d_itemsize); // len of msg + memcpy(msg->msg(), in, noutput_items * d_itemsize); + + d_msgq->handle(msg); // send it + } + return noutput_items; + } } diff --git a/gnuradio-core/src/lib/io/gr_message_sink.h b/gnuradio-core/src/lib/io/gr_message_sink.h index 84005694a1..2db84cff44 100644 --- a/gnuradio-core/src/lib/io/gr_message_sink.h +++ b/gnuradio-core/src/lib/io/gr_message_sink.h @@ -27,13 +27,23 @@ #include <gr_sync_block.h> #include <gr_message.h> #include <gr_msg_queue.h> +#include <string> class gr_message_sink; typedef boost::shared_ptr<gr_message_sink> gr_message_sink_sptr; -GR_CORE_API gr_message_sink_sptr gr_make_message_sink (size_t itemsize, - gr_msg_queue_sptr msgq, - bool dont_block); +GR_CORE_API gr_message_sink_sptr gr_make_message_sink ( + size_t itemsize, + gr_msg_queue_sptr msgq, + bool dont_block +); + +GR_CORE_API gr_message_sink_sptr gr_make_message_sink ( + size_t itemsize, + gr_msg_queue_sptr msgq, + bool dont_block, + const std::string& lengthtagname +); /*! * \brief Gather received items into messages and insert into msgq @@ -45,12 +55,21 @@ class GR_CORE_API gr_message_sink : public gr_sync_block size_t d_itemsize; gr_msg_queue_sptr d_msgq; bool d_dont_block; + bool d_tags; + std::string d_lengthtagname; + uint64_t d_items_read; friend GR_CORE_API gr_message_sink_sptr - gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq, + bool dont_block); + friend GR_CORE_API gr_message_sink_sptr + gr_make_message_sink(size_t itemsize, gr_msg_queue_sptr msgq, + bool dont_block, const std::string& lengthtagname); protected: gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, + const std::string& lengthtagname); public: ~gr_message_sink (); diff --git a/gnuradio-core/src/lib/io/gr_message_sink.i b/gnuradio-core/src/lib/io/gr_message_sink.i index 8415cbd66d..b22eff18c0 100644 --- a/gnuradio-core/src/lib/io/gr_message_sink.i +++ b/gnuradio-core/src/lib/io/gr_message_sink.i @@ -22,14 +22,21 @@ GR_SWIG_BLOCK_MAGIC(gr,message_sink); +#include <string> + gr_message_sink_sptr gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); +gr_message_sink_sptr gr_make_message_sink (size_t itemsize, + gr_msg_queue_sptr msgq, + bool dont_block, + const std::string& lengthtagname); class gr_message_sink : public gr_sync_block { protected: gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block, const std::string& lengthtagname); public: ~gr_message_sink (); diff --git a/gnuradio-core/src/lib/io/gr_message_source.cc b/gnuradio-core/src/lib/io/gr_message_source.cc index fb3da89a8b..0b79bb526b 100644 --- a/gnuradio-core/src/lib/io/gr_message_source.cc +++ b/gnuradio-core/src/lib/io/gr_message_source.cc @@ -36,7 +36,6 @@ // public constructor that returns a shared_ptr - gr_message_source_sptr gr_make_message_source(size_t itemsize, int msgq_limit) { @@ -50,11 +49,19 @@ gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq) return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq)); } +// public constructor that takes existing message queue and adds messages length tags. +gr_message_source_sptr +gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname) +{ + return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq, lengthtagname)); +} + gr_message_source::gr_message_source (size_t itemsize, int msgq_limit) : gr_sync_block("message_source", gr_make_io_signature(0, 0, 0), gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false) + d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false), + d_tags(false) { } @@ -62,11 +69,19 @@ gr_message_source::gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq) : gr_sync_block("message_source", gr_make_io_signature(0, 0, 0), gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false) + d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false), d_tags(false) { } gr_message_source::~gr_message_source() +{} + +gr_message_source::gr_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname) + : gr_sync_block("message_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false), + d_tags(true), d_lengthtagname(lengthtagname) { } @@ -86,15 +101,21 @@ gr_message_source::work(int noutput_items, int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize)); memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize); + if (d_tags && (d_msg_offset == 0)) { + const uint64_t offset = this->nitems_written(0) + nn; + pmt::pmt_t key = pmt::pmt_string_to_symbol(d_lengthtagname); + pmt::pmt_t value = pmt::pmt_from_long(d_msg->length()); + this->add_item_tag(0, offset, key, value); + } nn += mm; out += mm * d_itemsize; d_msg_offset += mm * d_itemsize; assert(d_msg_offset <= d_msg->length()); if (d_msg_offset == d_msg->length()){ - if (d_msg->type() == 1) // type == 1 sets EOF - d_eof = true; - d_msg.reset(); + if (d_msg->type() == 1) // type == 1 sets EOF + d_eof = true; + d_msg.reset(); } } else { @@ -102,17 +123,17 @@ gr_message_source::work(int noutput_items, // No current message // if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got - break; + break; } - + if (d_eof) - return -1; - + return -1; + d_msg = d_msgq->delete_head(); // block, waiting for a message d_msg_offset = 0; - + if ((d_msg->length() % d_itemsize) != 0) - throw std::runtime_error("msg length is not a multiple of d_itemsize"); + throw std::runtime_error("msg length is not a multiple of d_itemsize"); } } diff --git a/gnuradio-core/src/lib/io/gr_message_source.h b/gnuradio-core/src/lib/io/gr_message_source.h index c510d1775f..1828475987 100644 --- a/gnuradio-core/src/lib/io/gr_message_source.h +++ b/gnuradio-core/src/lib/io/gr_message_source.h @@ -33,6 +33,8 @@ typedef boost::shared_ptr<gr_message_source> gr_message_source_sptr; GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0); GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq); +GR_CORE_API gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq, + const std::string& lengthtagname); /*! * \brief Turn received messages into a stream @@ -46,15 +48,21 @@ class GR_CORE_API gr_message_source : public gr_sync_block gr_message_sptr d_msg; unsigned d_msg_offset; bool d_eof; + bool d_tags; + // FIXME: Is this adequate tagname length. + std::string d_lengthtagname; friend GR_CORE_API gr_message_source_sptr - gr_make_message_source(size_t itemsize, int msgq_limit); + gr_make_message_source(size_t itemsize, int msgq_limit); friend GR_CORE_API gr_message_source_sptr - gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq); + gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq); + friend GR_CORE_API gr_message_source_sptr + gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname); protected: gr_message_source (size_t itemsize, int msgq_limit); gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq); + gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname); public: ~gr_message_source (); diff --git a/gnuradio-core/src/lib/io/gr_message_source.i b/gnuradio-core/src/lib/io/gr_message_source.i index 9ee9157e8c..bb1ddfcc31 100644 --- a/gnuradio-core/src/lib/io/gr_message_source.i +++ b/gnuradio-core/src/lib/io/gr_message_source.i @@ -22,14 +22,18 @@ GR_SWIG_BLOCK_MAGIC(gr,message_source); +#include <string> + gr_message_source_sptr gr_make_message_source (size_t itemsize, int msgq_limit=0); gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq); +gr_message_source_sptr gr_make_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname); class gr_message_source : public gr_sync_block { protected: gr_message_source (size_t itemsize, int msgq_limit); gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq); + gr_message_source (size_t itemsize, gr_msg_queue_sptr msgq, const std::string& lengthtagname); public: ~gr_message_source (); diff --git a/gnuradio-core/src/lib/io/gr_pdu.h b/gnuradio-core/src/lib/io/gr_pdu.h index a5ae87db7f..53058ccb6c 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.h +++ b/gnuradio-core/src/lib/io/gr_pdu.h @@ -23,17 +23,18 @@ #ifndef GR_PDU_H #define GR_PDU_H +#include <gr_core_api.h> #include <gr_complex.h> #include <gruel/pmt.h> -#define pdu_port_id pmt::mp("pdus") -#define pdu_length_tag pmt::mp("pdu_length") +#define PDU_PORT_ID pmt::mp("pdus") +#define PDU_LENGTH_TAG pmt::mp("pdu_length") enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex }; -size_t gr_pdu_itemsize(gr_pdu_vector_type type); -bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); -pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items); -gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector); +GR_CORE_API size_t gr_pdu_itemsize(gr_pdu_vector_type type); +GR_CORE_API bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); +GR_CORE_API pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items); +GR_CORE_API gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector); #endif diff --git a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc index 5c319dc39d..a702b66a2b 100644 --- a/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc +++ b/gnuradio-core/src/lib/io/gr_pdu_to_tagged_stream.cc @@ -49,7 +49,7 @@ gr_pdu_to_tagged_stream::gr_pdu_to_tagged_stream (gr_pdu_vector_type t) gr_make_io_signature(1, 1, gr_pdu_itemsize(t))), d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)) { - message_port_register_in(pdu_port_id); + message_port_register_in(PDU_PORT_ID); } gr_pdu_to_tagged_stream::~gr_pdu_to_tagged_stream() @@ -77,8 +77,8 @@ gr_pdu_to_tagged_stream::work(int noutput_items, if(noutput_items > 0){ // grab a message if one exists - //pmt::pmt_t msg( delete_head_nowait( pdu_port_id ) ); - pmt::pmt_t msg( delete_head_blocking( pdu_port_id ) ); + //pmt::pmt_t msg( delete_head_nowait( PDU_PORT_ID ) ); + pmt::pmt_t msg( delete_head_blocking( PDU_PORT_ID ) ); if(msg.get() == NULL ){ return nout; } @@ -99,7 +99,7 @@ gr_pdu_to_tagged_stream::work(int noutput_items, uint64_t offset = nitems_written(0) + nout; // add a tag for pdu length - add_item_tag(0, offset, pdu_length_tag, pmt::pmt_from_long( pmt::pmt_length(vect) ), pmt::mp(alias())); + add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::pmt_from_long( pmt::pmt_length(vect) ), pmt::mp(alias())); // if we recieved metadata add it as tags if( !pmt_eq(meta, pmt::PMT_NIL) ){ diff --git a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc index 8211b7672d..1b869edfab 100644 --- a/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc +++ b/gnuradio-core/src/lib/io/gr_tagged_stream_to_pdu.cc @@ -49,7 +49,7 @@ gr_tagged_stream_to_pdu::gr_tagged_stream_to_pdu (gr_pdu_vector_type t) d_vectortype(t), d_itemsize(gr_pdu_itemsize(t)), d_inpdu(false), d_pdu_meta(pmt::PMT_NIL), d_pdu_vector(pmt::PMT_NIL) { - message_port_register_out(pdu_port_id); + message_port_register_out(PDU_PORT_ID); } gr_tagged_stream_to_pdu::~gr_tagged_stream_to_pdu() @@ -70,7 +70,7 @@ gr_tagged_stream_to_pdu::work(int noutput_items, get_tags_in_range(d_tags, 0, abs_N, abs_N+1); bool found_length_tag(false); for(d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++){ - if( pmt::pmt_equal( (*d_tags_itr).key, pdu_length_tag ) ){ + if( pmt::pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){ if( (*d_tags_itr).offset != abs_N ){ throw std::runtime_error("expected next pdu length tag on a different item..."); } @@ -91,7 +91,7 @@ gr_tagged_stream_to_pdu::work(int noutput_items, // copy any tags in this range into our meta object get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy); for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++){ - if( ! pmt_equal( (*d_tags_itr).key, pdu_length_tag ) ){ + if( ! pmt_equal( (*d_tags_itr).key, PDU_LENGTH_TAG ) ){ d_pdu_meta = pmt_dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value); } } @@ -127,7 +127,7 @@ void gr_tagged_stream_to_pdu::send_message(){ } pmt::pmt_t msg = pmt::pmt_cons( d_pdu_meta, d_pdu_vector ); - message_port_pub( pdu_port_id, msg ); + message_port_pub( PDU_PORT_ID, msg ); d_pdu_meta = pmt::PMT_NIL; d_pdu_vector = pmt::PMT_NIL; diff --git a/gnuradio-core/src/lib/runtime/CMakeLists.txt b/gnuradio-core/src/lib/runtime/CMakeLists.txt index 70938a0f17..80db1e7e7e 100644 --- a/gnuradio-core/src/lib/runtime/CMakeLists.txt +++ b/gnuradio-core/src/lib/runtime/CMakeLists.txt @@ -62,6 +62,7 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_local_sighandler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_accepter.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.cc @@ -78,6 +79,7 @@ list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_sys_paths.cc + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tagged_stream_block.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block_impl.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_tpb_detail.cc @@ -105,6 +107,7 @@ list(APPEND test_gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_runtime.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_set_msg_handler.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_logger.cc ) ######################################################################## @@ -126,6 +129,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_local_sighandler.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_accepter.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.h @@ -143,6 +147,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_block.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.h + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tagged_stream_block.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block_impl.h ${CMAKE_CURRENT_SOURCE_DIR}/gr_tpb_detail.h @@ -170,6 +175,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_dispatcher.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_error_handler.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_io_signature.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_logger.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_message.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_handler.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_msg_queue.i @@ -178,10 +184,12 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_block.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_decimator.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_sync_interpolator.i + ${CMAKE_CURRENT_SOURCE_DIR}/gr_tagged_stream_block.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_tags.i ${CMAKE_CURRENT_SOURCE_DIR}/gr_top_block.i ${CMAKE_CURRENT_SOURCE_DIR}/runtime.i DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "core_swig" ) + endif(ENABLE_PYTHON) diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc index 587e9d195b..bfb23e9c4b 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.cc +++ b/gnuradio-core/src/lib/runtime/gr_block.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2009,2010 Free Software Foundation, Inc. + * Copyright 2004,2009,2010,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,6 +29,7 @@ #include <stdexcept> #include <iostream> #include <gr_block_registry.h> +#include <gr_prefs.h> gr_block::gr_block (const std::string &name, gr_io_signature_sptr input_signature, @@ -49,6 +50,52 @@ gr_block::gr_block (const std::string &name, d_min_output_buffer(std::max(output_signature->max_streams(),1), -1) { global_block_registry.register_primitive(alias(), this); + +#ifdef ENABLE_GR_LOG +#ifdef HAVE_LOG4CPP + gr_prefs *p = gr_prefs::singleton(); + std::string config_file = p->get_string("LOG", "log_config", ""); + std::string log_level = p->get_string("LOG", "log_level", "off"); + std::string log_file = p->get_string("LOG", "log_file", ""); + std::string debug_level = p->get_string("LOG", "debug_level", "off"); + std::string debug_file = p->get_string("LOG", "debug_file", ""); + + GR_CONFIG_LOGGER(config_file); + + GR_LOG_GETLOGGER(LOG, "gr_log." + alias()); + GR_LOG_SET_LEVEL(LOG, log_level); + if(log_file.size() > 0) { + if(log_file == "stdout") { + GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cout","gr::log :%p: %c{1} - %m%n"); + } + else if(log_file == "stderr") { + GR_LOG_ADD_CONSOLE_APPENDER(LOG, "cerr","gr::log :%p: %c{1} - %m%n"); + } + else { + GR_LOG_ADD_FILE_APPENDER(LOG, log_file , true,"%r :%p: %c{1} - %m%n"); + } + } + d_logger = LOG; + + GR_LOG_GETLOGGER(DLOG, "gr_log_debug." + alias()); + GR_LOG_SET_LEVEL(DLOG, debug_level); + if(debug_file.size() > 0) { + if(debug_file == "stdout") { + GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "cout","gr::debug :%p: %c{1} - %m%n"); + } + else if(debug_file == "stderr") { + GR_LOG_ADD_CONSOLE_APPENDER(DLOG, "cerr", "gr::debug :%p: %c{1} - %m%n"); + } + else { + GR_LOG_ADD_FILE_APPENDER(DLOG, debug_file, true, "%r :%p: %c{1} - %m%n"); + } + } + d_debug_logger = DLOG; +#endif /* HAVE_LOG4CPP */ +#else /* ENABLE_GR_LOG */ + d_logger = NULL; + d_debug_logger = NULL; +#endif /* ENABLE_GR_LOG */ } gr_block::~gr_block () @@ -191,7 +238,7 @@ void gr_block::remove_item_tag(unsigned int which_input, const gr_tag_t &tag) { - d_detail->remove_item_tag(which_input, tag); + d_detail->remove_item_tag(which_input, tag, unique_id()); } void @@ -199,7 +246,7 @@ gr_block::get_tags_in_range(std::vector<gr_tag_t> &v, 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 @@ -208,7 +255,7 @@ gr_block::get_tags_in_range(std::vector<gr_tag_t> &v, 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()); } gr_block::tag_propagation_policy_t diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index c5e510c3be..402c8ee7f1 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -26,6 +26,7 @@ #include <gr_core_api.h> #include <gr_basic_block.h> #include <gr_tags.h> +#include <gr_logger.h> /*! * \brief The abstract base class for all 'terminal' processing blocks. @@ -616,6 +617,11 @@ class GR_CORE_API gr_block : public gr_basic_block { */ gruel::mutex d_setlock; + /*! Used by blocks to access the logger system. + */ + gr_logger_ptr d_logger; + gr_logger_ptr d_debug_logger; + // These are really only for internal use, but leaving them public avoids // having to work up an ever-varying list of friend GR_CORE_APIs diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc index 4922ea083e..2461ad99bb 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc @@ -168,14 +168,14 @@ gr_block_detail::add_item_tag(unsigned int which_output, const gr_tag_t &tag) } void -gr_block_detail::remove_item_tag(unsigned int which_input, const gr_tag_t &tag) +gr_block_detail::remove_item_tag(unsigned int which_input, const gr_tag_t &tag, long id) { if(!pmt_is_symbol(tag.key)) { throw pmt_wrong_type("gr_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); } } @@ -183,10 +183,11 @@ void gr_block_detail::get_tags_in_range(std::vector<gr_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 @@ -194,14 +195,15 @@ gr_block_detail::get_tags_in_range(std::vector<gr_tag_t> &v, unsigned int which_input, uint64_t abs_start, uint64_t abs_end, - const pmt_t &key) + const pmt_t &key, + long id) { std::vector<gr_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_t itemkey; diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h index 15d85135ae..cff5ad6729 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_detail.h +++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h @@ -107,12 +107,14 @@ class GR_CORE_API gr_block_detail { /*! * \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 gr_tag_t &tag); + void remove_item_tag(unsigned int which_input, const gr_tag_t &tag, long id); /*! * \brief Given a [start,end), returns a vector of all tags in the range. @@ -127,11 +129,13 @@ class GR_CORE_API gr_block_detail { * \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<gr_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 range @@ -149,12 +153,14 @@ class GR_CORE_API gr_block_detail { * \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<gr_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 mask. diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index e070f3c508..b426b4f8c3 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -91,7 +91,7 @@ min_available_space (gr_block_detail *d, int output_multiple, int min_noutput_it static bool propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, const std::vector<uint64_t> &start_nitems_read, double rrate, - std::vector<gr_tag_t> &rtags) + std::vector<gr_tag_t> &rtags, long block_id) { // Move tags downstream // if a sink, we don't need to move downstream @@ -107,7 +107,7 @@ propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, // 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<gr_tag_t>::iterator t; if(rrate == 1.0) { @@ -133,7 +133,7 @@ propagate_tags(gr_block::tag_propagation_policy_t policy, gr_block_detail *d, 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<gr_tag_t>::iterator t; for(t = rtags.begin(); t != rtags.end(); t++) { @@ -450,7 +450,7 @@ gr_block_executor::run_one_iteration() 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 == gr_block::WORK_DONE) diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc index 369959d65f..1764b0a8e9 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.cc +++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc @@ -234,13 +234,12 @@ gr_buffer::add_item_tag(const gr_tag_t &tag) } void -gr_buffer::remove_item_tag(const gr_tag_t &tag) +gr_buffer::remove_item_tag(const gr_tag_t &tag, long id) { gruel::scoped_lock guard(*mutex()); for (std::deque<gr_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); } } } @@ -321,7 +320,8 @@ gr_buffer_reader::update_read_pointer (int nitems) void gr_buffer_reader::get_tags_in_range(std::vector<gr_tag_t> &v, uint64_t abs_start, - uint64_t abs_end) + uint64_t abs_end, + long id) { gruel::scoped_lock guard(*mutex()); @@ -333,7 +333,12 @@ gr_buffer_reader::get_tags_in_range(std::vector<gr_tag_t> &v, 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-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h index 28ea977269..631ee3071c 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.h +++ b/gnuradio-core/src/lib/runtime/gr_buffer.h @@ -106,10 +106,15 @@ class GR_CORE_API gr_buffer { * \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 gr_tag_t &tag); + void remove_item_tag(const gr_tag_t &tag, long id); /*! * \brief Removes all tags before \p max_time from buffer @@ -279,10 +284,12 @@ class GR_CORE_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, - uint64_t abs_end); + uint64_t abs_end, + long id); // ------------------------------------------------------------------------- diff --git a/gnuradio-core/src/lib/runtime/gr_logger.cc b/gnuradio-core/src/lib/runtime/gr_logger.cc new file mode 100644 index 0000000000..1ffb04f789 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_logger.cc @@ -0,0 +1,204 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +/******************************************************************************* +* Author: Mark Plett +* Description: +* The gr_log module wraps the log4cpp library for logging in gnuradio. +*******************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_logger.h> +#include <stdexcept> +#include <algorithm> + +#ifdef ENABLE_GR_LOG +#ifdef HAVE_LOG4CPP + +bool gr_logger_configured(false); + +void +logger_load_config(const std::string &config_filename) +{ + if(!gr_logger_configured){ + gr_logger_configured = true; + if(config_filename.size() != 0) { + try + { + log4cpp::PropertyConfigurator::configure(config_filename); + } + catch( log4cpp::ConfigureFailure &e ) + { + std::cout << "Logger config failed :" << e.what() << std::endl; + } + }; + }; +} + +void +logger_load_config_and_watch(const std::string &config_filename, + unsigned int watch_period) +{ +// NOTE:: NEEDS CODE TO WATCH FILE HERE + if(!gr_logger_configured){ + gr_logger_configured = true; + if(config_filename.size() != 0) { + try + { + log4cpp::PropertyConfigurator::configure(config_filename); + } + catch( log4cpp::ConfigureFailure &e ) + { + std::cout << "Logger config failed :" << e.what() << std::endl; + } + }; + }; +} + +void +logger_reset_config(void){ + std::vector<log4cpp::Category*> *loggers = log4cpp::Category::getCurrentCategories(); + std::vector<log4cpp::Category*>::iterator logger = loggers->begin(); +// We can't destroy categories but we can neuter them by removing all appenders. + for (;logger!=loggers->end();logger++){ + (*logger)->removeAllAppenders(); + }; +} + +void +logger_set_level(gr_logger_ptr logger, const std::string &level) +{ + std::string nocase = level; + std::transform(level.begin(), level.end(), nocase.begin(), ::tolower); + + if(nocase == "off" || nocase == "notset") + logger_set_level(logger, log4cpp::Priority::NOTSET); + else if(nocase == "debug") + logger_set_level(logger, log4cpp::Priority::DEBUG); + else if(nocase == "info") + logger_set_level(logger, log4cpp::Priority::INFO); + else if(nocase == "notice") + logger_set_level(logger, log4cpp::Priority::NOTICE); + else if(nocase == "warn") + logger_set_level(logger, log4cpp::Priority::WARN); + else if(nocase == "error") + logger_set_level(logger, log4cpp::Priority::ERROR); + else if(nocase == "crit") + logger_set_level(logger, log4cpp::Priority::CRIT); + else if(nocase == "alert") + logger_set_level(logger, log4cpp::Priority::ALERT); + else if(nocase=="fatal") + logger_set_level(logger, log4cpp::Priority::FATAL); + else if(nocase == "all" || nocase == "emerg") + logger_set_level(logger, log4cpp::Priority::EMERG); + else + throw std::runtime_error("logger_set_level: Bad level type.\n"); +} + +void +logger_set_level(gr_logger_ptr logger, log4cpp::Priority::Value level) +{ + logger->setPriority(level); +} + +void +logger_get_level(gr_logger_ptr logger, std::string &level) +{ + log4cpp::Priority::Value levelPtr = logger->getPriority(); + if(levelPtr == log4cpp::Priority::NOTSET) level = "noset"; + if(levelPtr == log4cpp::Priority::DEBUG) level = "debug"; + if(levelPtr == log4cpp::Priority::INFO) level = "info"; + if(levelPtr == log4cpp::Priority::NOTICE) level = "notice"; + if(levelPtr == log4cpp::Priority::WARN) level = "warn"; + if(levelPtr == log4cpp::Priority::ERROR) level = "error"; + if(levelPtr == log4cpp::Priority::CRIT) level = "crit"; + if(levelPtr == log4cpp::Priority::ALERT) level = "alert"; + if(levelPtr == log4cpp::Priority::FATAL) level = "fatal"; + if(levelPtr == log4cpp::Priority::EMERG) level = "emerg"; +}; + +void +logger_get_level(gr_logger_ptr logger,log4cpp::Priority::Value level) +{ + level = logger->getPriority(); +} + +void +logger_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern) +{ + + log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); + log4cpp::Appender* app; + if(target=="cout") + app = new log4cpp::OstreamAppender("ConsoleAppender::",&std::cout); + else + app = new log4cpp::OstreamAppender("ConsoleAppender::",&std::cerr); + + layout->setConversionPattern(pattern); + app->setLayout(layout); + logger->setAppender(app); + +} + +void +logger_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern) +{ + + log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); + log4cpp::Appender* app = new + log4cpp::FileAppender("FileAppender::"+filename, + filename); + layout->setConversionPattern(pattern); + app->setLayout(layout); + logger->setAppender(app); + +} + +void +logger_add_rollingfile_appender(gr_logger_ptr logger,std::string filename, + size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern) +{ + log4cpp::PatternLayout* layout = new log4cpp::PatternLayout(); + log4cpp::Appender* app = new + log4cpp::RollingFileAppender("RollFileAppender::"+filename,filename,filesize,bkup_index,append,mode); + layout->setConversionPattern(pattern); + app->setLayout(layout); + logger->setAppender(app); +} + +void +logger_get_logger_names(std::vector<std::string>& names){ + std::vector<log4cpp::Category*> *loggers = log4cpp::Category::getCurrentCategories(); + std::vector<log4cpp::Category*>::iterator logger = loggers->begin(); + + names.clear(); + for (;logger!=loggers->end();logger++){ + names.push_back((*logger)->getName()); + }; + +} + +#endif /* HAVE_LOG4CPP */ +#endif /* ENABLE_GR_LOGGER */ diff --git a/gnuradio-core/src/lib/runtime/gr_logger.h b/gnuradio-core/src/lib/runtime/gr_logger.h new file mode 100644 index 0000000000..97804ca756 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_logger.h @@ -0,0 +1,553 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +/******************************************************************************* +* Author: Mark Plett +* Description: +* The gr_logger module wraps the log4cpp library for logging in gnuradio +*******************************************************************************/ + +#ifndef INCLUDED_GR_LOGGER_H +#define INCLUDED_GR_LOGGER_H + +/*! +* \file gr_logger.h +* \ingroup logging +* \brief GNURADIO logging wrapper for log4cpp library (C++ port of log4j) +* +*/ + +#include <gr_core_api.h> +#include <assert.h> +#include <iostream> +#include <boost/format.hpp> + +#ifdef ENABLE_GR_LOG + +// We have three configurations... first logging to stdout/stderr +#ifndef HAVE_LOG4CPP +//#warning GR logging Enabled and using std::cout + +typedef std::string gr_logger_ptr; + +#define GR_LOG_DECLARE_LOGPTR(logger) +#define GR_LOG_ASSIGN_LOGPTR(logger,name) +#define GR_CONFIG_LOGGER(config) +#define GR_CONFIG_AND_WATCH_LOGGER(config,period) +#define GR_LOG_GETLOGGER(logger, name) +#define GR_SET_LEVEL(name, level) +#define GR_LOG_SET_LEVEL(logger, level) +#define GR_GET_LEVEL(name, level) +#define GR_LOG_GET_LEVEL(logger, level) +#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern) +#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern) +#define GR_ADD_FILE_APPENDER(name,filename,append,pattern) +#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern) +#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern) +#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern) +#define GR_GET_LOGGER_NAMES(names) +#define GR_RESET_CONFIGURATION() +#define GR_DEBUG(name, msg) std::cout<<"DEBUG: "<<msg<<std::endl +#define GR_INFO(name, msg) std::cout<<"INFO: "<<msg<<std::endl +#define GR_NOTICE(name, msg) std::cout<<"NOTICE: "<<msg<<std::endl +#define GR_WARN(name, msg) std::cerr<<"WARN: "<<msg<<std::endl +#define GR_ERROR(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_ALERT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_CRIT(name, msg) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_FATAL(name, msg) std::cerr<<"FATAL: "<<msg<<std::endl +#define GR_EMERG(name, msg) std::cerr<<"EMERG: "<<msg<<std::endl +#define GR_ERRORIF(name, cond, msg) if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_ASSERT(name, cond, msg) if(!(cond)) std::cerr<<"ERROR: "<<msg<<std::endl; assert(cond) +#define GR_LOG_DEBUG(logger, msg) std::cout<<"DEBUG: "<<msg<<std::endl +#define GR_LOG_INFO(logger, msg) std::cout<<"INFO: "<<msg<<std::endl +#define GR_LOG_NOTICE(logger, msg) std::cout<<"NOTICE: "<<msg<<std::endl +#define GR_LOG_WARN(logger, msg) std::cerr<<"WARN: "<<msg<<std::endl +#define GR_LOG_ERROR(logger, msg) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_LOG_ALERT(logger, msg) std::cerr<<"ALERT: "<<msg<<std::endl +#define GR_LOG_CRIT(logger, msg) std::cerr<<"CRIT: "<<msg<<std::endl +#define GR_LOG_FATAL(logger, msg) std::cerr<<"FATAL: "<<msg<<std::endl +#define GR_LOG_EMERG(logger, msg) std::cerr<<"EMERG: "<<msg<<std::endl +#define GR_LOG_ERRORIF(logger, cond, msg) if((cond)) std::cerr<<"ERROR: "<<msg<<std::endl +#define GR_LOG_ASSERT(logger, cond, msg) std::cerr<<"ERROR: "<<msg<<std::endl; assert(cond) + +#else /* HAVE_LOG4CPP */ +// Second configuration...logging to log4cpp + +#include <log4cpp/Category.hh> +#include <log4cpp/PropertyConfigurator.hh> +#include <log4cpp/FileAppender.hh> +#include <log4cpp/RollingFileAppender.hh> +#include <log4cpp/OstreamAppender.hh> +#include <log4cpp/PatternLayout.hh> + +/*! + * \brief GR_LOG macros + * \ingroup logging + * + * These macros wrap the standard LOG4CPP_LEVEL macros. The availablie macros + * are: + * GR_LOG_DEBUG + * GR_LOG_INFO + * GR_LOG_WARN + * GR_LOG_TRACE + * GR_LOG_ERROR + * GR_LOG_ALERT + * GR_LOG_CRIT + * GR_LOG_FATAL + * GR_LOG_EMERG + */ +typedef log4cpp::Category* gr_logger_ptr; + +/* Macros for Programmatic Configuration */ +#define GR_LOG_DECLARE_LOGPTR(logger) \ + gr_logger_ptr logger; + +#define GR_LOG_ASSIGN_LOGPTR(logger,name) \ + logger = gr_logger::getLogger(name); + +#define GR_CONFIG_LOGGER(config) \ + logger_load_config(config) + +#define GR_CONFIG_AND_WATCH_LOGGER(config,period) \ + logger_load_config_and_watch(config,period) + +#define GR_LOG_GETLOGGER(logger, name) \ + gr_logger_ptr logger = gr_logger::getLogger(name); + +#define GR_SET_LEVEL(name, level){ \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_set_level(logger,level);} + +#define GR_LOG_SET_LEVEL(logger, level) \ + logger_set_level(logger, level); + +#define GR_GET_LEVEL(name, level){ \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_get_level(logger,level);} + +#define GR_LOG_GET_LEVEL(logger, level) \ + logger_get_level(logger,level); + +#define GR_ADD_CONSOLE_APPENDER(name,target,pattern){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_add_console_appender(logger,target,pattern);} + +#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern){\ + logger_add_console_appender(logger,target,pattern);} + +#define GR_ADD_FILE_APPENDER(name,filename,append,pattern){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_add_file_appender(logger,filename,append,pattern);} + +#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern){\ + logger_add_file_appender(logger,filename,append,pattern);} + +#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);} + +#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern){\ + logger_add_rollingfile_appender(logger,filename,filesize,bkup_index,append,mode,pattern);} + +#define GR_GET_LOGGER_NAMES(names){ \ + logger_get_logger_names(names);} + +#define GR_RESET_CONFIGURATION(){ \ + logger_reset_config();} + +/* Logger name referenced macros */ +#define GR_DEBUG(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::DEBUG << msg << log4cpp::eol;} + +#define GR_INFO(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::INFO << msg << log4cpp::eol;} + +#define GR_NOTICE(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger << log4cpp::Priority::NOTICE << msg;} + +#define GR_WARN(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::WARN << msg << log4cpp::eol;} + +#define GR_ERROR(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;} + +#define GR_CRIT(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::CRIT << msg << log4cpp::eol;} + +#define GR_ALERT(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::ALERT << msg << log4cpp::eol;} + +#define GR_FATAL(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::FATAL << msg << log4cpp::eol;} + +#define GR_EMERG(name, msg) { \ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;} + +#define GR_ERRORIF(name, cond, msg) { \ +if((cond)){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;};\ +}; + +#define GR_ASSERT(name, cond, msg) { \ +if((!cond)){\ + gr_logger_ptr logger = gr_logger::getLogger(name);\ + *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;};\ + assert(0);\ +}; + +/* LoggerPtr Referenced Macros */ +#define GR_LOG_DEBUG(logger, msg) { \ + *logger << log4cpp::Priority::DEBUG << msg << log4cpp::eol;} + +#define GR_LOG_INFO(logger, msg) { \ + *logger << log4cpp::Priority::INFO << msg << log4cpp::eol;} + +#define GR_LOG_NOTICE(logger, msg) { \ + *logger << log4cpp::Priority::NOTICE << msg << log4cpp::eol;} + +#define GR_LOG_WARN(logger, msg) { \ + *logger << log4cpp::Priority::WARN << msg << log4cpp::eol;} + +#define GR_LOG_ERROR(logger, msg) { \ + *logger << log4cpp::Priority::ERROR << msg << log4cpp::eol;} + +#define GR_LOG_CRIT(logger, msg) { \ + *logger << log4cpp::Priority::CRIT << msg << log4cpp::eol;} + +#define GR_LOG_ALERT(logger, msg) { \ + *logger << log4cpp::Priority::ALERT << msg << log4cpp::eol;} + +#define GR_LOG_FATAL(logger, msg) { \ + *logger << log4cpp::Priority::FATAL << msg << log4cpp::eol;} + +#define GR_LOG_EMERG(logger, msg) { \ + *logger << log4cpp::Priority::EMERG << msg << log4cpp::eol;} + +#define GR_LOG_ERRORIF(logger,cond, msg) { \ +if((!cond)){\ + *logger<< log4cpp::Priority::ERROR << msg << log4cpp::eol;};\ + assert(0);\ +}; + +#define GR_LOG_ASSERT(logger, cond, msg) { \ +if((!cond)){\ + *logger<< log4cpp::Priority::EMERG << msg << log4cpp::eol;};\ + assert(0);\ +}; + +/*! + * \brief Load logger's configuration file. + * + * Initialize the GNU Radio logger by loading the configuration file + * \p config_filename. + * + * \param config_filename The configuration file. Set to "" for the + * basic logger that outputs to the console. + */ +GR_CORE_API void logger_load_config(const std::string &config_filename=""); + + +GR_CORE_API void logger_load_config_and_watch(const std::string &config_filename, + unsigned int watch_period); + +GR_CORE_API void logger_reset_config(void); + +/*! + * \brief Set the logger's output level. + * + * Sets the level of the logger. This takes a string that is + * translated to the standard levels and can be (case insensitive): + * + * \li off , notset + * \li debug + * \li info + * \li notice + * \li warn + * \li error + * \li crit + * \li alert + * \li fatal + * \li emerg + * + * \param logger the logger to set the level of. + * \param level string to set the level to. + */ +GR_CORE_API void logger_set_level(gr_logger_ptr logger, const std::string &level); + +/*! + * \brief Set the logger's output level. + * + * Sets the level of the logger. This takes the actual Log4cpp::Priority + * data type, which can be: + * + * \li log4cpp::Priority::NOTSET + * \li log4cpp::Priority::DEBUG + * \li log4cpp::Priority::INFO + * \li log4cpp::Priority::NOTICE + * \li log4cpp::Priority::WARN + * \li log4cpp::Priority::ERROR + * \li log4cpp::Priority::CRIT + * \li log4cpp::Priority::ALERT + * \li log4cpp::Priority::FATAL + * \li log4cpp::Priority::EMERG + * + * \param logger the logger to set the level of. + * \param level new logger level of type Log4cpp::Priority + */ +void logger_set_level(gr_logger_ptr logger, log4cpp::Priority::Value level); + + +/*! + * \brief Get the logger's output level. + * + * Gets the level of the logger. This returns a string that + * corresponds to the standard levels and can be (case insensitive): + * + * \li notset + * \li debug + * \li info + * \li notice + * \li warn + * \li error + * \li crit + * \li alert + * \li fatal + * \li emerg + * + * \param logger the logger to get the level of. + * \param level string to get the level into. + */ +GR_CORE_API void logger_get_level(gr_logger_ptr logger, std::string &level); + +/*! + * \brief Get the logger's output level. + * + * Gets the level of the logger. This returns the actual Log4cpp::Level + * data type, which can be: + * + * \li log4cpp::Priority::NOTSET + * \li log4cpp::Priority::DEBUG + * \li log4cpp::Priority::INFO + * \li log4cpp::Priority::NOTICE + * \li log4cpp::Priority::WARN + * \li log4cpp::Priority::ERROR + * \li log4cpp::Priority::CRIT + * \li log4cpp::Priority::ALERT + * \li log4cpp::Priority::FATAL + * \li log4cpp::Priority::EMERG + * + * \param logger the logger to get the level of. + * \param level of the logger. + */ +GR_CORE_API void logger_get_level(gr_logger_ptr logger, log4cpp::Priority::Value &level); + +GR_CORE_API void logger_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern); + +GR_CORE_API void logger_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern); + +GR_CORE_API void logger_add_rollingfile_appender(gr_logger_ptr logger,std::string filename, + size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern); + +GR_CORE_API void logger_get_logger_names(std::vector<std::string>& names); + +/*! + * \brief instantiate (configure) logger. + * \ingroup logging + * + */ +class gr_logger +{ + public: + /*! + * \brief contructor take log configuration file and configures loggers. + */ + gr_logger(std::string config_filename) + { + // Load configuration file + logger_load_config(config_filename); + }; + + /*! + * \brief contructor take log configuration file and watchtime and configures + */ + gr_logger(std::string config_filename, int watchPeriodSec) + { + // Load configuration file + logger_load_config_and_watch(config_filename,watchPeriodSec); + + }; + + static gr_logger_ptr getLogger(std::string name) + { + if(log4cpp::Category::exists(name)){ + gr_logger_ptr logger = &log4cpp::Category::getInstance(name); + return logger; + } + else + { + gr_logger_ptr logger = &log4cpp::Category::getInstance(name); + logger->setPriority(log4cpp::Priority::NOTSET); + return logger; + }; + }; + + // Wrappers for logging macros + /*! \brief inline function, wrapper to set the logger level */ + void set_level(std::string name,std::string level){GR_SET_LEVEL(name,level);} + + /*! \brief inline function, wrapper to get the logger level */ + void get_level(std::string name,std::string &level){GR_GET_LEVEL(name,level);} + + /*! \brief inline function, wrapper for DEBUG message */ + void debug(std::string name,std::string msg){GR_DEBUG(name,msg);}; + + /*! \brief inline function, wrapper for INFO message */ + void info(std::string name,std::string msg){GR_INFO(name,msg);}; + + /*! \brief inline function, wrapper for NOTICE message */ + void notice(std::string name,std::string msg){GR_NOTICE(name,msg);}; + + /*! \brief inline function, wrapper for WARN message */ + void warn(std::string name,std::string msg){GR_WARN(name,msg);}; + + /*! \brief inline function, wrapper for ERROR message */ + void error(std::string name,std::string msg){GR_ERROR(name,msg);}; + + /*! \brief inline function, wrapper for CRIT message */ + void crit(std::string name,std::string msg){GR_CRIT(name,msg);}; + + /*! \brief inline function, wrapper for ALERT message */ + void alert(std::string name,std::string msg){GR_ALERT(name,msg);}; + + /*! \brief inline function, wrapper for FATAL message */ + void fatal(std::string name,std::string msg){GR_FATAL(name,msg);}; + + /*! \brief inline function, wrapper for EMERG message */ + void emerg(std::string name,std::string msg){GR_EMERG(name,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */ + void errorIF(std::string name,bool cond,std::string msg){GR_ERRORIF(name,cond,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */ + void gr_assert(std::string name,bool cond,std::string msg){GR_ASSERT(name,cond,msg);}; + + // Wrappers for Logger Pointer referenced functions + /*! \brief inline function, wrapper to set the logger level */ + void set_log_level(gr_logger_ptr logger,std::string level){GR_LOG_SET_LEVEL(logger,level);} + + /*! \brief inline function, wrapper to get the logger level */ + void get_log_level(gr_logger_ptr logger,std::string &level){GR_LOG_GET_LEVEL(logger,level);} + + /*! \brief inline function, wrapper for LOG4CPP_DEBUG for DEBUG message */ + void log_debug(gr_logger_ptr logger,std::string msg){GR_LOG_DEBUG(logger,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_INFO for INFO message */ + void log_info(gr_logger_ptr logger,std::string msg){GR_LOG_INFO(logger,msg);}; + + /*! \brief inline function, wrapper for NOTICE message */ + void log_notice(gr_logger_ptr logger,std::string msg){GR_LOG_NOTICE(logger,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_WARN for WARN message */ + void log_warn(gr_logger_ptr logger,std::string msg){GR_LOG_WARN(logger,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_ERROR for ERROR message */ + void log_error(gr_logger_ptr logger,std::string msg){GR_LOG_ERROR(logger,msg);}; + + /*! \brief inline function, wrapper for NOTICE message */ + void log_crit(gr_logger_ptr logger,std::string msg){GR_LOG_CRIT(logger,msg);}; + + /*! \brief inline function, wrapper for ALERT message */ + void log_alert(gr_logger_ptr logger,std::string msg){GR_LOG_ALERT(logger,msg);}; + + /*! \brief inline function, wrapper for FATAL message */ + void log_fatal(gr_logger_ptr logger,std::string msg){GR_LOG_FATAL(logger,msg);}; + + /*! \brief inline function, wrapper for EMERG message */ + void log_emerg(gr_logger_ptr logger,std::string msg){GR_LOG_EMERG(logger,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */ + void log_errorIF(gr_logger_ptr logger,bool cond,std::string msg){GR_LOG_ERRORIF(logger,cond,msg);}; + + /*! \brief inline function, wrapper for LOG4CPP_ASSERT for conditional ERROR message */ + void log_assert(gr_logger_ptr logger,bool cond,std::string msg){GR_LOG_ASSERT(logger,cond,msg);}; +}; + + +#endif /* HAVE_LOG4CPP */ + +// If Logger disable do nothing +#else /* ENABLE_GR_LOG */ + +typedef void* gr_logger_ptr; + +#define GR_LOG_DECLARE_LOGPTR(logger) +#define GR_LOG_ASSIGN_LOGPTR(logger,name) +#define GR_CONFIG_LOGGER(config) +#define GR_CONFIG_AND_WATCH_LOGGER(config,period) +#define GR_LOG_GETLOGGER(logger, name) +#define GR_SET_LEVEL(name, level) +#define GR_LOG_SET_LEVEL(logger, level) +#define GR_GET_LEVEL(name, level) +#define GR_LOG_GET_LEVEL(logger, level) +#define GR_ADD_CONSOLE_APPENDER(logger,target,pattern) +#define GR_LOG_ADD_CONSOLE_APPENDER(logger,target,pattern) +#define GR_ADD_FILE_APPENDER(name,filename,append,pattern) +#define GR_LOG_ADD_FILE_APPENDER(logger,filename,append,pattern) +#define GR_ADD_ROLLINGFILE_APPENDER(name,filename,filesize,bkup_index,append,mode,pattern) +#define GR_LOG_ADD_ROLLINGFILE_APPENDER(logger,filename,filesize,bkup_index,append,mode,pattern) +#define GR_GET_LOGGER_NAMES(names) +#define GR_RESET_CONFIGURATION() +#define GR_DEBUG(name, msg) +#define GR_INFO(name, msg) +#define GR_NOTICE(name, msg) +#define GR_WARN(name, msg) +#define GR_ERROR(name, msg) +#define GR_ALERT(name, msg) +#define GR_CRIT(name, msg) +#define GR_FATAL(name, msg) +#define GR_EMERG(name, msg) +#define GR_ERRORIF(name, cond, msg) +#define GR_ASSERT(name, cond, msg) +#define GR_LOG_DEBUG(logger, msg) +#define GR_LOG_INFO(logger, msg) +#define GR_LOG_NOTICE(logger, msg) +#define GR_LOG_WARN(logger, msg) +#define GR_LOG_ERROR(logger, msg) +#define GR_LOG_ALERT(logger, msg) +#define GR_LOG_CRIT(logger, msg) +#define GR_LOG_FATAL(logger, msg) +#define GR_LOG_EMERG(logger, msg) +#define GR_LOG_ERRORIF(logger, cond, msg) +#define GR_LOG_ASSERT(logger, cond, msg) + +#endif /* ENABLE_GR_LOG */ +#endif /* INCLUDED_GR_LOGGER_H */ diff --git a/gnuradio-core/src/lib/runtime/gr_logger.i b/gnuradio-core/src/lib/runtime/gr_logger.i new file mode 100644 index 0000000000..70e50e02b3 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_logger.i @@ -0,0 +1,109 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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 this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +/******************************************************************************* +* Copyright 2011 Johns Hopkins University Applied Physics Lab +* Author: Mark Plett +* Description: +* SWIG interface generator file for gr_logger module. gr_logger wraps log4cpp logging +* for gnuradio. +*******************************************************************************/ + +%feature("autodoc", "1"); // generate python docstrings + +%include "exception.i" +%import "gnuradio.i" // the common stuff + +%{ +#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix +#include <stdexcept> +%} + +//----------------------------------- + +#ifdef ENABLE_GR_LOG +#ifdef HAVE_LOG4CPP + +%{ +// The .h files +#include <gr_logger.h> +#include <log4cpp/Category.hh> +%} + +namespace log4cpp{ +class LoggerPtr { +public: + ~LoggerPtr(); +}; +}; +void logger_load_config(const std::string &config_filename); +void logger_set_level(log4cpp::LoggerPtr logger, const std::string &level); + +%rename(log) gr_logger; + +class gr_logger +{ +private: + +public: + //gr_logger(std::string config_filename); + gr_logger(std::string config_filename,int watchPeriodSec); + void set_level(std::string name,std::string level); + void get_level(std::string name,std::string &level); + void add_console_appender(std::string name,std::string target,std::string pattern); + void add_file_appender(std::string name,std::string filename,bool append,std::string patter); + void add_rollingfile_appender(std::string name,std::string filename,size_t filesize,int bkup_indx,bool append,mode_t mode,std::string pattern); + + void notice(std::string name,std::string msg); + void debug(std::string name,std::string msg); + void info(std::string name,std::string msg); + void warn(std::string name,std::string msg); + void error(std::string name,std::string msg); + void emerg(std::string name,std::string msg); + void crit(std::string name,std::string msg); + void errorIF(std::string name,bool cond,std::string msg); + void gr_assert(std::string name,bool cond,std::string msg); + + static gr_logger_ptr getLogger(std::string name); + + void log_set_level(gr_logger_ptr logger,std::string level); + void log_get_level(gr_logger_ptr logger,std::string &level); + void log_add_console_appender(gr_logger_ptr logger,std::string target,std::string pattern); + void log_add_file_appender(gr_logger_ptr logger,std::string filename,bool append,std::string pattern); + void log_add_rollingfile_appender(gr_logger_ptr logger,std::string filename,size_t filesize,int bkup_index,bool append,mode_t mode,std::string pattern); + + void log_notice(gr_logger_ptr logger,std::string msg); + void log_debug(gr_logger_ptr logger,std::string msg); + void log_info(gr_logger_ptr logger,std::string msg); + void log_warn(gr_logger_ptr logger,std::string msg); + void log_error(gr_logger_ptr logger,std::string msg); + void log_crit(gr_logger_ptr logger,std::string msg); + void log_emerg(gr_logger_ptr logger,std::string msg); + void log_errorIF(gr_logger_ptr logger,bool cond,std::string msg); + void log_assert(gr_logger_ptr logger,bool cond,std::string msg); + + void get_logger_names(std::vector<std::string>& names); + void reset_configuration(); + +}; + +#endif /* HAVE_LOG4CPP */ +#endif /* ENABLE_GR_LOG */ diff --git a/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc new file mode 100644 index 0000000000..26ce2231aa --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.cc @@ -0,0 +1,146 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <boost/format.hpp> +#include <gr_tagged_stream_block.h> + +gr_tagged_stream_block::gr_tagged_stream_block (const std::string &name, + gr_io_signature_sptr input_signature, + gr_io_signature_sptr output_signature, + const std::string &length_tag_key) + : gr_block(name, input_signature, output_signature), + d_length_tag_key(pmt::pmt_string_to_symbol(length_tag_key)), + d_n_input_items_reqd(input_signature->min_streams(), 0), + d_length_tag_key_str(length_tag_key) +{ +} + + +// This is evil hackery: We trick the scheduler into creating the right number of input items +void +gr_tagged_stream_block::forecast (int noutput_items, gr_vector_int &ninput_items_required) +{ + unsigned ninputs = ninput_items_required.size(); + for (unsigned i = 0; i < ninputs; i++) { + if (i < d_n_input_items_reqd.size() && d_n_input_items_reqd[i] != 0) { + ninput_items_required[i] = d_n_input_items_reqd[i]; + } else { + // If there's no item, there's no tag--so there must at least be one! + ninput_items_required[i] = std::max(1, (int) std::floor((double) noutput_items / relative_rate() + 0.5)); + } + } +} + + +void +gr_tagged_stream_block::parse_length_tags( + const std::vector<std::vector<gr_tag_t> > &tags, + gr_vector_int &n_input_items_reqd +){ + for (unsigned i = 0; i < tags.size(); i++) { + for (unsigned k = 0; k < tags[i].size(); k++) { + if (tags[i][k].key == d_length_tag_key) { + n_input_items_reqd[i] = pmt::pmt_to_long(tags[i][k].value); + remove_item_tag(i, tags[i][k]); + } + } + } +} + + +int +gr_tagged_stream_block::calculate_output_stream_length(const gr_vector_int &ninput_items) +{ + int noutput_items = *std::max_element(ninput_items.begin(), ninput_items.end()); + return (int) std::floor(relative_rate() * noutput_items + 0.5); +} + + +void +gr_tagged_stream_block::update_length_tags(int n_produced, int n_ports) +{ + for (int i = 0; i < n_ports; i++) { + add_item_tag(i, nitems_written(i), + d_length_tag_key, + pmt::pmt_from_long(n_produced) + ); + } + return; +} + + +int +gr_tagged_stream_block::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + if (d_length_tag_key_str.empty()) { + return work(noutput_items, ninput_items, input_items, output_items); + } + + if (d_n_input_items_reqd[0] == 0) { // Otherwise, it's already set from a previous call + std::vector<std::vector<gr_tag_t> > tags(input_items.size(), std::vector<gr_tag_t>()); + for (unsigned i = 0; i < input_items.size(); i++) { + get_tags_in_range(tags[i], i, nitems_read(i), nitems_read(i)+1); + } + d_n_input_items_reqd.assign(input_items.size(), -1); + parse_length_tags(tags, d_n_input_items_reqd); + } + for (unsigned i = 0; i < input_items.size(); i++) { + if (d_n_input_items_reqd[i] == -1) { + GR_LOG_FATAL(d_logger, boost::format("Missing a required length tag on port %1% at item #%2%") % i % nitems_read(i)); + throw std::runtime_error("Missing length tag."); + } + if (d_n_input_items_reqd[i] > ninput_items[i]) { + return 0; + } + } + + int min_output_size = calculate_output_stream_length(d_n_input_items_reqd); + if (noutput_items < min_output_size) { + set_min_noutput_items(min_output_size); + return 0; + } + set_min_noutput_items(1); + + // WORK CALLED HERE // + int n_produced = work(noutput_items, d_n_input_items_reqd, input_items, output_items); + ////////////////////// + + if (n_produced == WORK_DONE) { + return n_produced; + } + for (int i = 0; i < (int) d_n_input_items_reqd.size(); i++) { + consume(i, d_n_input_items_reqd[i]); + } + update_length_tags(n_produced, output_items.size()); + + d_n_input_items_reqd.assign(input_items.size(), 0); + + return n_produced; +} + diff --git a/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.h b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.h new file mode 100644 index 0000000000..a82b27f6a6 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.h @@ -0,0 +1,142 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_GR_TAGGED_STREAM_BLOCK_H +#define INCLUDED_GR_TAGGED_STREAM_BLOCK_H + +#include <gr_core_api.h> +#include <gr_block.h> + +/*! + * \brief Block that operates on PDUs in form of tagged streams + * \ingroup base_blk + * + * Override work to provide the signal processing implementation. + */ +class GR_CORE_API gr_tagged_stream_block : public gr_block +{ + private: + pmt::pmt_t d_length_tag_key; //!< This is the key for the tag that stores the PDU length + gr_vector_int d_n_input_items_reqd; //!< How many input items do I need to process the next PDU? + + protected: + std::string d_length_tag_key_str; + gr_tagged_stream_block (void){} //allows pure virtual interface sub-classes + gr_tagged_stream_block (const std::string &name, + gr_io_signature_sptr input_signature, + gr_io_signature_sptr output_signature, + const std::string &length_tag_key); + + /*! + * \brief Parse all tags on the first sample of a PDU, return the number of items per input + * and prune the length tags. + * + * In most cases, you don't need to override this, unless the number of items read + * is not directly coded in one single tag. + * + * Default behaviour: + * - Go through all input ports + * - On every input port, search for the tag with the key specified in \p length_tag_key + * - Copy that value as an int to the corresponding position in \p n_input_items_reqd + * - Remove the length tag. + * + * \param[in] tags All the tags found on the first item of every input port. + * \param[out] n_input_items_reqd Number of items which will be read from every input + */ + virtual void parse_length_tags( + const std::vector<std::vector<gr_tag_t> > &tags, + gr_vector_int &n_input_items_reqd + ); + + /*! + * \brief Calculate the number of output items. + * + * This is basically the inverse function to forecast(): Given a number of input + * items, it returns the maximum number of output items. + * + * You most likely need to override this function, unless your block is a sync + * block or integer interpolator/decimator. + * + */ + virtual int calculate_output_stream_length(const gr_vector_int &ninput_items); + + /*! + * \brief Set the new length tags on the output stream + * + * Default behaviour: Set a tag with key \p length_tag_key and + * the number of produced items on every output port. + * + * For anything else, override this. + * + * \param n_produced Length of the new PDU + * \param n_ports Number of output ports + */ + virtual void update_length_tags(int n_produced, int n_ports); + + public: + + /*! \brief Don't override this. + */ + void /* final */ forecast (int noutput_items, gr_vector_int &ninput_items_required); + + /*! + * - Reads the number of input items from the tags using parse_length_tags() + * - Checks there's enough data on the input and output buffers + * - If not, inform the scheduler and do nothing + * - Calls work() with the exact number of items per PDU + * - Updates the tags using update_length_tags() + */ + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + /*! + * \brief Just like gr_block::general_work, but makes sure the input is valid + * + * The user must override work to define the signal processing code. + * Check the documentation for general_work() to see what happens here. + * + * Like gr_sync_block, this calls consume() for you (it consumes ninput_items[i] + * items from the i-th port). + * + * A note on tag propagation: The PDU length tags are handled by other functions, + * but all other tags are handled just as in any other \p gr_block. So, most likely, + * you either set the tag propagation policy to TPP_DONT and handle the tag + * propagation manually, or you propagate tags through the scheduler and don't + * do anything here. + * + * \param noutput_items The size of the writable output buffer + * \param ninput_items The exact size of the items on every input for this particular PDU. + * These will be consumed if a length tag key is provided! + * \param input_items See gr_block + * \param output_items See gr_block + */ + virtual int work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) = 0; + +}; + +#endif /* INCLUDED_GR_TAGGED_STREAM_BLOCK_H */ + diff --git a/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.i b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.i new file mode 100644 index 0000000000..9fc803dca1 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_tagged_stream_block.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * 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. + */ +class gr_tagged_stream_block : public gr_block +{ + protected: + gr_tagged_stream_block (const std::string &name, + gr_io_signature_sptr input_signature, + gr_io_signature_sptr output_signature, + const std::string &length_tag_key); +}; + diff --git a/gnuradio-core/src/lib/runtime/gr_tags.h b/gnuradio-core/src/lib/runtime/gr_tags.h index a9ca902352..ea60f89928 100644 --- a/gnuradio-core/src/lib/runtime/gr_tags.h +++ b/gnuradio-core/src/lib/runtime/gr_tags.h @@ -39,6 +39,9 @@ struct GR_CORE_API gr_tag_t{ //! 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 static inline bool offset_compare( const gr_tag_t &x, const gr_tag_t &y diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.cc b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc new file mode 100644 index 0000000000..a8e4a1d766 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.cc @@ -0,0 +1,52 @@ +/* + * Copyright 2012 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. + */ + +/* + * This class gathers together all the test cases for the example + * directory into a single test suite. As you create new test cases, + * add them here. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qa_gr_logger.h> +#include <gr_logger.h> + +void +qa_gr_logger::t1() +{ +#ifdef ENABLE_GR_LOG + // This doesn't really test anything, more just + // making sure nothing's gone horribly wrong. + + GR_LOG_GETLOGGER(LOG,"main"); + GR_ADD_CONSOLE_APPENDER("main","cout","%d{%H:%M:%S} : %m%n"); + GR_LOG_NOTICE(LOG,"test from c++ NOTICE"); + GR_LOG_DEBUG(LOG,"test from c++ DEBUG"); + GR_LOG_INFO(LOG,"test from c++ INFO"); + GR_LOG_WARN(LOG,"test from c++ WARN"); + GR_LOG_ERROR(LOG,"test from c++ ERROR"); + GR_LOG_FATAL(LOG,"test from c++ FATAL"); + CPPUNIT_ASSERT(true); +#endif +} diff --git a/gnuradio-core/src/lib/runtime/qa_gr_logger.h b/gnuradio-core/src/lib/runtime/qa_gr_logger.h new file mode 100644 index 0000000000..b0d3711523 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/qa_gr_logger.h @@ -0,0 +1,42 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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 Example 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 Example Public License for more details. + * + * You should have received a copy of the GNU Example 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. + */ + +#ifndef INCLUDED_QA_GR_LOG_H +#define INCLUDED_QA_GR_LOG_H + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestSuite.h> + +//! collect all the tests for the example directory + +class qa_gr_logger : public CppUnit::TestCase { + public: + CPPUNIT_TEST_SUITE(qa_gr_logger); + CPPUNIT_TEST(t1); + CPPUNIT_TEST_SUITE_END(); + + private: + void t1(); + +}; + +#endif /* INCLUDED_QA_GR_LOG_H */ diff --git a/gnuradio-core/src/lib/runtime/qa_runtime.cc b/gnuradio-core/src/lib/runtime/qa_runtime.cc index 5e62c79915..62c95ef5c4 100644 --- a/gnuradio-core/src/lib/runtime/qa_runtime.cc +++ b/gnuradio-core/src/lib/runtime/qa_runtime.cc @@ -34,6 +34,7 @@ #include <qa_gr_io_signature.h> #include <qa_gr_block.h> #include <qa_gr_flowgraph.h> +#include <qa_gr_logger.h> #include <qa_gr_top_block.h> #include <qa_gr_hier_block2.h> #include <qa_gr_hier_block2_derived.h> @@ -50,6 +51,7 @@ qa_runtime::suite () s->addTest (qa_gr_io_signature::suite ()); s->addTest (qa_gr_block::suite ()); s->addTest (qa_gr_flowgraph::suite ()); + s->addTest (qa_gr_logger::suite ()); s->addTest (qa_gr_top_block::suite ()); s->addTest (qa_gr_hier_block2::suite ()); s->addTest (qa_gr_hier_block2_derived::suite ()); diff --git a/gnuradio-core/src/lib/runtime/runtime.i b/gnuradio-core/src/lib/runtime/runtime.i index 8e35df8342..dd7b095547 100644 --- a/gnuradio-core/src/lib/runtime/runtime.i +++ b/gnuradio-core/src/lib/runtime/runtime.i @@ -39,7 +39,9 @@ #include <gr_sync_block.h> #include <gr_sync_decimator.h> #include <gr_sync_interpolator.h> +#include <gr_tagged_stream_block.h> #include <gr_top_block.h> +#include <gr_logger.h> %} %constant int sizeof_char = sizeof(char); @@ -66,4 +68,6 @@ %include <gr_sync_block.i> %include <gr_sync_decimator.i> %include <gr_sync_interpolator.i> +%include <gr_tagged_stream_block.i> %include <gr_top_block.i> +%include <gr_logger.i> diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index d8a64cc0f6..2c89494e78 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -25,9 +25,19 @@ set(GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) -set(GR_SWIG_LIBRARIES gnuradio-core) +set(GR_SWIG_LIBRARIES + gnuradio-core + ${LOG4CPP_LIBRARIES} +) + +# Only use if log4cpp is installed +# Define ENABLE_GR_LOG for the .i file to ignore it. +if(ENABLE_GR_LOG) + SET(GR_SWIG_FLAGS "-DENABLE_GR_LOG") +endif(ENABLE_GR_LOG) link_directories(${Boost_LIBRARY_DIRS}) diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i index 0f02554c9e..03b7817e22 100644 --- a/gnuradio-core/src/lib/swig/gnuradio.i +++ b/gnuradio-core/src/lib/swig/gnuradio.i @@ -38,6 +38,7 @@ #include <gr_types.h> #include <stddef.h> // size_t #include <complex> +#include <string.h> %} %feature("autodoc","1"); @@ -49,6 +50,7 @@ %include <std_vector.i> %include <stl.i> %include <std_except.i> +%include <std_string.i> typedef std::complex<float> gr_complex; typedef std::complex<double> gr_complexd; @@ -65,7 +67,8 @@ namespace std { %template() vector<int>; %template() vector<float>; %template() vector<double>; - // %template() std::complex<float>; + %template() vector<std::string>; + %template() vector<gr_tag_t>; %template() vector< std::complex<float> >; %template() vector< std::vector< unsigned char > >; diff --git a/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h b/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h index 1994f06609..bbbabaf07b 100644 --- a/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h +++ b/gnuradio-core/src/lib/swig/gnuradio_swig_bug_workaround.h @@ -40,6 +40,7 @@ class gr_msg_queue; class gr_sync_block; class gr_sync_decimator; class gr_sync_interpolator; +class gr_tagged_stream_block; class gr_top_block; #endif /* INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H */ diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_message_tags.py b/gnuradio-core/src/python/gnuradio/gr/qa_message_tags.py new file mode 100644 index 0000000000..566a09988e --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_message_tags.py @@ -0,0 +1,26 @@ +import time + +from gnuradio import gr, gr_unittest + +class test_message_tags (gr_unittest.TestCase): + + def test_1 (self): + data = ('hello', 'you', 'there') + tx_msgq = gr.msg_queue () + rx_msgq = gr.msg_queue () + for d in data: + tx_msgq.insert_tail(gr.message_from_string(d)) + tb = gr.top_block() + src = gr.message_source(gr.sizeof_char, tx_msgq, "packet_length") + snk = gr.message_sink(gr.sizeof_char, rx_msgq, False, "packet_length") + tb.connect(src, snk) + tb.start() + time.sleep(1) + tb.stop() + for d in data: + msg = rx_msgq.delete_head() + contents = msg.to_string() + self.assertEqual(d, contents) + +if __name__ == '__main__': + gr_unittest.run(test_message_tags, "test_message_tags.xml") diff --git a/gnuradio-core/src/tests/CMakeLists.txt b/gnuradio-core/src/tests/CMakeLists.txt index dbd52f05c7..2340f123e1 100644 --- a/gnuradio-core/src/tests/CMakeLists.txt +++ b/gnuradio-core/src/tests/CMakeLists.txt @@ -36,6 +36,9 @@ link_directories( ${CPPUNIT_LIBRARY_DIRS} ) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Build benchmarks and non-registered tests ######################################################################## diff --git a/gr-analog/doc/analog.dox b/gr-analog/doc/analog.dox index d3af364f74..437eb05c74 100644 --- a/gr-analog/doc/analog.dox +++ b/gr-analog/doc/analog.dox @@ -11,7 +11,7 @@ imported as: \endcode See the Doxygen documentation for details about the blocks available -in this package. The relevant blocks are listed in the \ref analog group. +in this package. A quick listing of the details can be found in Python after importing by using: diff --git a/gr-analog/grc/analog_block_tree.xml b/gr-analog/grc/analog_block_tree.xml index b5b2ecd568..3991aee915 100644 --- a/gr-analog/grc/analog_block_tree.xml +++ b/gr-analog/grc/analog_block_tree.xml @@ -29,10 +29,9 @@ <cat> <name></name> <!-- Blank for Root Name --> <cat> - <name>Level Controls</name> + <name>Level Controllers</name> <block>analog_agc_xx</block> <block>analog_agc2_xx</block> - <block>analog_dpll_bb</block> <block>analog_feedforward_agc_cc</block> <block>analog_ctcss_squelch_ff</block> <block>analog_pwr_squelch_xx</block> @@ -47,7 +46,7 @@ <block>analog_quadrature_demod_cf</block> </cat> <cat> - <name>Sources</name> + <name>Waveform Generators</name> <block>analog_sig_source_x</block> <block>analog_noise_source_x</block> </cat> @@ -58,7 +57,11 @@ <block>analog_pll_refout_cc</block> </cat> <cat> - <name>Probes</name> + <name>Peak Detectors</name> + <block>analog_dpll_bb</block> + </cat> + <cat> + <name>Measurement Tools</name> <block>analog_probe_avg_mag_sqrd_x</block> </cat> </cat> diff --git a/gr-analog/grc/analog_plateau_detector_fb.xml b/gr-analog/grc/analog_plateau_detector_fb.xml new file mode 100644 index 0000000000..f14efc97f4 --- /dev/null +++ b/gr-analog/grc/analog_plateau_detector_fb.xml @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<block> + <name>Plateau Detector</name> + <key>analog_plateau_detector_fb</key> + <import>from gnuradio import analog</import> + <make>analog.plateau_detector_fb($max_len, $threshold)</make> + <param> + <name>Max. plateau length</name> + <key>max_len</key> + <type>int</type> + </param> + <param> + <name>Threshold</name> + <key>threshold</key> + <value>0.9</value> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>real</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-analog/include/analog/CMakeLists.txt b/gr-analog/include/analog/CMakeLists.txt index b113dacc44..f46960c984 100644 --- a/gr-analog/include/analog/CMakeLists.txt +++ b/gr-analog/include/analog/CMakeLists.txt @@ -93,6 +93,7 @@ install(FILES fmdet_cf.h frequency_modulator_fc.h phase_modulator_fc.h + plateau_detector_fb.h pll_carriertracking_cc.h pll_freqdet_cf.h pll_refout_cc.h @@ -105,7 +106,7 @@ install(FILES rail_ff.h rotator.h sig_source_waveform.h - simple_squelch_cc.h + simple_squelch_cc.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/analog COMPONENT "analog_devel" ) diff --git a/gr-analog/include/analog/agc.h b/gr-analog/include/analog/agc.h index 92d777fa19..c939431fe4 100644 --- a/gr-analog/include/analog/agc.h +++ b/gr-analog/include/analog/agc.h @@ -34,6 +34,7 @@ namespace gr { /*! * \brief high performance Automatic Gain Control class for complex signals. * + * \details * For Power the absolute value of the complex number is used. */ class ANALOG_API agc_cc diff --git a/gr-analog/include/analog/agc2.h b/gr-analog/include/analog/agc2.h index 75a203e9fc..be28301070 100644 --- a/gr-analog/include/analog/agc2.h +++ b/gr-analog/include/analog/agc2.h @@ -34,6 +34,7 @@ namespace gr { /*! * \brief high performance Automatic Gain Control class * + * \details * For Power the absolute value of the complex number is used. */ class ANALOG_API agc2_cc diff --git a/gr-analog/include/analog/agc2_cc.h b/gr-analog/include/analog/agc2_cc.h index c922ccd4da..87e6200346 100644 --- a/gr-analog/include/analog/agc2_cc.h +++ b/gr-analog/include/analog/agc2_cc.h @@ -32,8 +32,9 @@ namespace gr { /*! * \brief high performance Automatic Gain Control class - * \ingroup level_blk + * \ingroup level_controllers_blk * + * \details * For Power the absolute value of the complex number is used. */ class ANALOG_API agc2_cc : virtual public gr_sync_block diff --git a/gr-analog/include/analog/agc2_ff.h b/gr-analog/include/analog/agc2_ff.h index 27dd6d92e5..b960493dca 100644 --- a/gr-analog/include/analog/agc2_ff.h +++ b/gr-analog/include/analog/agc2_ff.h @@ -32,8 +32,9 @@ namespace gr { /*! * \brief high performance Automatic Gain Control class + * \ingroup level_controllers_blk * - * \ingroup level_blk + * \details * Power is approximated by absolute value */ class ANALOG_API agc2_ff : virtual public gr_sync_block diff --git a/gr-analog/include/analog/agc_cc.h b/gr-analog/include/analog/agc_cc.h index b2b1a9b430..d516af4565 100644 --- a/gr-analog/include/analog/agc_cc.h +++ b/gr-analog/include/analog/agc_cc.h @@ -32,8 +32,9 @@ namespace gr { /*! * \brief high performance Automatic Gain Control class - * \ingroup level_blk + * \ingroup level_controllers_blk * + * \details * For Power the absolute value of the complex number is used. */ class ANALOG_API agc_cc : virtual public gr_sync_block diff --git a/gr-analog/include/analog/agc_ff.h b/gr-analog/include/analog/agc_ff.h index 30d1ae1fd9..3056b96476 100644 --- a/gr-analog/include/analog/agc_ff.h +++ b/gr-analog/include/analog/agc_ff.h @@ -32,8 +32,9 @@ namespace gr { /*! * \brief high performance Automatic Gain Control class - * \ingroup level_blk + * \ingroup level_controllers_blk * + * \details * Power is approximated by absolute value */ class ANALOG_API agc_ff : virtual public gr_sync_block diff --git a/gr-analog/include/analog/cpfsk_bc.h b/gr-analog/include/analog/cpfsk_bc.h index 904730e2b5..8150e0d08f 100644 --- a/gr-analog/include/analog/cpfsk_bc.h +++ b/gr-analog/include/analog/cpfsk_bc.h @@ -30,7 +30,7 @@ namespace gr { /*! * \brief Perform continuous phase 2-level frequency shift keying modulation * on an input stream of unpacked bits. - * \ingroup modulation_blk + * \ingroup modulators_blk */ class ANALOG_API cpfsk_bc : virtual public gr_sync_interpolator { diff --git a/gr-analog/include/analog/cpm.h b/gr-analog/include/analog/cpm.h index d22e02321c..205fcfe809 100644 --- a/gr-analog/include/analog/cpm.h +++ b/gr-analog/include/analog/cpm.h @@ -42,6 +42,7 @@ namespace gr { /*! \brief Return the taps for an interpolating FIR filter (gr_interp_fir_filter_fff). * + * \details * These taps represent the phase response \f$g(k)\f$ for use in a CPM modulator, * see also gr_cpmmod_bc. * diff --git a/gr-analog/include/analog/ctcss_squelch_ff.h b/gr-analog/include/analog/ctcss_squelch_ff.h index f880299173..471021d008 100644 --- a/gr-analog/include/analog/ctcss_squelch_ff.h +++ b/gr-analog/include/analog/ctcss_squelch_ff.h @@ -32,7 +32,7 @@ namespace gr { /*! * \brief gate or zero output if ctcss tone not present - * \ingroup level_blk + * \ingroup level_controllers_blk */ class ANALOG_API ctcss_squelch_ff : public squelch_base_ff, virtual public gr_block diff --git a/gr-analog/include/analog/dpll_bb.h b/gr-analog/include/analog/dpll_bb.h index 78efb8fde9..f25e860b2c 100644 --- a/gr-analog/include/analog/dpll_bb.h +++ b/gr-analog/include/analog/dpll_bb.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief Detect the peak of a signal - * \ingroup level_blk + * \ingroup peak_detectors_blk * + * \details * If a peak is detected, this block outputs a 1, * or it outputs 0's. */ diff --git a/gr-analog/include/analog/feedforward_agc_cc.h b/gr-analog/include/analog/feedforward_agc_cc.h index 9e259a4eba..13b4fe0486 100644 --- a/gr-analog/include/analog/feedforward_agc_cc.h +++ b/gr-analog/include/analog/feedforward_agc_cc.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief Non-causal AGC which computes required gain based on max absolute value over nsamples - * \ingroup level_blk + * \ingroup level_controllers_blk */ class ANALOG_API feedforward_agc_cc : virtual public gr_sync_block { diff --git a/gr-analog/include/analog/fmdet_cf.h b/gr-analog/include/analog/fmdet_cf.h index 6878775e6c..bd26e39226 100644 --- a/gr-analog/include/analog/fmdet_cf.h +++ b/gr-analog/include/analog/fmdet_cf.h @@ -32,6 +32,7 @@ namespace gr { /*! * \brief Implements an IQ slope detector * + * \details * input: stream of complex; output: stream of floats * * This implements a limiting slope detector. The limiter is in diff --git a/gr-analog/include/analog/frequency_modulator_fc.h b/gr-analog/include/analog/frequency_modulator_fc.h index 8706d513a6..86f6d20d98 100644 --- a/gr-analog/include/analog/frequency_modulator_fc.h +++ b/gr-analog/include/analog/frequency_modulator_fc.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief Frequency modulator block - * \ingroup modulation_blk + * \ingroup modulators_blk * + * \details * float input; complex baseband output */ class ANALOG_API frequency_modulator_fc : virtual public gr_sync_block diff --git a/gr-analog/include/analog/lfsr.h b/gr-analog/include/analog/lfsr.h index 5cf2ec70df..bb5c4b0ea4 100644 --- a/gr-analog/include/analog/lfsr.h +++ b/gr-analog/include/analog/lfsr.h @@ -35,6 +35,7 @@ namespace gr { * polynomial mask * \ingroup misc * + * \details * Generates a maximal length pseudo-random sequence of length * 2^degree-1 * diff --git a/gr-analog/include/analog/noise_source_X.h.t b/gr-analog/include/analog/noise_source_X.h.t index 9d1be6fedf..9fa470c47d 100644 --- a/gr-analog/include/analog/noise_source_X.h.t +++ b/gr-analog/include/analog/noise_source_X.h.t @@ -35,7 +35,7 @@ namespace gr { /*! * \brief Random number source - * \ingroup source_blk + * \ingroup waveform_generators_blk * * \details * Generate random values from different distributions. @@ -47,11 +47,11 @@ namespace gr { // gr::analog::@BASE_NAME@::sptr typedef boost::shared_ptr<@BASE_NAME@> sptr; - /*! \brief Make a noise source + /*! Build a noise source * \param type the random distribution to use (see analog/noise_type.h) * \param ampl a scaling factor for the output * \param seed seed for random generators. Note that for uniform and - * Gaussian distributions, this should be a negative number. + * Gaussian distributions, this should be a negative number. */ static sptr make(noise_type_t type, float ampl, long seed); diff --git a/gr-analog/include/analog/phase_modulator_fc.h b/gr-analog/include/analog/phase_modulator_fc.h index 409de7804b..2ec7c1a3c4 100644 --- a/gr-analog/include/analog/phase_modulator_fc.h +++ b/gr-analog/include/analog/phase_modulator_fc.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief Phase modulator block - * \ingroup modulation_blk + * \ingroup modulators_blk * + * \details * output = complex(cos(in*sensitivity), sin(in*sensitivity)) * * Input stream 0: floats diff --git a/gr-analog/include/analog/plateau_detector_fb.h b/gr-analog/include/analog/plateau_detector_fb.h new file mode 100644 index 0000000000..767aafe23a --- /dev/null +++ b/gr-analog/include/analog/plateau_detector_fb.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + + +#ifndef INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_H +#define INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_H + +#include <analog/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace analog { + + /*! + * \brief Detects a plateau and marks the middle. + * + * \details + * Detect a plateau of a-priori known height. Input is a stream of floats, + * the output is a stream of bytes. Whenever a plateau is detected, the + * middle of that plateau is marked with a '1' on the output stream (all + * other samples are left at zero). + * + * You can use this in a Schmidl & Cox synchronisation algorithm to interpret + * the output of the normalized correlator. Just pass the length of the cyclic + * prefix (in samples) as the max_len parameter). + * + * Unlike the peak detectors, you must the now the absolute height of the plateau. + * Whenever the amplitude exceeds the given threshold, it starts assuming the + * presence of a plateau. + * + * An implicit hysteresis is provided by the fact that after detecting one plateau, + * it waits at least max_len samples before the next plateau can be detected. + */ + class ANALOG_API plateau_detector_fb : virtual public gr_sync_block + { + public: + typedef boost::shared_ptr<plateau_detector_fb> sptr; + + /*! + * \param max_len Maximum length of the plateau + * \param threshold Anything above this value is considered a plateau + */ + static sptr make(int max_len, float threshold=0.9); + }; + + } // namespace analog +} // namespace gr + +#endif /* INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_H */ + diff --git a/gr-analog/include/analog/pll_carriertracking_cc.h b/gr-analog/include/analog/pll_carriertracking_cc.h index 3596429d49..bb92673185 100644 --- a/gr-analog/include/analog/pll_carriertracking_cc.h +++ b/gr-analog/include/analog/pll_carriertracking_cc.h @@ -32,8 +32,9 @@ namespace gr { /*! * \brief Implements a PLL which locks to the input frequency and outputs the * input signal mixed with that carrier. - * \ingroup sync_blk + * \ingroup synchronizers_blk * + * \details * Input stream 0: complex * Output stream 0: complex * diff --git a/gr-analog/include/analog/pll_freqdet_cf.h b/gr-analog/include/analog/pll_freqdet_cf.h index 613e85263f..a653261c30 100644 --- a/gr-analog/include/analog/pll_freqdet_cf.h +++ b/gr-analog/include/analog/pll_freqdet_cf.h @@ -32,8 +32,9 @@ namespace gr { /*! * \brief Implements a PLL which locks to the input frequency and outputs * an estimate of that frequency. Useful for FM Demod. - * \ingroup sync_blk + * \ingroup synchronizers_blk * + * \details * Input stream 0: complex * Output stream 0: float * diff --git a/gr-analog/include/analog/pll_refout_cc.h b/gr-analog/include/analog/pll_refout_cc.h index a18d177e6e..da15762779 100644 --- a/gr-analog/include/analog/pll_refout_cc.h +++ b/gr-analog/include/analog/pll_refout_cc.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief Implements a PLL which locks to the input frequency and outputs a carrier - * \ingroup sync_blk + * \ingroup synchronizers_blk * + * \details * Input stream 0: complex * Output stream 0: complex * diff --git a/gr-analog/include/analog/probe_avg_mag_sqrd_c.h b/gr-analog/include/analog/probe_avg_mag_sqrd_c.h index 9e62732a36..2fed4fff0b 100644 --- a/gr-analog/include/analog/probe_avg_mag_sqrd_c.h +++ b/gr-analog/include/analog/probe_avg_mag_sqrd_c.h @@ -30,8 +30,9 @@ namespace gr { /*! * \brief compute avg magnitude squared. - * \ingroup sink_blk + * \ingroup measurement_tools_blk * + * \details * Input stream 0: complex * * Compute a running average of the magnitude squared of the the diff --git a/gr-analog/include/analog/probe_avg_mag_sqrd_cf.h b/gr-analog/include/analog/probe_avg_mag_sqrd_cf.h index b18916ae9b..303670adee 100644 --- a/gr-analog/include/analog/probe_avg_mag_sqrd_cf.h +++ b/gr-analog/include/analog/probe_avg_mag_sqrd_cf.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief compute avg magnitude squared. - * \ingroup sink_blk + * \ingroup measurement_tools_blk * + * \details * Input stream 0: complex * Output stream 0: float * diff --git a/gr-analog/include/analog/probe_avg_mag_sqrd_f.h b/gr-analog/include/analog/probe_avg_mag_sqrd_f.h index fe9d27793f..2300f8bca1 100644 --- a/gr-analog/include/analog/probe_avg_mag_sqrd_f.h +++ b/gr-analog/include/analog/probe_avg_mag_sqrd_f.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief compute avg magnitude squared. - * \ingroup sink_blk + * \ingroup measurement_tools_blk * + * \details * input stream 0: float * * Compute a running average of the magnitude squared of the the diff --git a/gr-analog/include/analog/pwr_squelch_cc.h b/gr-analog/include/analog/pwr_squelch_cc.h index 79364a86b5..840669b6b7 100644 --- a/gr-analog/include/analog/pwr_squelch_cc.h +++ b/gr-analog/include/analog/pwr_squelch_cc.h @@ -32,7 +32,7 @@ namespace gr { /*! * \brief gate or zero output when input power below threshold - * \ingroup level_blk + * \ingroup level_controllers_blk */ class ANALOG_API pwr_squelch_cc : public squelch_base_cc, virtual public gr_block diff --git a/gr-analog/include/analog/pwr_squelch_ff.h b/gr-analog/include/analog/pwr_squelch_ff.h index 6fdebec746..9aca73a175 100644 --- a/gr-analog/include/analog/pwr_squelch_ff.h +++ b/gr-analog/include/analog/pwr_squelch_ff.h @@ -32,7 +32,7 @@ namespace gr { /*! * \brief gate or zero output when input power below threshold - * \ingroup level_blk + * \ingroup level_controllers_blk */ class ANALOG_API pwr_squelch_ff : public squelch_base_ff, virtual public gr_block diff --git a/gr-analog/include/analog/quadrature_demod_cf.h b/gr-analog/include/analog/quadrature_demod_cf.h index 916d8b2ece..919cf779f7 100644 --- a/gr-analog/include/analog/quadrature_demod_cf.h +++ b/gr-analog/include/analog/quadrature_demod_cf.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief quadrature demodulator: complex in, float out - * \ingroup demodulation_blk + * \ingroup modulators_blk * + * \details * This can be used to demod FM, FSK, GMSK, etc. * The input is complex baseband. */ diff --git a/gr-analog/include/analog/rail_ff.h b/gr-analog/include/analog/rail_ff.h index e51b2fc935..7771fd9e8e 100644 --- a/gr-analog/include/analog/rail_ff.h +++ b/gr-analog/include/analog/rail_ff.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief clips input values to min, max - * \ingroup misc + * \ingroup level_controllers_blk */ class ANALOG_API rail_ff : virtual public gr_sync_block { diff --git a/gr-analog/include/analog/sig_source_X.h.t b/gr-analog/include/analog/sig_source_X.h.t index 2915c2abe9..752fe4cd29 100644 --- a/gr-analog/include/analog/sig_source_X.h.t +++ b/gr-analog/include/analog/sig_source_X.h.t @@ -34,7 +34,7 @@ namespace gr { /*! * \brief signal generator with @TYPE@ output. - * \ingroup source_blk + * \ingroup waveform_generators_blk */ class ANALOG_API @BASE_NAME@ : virtual public gr_sync_block { @@ -43,7 +43,7 @@ namespace gr { typedef boost::shared_ptr<@BASE_NAME@> sptr; /*! - * \brief Make a signal source block. + * Build a signal source block. * * \param sampling_freq Sampling rate of signal. * \param waveform wavetform type. diff --git a/gr-analog/include/analog/simple_squelch_cc.h b/gr-analog/include/analog/simple_squelch_cc.h index 1e12646e4e..bf949e3d2e 100644 --- a/gr-analog/include/analog/simple_squelch_cc.h +++ b/gr-analog/include/analog/simple_squelch_cc.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief simple squelch block based on average signal power and threshold in dB. - * \ingroup level_blk + * \ingroup level_controllers_blk */ class ANALOG_API simple_squelch_cc : virtual public gr_sync_block { diff --git a/gr-analog/lib/CMakeLists.txt b/gr-analog/lib/CMakeLists.txt index f7d6723b4e..396ff04654 100644 --- a/gr-analog/lib/CMakeLists.txt +++ b/gr-analog/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -121,6 +121,7 @@ list(APPEND analog_sources fmdet_cf_impl.cc frequency_modulator_fc_impl.cc phase_modulator_fc_impl.cc + plateau_detector_fb_impl.cc pll_carriertracking_cc_impl.cc pll_freqdet_cf_impl.cc pll_refout_cc_impl.cc @@ -135,6 +136,21 @@ list(APPEND analog_sources sincos.cc ) +#Add Windows DLL resource file if using MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-analog.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-analog.rc + @ONLY) + + list(APPEND analog_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-analog.rc + ) + +ENDIF(MSVC) + list(APPEND analog_libs volk gnuradio-core diff --git a/gr-analog/lib/gnuradio-analog.rc.in b/gr-analog/lib/gnuradio-analog.rc.in new file mode 100644 index 0000000000..7c8c1919f0 --- /dev/null +++ b/gr-analog/lib/gnuradio-analog.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-analog" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-analog.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-analog.dll" + VALUE "ProductName", "gnuradio-analog" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-analog/lib/plateau_detector_fb_impl.cc b/gr-analog/lib/plateau_detector_fb_impl.cc new file mode 100644 index 0000000000..0d2890bc55 --- /dev/null +++ b/gr-analog/lib/plateau_detector_fb_impl.cc @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "plateau_detector_fb_impl.h" + +namespace gr { + namespace analog { + +plateau_detector_fb::sptr +plateau_detector_fb::make(int max_len, float threshold) +{ + return gnuradio::get_initial_sptr (new plateau_detector_fb_impl(max_len, threshold)); +} + +plateau_detector_fb_impl::plateau_detector_fb_impl(int max_len, float threshold) + : gr_sync_block("plateau_detector_fb", + gr_make_io_signature(1, 1, sizeof (float)), + gr_make_io_signature(1, 1, sizeof (char))), + d_max_len(max_len), + d_threshold(threshold) +{} + +plateau_detector_fb_impl::~plateau_detector_fb_impl() +{ +} + +int +plateau_detector_fb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const float *in = (const float *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + int flank_start; + + memset((void *) out, 0x00, noutput_items); + int i; + for (i = 0; i < noutput_items; i++) { + if (in[i] >= d_threshold) { + if (noutput_items-i < 2*d_max_len) { // If we can't finish, come back later + break; + } + flank_start = i; + while (i < noutput_items && in[i] >= d_threshold) + i++; + if ((i - flank_start) > 1) { // 1 Sample is not a plateau + out[flank_start + (i-flank_start)/2] = 1; + i = std::min(i+d_max_len, noutput_items-1); + } + } + } + + return i; +} + + } /* namespace analog */ +} /* namespace gr */ + diff --git a/gr-analog/lib/plateau_detector_fb_impl.h b/gr-analog/lib/plateau_detector_fb_impl.h new file mode 100644 index 0000000000..daf1dd56d9 --- /dev/null +++ b/gr-analog/lib/plateau_detector_fb_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +#ifndef INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H +#define INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H + +#include <analog/plateau_detector_fb.h> + +namespace gr { + namespace analog { + +class plateau_detector_fb_impl : public plateau_detector_fb +{ + private: + int d_max_len; + float d_threshold; + + public: + plateau_detector_fb_impl(int max_len, float threshold); + ~plateau_detector_fb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + + } // namespace analog +} // namespace gr + +#endif /* INCLUDED_ANALOG_PLATEAU_DETECTOR_FB_IMPL_H */ + diff --git a/gr-analog/python/CMakeLists.txt b/gr-analog/python/CMakeLists.txt index 1657e5bf32..af4ed578f3 100644 --- a/gr-analog/python/CMakeLists.txt +++ b/gr-analog/python/CMakeLists.txt @@ -49,3 +49,4 @@ foreach(py_qa_test_file ${py_qa_test_files}) GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file}) endforeach(py_qa_test_file) endif(ENABLE_TESTING) + diff --git a/gr-analog/python/qa_plateau_detector_fb.py b/gr-analog/python/qa_plateau_detector_fb.py new file mode 100755 index 0000000000..5f8abc74ec --- /dev/null +++ b/gr-analog/python/qa_plateau_detector_fb.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# Copyright 2012 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. +# + +from gnuradio import gr, gr_unittest +import analog_swig as analog + +class qa_plateau_detector_fb (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_t (self): + # | Spur spike 1 | Plateau | Spur spike 2 + test_signal = (0, 1, .2, .4, .6, .8, 1, 1, 1, 1, 1, .8, .6, .4, 1, 0) + expected_sig = (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0) + # | Center of Plateau + sink = gr.vector_sink_b() + self.tb.connect(gr.vector_source_f(test_signal), analog.plateau_detector_fb(5), sink) + self.tb.run () + self.assertEqual(expected_sig, sink.data()) + + +if __name__ == '__main__': + gr_unittest.run(qa_plateau_detector_fb, "qa_plateau_detector_fb.xml") diff --git a/gr-analog/swig/analog_swig.i b/gr-analog/swig/analog_swig.i index 016537c949..96f4e23a8c 100644 --- a/gr-analog/swig/analog_swig.i +++ b/gr-analog/swig/analog_swig.i @@ -46,6 +46,7 @@ #include "analog/noise_source_f.h" #include "analog/noise_source_c.h" #include "analog/phase_modulator_fc.h" +#include "analog/plateau_detector_fb.h" #include "analog/pll_carriertracking_cc.h" #include "analog/pll_freqdet_cf.h" #include "analog/pll_refout_cc.h" @@ -85,6 +86,7 @@ %include "analog/noise_source_f.h" %include "analog/noise_source_c.h" %include "analog/phase_modulator_fc.h" +%include "analog/plateau_detector_fb.h" %include "analog/pll_carriertracking_cc.h" %include "analog/pll_freqdet_cf.h" %include "analog/pll_refout_cc.h" @@ -120,6 +122,7 @@ GR_SWIG_BLOCK_MAGIC2(analog, noise_source_i); GR_SWIG_BLOCK_MAGIC2(analog, noise_source_f); GR_SWIG_BLOCK_MAGIC2(analog, noise_source_c); GR_SWIG_BLOCK_MAGIC2(analog, phase_modulator_fc); +GR_SWIG_BLOCK_MAGIC2(analog, plateau_detector_fb); GR_SWIG_BLOCK_MAGIC2(analog, pll_carriertracking_cc); GR_SWIG_BLOCK_MAGIC2(analog, pll_freqdet_cf); GR_SWIG_BLOCK_MAGIC2(analog, pll_refout_cc); diff --git a/gr-atsc/src/lib/CMakeLists.txt b/gr-atsc/src/lib/CMakeLists.txt index 3d2b84a03c..86c0be4430 100644 --- a/gr-atsc/src/lib/CMakeLists.txt +++ b/gr-atsc/src/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011-212 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -30,6 +30,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Generate viterbi mux source # http://www.vtk.org/Wiki/CMake_Cross_Compiling#Using_executables_in_the_build_created_during_the_build @@ -95,9 +98,24 @@ list(APPEND gr_atsc_sources plinfo.cc ) +#Add Windows DLL resource file under MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-atsc.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-atsc.rc + @ONLY) + + list(APPEND gr_atsc_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-atsc.rc + ) +ENDIF(MSVC) + list(APPEND atsc_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-atsc SHARED ${gr_atsc_sources}) diff --git a/gr-atsc/src/lib/gnuradio-atsc.rc.in b/gr-atsc/src/lib/gnuradio-atsc.rc.in new file mode 100644 index 0000000000..f0d7699f00 --- /dev/null +++ b/gr-atsc/src/lib/gnuradio-atsc.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-atsc" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-atsc.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-atsc.dll" + VALUE "ProductName", "gnuradio-atsc" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-audio/grc/audio_sink.xml b/gr-audio/grc/audio_sink.xml index 4a88a7fa27..9a70006e72 100644 --- a/gr-audio/grc/audio_sink.xml +++ b/gr-audio/grc/audio_sink.xml @@ -7,7 +7,7 @@ <block> <name>Audio Sink</name> <key>audio_sink</key> - <category>Sinks</category> + <category>Audio</category> <throttle>1</throttle> <import>from gnuradio import audio</import> <make>audio.sink($samp_rate, $device_name, $ok_to_block)</make> diff --git a/gr-audio/grc/audio_source.xml b/gr-audio/grc/audio_source.xml index d56e9153a5..0cb73a3ae9 100644 --- a/gr-audio/grc/audio_source.xml +++ b/gr-audio/grc/audio_source.xml @@ -7,7 +7,7 @@ <block> <name>Audio Source</name> <key>audio_source</key> - <category>Sources</category> + <category>Audio</category> <throttle>1</throttle> <import>from gnuradio import audio</import> <make>audio.source($samp_rate, $device_name, $ok_to_block)</make> diff --git a/gr-audio/lib/CMakeLists.txt b/gr-audio/lib/CMakeLists.txt index f39264d5d2..c9e2806ebd 100644 --- a/gr-audio/lib/CMakeLists.txt +++ b/gr-audio/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -30,7 +30,10 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) -list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + +list(APPEND gr_audio_libs gnuradio-core ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES}) list(APPEND gr_audio_sources gr_audio_registry.cc) list(APPEND gr_audio_confs ${CMAKE_CURRENT_SOURCE_DIR}/gr-audio.conf) @@ -142,6 +145,20 @@ if(WIN32) ${CMAKE_CURRENT_SOURCE_DIR}/windows/audio_windows_sink.cc ) + #Add Windows DLL resource file if using MSVC + IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-audio.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-audio.rc + @ONLY) + + list(APPEND gr_audio_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-audio.rc + ) + ENDIF() + endif(WIN32) ######################################################################## diff --git a/gr-audio/lib/gnuradio-audio.rc.in b/gr-audio/lib/gnuradio-audio.rc.in new file mode 100644 index 0000000000..5173278a0a --- /dev/null +++ b/gr-audio/lib/gnuradio-audio.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-audio" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-audio.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-audio.dll" + VALUE "ProductName", "gnuradio-audio" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-blocks/CMakeLists.txt b/gr-blocks/CMakeLists.txt index 7e2f43562f..c4821da2b8 100644 --- a/gr-blocks/CMakeLists.txt +++ b/gr-blocks/CMakeLists.txt @@ -34,6 +34,8 @@ GR_REGISTER_COMPONENT("gr-blocks" ENABLE_GR_BLOCKS GR_SET_GLOBAL(GR_BLOCKS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/lib ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_BINARY_DIR}/lib + ${CMAKE_CURRENT_BINARY_DIR}/include ) ######################################################################## @@ -80,6 +82,9 @@ CPACK_COMPONENT("blocks_swig" ######################################################################## add_subdirectory(include/blocks) add_subdirectory(lib) +#if(ENABLE_TESTING) +# add_subdirectory(tests) +#endif(ENABLE_TESTING) if(ENABLE_PYTHON) add_subdirectory(python) add_subdirectory(swig) diff --git a/gr-blocks/doc/blocks.dox b/gr-blocks/doc/blocks.dox index 110dcb677e..2809c6a943 100644 --- a/gr-blocks/doc/blocks.dox +++ b/gr-blocks/doc/blocks.dox @@ -11,7 +11,7 @@ imported as: \endcode See the Doxygen documentation for details about the blocks available -in this package. The relevant blocks are listed in the \ref digital group. +in this package. A quick listing of the details can be found in Python after importing by using: diff --git a/gr-blocks/grc/blocks_argmax_xx.xml b/gr-blocks/grc/blocks_argmax_xx.xml new file mode 100644 index 0000000000..7adfa75973 --- /dev/null +++ b/gr-blocks/grc/blocks_argmax_xx.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<!-- +################################################### +##ArgMax: +## 1 output, 2 to inf inputs +################################################### + --> +<block> + <name>Argmax</name> + <key>blocks_argmax_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.argmax_$(type.fcn)($vlen)</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:fs</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:is</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:dd</opt> + </option> + </param> + <param> + <name>Num Inputs</name> + <key>num_inputs</key> + <value>2</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_inputs >= 1</check> + <check>$vlen >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_inputs</nports> + </sink> + <source> + <name>max_vec</name> + <type>short</type> + </source> + <source> + <name>max_inp</name> + <type>short</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_block_tree.xml b/gr-blocks/grc/blocks_block_tree.xml index 0077ec9484..64eacfa91e 100644 --- a/gr-blocks/grc/blocks_block_tree.xml +++ b/gr-blocks/grc/blocks_block_tree.xml @@ -1,7 +1,7 @@ <?xml version="1.0"?> <!-- - Copyright 2012 Free Software Foundation, Inc. + Copyright 2012,2013 Free Software Foundation, Inc. This file is part of GNU Radio @@ -29,16 +29,53 @@ <cat> <name></name> <!-- Blank for Root Name --> <cat> - <name>Sources (New)</name> + <name>Audio</name> + <block>blocks_wavfile_source</block> + <block>blocks_wavfile_sink</block> + </cat> + <cat> + <name>Boolean Operators</name> + <block>blocks_and_xx</block> + <block>blocks_and_const_xx</block> + <block>blocks_not_xx</block> + <block>blocks_or_xx</block> + <block>blocks_xor_xx</block> + </cat> + <cat> + <name>Byte Operators</name> + <block>blocks_packed_to_unpacked_xx</block> + <block>blocks_unpacked_to_packed_xx</block> + <block>blocks_pack_k_bits_bb</block> + <block>blocks_unpack_k_bits_bb</block> + <block>blocks_repack_bits_bb</block> + </cat> + <cat> + <name>Debug Tools</name> + <block>blocks_vector_sink_x</block> + <block>blocks_tag_debug</block> + <block>blocks_message_debug</block> + </cat> + <cat> + <name>File Operators</name> + <block>blocks_wavfile_source</block> + <block>blocks_wavfile_sink</block> <block>blocks_file_source</block> + <block>blocks_file_sink</block> + <block>blocks_file_descriptor_source</block> + <block>blocks_file_descriptor_sink</block> <block>blocks_file_meta_source</block> + <block>blocks_file_meta_sink</block> + <block>blocks_tagged_file_sink</block> </cat> <cat> - <name>Sinks (New)</name> - <block>blocks_file_meta_sink</block> + <name>Level Controllers</name> + <block>blocks_mute_xx</block> + <block>blocks_sample_and_hold_xx</block> + <block>blocks_moving_average_xx</block> + <block>blocks_threshold_ff</block> </cat> <cat> - <name>Math Operations (New) </name> + <name>Math Operators</name> <block>blocks_add_xx</block> <block>blocks_add_const_vxx</block> <block>blocks_divide_xx</block> @@ -51,17 +88,87 @@ <block>blocks_nlog10_ff</block> <block>blocks_rms_xx</block> <block>blocks_transcendental</block> + <block>blocks_argmax_xx</block> + <block>blocks_max_xx</block> </cat> + <cat> + <name>Measurement Tools</name> + <block>blocks_message_debug</block> + <block>blocks_tag_debug</block> + <block>blocks_probe_signal_x</block> + <block>blocks_probe_signal_vx</block> + <block>blocks_probe_rate</block> + </cat> + <cat> + <name>Message Tools</name> + <block>blocks_message_source</block> + <block>blocks_message_sink</block> + <block>blocks_message_burst_source</block> + <block>blocks_message_strobe</block> + <block>blocks_message_debug</block> + <block>blocks_pdu_to_tagged_stream</block> + <block>blocks_tagged_stream_to_pdu</block> + </cat> <cat> - <name>Boolean Operations (New) </name> - <block>blocks_and_xx</block> - <block>blocks_and_const_xx</block> - <block>blocks_not_xx</block> - <block>blocks_or_xx</block> - <block>blocks_xor_xx</block> + <name>Misc</name> + <block>blocks_throttle</block> + <block>blocks_vector_source_x</block> + <block>blocks_head</block> + <block>blocks_skiphead</block> + <block>blocks_delay</block> + <block>blocks_null_source</block> + <block>blocks_null_sink</block> + <block>blocks_copy</block> + <block>blocks_nop</block> + </cat> + <cat> + <name>Modulators</name> + <block>blocks_vco_f</block> + </cat> + <cat> + <name>Networking Tools</name> + <block>blocks_tuntap_pdu</block> + <block>blocks_socket_pdu</block> + <block>blocks_udp_source</block> + <block>blocks_udp_sink</block> + </cat> + <cat> + <name>Peak Detectors</name> + <block>blocks_burst_tagger</block> + <block>blocks_peak_detector_xb</block> + <block>blocks_peak_detector2_fb</block> + <block>blocks_plateau_detector_fb</block> + </cat> + <cat> + <name>Stream Operators</name> + <block>blocks_deinterleave</block> + <block>blocks_interleave</block> + <block>blocks_keep_m_in_n</block> + <block>blocks_keep_one_in_n</block> + <block>blocks_stream_mux</block> + <block>blocks_stream_to_streams</block> + <block>blocks_stream_to_vector</block> + <block>blocks_streams_to_stream</block> + <block>blocks_streams_to_vector</block> + <block>blocks_vector_to_stream</block> + <block>blocks_vector_to_streams</block> + <block>blocks_patterned_interleaver</block> + <block>blocks_endian_swap</block> + <block>blocks_vector_insert_x</block> + <block>blocks_tagged_stream_mux</block> + <block>blocks_repeat</block> + <block>blocks_regenerate_bb</block> + <block>blocks_stretch_ff</block> + </cat> + <cat> + <name>Stream Tag Tools</name> + <block>blocks_tag_debug</block> + <block>blocks_tag_gate</block> + <block>blocks_tagged_file_sink</block> + <block>blocks_tagged_stream_mux</block> </cat> <cat> - <name>Stream Type Conversions (New) </name> + <name>Type Converters</name> <block>blocks_char_to_float</block> <block>blocks_char_to_short</block> <block>blocks_complex_to_interleaved_short</block> @@ -83,29 +190,7 @@ <block>blocks_uchar_to_float</block> </cat> <cat> - <name>Stream Operations (New) </name> - <block>blocks_delay</block> - <block>blocks_packed_to_unpacked_xx</block> - <block>blocks_unpacked_to_packed_xx</block> - <block>blocks_deinterleave</block> - <block>blocks_interleave</block> - <block>blocks_keep_m_in_n</block> - <block>blocks_keep_one_in_n</block> - <block>blocks_repeat</block> - <block>blocks_stream_mux</block> - <block>blocks_stream_to_streams</block> - <block>blocks_stream_to_vector</block> - <block>blocks_streams_to_stream</block> - <block>blocks_streams_to_vector</block> - <block>blocks_vector_to_stream</block> - <block>blocks_vector_to_streams</block> - <block>blocks_peak_detector2_fb</block> - <block>blocks_regenerate_bb</block> - <block>blocks_stretch_ff</block> - <block>blocks_threshold_ff</block> - </cat> - <cat> - <name>Misc (New) </name> - <block>blocks_throttle</block> + <name>Waveform Generators</name> + <block>blocks_vco_f</block> </cat> </cat> diff --git a/gr-blocks/grc/blocks_burst_tagger.xml b/gr-blocks/grc/blocks_burst_tagger.xml new file mode 100644 index 0000000000..f603b53489 --- /dev/null +++ b/gr-blocks/grc/blocks_burst_tagger.xml @@ -0,0 +1,87 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Burst tagger: +## all types, 1 output, 2 input: stream & trigger (short) +################################################### + --> +<block> + <name>Burst Tagger</name> + <key>blocks_burst_tagger</key> + <import>from gnuradio import blocks</import> + <make>blocks.burst_tagger($type.size) +self.$(id).set_true_tag($true_key,$true_value) +self.$(id).set_false_tag($false_key,$false_value) + </make> + <callback>set_true_tag($true_key,$true_value)</callback> + <callback>set_false_tag($false_key,$false_value)</callback> + <param> + <name>Stream Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>True KeyID</name> + <key>true_key</key> + <value>burst</value> + <type>string</type> + </param> + <param> + <name>True Value</name> + <key>true_value</key> + <value>True</value> + <type>bool</type> + </param> + <param> + <name>False KeyID</name> + <key>false_key</key> + <value>burst</value> + <type>string</type> + </param> + <param> + <name>False Value</name> + <key>false_value</key> + <value>False</value> + <type>bool</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + <vlen>1</vlen> + </sink> + <sink> + <name>trigger</name> + <type>short</type> + <vlen>1</vlen> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>1</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_copy.xml b/gr-blocks/grc/blocks_copy.xml new file mode 100644 index 0000000000..55c4b343d3 --- /dev/null +++ b/gr-blocks/grc/blocks_copy.xml @@ -0,0 +1,75 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Copy +################################################### + --> +<block> + <name>Copy</name> + <key>blocks_copy</key> + <import>from gnuradio import blocks</import> + <make>blocks.copy($type.size*$vlen) +self.$(id).set_enabled($enabled)</make> + <callback>set_enabled($enabled)</callback> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Enabled</name> + <key>enabled</key> + <value>True</value> + <type>bool</type> + <option> + <name>Enabled</name> + <key>True</key> + </option> + <option> + <name>Disabled</name> + <key>False</key> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_deinterleave.xml b/gr-blocks/grc/blocks_deinterleave.xml index 1030913241..e3970bd326 100644 --- a/gr-blocks/grc/blocks_deinterleave.xml +++ b/gr-blocks/grc/blocks_deinterleave.xml @@ -16,27 +16,27 @@ <option> <name>Complex</name> <key>complex</key> - <opt>size:blocks.sizeof_blocks_complex</opt> + <opt>size:gr.sizeof_gr_complex</opt> </option> <option> <name>Float</name> <key>float</key> - <opt>size:blocks.sizeof_float</opt> + <opt>size:gr.sizeof_float</opt> </option> <option> <name>Int</name> <key>int</key> - <opt>size:blocks.sizeof_int</opt> + <opt>size:gr.sizeof_int</opt> </option> <option> <name>Short</name> <key>short</key> - <opt>size:blocks.sizeof_short</opt> + <opt>size:gr.sizeof_short</opt> </option> <option> <name>Byte</name> <key>byte</key> - <opt>size:blocks.sizeof_char</opt> + <opt>size:gr.sizeof_char</opt> </option> </param> <param> diff --git a/gr-blocks/grc/blocks_endian_swap.xml b/gr-blocks/grc/blocks_endian_swap.xml new file mode 100644 index 0000000000..5fea420664 --- /dev/null +++ b/gr-blocks/grc/blocks_endian_swap.xml @@ -0,0 +1,41 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Add Block: +## all types, 1 output, 2 to inf inputs +################################################### + --> +<block> + <name>Endian Swap</name> + <key>blocks_endian_swap</key> + <import>from gnuradio import blocks</import> + <make>blocks.endian_swap($type.size)</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:8</opt> + </option> + <option> + <name>Int</name> + <key>s32</key> + <opt>size:4</opt> + </option> + <option> + <name>Short</name> + <key>s16</key> + <opt>size:2</opt> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_file_descriptor_sink.xml b/gr-blocks/grc/blocks_file_descriptor_sink.xml new file mode 100644 index 0000000000..211d86dfd3 --- /dev/null +++ b/gr-blocks/grc/blocks_file_descriptor_sink.xml @@ -0,0 +1,59 @@ +<?xml version="1.0"?> +<!-- +################################################### +##File Sink +################################################### + --> +<block> + <name>File Descriptor Sink</name> + <key>blocks_file_descriptor_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.file_descriptor_sink($type.size*$vlen, $fd)</make> + <param> + <name>File Descriptor</name> + <key>fd</key> + <type>int</type> + </param> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_file_descriptor_source.xml b/gr-blocks/grc/blocks_file_descriptor_source.xml new file mode 100644 index 0000000000..b29335c3af --- /dev/null +++ b/gr-blocks/grc/blocks_file_descriptor_source.xml @@ -0,0 +1,73 @@ +<?xml version="1.0"?> +<!-- +################################################### +##File Source +################################################### + --> +<block> + <name>File Descriptor Source</name> + <key>blocks_file_descriptor_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.file_descriptor_source($type.size*$vlen, $fd, $repeat)</make> + <param> + <name>File Descriptor</name> + <key>fd</key> + <type>int</type> + </param> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Repeat</name> + <key>repeat</key> + <value>True</value> + <type>enum</type> + <option> + <name>Yes</name> + <key>True</key> + </option> + <option> + <name>No</name> + <key>False</key> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_file_sink.xml b/gr-blocks/grc/blocks_file_sink.xml new file mode 100644 index 0000000000..75ef86a6b8 --- /dev/null +++ b/gr-blocks/grc/blocks_file_sink.xml @@ -0,0 +1,78 @@ +<?xml version="1.0"?> +<!-- +################################################### +##File Sink +################################################### + --> +<block> + <name>File Sink</name> + <key>blocks_file_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.file_sink($type.size*$vlen, $file) +self.$(id).set_unbuffered($unbuffered)</make> + <callback>set_unbuffered($unbuffered)</callback> + <callback>open($file)</callback> + <param> + <name>File</name> + <key>file</key> + <value></value> + <type>file_save</type> + </param> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Unbuffered</name> + <key>unbuffered</key> + <value>False</value> + <type>bool</type> + <option> + <name>Off</name> + <key>False</key> + </option> + <option> + <name>On</name> + <key>True</key> + </option> + </param> + + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_head.xml b/gr-blocks/grc/blocks_head.xml new file mode 100644 index 0000000000..8b6e67820c --- /dev/null +++ b/gr-blocks/grc/blocks_head.xml @@ -0,0 +1,65 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Head +################################################### + --> +<block> + <name>Head</name> + <key>blocks_head</key> + <import>from gnuradio import blocks</import> + <make>blocks.head($type.size*$vlen, $num_items)</make> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Num Items</name> + <key>num_items</key> + <value>1024</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_max_xx.xml b/gr-blocks/grc/blocks_max_xx.xml new file mode 100644 index 0000000000..afbcae93dc --- /dev/null +++ b/gr-blocks/grc/blocks_max_xx.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Max: +## 1 output, 2 to inf inputs +################################################### + --> +<block> + <name>Max</name> + <key>blocks_max_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.max_$(type.fcn)($vlen)</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:dd</opt> + </option> + </param> + <param> + <name>Num Inputs</name> + <key>num_inputs</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_inputs >= 1</check> + <check>$vlen >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_inputs</nports> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>1</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_message_burst_source.xml b/gr-blocks/grc/blocks_message_burst_source.xml new file mode 100644 index 0000000000..208955e557 --- /dev/null +++ b/gr-blocks/grc/blocks_message_burst_source.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Burst Source (the sink port is a message) +################################################### + --> +<block> + <name>Message Burst Source</name> + <key>blocks_message_burst_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.message_burst_source($type.size*$vlen, $(id)_msgq_in)</make> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>msg</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_message_debug.xml b/gr-blocks/grc/blocks_message_debug.xml new file mode 100644 index 0000000000..c547c7542d --- /dev/null +++ b/gr-blocks/grc/blocks_message_debug.xml @@ -0,0 +1,27 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Debug +################################################### + --> +<block> + <name>Message Debug</name> + <key>blocks_message_debug</key> + <import>from gnuradio import blocks</import> + <make>blocks.message_debug()</make> + <sink> + <name>print</name> + <type>message</type> + <optional>1</optional> + </sink> + <sink> + <name>store</name> + <type>message</type> + <optional>1</optional> + </sink> + <sink> + <name>print_pdu</name> + <type>message</type> + <optional>1</optional> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_message_sink.xml b/gr-blocks/grc/blocks_message_sink.xml new file mode 100644 index 0000000000..c1f21f6521 --- /dev/null +++ b/gr-blocks/grc/blocks_message_sink.xml @@ -0,0 +1,72 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Sink (the source port is a message) +################################################### + --> +<block> + <name>Message Sink</name> + <key>blocks_message_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.message_sink($type.size*$vlen, $(id)_msgq_out, $dont_block)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Don't Block</name> + <key>dont_block</key> + <value>False</value> + <type>enum</type> + <option> + <name>Don't Block</name> + <key>True</key> + </option> + <option> + <name>Block</name> + <key>False</key> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> + <source> + <name>out</name> + <type>msg</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_message_source.xml b/gr-blocks/grc/blocks_message_source.xml new file mode 100644 index 0000000000..12c6569606 --- /dev/null +++ b/gr-blocks/grc/blocks_message_source.xml @@ -0,0 +1,58 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Source (the sink port is a message) +################################################### + --> +<block> + <name>Message Source</name> + <key>blocks_message_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.message_source($type.size*$vlen, $(id)_msgq_in)</make> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>msg</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_message_strobe.xml b/gr-blocks/grc/blocks_message_strobe.xml new file mode 100644 index 0000000000..25c98cd01c --- /dev/null +++ b/gr-blocks/grc/blocks_message_strobe.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Message Strobe +################################################### + --> +<block> + <name>Message Strobe</name> + <key>blocks_message_strobe</key> + <import>from gnuradio import blocks</import> + <import>from gruel import pmt</import> + <make>blocks.message_strobe($msg, $period)</make> + <param> + <name>Message PMT</name> + <key>msg</key> + <value>pmt.pmt_intern("TEST")</value> + <type>raw</type> + </param> + <param> + <name>Period (ms)</name> + <key>period</key> + <value>1000</value> + <type>real</type> + </param> + <sink> + <name>set_msg</name> + <type>message</type> + <optional>1</optional> + </sink> + <source> + <name>strobe</name> + <type>message</type> + <optional>1</optional> + </source> +</block> diff --git a/gr-blocks/grc/blocks_moving_average_xx.xml b/gr-blocks/grc/blocks_moving_average_xx.xml new file mode 100644 index 0000000000..e90903ad85 --- /dev/null +++ b/gr-blocks/grc/blocks_moving_average_xx.xml @@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Moving Average +################################################### + --> +<block> + <name>Moving Average</name> + <key>blocks_moving_average_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.moving_average_$(type.fcn)($length, $scale, $max_iter)</make> + <callback>set_length_and_scale($length, $scale)</callback> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:cc</opt> + <opt>scale:complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + <opt>scale:real</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + <opt>scale:int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + <opt>scale:int</opt> + </option> + </param> + <param> + <name>Length</name> + <key>length</key> + <value>1000</value> + <type>int</type> + </param> + <param> + <name>Scale</name> + <key>scale</key> + <value>1</value> + <type>$type.scale</type> + </param> + <param> + <name>Max Iter</name> + <key>max_iter</key> + <value>4000</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_mute_xx.xml b/gr-blocks/grc/blocks_mute_xx.xml new file mode 100644 index 0000000000..7023d32674 --- /dev/null +++ b/gr-blocks/grc/blocks_mute_xx.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Mute Block: +## Cast input to bool. +################################################### + --> +<block> + <name>Mute</name> + <key>blocks_mute_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.mute_$(type.fcn)(bool($mute))</make> + <callback>set_mute(bool($mute))</callback> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:cc</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + </option> + </param> + <param> + <name>Mute</name> + <key>mute</key> + <value>False</value> + <type>raw</type> + <option> + <name>True</name> + <key>True</key> + </option> + <option> + <name>False</name> + <key>False</key> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_nop.xml b/gr-blocks/grc/blocks_nop.xml new file mode 100644 index 0000000000..d38c23839d --- /dev/null +++ b/gr-blocks/grc/blocks_nop.xml @@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Nop +################################################### + --> +<block> + <name>Nop</name> + <key>blocks_nop</key> + <import>from gnuradio import blocks</import> + <make>blocks.nop($type.size*$vlen)</make> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Num Ports</name> + <key>num_ports</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$num_ports > 0</check> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_ports</nports> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_ports</nports> + </source> +</block> diff --git a/gr-blocks/grc/blocks_null_sink.xml b/gr-blocks/grc/blocks_null_sink.xml new file mode 100644 index 0000000000..2ae20e619a --- /dev/null +++ b/gr-blocks/grc/blocks_null_sink.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Null Sink +################################################### + --> +<block> + <name>Null Sink</name> + <key>blocks_null_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.null_sink($type.size*$vlen)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_null_source.xml b/gr-blocks/grc/blocks_null_source.xml new file mode 100644 index 0000000000..01d3905cab --- /dev/null +++ b/gr-blocks/grc/blocks_null_source.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Null Source +################################################### + --> +<block> + <name>Null Source</name> + <key>blocks_null_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.null_source($type.size*$vlen)</make> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_pack_k_bits_bb.xml b/gr-blocks/grc/blocks_pack_k_bits_bb.xml new file mode 100644 index 0000000000..5400eb4af9 --- /dev/null +++ b/gr-blocks/grc/blocks_pack_k_bits_bb.xml @@ -0,0 +1,30 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Pack K Bits +################################################### + --> +<block> + <name>Pack K Bits</name> + <key>blocks_pack_k_bits_bb</key> + <import>from gnuradio import blocks</import> + <make>blocks.pack_k_bits_bb($k)</make> + <param> + <name>K</name> + <key>k</key> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> + + <doc> + Pack K unpacked bits (one bit per byte) into a single packed byte containing k bits and 8 - k zeros. + </doc> + +</block> diff --git a/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml b/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml new file mode 100644 index 0000000000..2a7de84759 --- /dev/null +++ b/gr-blocks/grc/blocks_pdu_to_tagged_stream.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +################################################### +## PDU Message to Tagged Stream +################################################### + --> +<block> + <name>PDU to Tagged Stream</name> + <key>blocks_pdu_to_tagged_stream</key> + <import>from gnuradio import blocks</import> + <make>blocks.pdu_to_tagged_stream($type.tv)</make> + <param> + <name>Item Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Byte</name> + <key>byte</key> + <opt>tv:blocks.byte_t</opt> + </option> + <option> + <name>Complex</name> + <key>complex</key> + <opt>tv:blocks.complex_t</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>tv:blocks.float_t</opt> + </option> + </param> + <sink> + <name>pdus</name> + <type>message</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_peak_detector_xb.xml b/gr-blocks/grc/blocks_peak_detector_xb.xml new file mode 100644 index 0000000000..1aabf89474 --- /dev/null +++ b/gr-blocks/grc/blocks_peak_detector_xb.xml @@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Peak Detector +################################################### + --> +<block> + <name>Peak Detector</name> + <key>blocks_peak_detector_xb</key> + <import>from gnuradio import blocks</import> + <make>blocks.peak_detector_$(type.fcn)b($threshold_factor_rise, $threshold_factor_fall, $look_ahead, $alpha)</make> + <callback>set_threshold_factor_rise($threshold_factor_rise)</callback> + <callback>set_threshold_factor_fall($threshold_factor_fall)</callback> + <callback>set_look_ahead($look_ahead)</callback> + <callback>set_alpha($alpha)</callback> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + </option> + </param> + <param> + <name>TH Factor Rise</name> + <key>threshold_factor_rise</key> + <value>0.25</value> + <type>real</type> + </param> + <param> + <name>TH Factor Fall</name> + <key>threshold_factor_fall</key> + <value>0.40</value> + <type>real</type> + </param> + <param> + <name>Look Ahead</name> + <key>look_ahead</key> + <value>10</value> + <type>int</type> + </param> + <param> + <name>Alpha</name> + <key>alpha</key> + <value>0.001</value> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_plateau_detector_fb.xml b/gr-blocks/grc/blocks_plateau_detector_fb.xml new file mode 100644 index 0000000000..90f67a4cf5 --- /dev/null +++ b/gr-blocks/grc/blocks_plateau_detector_fb.xml @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<block> + <name>Plateau Detector</name> + <key>blocks_plateau_detector_fb</key> + <import>from gnuradio import blocks</import> + <make>blocks.plateau_detector_fb($max_len, $threshold)</make> + <param> + <name>Max. plateau length</name> + <key>max_len</key> + <type>int</type> + </param> + <param> + <name>Threshold</name> + <key>threshold</key> + <value>0.9</value> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>float</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_probe_rate.xml b/gr-blocks/grc/blocks_probe_rate.xml new file mode 100644 index 0000000000..08df23e0d2 --- /dev/null +++ b/gr-blocks/grc/blocks_probe_rate.xml @@ -0,0 +1,66 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Probe Rate +################################################### + --> +<block> + <name>Probe Rate</name> + <key>blocks_probe_rate</key> + <import>from gnuradio import blocks</import> + <make>blocks.probe_rate($type.size*$vlen, $mintime, $alpha)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Min Update Time (ms)</name> + <key>mintime</key> + <value>500.0</value> + <type>real</type> + </param> + <param> + <name>Update Alpha</name> + <key>alpha</key> + <value>0.15</value> + <type>real</type> + </param> + <check>$vlen >= 1</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_probe_signal_vx.xml b/gr-blocks/grc/blocks_probe_signal_vx.xml new file mode 100644 index 0000000000..930a49643c --- /dev/null +++ b/gr-blocks/grc/blocks_probe_signal_vx.xml @@ -0,0 +1,59 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Probe Signal +################################################### + --> +<block> + <name>Probe Signal Vector</name> + <key>blocks_probe_signal_vx</key> + <import>from gnuradio import blocks</import> + <make>blocks.probe_signal_v$(type.fcn)($vlen)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> + <doc> +Available functions to probe: level() + +Use with the function probe block. + </doc> +</block> diff --git a/gr-blocks/grc/blocks_probe_signal_x.xml b/gr-blocks/grc/blocks_probe_signal_x.xml new file mode 100644 index 0000000000..726f0fa747 --- /dev/null +++ b/gr-blocks/grc/blocks_probe_signal_x.xml @@ -0,0 +1,51 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Probe Signal +################################################### + --> +<block> + <name>Probe Signal</name> + <key>blocks_probe_signal_x</key> + <import>from gnuradio import blocks</import> + <make>blocks.probe_signal_$(type.fcn)()</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <doc> +Available functions to probe: level() + +Use with the function probe block. + </doc> +</block> diff --git a/gr-blocks/grc/blocks_repack_bits_bb.xml b/gr-blocks/grc/blocks_repack_bits_bb.xml new file mode 100644 index 0000000000..4ad5ec631b --- /dev/null +++ b/gr-blocks/grc/blocks_repack_bits_bb.xml @@ -0,0 +1,46 @@ +<block> + <name>Repack Bits</name> + <key>blocks_repack_bits_bb</key> + <import>from gnuradio import blocks</import> + <make>blocks.repack_bits_bb($k, $l, $len_tag_key, $align_output)</make> + <param> + <name>Bits per input byte</name> + <key>k</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Bits per output byte</name> + <key>l</key> + <value>8</value> + <type>int</type> + </param> + <param> + <name>Length Tag Key</name> + <key>len_tag_key</key> + <value>""</value> + <type>string</type> + </param> + <param> + <name>Packet Alignment</name> + <key>align_output</key> + <value>False</value> + <type>enum</type> + <option> + <name>Output</name> + <key>True</key> + </option> + <option> + <name>Input</name> + <key>False</key> + </option> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_sample_and_hold_xx.xml b/gr-blocks/grc/blocks_sample_and_hold_xx.xml new file mode 100644 index 0000000000..1583204c02 --- /dev/null +++ b/gr-blocks/grc/blocks_sample_and_hold_xx.xml @@ -0,0 +1,49 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Sample and Hold +################################################### + --> +<block> + <name>Sample and Hold</name> + <key>blocks_sample_and_hold_xx</key> + <import>from gnuradio import blocks</import> + <make>blocks.sample_and_hold_$(type.fcn)()</make> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:bb</opt> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <sink> + <name>ctrl</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_skiphead.xml b/gr-blocks/grc/blocks_skiphead.xml new file mode 100644 index 0000000000..7d90862830 --- /dev/null +++ b/gr-blocks/grc/blocks_skiphead.xml @@ -0,0 +1,65 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Skip Head +################################################### + --> +<block> + <name>Skip Head</name> + <key>blocks_skiphead</key> + <import>from gnuradio import blocks</import> + <make>blocks.skiphead($type.size*$vlen, $num_items)</make> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Num Items</name> + <key>num_items</key> + <value>1024</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_socket_pdu.xml b/gr-blocks/grc/blocks_socket_pdu.xml new file mode 100644 index 0000000000..1e897cfc4b --- /dev/null +++ b/gr-blocks/grc/blocks_socket_pdu.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Socket PDU Message source/sink +################################################### + --> +<block> + <name>Socket PDU</name> + <key>blocks_socket_pdu</key> + <import>from gnuradio import blocks</import> + <make>blocks.socket_pdu($type, $host, $port, $mtu)</make> + <param> + <name>Type</name> + <key>type</key> + <value>TCP_SERVER</value> + <type>enum</type> + <option> + <name>TCP Server</name> + <key>"TCP_SERVER"</key> + </option> + <option> + <name>TCP Client</name> + <key>"TCP_CLIENT"</key> + </option> + <option> + <name>UDP Server</name> + <key>"UDP_SERVER"</key> + </option> + <option> + <name>UDP Client</name> + <key>"UDP_CLIENT"</key> + </option> + </param> + <param> + <name>Host</name> + <key>host</key> + <value></value> + <type>string</type> + </param> + <param> + <name>Port</name> + <key>port</key> + <value>52001</value> + <type>string</type> + </param> + <param> + <name>MTU</name> + <key>mtu</key> + <value>10000</value> + <type>int</type> + </param> + <sink> + <name>pdus</name> + <type>message</type> + <optional>1</optional> + </sink> + <source> + <name>pdus</name> + <type>message</type> + <optional>1</optional> + </source> +</block> diff --git a/gr-blocks/grc/blocks_tag_debug.xml b/gr-blocks/grc/blocks_tag_debug.xml new file mode 100644 index 0000000000..929e53afed --- /dev/null +++ b/gr-blocks/grc/blocks_tag_debug.xml @@ -0,0 +1,82 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Tag Debug +################################################### + --> +<block> + <name>Tag Debug</name> + <key>blocks_tag_debug</key> + <import>from gnuradio import blocks</import> + <make>blocks.tag_debug($type.size*$vlen, $name)</make> + <callback>set_display($display)</callback> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Name</name> + <key>name</key> + <type>string</type> + </param> + <param> + <name>Num Inputs</name> + <key>num_inputs</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Display</name> + <key>display</key> + <value>True</value> + <type>bool</type> + <option> + <name>On</name> + <key>True</key> + </option> + <option> + <name>Off</name> + <key>False</key> + </option> + </param> + <check>$num_inputs >= 1</check> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$num_inputs</nports> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_tag_gate.xml b/gr-blocks/grc/blocks_tag_gate.xml new file mode 100644 index 0000000000..5c748f27cf --- /dev/null +++ b/gr-blocks/grc/blocks_tag_gate.xml @@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<block> + <name>Tag Gate</name> + <key>blocks_tag_gate</key> + <import>from gnuradio import blocks</import> + <make>blocks.tag_gate($type.size * $vlen, $propagate_tags)</make> + <param> + <name>Item Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Propagate_tags</name> + <key>propagate_tags</key> + <value>False</value> + <type>enum</type> + <option> + <name>Yes</name> + <key>True</key> + </option> + <option> + <name>No</name> + <key>False</key> + </option> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_tagged_file_sink.xml b/gr-blocks/grc/blocks_tagged_file_sink.xml new file mode 100644 index 0000000000..a849c48c9a --- /dev/null +++ b/gr-blocks/grc/blocks_tagged_file_sink.xml @@ -0,0 +1,60 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Tagged File Sink +################################################### + --> +<block> + <name>Tagged File Sink</name> + <key>blocks_tagged_file_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.tagged_file_sink($type.size*$vlen, $samp_rate)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Sample Rate</name> + <key>samp_rate</key> + <value>samp_rate</value> + <type>int</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_tagged_stream_mux.xml b/gr-blocks/grc/blocks_tagged_stream_mux.xml new file mode 100644 index 0000000000..98c4b6dfb5 --- /dev/null +++ b/gr-blocks/grc/blocks_tagged_stream_mux.xml @@ -0,0 +1,64 @@ +<block> + <name>Tagged Stream Mux</name> + <key>blocks_tagged_stream_mux</key> + <import>from gnuradio import blocks</import> + <make>blocks.tagged_stream_mux($type.size*$vlen, $lengthtagname)</make> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Number of inputs</name> + <key>ninputs</key> + <type>int</type> + </param> + <param> + <name>Length tag names</name> + <key>lengthtagname</key> + <type>string</type> + </param> + <param> + <name>Vector Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + <nports>$ninputs</nports> + </sink> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> + diff --git a/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml b/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml new file mode 100644 index 0000000000..6dd7b9be30 --- /dev/null +++ b/gr-blocks/grc/blocks_tagged_stream_to_pdu.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<!-- +################################################### +## Tagged Stream to PDU Message +################################################### + --> +<block> + <name>Tagged Stream to PDU</name> + <key>blocks_tagged_stream_to_pdu</key> + <import>from gnuradio import blocks</import> + <make>blocks.tagged_stream_to_pdu($type.tv)</make> + <param> + <name>Item Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Byte</name> + <key>byte</key> + <opt>tv:blocks.byte_t</opt> + </option> + <option> + <name>Complex</name> + <key>complex</key> + <opt>tv:blocks.complex_t</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>tv:blocks.float_t</opt> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>pdus</name> + <type>message</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_tuntap_pdu.xml b/gr-blocks/grc/blocks_tuntap_pdu.xml new file mode 100644 index 0000000000..d9a63d4a7f --- /dev/null +++ b/gr-blocks/grc/blocks_tuntap_pdu.xml @@ -0,0 +1,34 @@ +<?xml version="1.0"?> +<!-- +################################################### +## TUNTAP PDU async message source/sink +################################################### + --> +<block> + <name>TUNTAP PDU</name> + <key>blocks_tuntap_pdu</key> + <import>from gnuradio import blocks</import> + <make>blocks.tuntap_pdu($ifn, $mtu)</make> + <param> + <name>Interface Name</name> + <key>ifn</key> + <value>tun0</value> + <type>string</type> + </param> + <param> + <name>MTU</name> + <key>mtu</key> + <value>10000</value> + <type>int</type> + </param> + <sink> + <name>pdus</name> + <type>message</type> + <optional>1</optional> + </sink> + <source> + <name>pdus</name> + <type>message</type> + <optional>1</optional> + </source> +</block> diff --git a/gr-blocks/grc/blocks_udp_sink.xml b/gr-blocks/grc/blocks_udp_sink.xml new file mode 100644 index 0000000000..a001b2f1bb --- /dev/null +++ b/gr-blocks/grc/blocks_udp_sink.xml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<!-- +################################################### +##UDP Sink +################################################### + --> +<block> + <name>UDP Sink</name> + <key>blocks_udp_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.udp_sink($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make> + <callback>set_mtu($mtu)</callback> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>Destination IP Address</name> + <key>ipaddr</key> + <type>string</type> + </param> + <param> + <name>Destination Port</name> + <key>port</key> + <type>int</type> + </param> + <param> + <name>Payload Size</name> + <key>psize</key> + <value>1472</value> + <type>int</type> + </param> + <param> + <name>Send Null Pkt as EOF</name> + <key>eof</key> + <value>True</value> + <type>bool</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_udp_source.xml b/gr-blocks/grc/blocks_udp_source.xml new file mode 100644 index 0000000000..bca1dff8b8 --- /dev/null +++ b/gr-blocks/grc/blocks_udp_source.xml @@ -0,0 +1,79 @@ +<?xml version="1.0"?> +<!-- +################################################### +##UDP Source +################################################### + --> +<block> + <name>UDP Source</name> + <key>blocks_udp_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.udp_source($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make> + <callback>set_mtu($mtu)</callback> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>size:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>size:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>size:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>size:gr.sizeof_short</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>size:gr.sizeof_char</opt> + </option> + </param> + <param> + <name>IP Address</name> + <key>ipaddr</key> + <value>127.0.0.1</value> + <type>string</type> + </param> + <param> + <name>Port</name> + <key>port</key> + <value>1234</value> + <type>int</type> + </param> + <param> + <name>Payload Size</name> + <key>psize</key> + <value>1472</value> + <type>int</type> + </param> + <param> + <name>Null Pkt is EOF</name> + <key>eof</key> + <value>True</value> + <type>bool</type> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_unpack_k_bits_bb.xml b/gr-blocks/grc/blocks_unpack_k_bits_bb.xml new file mode 100644 index 0000000000..90d7493af0 --- /dev/null +++ b/gr-blocks/grc/blocks_unpack_k_bits_bb.xml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Unpack K Bits +################################################### + --> +<block> + <name>Unpack K Bits</name> + <key>blocks_unpack_k_bits_bb</key> + <import>from gnuradio import blocks</import> + <make>blocks.unpack_k_bits_bb($k)</make> + <param> + <name>K</name> + <key>k</key> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_vco_f.xml b/gr-blocks/grc/blocks_vco_f.xml new file mode 100644 index 0000000000..77a3ba0bd4 --- /dev/null +++ b/gr-blocks/grc/blocks_vco_f.xml @@ -0,0 +1,35 @@ +<?xml version="1.0"?> +<!-- +################################################### +##VCO +################################################### + --> +<block> + <name>VCO</name> + <key>blocks_vco_f</key> + <import>from gnuradio import blocks</import> + <make>blocks.vco_f($samp_rate, $sensitivity, $amplitude)</make> + <param> + <name>Sample Rate</name> + <key>samp_rate</key> + <type>real</type> + </param> + <param> + <name>Sensitivity</name> + <key>sensitivity</key> + <type>real</type> + </param> + <param> + <name>Amplitude</name> + <key>amplitude</key> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>float</type> + </sink> + <source> + <name>out</name> + <type>float</type> + </source> +</block> diff --git a/gr-blocks/grc/blocks_vector_insert_x.xml b/gr-blocks/grc/blocks_vector_insert_x.xml new file mode 100644 index 0000000000..2bc7ada2e6 --- /dev/null +++ b/gr-blocks/grc/blocks_vector_insert_x.xml @@ -0,0 +1,80 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Vector Source +################################################### + --> +<block> + <name>Vector Insert</name> + <key>blocks_vector_insert_x</key> + <import>from gnuradio import blocks</import> + <make>blocks.vector_insert_$(type.fcn)($vector, $period, $offset)</make> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + <opt>vec_type:int_vector</opt> + </option> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + <opt>vec_type:complex_vector</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + <opt>vec_type:real_vector</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + <opt>vec_type:int_vector</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + <opt>vec_type:int_vector</opt> + </option> + </param> + <param> + <name>Vector</name> + <key>vector</key> + <value>0, 0, 0</value> + <type>$type.vec_type</type> + </param> + <param> + <name>Periodicity</name> + <key>period</key> + <value>100</value> + <type>int</type> + </param> + <param> + <name>Offset</name> + <key>offset</key> + <value>0</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> + + <doc> + Periodicity, the length of the periodicity at which the vector should be inserted at the output. + (i.e. one vector for every N output items) + + Offset sepcifies where in the cycle period we should begin at. + </doc> +</block> diff --git a/gr-blocks/grc/blocks_vector_sink_x.xml b/gr-blocks/grc/blocks_vector_sink_x.xml new file mode 100644 index 0000000000..7f51731975 --- /dev/null +++ b/gr-blocks/grc/blocks_vector_sink_x.xml @@ -0,0 +1,54 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Vector sink +################################################### + --> +<block> + <name>Vector Sink</name> + <key>blocks_vector_sink_x</key> + <import>from gnuradio import blocks</import> + <make>blocks.vector_sink_$(type.fcn)($vlen)</make> + <param> + <name>Input Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <sink> + <name>in</name> + <type>$type</type> + <vlen>$vlen</vlen> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_vector_source_x.xml b/gr-blocks/grc/blocks_vector_source_x.xml new file mode 100644 index 0000000000..5221c4f3eb --- /dev/null +++ b/gr-blocks/grc/blocks_vector_source_x.xml @@ -0,0 +1,85 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Vector Source +################################################### + --> +<block> + <name>Vector Source</name> + <key>blocks_vector_source_x</key> + <import>from gnuradio import blocks</import> + <make>blocks.vector_source_$(type.fcn)($vector, $repeat, $vlen, $tags)</make> + <param> + <name>Output Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:c</opt> + <opt>vec_type:complex_vector</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:f</opt> + <opt>vec_type:real_vector</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:i</opt> + <opt>vec_type:int_vector</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:s</opt> + <opt>vec_type:int_vector</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:b</opt> + <opt>vec_type:int_vector</opt> + </option> + </param> + <param> + <name>Vector</name> + <key>vector</key> + <value>[0, 0, 0]</value> + <type>raw</type> + </param> + <param> + <name>Tags</name> + <key>tags</key> + <value>[]</value> + <type>raw</type> + </param> + <param> + <name>Repeat</name> + <key>repeat</key> + <value>True</value> + <type>enum</type> + <option> + <name>Yes</name> + <key>True</key> + </option> + <option> + <name>No</name> + <key>False</key> + </option> + </param> + <param> + <name>Vec Length</name> + <key>vlen</key> + <value>1</value> + <type>int</type> + </param> + <check>$vlen > 0</check> + <source> + <name>out</name> + <type>$type</type> + <vlen>$vlen</vlen> + </source> +</block> diff --git a/gr-blocks/grc/blocks_wavfile_sink.xml b/gr-blocks/grc/blocks_wavfile_sink.xml new file mode 100644 index 0000000000..8e81d8d202 --- /dev/null +++ b/gr-blocks/grc/blocks_wavfile_sink.xml @@ -0,0 +1,43 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Wav File Sink +################################################### + --> +<block> + <name>Wav File Sink</name> + <key>blocks_wavfile_sink</key> + <import>from gnuradio import blocks</import> + <make>blocks.wavfile_sink($file, $nchan, $samp_rate, $bits_per_sample)</make> + <callback>open($file)</callback> + <param> + <name>File</name> + <key>file</key> + <value></value> + <type>file_save</type> + </param> + <param> + <name>N Channels</name> + <key>nchan</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Sample Rate</name> + <key>samp_rate</key> + <value>samp_rate</value> + <type>int</type> + </param> + <param> + <name>Bits per Sample</name> + <key>bits_per_sample</key> + <value>8</value> + <type>int</type> + </param> + <check>1 <= $nchan</check> + <sink> + <name>in</name> + <type>float</type> + <nports>$nchan</nports> + </sink> +</block> diff --git a/gr-blocks/grc/blocks_wavfile_source.xml b/gr-blocks/grc/blocks_wavfile_source.xml new file mode 100644 index 0000000000..deb48472a4 --- /dev/null +++ b/gr-blocks/grc/blocks_wavfile_source.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Wav File Source +################################################### + --> +<block> + <name>Wav File Source</name> + <key>blocks_wavfile_source</key> + <import>from gnuradio import blocks</import> + <make>blocks.wavfile_source($file, $repeat)</make> + <param> + <name>File</name> + <key>file</key> + <value></value> + <type>file_open</type> + </param> + <param> + <name>Repeat</name> + <key>repeat</key> + <value>True</value> + <type>enum</type> + <option> + <name>Yes</name> + <key>True</key> + </option> + <option> + <name>No</name> + <key>False</key> + </option> + </param> + <param> + <name>N Channels</name> + <key>nchan</key> + <value>1</value> + <type>int</type> + </param> + <check>1 <= $nchan</check> + <source> + <name>out</name> + <type>float</type> + <nports>$nchan</nports> + </source> +</block> diff --git a/gr-blocks/include/blocks/CMakeLists.txt b/gr-blocks/include/blocks/CMakeLists.txt index d3c08f6e6d..a877dfc557 100644 --- a/gr-blocks/include/blocks/CMakeLists.txt +++ b/gr-blocks/include/blocks/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -69,17 +69,28 @@ expand_h(add_const_XX ss ii ff cc) expand_h(add_const_vXX ss ii ff cc) expand_h(and_XX bb ss ii) expand_h(and_const_XX bb ss ii) +expand_h(argmax_XX fs is ss) expand_h(divide_XX ss ii ff cc) expand_h(integrate_XX ss ii ff cc) +expand_h(max_XX ff ii ss) +expand_h(moving_average_XX ss ii ff cc) expand_h(multiply_XX ss ii) expand_h(multiply_const_XX ss ii) expand_h(multiply_const_vXX ss ii ff cc) +expand_h(mute_XX ss ii ff cc) expand_h(not_XX bb ss ii) expand_h(or_XX bb ss ii) +expand_h(peak_detector_XX fb ib sb) +expand_h(probe_signal_X b s i f c) +expand_h(probe_signal_vX b s i f c) +expand_h(sample_and_hold_XX bb ss ii ff) expand_h(sub_XX ss ii ff cc) expand_h(xor_XX bb ss ii) expand_h(packed_to_unpacked_XX bb ss ii) expand_h(unpacked_to_packed_XX bb ss ii) +expand_h(vector_insert_X b s i f c) +expand_h(vector_sink_X b s i f c) +expand_h(vector_source_X b s i f c) add_custom_target(blocks_generated_includes DEPENDS ${generated_includes} @@ -91,11 +102,23 @@ add_custom_target(blocks_generated_includes DEPENDS install(FILES ${generated_includes} api.h + control_loop.h count_bits.h + file_sink_base.h + lfsr_15_1_0.h + lfsr_32k.h log2_const.h + rotator.h + wavfile.h add_ff.h + annotator_1to1.h + annotator_alltoall.h + annotator_raw.h + bin_statistics_f.h + burst_tagger.h char_to_float.h char_to_short.h + check_lfsr_32k_s.h complex_to_interleaved_short.h complex_to_float.h complex_to_imag.h @@ -104,8 +127,13 @@ install(FILES complex_to_mag_squared.h complex_to_arg.h conjugate_cc.h + copy.h deinterleave.h delay.h + endian_swap.h + file_descriptor_sink.h + file_descriptor_source.h + file_sink.h file_source.h file_meta_sink.h file_meta_source.h @@ -114,37 +142,67 @@ install(FILES float_to_int.h float_to_short.h float_to_uchar.h + head.h int_to_float.h interleave.h interleaved_short_to_complex.h keep_m_in_n.h keep_one_in_n.h + lfsr_32k_source_s.h + message_debug.h + message_sink.h + message_source.h + message_strobe.h + message_burst_source.h multiply_cc.h multiply_ff.h multiply_conjugate_cc.h multiply_const_cc.h multiply_const_ff.h nlog10_ff.h + nop.h + null_sink.h + null_source.h + pack_k_bits_bb.h patterned_interleaver.h + pdu.h + pdu_to_tagged_stream.h peak_detector2_fb.h + plateau_detector_fb.h + probe_rate.h regenerate_bb.h + repack_bits_bb.h repeat.h rms_cf.h rms_ff.h short_to_char.h short_to_float.h + skiphead.h + socket_pdu.h stream_mux.h stream_to_streams.h stream_to_vector.h streams_to_stream.h streams_to_vector.h stretch_ff.h + tag_debug.h + tagged_file_sink.h + tagged_stream_mux.h + tagged_stream_to_pdu.h threshold_ff.h throttle.h transcendental.h + tuntap_pdu.h uchar_to_float.h + udp_sink.h + udp_source.h + unpack_k_bits_bb.h + vco_f.h + vector_map.h vector_to_stream.h vector_to_streams.h - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks + wavfile_sink.h + wavfile_source.h + tag_gate.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio/blocks COMPONENT "blocks_devel" ) diff --git a/gr-blocks/include/blocks/add_XX.h.t b/gr-blocks/include/blocks/add_XX.h.t index 607b820669..ffe08f683b 100644 --- a/gr-blocks/include/blocks/add_XX.h.t +++ b/gr-blocks/include/blocks/add_XX.h.t @@ -33,8 +33,9 @@ namespace gr { /*! * \brief output = sum (input_0, input_1, ...) - * \ingroup math_blk + * \ingroup math_operators_blk * + * \details * Add across all input streams. */ class BLOCKS_API @NAME@ : virtual public gr_sync_block diff --git a/gr-blocks/include/blocks/add_const_XX.h.t b/gr-blocks/include/blocks/add_const_XX.h.t index df968feac1..3a99978b6b 100644 --- a/gr-blocks/include/blocks/add_const_XX.h.t +++ b/gr-blocks/include/blocks/add_const_XX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = input + constant - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API @NAME@ : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/add_const_vXX.h.t b/gr-blocks/include/blocks/add_const_vXX.h.t index c4cd49fa48..33a50a42ca 100644 --- a/gr-blocks/include/blocks/add_const_vXX.h.t +++ b/gr-blocks/include/blocks/add_const_vXX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = input + constant vector - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API @NAME@ : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/add_ff.h b/gr-blocks/include/blocks/add_ff.h index 1e7350c1bb..6a9bbfbded 100644 --- a/gr-blocks/include/blocks/add_ff.h +++ b/gr-blocks/include/blocks/add_ff.h @@ -29,6 +29,13 @@ namespace gr { namespace blocks { + /*! + * \brief output = sum (input_0, input_1, ...) + * \ingroup math_operators_blk + * + * \details + * Add across all input streams. + */ class BLOCKS_API add_ff : virtual public gr_sync_block { public: diff --git a/gr-blocks/include/blocks/and_XX.h.t b/gr-blocks/include/blocks/and_XX.h.t index 68ddcc33d5..048e1bea57 100644 --- a/gr-blocks/include/blocks/and_XX.h.t +++ b/gr-blocks/include/blocks/and_XX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = input_0 & input_1 & , ... & input_N) - * \ingroup math_blk + * \ingroup boolean_operators_blk * * bitwise boolean and across all input streams. */ diff --git a/gr-blocks/include/blocks/and_const_XX.h.t b/gr-blocks/include/blocks/and_const_XX.h.t index 945a1f48b7..9e478819cb 100644 --- a/gr-blocks/include/blocks/and_const_XX.h.t +++ b/gr-blocks/include/blocks/and_const_XX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output_N = input_N & value - * \ingroup math_blk + * \ingroup boolean_operators_blk * * bitwise boolean and of const to the data stream. */ diff --git a/gr-blocks/include/blocks/annotator_1to1.h b/gr-blocks/include/blocks/annotator_1to1.h new file mode 100644 index 0000000000..1c5ab038fc --- /dev/null +++ b/gr-blocks/include/blocks/annotator_1to1.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_1TO1_H +#define INCLUDED_GR_ANNOTATOR_1TO1_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief 1-to-1 stream annotator testing block. FOR TESTING PURPOSES ONLY. + * + * \details + * This block creates tags to be sent downstream every 10,000 + * items it sees. The tags contain the name and ID of the + * instantiated block, use "seq" as a key, and have a counter that + * increments by 1 for every tag produced that is used as the + * tag's value. The tags are propagated using the 1-to-1 policy. + * + * It also stores a copy of all tags it sees flow past it. These + * tags can be recalled externally with the data() member. + * + * This block is only meant for testing and showing how to use the tags. + */ + class BLOCKS_API annotator_1to1 : virtual public gr_sync_block + { + public: + // gr::blocks::annotator_1to1::sptr + typedef boost::shared_ptr<annotator_1to1> sptr; + + static sptr make(int when, size_t sizeof_stream_item); + + virtual std::vector<gr_tag_t> data() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_1TO1_H */ diff --git a/gr-blocks/include/blocks/annotator_alltoall.h b/gr-blocks/include/blocks/annotator_alltoall.h new file mode 100644 index 0000000000..7bad73b291 --- /dev/null +++ b/gr-blocks/include/blocks/annotator_alltoall.h @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_ALLTOALL_H +#define INCLUDED_GR_ANNOTATOR_ALLTOALL_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief All-to-all stream annotator testing block. FOR TESTING PURPOSES ONLY. + * + * \details + * This block creates tags to be sent downstream every 10,000 + * items it sees. The tags contain the name and ID of the + * instantiated block, use "seq" as a key, and have a counter that + * increments by 1 for every tag produced that is used as the + * tag's value. The tags are propagated using the all-to-all + * policy. + * + * It also stores a copy of all tags it sees flow past it. These + * tags can be recalled externally with the data() member. + * + * This block is only meant for testing and showing how to use the tags. + */ + class BLOCKS_API annotator_alltoall : virtual public gr_sync_block + { + public: + // gr::blocks::annotator_alltoall::sptr + typedef boost::shared_ptr<annotator_alltoall> sptr; + + static sptr make(int when, size_t sizeof_stream_item); + + virtual std::vector<gr_tag_t> data() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_ALLTOALL_H */ diff --git a/gr-blocks/include/blocks/annotator_raw.h b/gr-blocks/include/blocks/annotator_raw.h new file mode 100644 index 0000000000..afa0a364eb --- /dev/null +++ b/gr-blocks/include/blocks/annotator_raw.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_RAW_H +#define INCLUDED_GR_ANNOTATOR_RAW_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_tags.h> + +namespace gr { + namespace blocks { + + /*! + * \brief raw stream annotator testing block. + * + * \details + * This block creates arbitrary tags to be sent downstream blocks + * to be sent are set manually via accessor methods and are sent + * only once. + * + * This block is intended for testing of tag related blocks + */ + class BLOCKS_API annotator_raw : virtual public gr_sync_block + { + public: + // gr::blocks::annotator_raw::sptr + typedef boost::shared_ptr<annotator_raw> sptr; + + static sptr make(size_t sizeof_stream_item); + + // insert a tag to be added + void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_RAW_H */ diff --git a/gr-blocks/include/blocks/argmax_XX.h.t b/gr-blocks/include/blocks/argmax_XX.h.t new file mode 100644 index 0000000000..93aa367260 --- /dev/null +++ b/gr-blocks/include/blocks/argmax_XX.h.t @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Compares vectors from multiple streams and determines + * the index in the vector and stream number where the maximum + * value occurred. + * \ingroup math_operators_blk + * + * \details + * Data is passed in as a vector of length \p vlen from multiple + * input sources. It will look through these streams of \p vlen + * data items and output two streams. + * Stream 0 will contain the index value in the vector where + * the maximum value occurred. + * Stream 1 will contain the number of the input stream that + * held the maximum value. + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t vlen); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/bin_statistics_f.h b/gr-blocks/include/blocks/bin_statistics_f.h new file mode 100644 index 0000000000..a73afc82d6 --- /dev/null +++ b/gr-blocks/include/blocks/bin_statistics_f.h @@ -0,0 +1,76 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_GR_BIN_STATISTICS_F_H +#define INCLUDED_GR_BIN_STATISTICS_F_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> +#include <gr_feval.h> + +namespace gr { + namespace blocks { + + /*! + * \brief control scanning and record frequency domain statistics + * \ingroup sink_blk + */ + class BLOCKS_API bin_statistics_f : virtual public gr_sync_block + { + protected: + std::vector<float> d_max; // per bin maxima + + virtual size_t vlen() const = 0; + virtual double center_freq() const = 0; + virtual gr_msg_queue_sptr msgq() const = 0; + + virtual void reset_stats() = 0; + virtual void accrue_stats(const float *input) = 0; + virtual void send_stats() = 0; + + public: + // gr::blocks::bin_statistics_f::sptr + typedef boost::shared_ptr<bin_statistics_f> sptr; + + /*! + * Build a bin statistics block. See qa_bin_statistics.py and + * gr-uhd/examples/python/usrp_spectrum_sense.py for examples of + * its use, specifically how to use the callback function. + * + * \param vlen vector length + * \param msgq message queue + * \param tune a gr_feval_dd callback function + * \param tune_delay number of samples for the tune delay + * \param dwell_delay number of samples for the dwell delay + */ + static sptr make(unsigned int vlen, // vector length + gr_msg_queue_sptr msgq, + gr_feval_dd *tune, // callback + size_t tune_delay, // samples + size_t dwell_delay); // samples + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_BIN_STATISTICS_F_H */ diff --git a/gr-blocks/include/blocks/burst_tagger.h b/gr-blocks/include/blocks/burst_tagger.h new file mode 100644 index 0000000000..312fb2ffbd --- /dev/null +++ b/gr-blocks/include/blocks/burst_tagger.h @@ -0,0 +1,76 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_BURST_TAGGER_H +#define INCLUDED_GR_BURST_TAGGER_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Sets a burst on/off tag based on the value of the trigger input. + * \ingroup peak_detectors_blk + * \ingroup stream_tag_tools_blk + * + * \details + * This block takes two inputs, a signal stream on the input + * stream 0 and a trigger stream of shorts on input stream 1. If + * the trigger stream goes above 0, a tag with the key "burst" + * will be transmitted as a pmt::PMT_T. When the trigger signal + * falls below 0, the "burst" tag will be transmitted as + * pmt::PMT_F. + * + * The signal on stream 0 is retransmitted to output stream 0. + */ + class BLOCKS_API burst_tagger : virtual public gr_sync_block + { + public: + // gr::blocks::burst_tagger::sptr + typedef boost::shared_ptr<burst_tagger> sptr; + + /*! + * Build a burst tagger blocks. + * + * \param itemsize itemsize of the signal stream on input 0. + */ + static sptr make(size_t itemsize); + + /*! + * For the true burst tag, change the key name to \p key and a + * new value of \p value. + */ + virtual void set_true_tag(const std::string &key, bool value) = 0; + + /*! + * For the false burst tag, change the key name to \p key and a + * new value of \p value. + */ + virtual void set_false_tag(const std::string &key, bool value) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_BURST_TAGGER_H */ diff --git a/gr-blocks/include/blocks/char_to_float.h b/gr-blocks/include/blocks/char_to_float.h index 92a2dbf800..0002ceb30b 100644 --- a/gr-blocks/include/blocks/char_to_float.h +++ b/gr-blocks/include/blocks/char_to_float.h @@ -31,10 +31,7 @@ namespace gr { /*! * \brief Convert stream of chars to a stream of float - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. + * \ingroup type_converters_blk */ class BLOCKS_API char_to_float : virtual public gr_sync_block { @@ -43,6 +40,12 @@ namespace gr { // gr::blocks::char_to_float_ff::sptr typedef boost::shared_ptr<char_to_float> sptr; + /*! + * Build a chars to float stream converter block. + * + * \param vlen vector length of data streams. + * \param scale a scalar divider to change the output signal scale. + */ static sptr make(size_t vlen=1, float scale=1.0); /*! diff --git a/gr-blocks/include/blocks/char_to_short.h b/gr-blocks/include/blocks/char_to_short.h index e2bb3a8590..fc9d3b4b52 100644 --- a/gr-blocks/include/blocks/char_to_short.h +++ b/gr-blocks/include/blocks/char_to_short.h @@ -31,9 +31,7 @@ namespace gr { /*! * \brief Convert stream of chars to a stream of short - * \ingroup converter_blk - * - * \param vlen vector length of data streams. + * \ingroup type_converters_blk */ class BLOCKS_API char_to_short : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/check_lfsr_32k_s.h b/gr-blocks/include/blocks/check_lfsr_32k_s.h new file mode 100644 index 0000000000..6eddd607b6 --- /dev/null +++ b/gr-blocks/include/blocks/check_lfsr_32k_s.h @@ -0,0 +1,57 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GR_CHECK_LFSR_32K_S_H +#define INCLUDED_GR_CHECK_LFSR_32K_S_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief sink that checks if its input stream consists of a lfsr_32k sequence. + * \ingroup sink_blk + * + * \details + * This sink is typically used along with + * gr::blocks::lfsr_32k_source_s to test the USRP using its + * digital loopback mode. + */ + class BLOCKS_API check_lfsr_32k_s : virtual public gr_sync_block + { + public: + // gr::blocks::check_lfsr_32k_s::sptr + typedef boost::shared_ptr<check_lfsr_32k_s> sptr; + + static sptr make(); + + virtual long ntotal () const = 0; + virtual long nright () const = 0; + virtual long runlength () const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_H */ diff --git a/gr-blocks/include/blocks/complex_to_arg.h b/gr-blocks/include/blocks/complex_to_arg.h index 5d38161d45..178f846704 100644 --- a/gr-blocks/include/blocks/complex_to_arg.h +++ b/gr-blocks/include/blocks/complex_to_arg.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief complex in, arg out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) + * \ingroup type_converters_blk */ class BLOCKS_API complex_to_arg : virtual public gr_sync_block { public: - // gr::blocks::complex_to_arg_ff::sptr typedef boost::shared_ptr<complex_to_arg> sptr; + /*! + * Build a complex to arg block. + * + * \param vlen vector len (default 1) + */ static sptr make(size_t vlen=1); }; diff --git a/gr-blocks/include/blocks/complex_to_float.h b/gr-blocks/include/blocks/complex_to_float.h index 322f67b624..7648648d6c 100644 --- a/gr-blocks/include/blocks/complex_to_float.h +++ b/gr-blocks/include/blocks/complex_to_float.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief convert a stream of gr_complex to 1 or 2 streams of float - * \ingroup converter_blk - * \param vlen vector len (default 1) + * \ingroup type_converters_blk */ class BLOCKS_API complex_to_float : virtual public gr_sync_block { public: - // gr::blocks::complex_to_float_ff::sptr typedef boost::shared_ptr<complex_to_float> sptr; + /*! + * Build a complex to float block. + * + * \param vlen vector len (default 1) + */ static sptr make(size_t vlen=1); }; diff --git a/gr-blocks/include/blocks/complex_to_imag.h b/gr-blocks/include/blocks/complex_to_imag.h index 71353a94a1..cb1d32fec6 100644 --- a/gr-blocks/include/blocks/complex_to_imag.h +++ b/gr-blocks/include/blocks/complex_to_imag.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief complex in, imag out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) + * \ingroup type_converters_blk */ class BLOCKS_API complex_to_imag : virtual public gr_sync_block { public: - // gr::blocks::complex_to_imag_ff::sptr typedef boost::shared_ptr<complex_to_imag> sptr; + /*! + * Build a complex to imaginary part block. + * + * \param vlen vector len (default 1) + */ static sptr make(size_t vlen=1); }; diff --git a/gr-blocks/include/blocks/complex_to_interleaved_short.h b/gr-blocks/include/blocks/complex_to_interleaved_short.h index f5e91123ce..c7304787a9 100644 --- a/gr-blocks/include/blocks/complex_to_interleaved_short.h +++ b/gr-blocks/include/blocks/complex_to_interleaved_short.h @@ -31,15 +31,17 @@ namespace gr { /*! * \brief Convert stream of complex to a stream of interleaved shorts - * \ingroup converter_blk + * \ingroup type_converters_blk */ class BLOCKS_API complex_to_interleaved_short : virtual public gr_sync_interpolator { public: - // gr::blocks::complex_to_interleaved_short::sptr typedef boost::shared_ptr<complex_to_interleaved_short> sptr; + /*! + * Build a complex to interleaved shorts block. + */ static sptr make(); }; diff --git a/gr-blocks/include/blocks/complex_to_mag.h b/gr-blocks/include/blocks/complex_to_mag.h index 7e03c1cac4..b1758fd3eb 100644 --- a/gr-blocks/include/blocks/complex_to_mag.h +++ b/gr-blocks/include/blocks/complex_to_mag.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief complex in, magnitude out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) + * \ingroup type_converters_blk */ class BLOCKS_API complex_to_mag : virtual public gr_sync_block { public: - // gr::blocks::complex_to_mag_ff::sptr typedef boost::shared_ptr<complex_to_mag> sptr; + /*! + * Build a complex to magnitude block. + * + * \param vlen vector len (default 1) + */ static sptr make(size_t vlen=1); }; diff --git a/gr-blocks/include/blocks/complex_to_mag_squared.h b/gr-blocks/include/blocks/complex_to_mag_squared.h index 9e122b4b1b..a7c464fbb0 100644 --- a/gr-blocks/include/blocks/complex_to_mag_squared.h +++ b/gr-blocks/include/blocks/complex_to_mag_squared.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief complex in, magnitude squared out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) + * \ingroup type_converters_blk */ class BLOCKS_API complex_to_mag_squared : virtual public gr_sync_block { public: - // gr::blocks::complex_to_mag_squared_ff::sptr typedef boost::shared_ptr<complex_to_mag_squared> sptr; + /*! + * Build a complex to magnitude squared block. + * + * \param vlen vector len (default 1) + */ static sptr make(size_t vlen=1); }; diff --git a/gr-blocks/include/blocks/complex_to_real.h b/gr-blocks/include/blocks/complex_to_real.h index a891c2e086..908ca9fc94 100644 --- a/gr-blocks/include/blocks/complex_to_real.h +++ b/gr-blocks/include/blocks/complex_to_real.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief complex in, real out (float) - * \ingroup converter_blk - * \param vlen vector len (default 1) + * \ingroup type_converters_blk */ class BLOCKS_API complex_to_real : virtual public gr_sync_block { public: - // gr::blocks::complex_to_real_ff::sptr typedef boost::shared_ptr<complex_to_real> sptr; + /*! + * Build a complex to real part block. + * + * \param vlen vector len (default 1) + */ static sptr make(size_t vlen=1); }; diff --git a/gr-blocks/include/blocks/conjugate_cc.h b/gr-blocks/include/blocks/conjugate_cc.h index 02297c56e2..92096eea31 100644 --- a/gr-blocks/include/blocks/conjugate_cc.h +++ b/gr-blocks/include/blocks/conjugate_cc.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief output = complex conjugate of input - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API conjugate_cc : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/control_loop.h b/gr-blocks/include/blocks/control_loop.h new file mode 100644 index 0000000000..e59429a1f7 --- /dev/null +++ b/gr-blocks/include/blocks/control_loop.h @@ -0,0 +1,233 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,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. + */ + +#ifndef GR_BLOCKS_CONTROL_LOOP +#define GR_BLOCKS_CONTROL_LOOP + +#include <blocks/api.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API control_loop + { + protected: + float d_phase, d_freq; + float d_max_freq, d_min_freq; + float d_damping, d_loop_bw; + float d_alpha, d_beta; + + public: + control_loop(float loop_bw, float max_freq, float min_freq); + virtual ~control_loop(); + + /*! \brief update the system gains from the loop bandwidth and damping factor + * + * This function updates the system gains based on the loop + * bandwidth and damping factor of the system. These two + * factors can be set separately through their own set + * functions. + */ + void update_gains(); + + /*! \brief Advance the control loop based on the current gain + * settings and the inputted error signal. + */ + void advance_loop(float error); + + /*! \brief Keep the phase between -2pi and 2pi + * + * This function keeps the phase between -2pi and 2pi. If the + * phase is greater than 2pi by d, it wraps around to be -2pi+d; + * similarly if it is less than -2pi by d, it wraps around to + * 2pi-d. + * + * This function should be called after advance_loop to keep the + * phase in a good operating region. It is set as a separate + * method in case another way is desired as this is fairly + * heavy-handed. + */ + void phase_wrap(); + + /*! \brief Keep the frequency between d_min_freq and d_max_freq + * + * This function keeps the frequency between d_min_freq and + * d_max_freq. If the frequency is greater than d_max_freq, it + * is set to d_max_freq. If the frequency is less than + * d_min_freq, it is set to d_min_freq. + * + * This function should be called after advance_loop to keep the + * frequency in the specified region. It is set as a separate + * method in case another way is desired as this is fairly + * heavy-handed. + */ + void frequency_limit(); + + /******************************************************************* + * SET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Set the loop bandwidth + * + * Set the loop filter's bandwidth to \p bw. This should be + * between 2*pi/200 and 2*pi/100 (in rads/samp). It must also be + * a positive number. + * + * When a new damping factor is set, the gains, alpha and beta, + * of the loop are recalculated by a call to update_gains(). + * + * \param bw (float) new bandwidth + */ + void set_loop_bandwidth(float bw); + + /*! + * \brief Set the loop damping factor + * + * Set the loop filter's damping factor to \p df. The damping + * factor should be sqrt(2)/2.0 for critically damped systems. + * Set it to anything else only if you know what you are + * doing. It must be a number between 0 and 1. + * + * When a new damping factor is set, the gains, alpha and beta, + * of the loop are recalculated by a call to update_gains(). + * + * \param df (float) new damping factor + */ + void set_damping_factor(float df); + + /*! + * \brief Set the loop gain alpha + * + * Set's the loop filter's alpha gain parameter. + * + * This value should really only be set by adjusting the loop + * bandwidth and damping factor. + * + * \param alpha (float) new alpha gain + * + */ + void set_alpha(float alpha); + + /*! + * \brief Set the loop gain beta + * + * Set's the loop filter's beta gain parameter. + * + * This value should really only be set by adjusting the loop + * bandwidth and damping factor. + * + * \param beta (float) new beta gain + */ + void set_beta(float beta); + + /*! + * \brief Set the control loop's frequency. + * + * Set's the control loop's frequency. While this is normally + * updated by the inner loop of the algorithm, it could be + * useful to manually initialize, set, or reset this under + * certain circumstances. + * + * \param freq (float) new frequency + */ + void set_frequency(float freq); + + /*! + * \brief Set the control loop's phase. + * + * Set's the control loop's phase. While this is normally + * updated by the inner loop of the algorithm, it could be + * useful to manually initialize, set, or reset this under + * certain circumstances. + * + * \param phase (float) new phase + */ + void set_phase(float phase); + + /*! + * \brief Set the control loop's maximum frequency. + * + * Set the maximum frequency the control loop can track. + * + * \param freq (float) new max frequency + */ + void set_max_freq(float freq); + + /*! + * \brief Set the control loop's minimum frequency. + * + * Set the minimum frequency the control loop can track. + * + * \param freq (float) new min frequency + */ + void set_min_freq(float freq); + + /******************************************************************* + * GET FUNCTIONS + *******************************************************************/ + + /*! + * \brief Returns the loop bandwidth + */ + float get_loop_bandwidth() const; + + /*! + * \brief Returns the loop damping factor + */ + float get_damping_factor() const; + + /*! + * \brief Returns the loop gain alpha + */ + float get_alpha() const; + + /*! + * \brief Returns the loop gain beta + */ + float get_beta() const; + + /*! + * \brief Get the control loop's frequency estimate + */ + float get_frequency() const; + + /*! + * \brief Get the control loop's phase estimate + */ + float get_phase() const; + + /*! + * \brief Get the control loop's maximum frequency. + */ + float get_max_freq() const; + + /*! + * \brief Get the control loop's minimum frequency. + */ + float get_min_freq() const; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* GR_BLOCKS_CONTROL_LOOP */ diff --git a/gr-blocks/include/blocks/copy.h b/gr-blocks/include/blocks/copy.h new file mode 100644 index 0000000000..a243a54917 --- /dev/null +++ b/gr-blocks/include/blocks/copy.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,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. + */ + +#ifndef INCLUDED_GR_COPY_H +#define INCLUDED_GR_COPY_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output[i] = input[i] + * \ingroup misc_blk + * + * \details + * When enabled (default), this block copies its input to its + * output. When disabled, this block drops its input on the floor. + */ + class BLOCKS_API copy : virtual public gr_block + { + public: + // gr::blocks::copy::sptr + typedef boost::shared_ptr<copy> sptr; + + static sptr make(size_t itemsize); + + virtual void set_enabled(bool enable) = 0; + virtual bool enabled() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_COPY_H */ diff --git a/gr-blocks/include/blocks/deinterleave.h b/gr-blocks/include/blocks/deinterleave.h index 24074d2fcf..bb6ad59a22 100644 --- a/gr-blocks/include/blocks/deinterleave.h +++ b/gr-blocks/include/blocks/deinterleave.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief deinterleave a single input into N outputs - * \ingroup slicedice_blk - * \param itemsize stream itemsize + * \ingroup stream_operators_blk */ class BLOCKS_API deinterleave : virtual public gr_sync_decimator { public: - // gr::blocks::deinterleave::sptr typedef boost::shared_ptr<deinterleave> sptr; + /*! + * Make a deinterleave block. + * + * \param itemsize stream itemsize + */ static sptr make(size_t itemsize); }; diff --git a/gr-blocks/include/blocks/divide_XX.h.t b/gr-blocks/include/blocks/divide_XX.h.t index 9a382e4a09..821a458ec4 100644 --- a/gr-blocks/include/blocks/divide_XX.h.t +++ b/gr-blocks/include/blocks/divide_XX.h.t @@ -33,8 +33,9 @@ namespace gr { /*! * \brief output = input_0 / input_1 / input_x ...) - * \ingroup math_blk + * \ingroup math_operators_blk * + * \details * Divide across all input streams. */ class BLOCKS_API @NAME@ : virtual public gr_sync_block diff --git a/gr-blocks/include/blocks/endian_swap.h b/gr-blocks/include/blocks/endian_swap.h new file mode 100644 index 0000000000..c26a1d2aa4 --- /dev/null +++ b/gr-blocks/include/blocks/endian_swap.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012,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. + */ + +#ifndef INCLUDED_GR_ENDIAN_SWAP_H +#define INCLUDED_GR_ENDIAN_SWAP_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Convert stream of items into thier byte swapped version + * \ingroup stream_operators_blk + */ + class BLOCKS_API endian_swap : virtual public gr_sync_block + { + public: + // gr::blocks::endian_swap::sptr + typedef boost::shared_ptr<endian_swap> sptr; + + /*! + * Make an endian swap block. + * + * \param item_size_bytes number of bytes per item, 1=no-op, + * 2=uint16_t, 4=uint32_t, 8=uint64_t + */ + static sptr make(size_t item_size_bytes=1); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ENDIAN_SWAP_H */ diff --git a/gr-blocks/include/blocks/file_descriptor_sink.h b/gr-blocks/include/blocks/file_descriptor_sink.h new file mode 100644 index 0000000000..e98f918c14 --- /dev/null +++ b/gr-blocks/include/blocks/file_descriptor_sink.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GR_FILE_DESCRIPTOR_SINK_H +#define INCLUDED_GR_FILE_DESCRIPTOR_SINK_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Write stream to file descriptor. + * \ingroup file_operators_blk + */ + class BLOCKS_API file_descriptor_sink : virtual public gr_sync_block + { + public: + // gr::blocks::file_descriptor_sink::sptr + typedef boost::shared_ptr<file_descriptor_sink> sptr; + + /*! + * Build a file descriptor sink block. + * + * \param itemsize item size of the incoming data stream. + * \param fd file descriptor (as an integer). + */ + static sptr make(size_t itemsize, int fd); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SINK_H */ diff --git a/gr-blocks/include/blocks/file_descriptor_source.h b/gr-blocks/include/blocks/file_descriptor_source.h new file mode 100644 index 0000000000..ac827800cd --- /dev/null +++ b/gr-blocks/include/blocks/file_descriptor_source.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H +#define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + + +namespace gr { + namespace blocks { + + /*! + * \brief Read stream from file descriptor. + * \ingroup file_operators_blk + */ + class BLOCKS_API file_descriptor_source : virtual public gr_sync_block + { + protected: + virtual int read_items(char *buf, int nitems) = 0; + virtual int handle_residue(char *buf, int nbytes_read) = 0; + virtual void flush_residue() = 0; + + public: + // gr::blocks::file_descriptor_source::sptr + typedef boost::shared_ptr<file_descriptor_source> sptr; + + /*! + * Build a file descriptor source block. + * + * \param itemsize item size of the incoming data stream. + * \param fd file descriptor (as an integer). + * \param repeat repeat the data stream continuously. + */ + static sptr make(size_t itemsize, int fd, bool repeat); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_H */ diff --git a/gr-blocks/include/blocks/file_meta_sink.h b/gr-blocks/include/blocks/file_meta_sink.h index ef64887cf9..763e0a2da0 100644 --- a/gr-blocks/include/blocks/file_meta_sink.h +++ b/gr-blocks/include/blocks/file_meta_sink.h @@ -45,8 +45,9 @@ namespace gr { /*! * \brief Write stream to file with meta-data headers. - * \ingroup sink_blk + * \ingroup file_operators_blk * + * \details * These files represent data as binary information in between * meta-data headers. The headers contain information about the * type of data and properties of the data in the next segment of diff --git a/gr-blocks/include/blocks/file_meta_source.h b/gr-blocks/include/blocks/file_meta_source.h index a992d52432..83997fc9b5 100644 --- a/gr-blocks/include/blocks/file_meta_source.h +++ b/gr-blocks/include/blocks/file_meta_source.h @@ -32,8 +32,9 @@ namespace gr { /*! * \brief Reads stream from file with meta-data headers. Headers * are parsed into tags. - * \ingroup source_blk + * \ingroup file_operators_blk * + * \details * The information in the metadata headers includes: * * rx_rate (double): sample rate of data. diff --git a/gr-blocks/include/blocks/file_sink.h b/gr-blocks/include/blocks/file_sink.h new file mode 100644 index 0000000000..c894defd78 --- /dev/null +++ b/gr-blocks/include/blocks/file_sink.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,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. + */ + +#ifndef INCLUDED_GR_FILE_SINK_H +#define INCLUDED_GR_FILE_SINK_H + +#include <blocks/api.h> +#include <blocks/file_sink_base.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Write stream to file. + * \ingroup file_operators_blk + */ + class BLOCKS_API file_sink : virtual public gr_sync_block, + virtual public file_sink_base + { + public: + // gr::blocks::file_sink::sptr + typedef boost::shared_ptr<file_sink> sptr; + + /*! + * \brief Make a file sink. + * \param itemsize size of the input data items. + * \param filename name of the file to open and write output to. + */ + static sptr make(size_t itemsize, const char *filename); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FILE_SINK_H */ diff --git a/gr-blocks/include/blocks/file_sink_base.h b/gr-blocks/include/blocks/file_sink_base.h new file mode 100644 index 0000000000..3eeb0e63da --- /dev/null +++ b/gr-blocks/include/blocks/file_sink_base.h @@ -0,0 +1,80 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2008,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. + */ + +#ifndef INCLUDED_GR_FILE_SINK_BASE_H +#define INCLUDED_GR_FILE_SINK_BASE_H + +#include <blocks/api.h> +#include <boost/thread.hpp> +#include <cstdio> + +namespace gr { + namespace blocks { + + /*! + * \brief Common base class for file sinks + */ + class BLOCKS_API file_sink_base + { + protected: + FILE *d_fp; // current FILE pointer + FILE *d_new_fp; // new FILE pointer + bool d_updated; // is there a new FILE pointer? + bool d_is_binary; + boost::mutex d_mutex; + bool d_unbuffered; + + protected: + file_sink_base(const char *filename, bool is_binary); + + public: + file_sink_base() {} + ~file_sink_base(); + + /*! + * \brief Open filename and begin output to it. + */ + bool open(const char *filename); + + /*! + * \brief Close current output file. + * + * Closes current output file and ignores any output until + * open is called to connect to another file. + */ + void close(); + + /*! + * \brief if we've had an update, do it now. + */ + void do_update(); + + /*! + * \brief turn on unbuffered writes for slower outputs + */ + void set_unbuffered(bool unbuffered); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FILE_SINK_BASE_H */ diff --git a/gr-blocks/include/blocks/file_source.h b/gr-blocks/include/blocks/file_source.h index 1a12aa905d..6f1bc49ea1 100644 --- a/gr-blocks/include/blocks/file_source.h +++ b/gr-blocks/include/blocks/file_source.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief Read stream from file - * \ingroup source_blk + * \ingroup file_operators_blk */ class BLOCKS_API file_source : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/float_to_char.h b/gr-blocks/include/blocks/float_to_char.h index de9ea85e33..c0193da573 100644 --- a/gr-blocks/include/blocks/float_to_char.h +++ b/gr-blocks/include/blocks/float_to_char.h @@ -31,18 +31,20 @@ namespace gr { /*! * \brief Convert stream of floats to a stream of char - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. + * \ingroup type_converters_blk */ class BLOCKS_API float_to_char : virtual public gr_sync_block { public: - // gr::blocks::float_to_char_ff::sptr typedef boost::shared_ptr<float_to_char> sptr; + /*! + * Build a float to char block. + * + * \param vlen vector length of data streams. + * \param scale a scalar multiplier to change the output signal scale. + */ static sptr make(size_t vlen=1, float scale=1.0); /*! diff --git a/gr-blocks/include/blocks/float_to_complex.h b/gr-blocks/include/blocks/float_to_complex.h index 48c5b6ead4..aba9aed8c4 100644 --- a/gr-blocks/include/blocks/float_to_complex.h +++ b/gr-blocks/include/blocks/float_to_complex.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief one or two floats in, complex out - * \ingroup converter_blk - * \param vlen vector len (default 1) + * \ingroup type_converters_blk */ class BLOCKS_API float_to_complex : virtual public gr_sync_block { public: - // gr::blocks::float_to_complex_ff::sptr typedef boost::shared_ptr<float_to_complex> sptr; + /*! + * Build a float to complex block. + * + * \param vlen vector len (default 1) + */ static sptr make(size_t vlen=1); }; diff --git a/gr-blocks/include/blocks/float_to_int.h b/gr-blocks/include/blocks/float_to_int.h index 95c62e5162..3c8e7ad5ab 100644 --- a/gr-blocks/include/blocks/float_to_int.h +++ b/gr-blocks/include/blocks/float_to_int.h @@ -30,19 +30,21 @@ namespace gr { namespace blocks { /*! - * \brief Convert stream of floats to a stream of char - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. + * \brief Convert stream of floats to a stream of ints. + * \ingroup type_converters_blk */ class BLOCKS_API float_to_int : virtual public gr_sync_block { public: - // gr::blocks::float_to_int_ff::sptr typedef boost::shared_ptr<float_to_int> sptr; + /*! + * Build a float to int block. + * + * \param vlen vector length of data streams. + * \param scale a scalar multiplier to change the output signal scale. + */ static sptr make(size_t vlen=1, float scale=1.0); /*! diff --git a/gr-blocks/include/blocks/float_to_short.h b/gr-blocks/include/blocks/float_to_short.h index 5f1ab3f958..8f5f60e55b 100644 --- a/gr-blocks/include/blocks/float_to_short.h +++ b/gr-blocks/include/blocks/float_to_short.h @@ -31,18 +31,20 @@ namespace gr { /*! * \brief Convert stream of floats to a stream of shorts - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar multiplier to change the output signal scale. + * \ingroup type_converters_blk */ class BLOCKS_API float_to_short : virtual public gr_sync_block { public: - // gr::blocks::float_to_short_ff::sptr typedef boost::shared_ptr<float_to_short> sptr; + /*! + * Build a float to short block. + * + * \param vlen vector length of data streams. + * \param scale a scalar multiplier to change the output signal scale. + */ static sptr make(size_t vlen=1, float scale=1.0); /*! diff --git a/gr-blocks/include/blocks/float_to_uchar.h b/gr-blocks/include/blocks/float_to_uchar.h index b5d0d08f7d..9bfaaa65aa 100644 --- a/gr-blocks/include/blocks/float_to_uchar.h +++ b/gr-blocks/include/blocks/float_to_uchar.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief Convert stream of floats to a stream of unsigned chars - * \ingroup converter_blk + * \ingroup type_converters_blk */ class BLOCKS_API float_to_uchar : virtual public gr_sync_block { @@ -40,6 +40,9 @@ namespace gr { // gr::blocks::float_to_uchar_ff::sptr typedef boost::shared_ptr<float_to_uchar> sptr; + /*! + * Build a float to uchar block. + */ static sptr make(); }; diff --git a/gr-blocks/include/blocks/head.h b/gr-blocks/include/blocks/head.h new file mode 100644 index 0000000000..4693f988b8 --- /dev/null +++ b/gr-blocks/include/blocks/head.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2009,2012,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. + */ + +#ifndef INCLUDED_GR_HEAD_H +#define INCLUDED_GR_HEAD_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <stddef.h> // size_t + +namespace gr { + namespace blocks { + + /*! + * \brief copies the first N items to the output then signals done + * \ingroup misc_blk + * + * \details + * Useful for building test cases + */ + class BLOCKS_API head : virtual public gr_sync_block + { + public: + // gr::blocks::head::sptr + typedef boost::shared_ptr<head> sptr; + + static sptr make(size_t sizeof_stream_item, + uint64_t nitems); + + virtual void reset() = 0; + virtual void set_length(int nitems) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_HEAD_H */ diff --git a/gr-blocks/include/blocks/int_to_float.h b/gr-blocks/include/blocks/int_to_float.h index ebee1c3c9e..179667e4df 100644 --- a/gr-blocks/include/blocks/int_to_float.h +++ b/gr-blocks/include/blocks/int_to_float.h @@ -30,19 +30,21 @@ namespace gr { namespace blocks { /*! - * \brief Convert stream of ints to a stream of floats - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. + * \brief Convert stream of ints to a stream of floats. + * \ingroup type_converters_blk */ class BLOCKS_API int_to_float : virtual public gr_sync_block { public: - // gr::blocks::int_to_float_ff::sptr typedef boost::shared_ptr<int_to_float> sptr; + /*! + * Build an int to float block. + * + * \param vlen vector length of data streams. + * \param scale a scalar divider to change the output signal scale. + */ static sptr make(size_t vlen=1, float scale=1.0); /*! diff --git a/gr-blocks/include/blocks/integrate_XX.h.t b/gr-blocks/include/blocks/integrate_XX.h.t index 8a313a0ba9..45a49def0c 100644 --- a/gr-blocks/include/blocks/integrate_XX.h.t +++ b/gr-blocks/include/blocks/integrate_XX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief Integrate successive samples and decimate - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API @NAME@ : virtual public gr_sync_decimator { diff --git a/gr-blocks/include/blocks/interleave.h b/gr-blocks/include/blocks/interleave.h index e98d01df9b..043ad6d27b 100644 --- a/gr-blocks/include/blocks/interleave.h +++ b/gr-blocks/include/blocks/interleave.h @@ -31,16 +31,19 @@ namespace gr { /*! * \brief interleave N inputs into a single output - * \ingroup slicedice_blk - * \param itemsize stream itemsize + * \ingroup stream_operators_blk */ class BLOCKS_API interleave : virtual public gr_sync_interpolator { public: - // gr::blocks::interleave::sptr typedef boost::shared_ptr<interleave> sptr; + /*! + * Make a stream interleave block. + * + * \param itemsize stream itemsize + */ static sptr make(size_t itemsize); }; diff --git a/gr-blocks/include/blocks/interleaved_short_to_complex.h b/gr-blocks/include/blocks/interleaved_short_to_complex.h index 40e96fc46a..961ce59a66 100644 --- a/gr-blocks/include/blocks/interleaved_short_to_complex.h +++ b/gr-blocks/include/blocks/interleaved_short_to_complex.h @@ -31,15 +31,17 @@ namespace gr { /*! * \brief Convert stream of interleaved shorts to a stream of complex - * \ingroup converter_blk + * \ingroup type_converters_blk */ class BLOCKS_API interleaved_short_to_complex : virtual public gr_sync_decimator { public: - // gr::blocks::interleaved_short_to_complex::sptr typedef boost::shared_ptr<interleaved_short_to_complex> sptr; + /*! + * Build an interleaved short to complex block. + */ static sptr make(); }; diff --git a/gr-blocks/include/blocks/keep_m_in_n.h b/gr-blocks/include/blocks/keep_m_in_n.h index 806ec3de54..88d94fab85 100644 --- a/gr-blocks/include/blocks/keep_m_in_n.h +++ b/gr-blocks/include/blocks/keep_m_in_n.h @@ -30,8 +30,8 @@ namespace gr { namespace blocks { /*! - * \brief decimate a stream, keeping one item out of every n. - * \ingroup slicedice_blk + * \brief decimate a stream, keeping \p m items out of every \p n. + * \ingroup stream_operators_blk */ class BLOCKS_API keep_m_in_n : virtual public gr_block { @@ -40,6 +40,14 @@ namespace gr { // gr::blocks::keep_m_in_n::sptr typedef boost::shared_ptr<keep_m_in_n> sptr; + /*! + * Make a keep m in n block. + * + * \param itemsize stream itemsize + * \param m number of items to take in block of \p n items + * \param n block size in items + * \param offset initial item offset into the stream + */ static sptr make(size_t itemsize, int m, int n, int offset); virtual void set_m(int m) = 0; diff --git a/gr-blocks/include/blocks/keep_one_in_n.h b/gr-blocks/include/blocks/keep_one_in_n.h index c487849941..9cce1e93ed 100644 --- a/gr-blocks/include/blocks/keep_one_in_n.h +++ b/gr-blocks/include/blocks/keep_one_in_n.h @@ -30,8 +30,8 @@ namespace gr { namespace blocks { /*! - * \brief decimate a stream, keeping one item out of every n. - * \ingroup slicedice_blk + * \brief decimate a stream, keeping one item out of every \p n. + * \ingroup stream_operators_blk */ class BLOCKS_API keep_one_in_n : virtual public gr_block { @@ -40,6 +40,12 @@ namespace gr { // gr::blocks::keep_one_in_n::sptr typedef boost::shared_ptr<keep_one_in_n> sptr; + /*! + * Make a keep one in n block. + * + * \param itemsize stream itemsize + * \param n block size in items + */ static sptr make(size_t itemsize, int n); virtual void set_n(int n) = 0; diff --git a/gr-blocks/include/blocks/lfsr_15_1_0.h b/gr-blocks/include/blocks/lfsr_15_1_0.h new file mode 100644 index 0000000000..b906844585 --- /dev/null +++ b/gr-blocks/include/blocks/lfsr_15_1_0.h @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004 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. + */ + +#ifndef INCLUDED_GRI_LFSR_15_1_0_H +#define INCLUDED_GRI_LFSR_15_1_0_H + +#include <blocks/api.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Linear Feedback Shift Register using primitive polynomial x^15 + x + 1 + * \ingroup misc + * + * \details + * Generates a maximal length pseudo-random sequence of length + * 2^15 - 1 bits. + */ + class BLOCKS_API lfsr_15_1_0 + { + private: + unsigned long d_sr; // shift register + + public: + lfsr_15_1_0() { reset(); } + + void reset() { d_sr = 0x7fff; } + + int next_bit() + { + d_sr = ((((d_sr >> 1) ^ d_sr) & 0x1) << 14) | (d_sr >> 1); + return d_sr & 0x1; + } + + int next_byte () + { + int v = 0; + for(int i = 0; i < 8; i++) { + v >>= 1; + if(next_bit ()) + v |= 0x80; + } + return v; + } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GRI_LFSR_15_1_0_H */ diff --git a/gr-blocks/include/blocks/lfsr_32k.h b/gr-blocks/include/blocks/lfsr_32k.h new file mode 100644 index 0000000000..23954139d8 --- /dev/null +++ b/gr-blocks/include/blocks/lfsr_32k.h @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GRI_LFSR_32k_H +#define INCLUDED_GRI_LFSR_32k_H + +#include <blocks/api.h> +#include <blocks/lfsr_15_1_0.h> + +namespace gr { + namespace blocks { + + /*! + * \brief generate pseudo-random sequence of length 32768 bits. + * \ingroup misc + * + * \details + * This is based on gri_lfsr_15_1_0 with an extra 0 added at the + * end of the sequence. + */ + class BLOCKS_API lfsr_32k + { + private: + lfsr_15_1_0 d_lfsr; + unsigned int d_count; + + public: + lfsr_32k() { reset (); } + + void reset() + { + d_lfsr.reset(); + d_count = 0; + } + + int next_bit() + { + if(d_count == 32767) { + d_count = 0; + return 0; + } + d_count++; + return d_lfsr.next_bit(); + } + + int next_byte() + { + int v = 0; + for(int i = 0; i < 8; i++) { + v >>= 1; + if(next_bit ()) + v |= 0x80; + } + return v; + } + + int next_short() + { + int v = 0; + for(int i = 0; i < 16; i++) { + v >>= 1; + if(next_bit ()) + v |= 0x8000; + } + return v; + } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GRI_LFSR_32k_H */ diff --git a/gr-blocks/include/blocks/lfsr_32k_source_s.h b/gr-blocks/include/blocks/lfsr_32k_source_s.h new file mode 100644 index 0000000000..9cc32fc2c9 --- /dev/null +++ b/gr-blocks/include/blocks/lfsr_32k_source_s.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GR_LFSR_32K_SOURCE_S_H +#define INCLUDED_GR_LFSR_32K_SOURCE_S_H + +#include <blocks/api.h> +#include <blocks/lfsr_32k.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief LFSR pseudo-random source with period of 2^15 bits (2^11 shorts) + * \ingroup source_blk + * + * \details + * This source is typically used along with gr::blocks::check_lfsr_32k_s to + * test the USRP using its digital loopback mode. + */ + class BLOCKS_API lfsr_32k_source_s : virtual public gr_sync_block + { + public: + // gr::blocks::lfsr_32k_source_s::sptr + typedef boost::shared_ptr<lfsr_32k_source_s> sptr; + + /*! + * \brief Make a LFSR 32k source block. + */ + static sptr make(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_H */ diff --git a/gr-blocks/include/blocks/max_XX.h.t b/gr-blocks/include/blocks/max_XX.h.t new file mode 100644 index 0000000000..738d7bb938 --- /dev/null +++ b/gr-blocks/include/blocks/max_XX.h.t @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Compares vectors from multiple streams and determines + * the maximum value from each vector over all streams. + * \ingroup math_operators_blk + * + * \details + * Data is passed in as a vector of length \p vlen from multiple + * input sources. It will look through these streams of \p vlen + * data items and output two streams. + * Stream 0 will contain the index value in the vector where + * the maximum value occurred. + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t vlen); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ + diff --git a/gr-blocks/include/blocks/message_burst_source.h b/gr-blocks/include/blocks/message_burst_source.h new file mode 100644 index 0000000000..72997abf2c --- /dev/null +++ b/gr-blocks/include/blocks/message_burst_source.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_GR_MESSAGE_BURST_SOURCE_H +#define INCLUDED_GR_MESSAGE_BURST_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Turn received messages into a stream and tag them for UHD to send. + * \ingroup message_tools_blk + */ + class BLOCKS_API message_burst_source : virtual public gr_sync_block + { + public: + // gr::blocks::message_source::sptr + typedef boost::shared_ptr<message_burst_source> sptr; + + static sptr make(size_t itemsize, int msgq_limit); + static sptr make(size_t itemsize, gr_msg_queue_sptr msgq); + + virtual gr_msg_queue_sptr msgq() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_BURST_SOURCE_H */ diff --git a/gr-blocks/include/blocks/message_debug.h b/gr-blocks/include/blocks/message_debug.h new file mode 100644 index 0000000000..59a778ba49 --- /dev/null +++ b/gr-blocks/include/blocks/message_debug.h @@ -0,0 +1,88 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-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. + */ + +#ifndef INCLUDED_GR_MESSAGE_DEBUG_H +#define INCLUDED_GR_MESSAGE_DEBUG_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Debug block for the message passing system. + * \ingroup message_tools_blk + * \ingroup measurement_tools_blk + * \ingroup debug_tools_blk + * + * \details + * The message debug block is used to capture and print or store + * messages as they are received. Any block that generates a + * message may connect that message port to one or more of the + * three message input ports of this debug block. The message + * ports are: + * + * \li print: prints the message directly to standard out. + * \li store: stores the message in an internal vector. May be + * access using the get_message function. + * \li print_pdu: specifically designed to handle formatted PDUs + * (see pdu.h). + */ + class BLOCKS_API message_debug : virtual public gr_block + { + public: + // gr::blocks::message_debug::sptr + typedef boost::shared_ptr<message_debug> sptr; + + /*! + * \brief Build the message debug block. It takes no parameters + * and has three message ports: print, store, and + * print_pdu. + */ + static sptr make(); + + /*! + * \brief Reports the number of messages received by this block. + */ + virtual int num_messages() = 0; + + /*! + * \brief Get a message (as a PMT) from the message vector at index \p i. + * + * Messages passed to the 'store' port will be stored in a + * vector. This function retrieves those messages by index. They + * are index in order of when they were received (all messages + * are just pushed onto the back of a vector). This is mostly + * useful in debugging message passing graphs and in QA code. + * + * \param i The index in the vector for the message to retrieve. + * + * \return a message at index \p i as a pmt_t. + */ + virtual pmt::pmt_t get_message(int i) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_DEBUG_H */ diff --git a/gr-blocks/include/blocks/message_sink.h b/gr-blocks/include/blocks/message_sink.h new file mode 100644 index 0000000000..32d862b9d2 --- /dev/null +++ b/gr-blocks/include/blocks/message_sink.h @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_MESSAGE_SINK_H +#define INCLUDED_GR_MESSAGE_SINK_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Gather received items into messages and insert into msgq + * \ingroup message_tools_blk + */ + class BLOCKS_API message_sink : virtual public gr_sync_block + { + public: + // gr::blocks::message_sink::sptr + typedef boost::shared_ptr<message_sink> sptr; + + static sptr make (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_SINK_H */ diff --git a/gr-blocks/include/blocks/message_source.h b/gr-blocks/include/blocks/message_source.h new file mode 100644 index 0000000000..4c0de84c14 --- /dev/null +++ b/gr-blocks/include/blocks/message_source.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_MESSAGE_SOURCE_H +#define INCLUDED_GR_MESSAGE_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Turn received messages into a stream + * \ingroup message_tools_blk + */ + class BLOCKS_API message_source : virtual public gr_sync_block + { + public: + // gr::blocks::message_source::sptr + typedef boost::shared_ptr<message_source> sptr; + + static sptr make(size_t itemsize, int msgq_limit=0); + static sptr make(size_t itemsize, gr_msg_queue_sptr msgq); + + virtual gr_msg_queue_sptr msgq() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_SOURCE_H */ diff --git a/gr-blocks/include/blocks/message_strobe.h b/gr-blocks/include/blocks/message_strobe.h new file mode 100644 index 0000000000..abd9b73596 --- /dev/null +++ b/gr-blocks/include/blocks/message_strobe.h @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_GR_MESSAGE_STROBE_H +#define INCLUDED_GR_MESSAGE_STROBE_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Send message at defined interval + * \ingroup message_tools_blk + * + * \details + * Takes a PMT message and sends it out every \p period_ms + * milliseconds. Useful for testing/debugging the message system. + */ + class BLOCKS_API message_strobe : virtual public gr_block + { + public: + // gr::blocks::message_strobe::sptr + typedef boost::shared_ptr<message_strobe> sptr; + + /*! + * Make a message stobe block to send message \p msg every \p + * period_ms milliseconds. + * + * \param msg The message to send as a PMT. + * \param period_ms the time period in milliseconds in which to + * send \p msg. + */ + static sptr make(pmt::pmt_t msg, float period_ms); + + /*! + * Reset the message being sent. + * \param msg The message to send as a PMT. + */ + virtual void set_msg(pmt::pmt_t msg) = 0; + + /*! + * Get the value of the message being sent. + */ + virtual pmt::pmt_t msg() const = 0; + + /*! + * Reset the sending interval. + * \param period_ms the time period in milliseconds. + */ + virtual void set_period(float period_ms) = 0; + + /*! + * Get the time interval of the strobe. + */ + virtual float period() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_STROBE_H */ diff --git a/gr-blocks/include/blocks/moving_average_XX.h.t b/gr-blocks/include/blocks/moving_average_XX.h.t new file mode 100644 index 0000000000..5b996bd4d5 --- /dev/null +++ b/gr-blocks/include/blocks/moving_average_XX.h.t @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output is the moving sum of the last N samples, scaled by the scale factor + * \ingroup level_controllers_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + /*! + * Create a moving average block. + * + * \param length Number of samples to use in the average. + * \param scale scale factor for the result. + * \param max_iter limits how long we go without flushing the accumulator + * This is necessary to avoid numerical instability for float and complex. + */ + static sptr make(int length, @O_TYPE@ scale, + int max_iter = 4096); + + /*! + * Get the length used in the avaraging calculation. + */ + virtual int length() const = 0; + + /*! + * Get the scale factor being used. + */ + virtual @O_TYPE@ scale() const = 0; + + /*! + * Set both the length and the scale factor together. + */ + virtual void set_length_and_scale(int length, @O_TYPE@ scale) = 0; + + /*! + * Set the length. + */ + virtual void set_length(int length) = 0; + + /*! + * Set the scale factor. + */ + virtual void set_scale(@O_TYPE@ scale) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/multiply_XX.h.t b/gr-blocks/include/blocks/multiply_XX.h.t index 47ed3746c7..4ad25d35e9 100644 --- a/gr-blocks/include/blocks/multiply_XX.h.t +++ b/gr-blocks/include/blocks/multiply_XX.h.t @@ -33,8 +33,9 @@ namespace gr { /*! * \brief output = prod (input_0, input_1, ...) - * \ingroup math_blk + * \ingroup math_operators_blk * + * \details * Multiply across all input streams. */ class BLOCKS_API @NAME@ : virtual public gr_sync_block diff --git a/gr-blocks/include/blocks/multiply_cc.h b/gr-blocks/include/blocks/multiply_cc.h index 559fcda579..79533c2dc6 100644 --- a/gr-blocks/include/blocks/multiply_cc.h +++ b/gr-blocks/include/blocks/multiply_cc.h @@ -29,6 +29,13 @@ namespace gr { namespace blocks { + /*! + * \brief output = prod (input_0, input_1, ...) + * \ingroup math_operators_blk + * + * \details + * Multiply across all input streams. + */ class BLOCKS_API multiply_cc : virtual public gr_sync_block { public: diff --git a/gr-blocks/include/blocks/multiply_conjugate_cc.h b/gr-blocks/include/blocks/multiply_conjugate_cc.h index fc587ae2f7..7fa46f891e 100644 --- a/gr-blocks/include/blocks/multiply_conjugate_cc.h +++ b/gr-blocks/include/blocks/multiply_conjugate_cc.h @@ -29,6 +29,10 @@ namespace gr { namespace blocks { + /*! + * \brief Multiplies stream 0 by the complex conjugate of stream 1. + * \ingroup math_operators_blk + */ class BLOCKS_API multiply_conjugate_cc : virtual public gr_sync_block { public: diff --git a/gr-blocks/include/blocks/multiply_const_XX.h.t b/gr-blocks/include/blocks/multiply_const_XX.h.t index a7cd3a8583..4f5ac5c5a6 100644 --- a/gr-blocks/include/blocks/multiply_const_XX.h.t +++ b/gr-blocks/include/blocks/multiply_const_XX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = input * constant - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API @NAME@ : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/multiply_const_cc.h b/gr-blocks/include/blocks/multiply_const_cc.h index 9572eaec70..3469b4df17 100644 --- a/gr-blocks/include/blocks/multiply_const_cc.h +++ b/gr-blocks/include/blocks/multiply_const_cc.h @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = input * complex constant - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API multiply_const_cc : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/multiply_const_ff.h b/gr-blocks/include/blocks/multiply_const_ff.h index d2d5e805cb..627e0c39a6 100644 --- a/gr-blocks/include/blocks/multiply_const_ff.h +++ b/gr-blocks/include/blocks/multiply_const_ff.h @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = input * real constant - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API multiply_const_ff : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/multiply_ff.h b/gr-blocks/include/blocks/multiply_ff.h index 683b540bbd..ef3f5109bd 100644 --- a/gr-blocks/include/blocks/multiply_ff.h +++ b/gr-blocks/include/blocks/multiply_ff.h @@ -29,6 +29,13 @@ namespace gr { namespace blocks { + /*! + * \brief output = prod (input_0, input_1, ...) + * \ingroup math_operators_blk + * + * \details + * Multiply across all input streams. + */ class BLOCKS_API multiply_ff : virtual public gr_sync_block { public: diff --git a/gr-blocks/include/blocks/mute_XX.h.t b/gr-blocks/include/blocks/mute_XX.h.t new file mode 100644 index 0000000000..b9a394df2f --- /dev/null +++ b/gr-blocks/include/blocks/mute_XX.h.t @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief output = input or zero if muted. + * \ingroup level_controllers_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(bool mute=false); + + virtual bool mute() const = 0; + virtual void set_mute(bool mute=false) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ + diff --git a/gr-blocks/include/blocks/nlog10_ff.h b/gr-blocks/include/blocks/nlog10_ff.h index cedd620fa0..7c4dfd8962 100644 --- a/gr-blocks/include/blocks/nlog10_ff.h +++ b/gr-blocks/include/blocks/nlog10_ff.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief output = n*log10(input) + k - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API nlog10_ff : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/nop.h b/gr-blocks/include/blocks/nop.h new file mode 100644 index 0000000000..b3135e1cc8 --- /dev/null +++ b/gr-blocks/include/blocks/nop.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifndef INCLUDED_GR_NOP_H +#define INCLUDED_GR_NOP_H + +#include <blocks/api.h> +#include <gr_block.h> +#include <stddef.h> // size_t + +namespace gr { + namespace blocks { + + /*! + * \brief Does nothing. Used for testing only. + * \ingroup misc_blk + */ + class BLOCKS_API nop : virtual public gr_block + { + public: + // gr::blocks::nop::sptr + typedef boost::shared_ptr<nop> sptr; + + /*! + * Build a nop block. + * + * \param sizeof_stream_item size of the stream items in bytes. + */ + static sptr make(size_t sizeof_stream_item); + + virtual int nmsgs_received() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_NOP_H */ diff --git a/gr-blocks/include/blocks/not_XX.h.t b/gr-blocks/include/blocks/not_XX.h.t index e406c82dc3..fc06327722 100644 --- a/gr-blocks/include/blocks/not_XX.h.t +++ b/gr-blocks/include/blocks/not_XX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = ~input - * \ingroup math_blk + * \ingroup boolean_operators_blk * * bitwise boolean not of input streams. */ diff --git a/gr-blocks/include/blocks/null_sink.h b/gr-blocks/include/blocks/null_sink.h new file mode 100644 index 0000000000..8e772ab61f --- /dev/null +++ b/gr-blocks/include/blocks/null_sink.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifndef INCLUDED_GR_NULL_SINK_H +#define INCLUDED_GR_NULL_SINK_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <stddef.h> // size_t + +namespace gr { + namespace blocks { + + /*! + * \brief Bit bucket. Use as a termination point when a sink is + * required and we don't want to do anything real. + * \ingroup misc_blk + */ + class BLOCKS_API null_sink : virtual public gr_sync_block + { + public: + // gr::blocks::null_sink::sptr + typedef boost::shared_ptr<null_sink> sptr; + + /*! + * Build a null sink block. + * + * \param sizeof_stream_item size of the stream items in bytes. + */ + static sptr make(size_t sizeof_stream_item); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_NULL_SINK_H */ diff --git a/gr-blocks/include/blocks/null_source.h b/gr-blocks/include/blocks/null_source.h new file mode 100644 index 0000000000..fc782c1cb5 --- /dev/null +++ b/gr-blocks/include/blocks/null_source.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifndef INCLUDED_GR_NULL_SOURCE_H +#define INCLUDED_GR_NULL_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief A source of zeros used mainly for testing. + * \ingroup misc_blk + */ + class BLOCKS_API null_source : virtual public gr_sync_block + { + public: + // gr::blocks::null_source::sptr + typedef boost::shared_ptr<null_source> sptr; + + /*! + * Build a null source block. + * + * \param sizeof_stream_item size of the stream items in bytes. + */ + static sptr make(size_t sizeof_stream_item); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_NULL_SOURCE_H */ diff --git a/gr-blocks/include/blocks/or_XX.h.t b/gr-blocks/include/blocks/or_XX.h.t index 8bc9a080f6..67afe54ea9 100644 --- a/gr-blocks/include/blocks/or_XX.h.t +++ b/gr-blocks/include/blocks/or_XX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = input_0 | input_1 | , ... | input_N) - * \ingroup math_blk + * \ingroup boolean_operators_blk * * Bitwise boolean or across all input streams. */ diff --git a/gr-blocks/include/blocks/pack_k_bits_bb.h b/gr-blocks/include/blocks/pack_k_bits_bb.h new file mode 100644 index 0000000000..41ae4bc418 --- /dev/null +++ b/gr-blocks/include/blocks/pack_k_bits_bb.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_GR_PACK_K_BITS_BB_H +#define INCLUDED_GR_PACK_K_BITS_BB_H + +#include <blocks/api.h> +#include <gr_sync_decimator.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Converts a stream of bytes with 1 bit in the LSB to a + * byte with k relevent bits. + * \ingroup byte_operators_blk + */ + class BLOCKS_API pack_k_bits_bb : virtual public gr_sync_decimator + { + public: + // gr::blocks::pack_k_bits_bb::sptr + typedef boost::shared_ptr<pack_k_bits_bb> sptr; + + /*! + * \brief Make a pack_k_bits block. + * \param k number of bits to be packed. + */ + static sptr make(unsigned k); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PACK_K_BITS_BB_H */ diff --git a/gr-blocks/include/blocks/packed_to_unpacked_XX.h.t b/gr-blocks/include/blocks/packed_to_unpacked_XX.h.t index 9ab8b8bdfc..f95490f2d5 100644 --- a/gr-blocks/include/blocks/packed_to_unpacked_XX.h.t +++ b/gr-blocks/include/blocks/packed_to_unpacked_XX.h.t @@ -34,8 +34,9 @@ namespace gr { /*! * \brief Convert a stream of packed bytes or shorts to stream of unpacked bytes or shorts. - * \ingroup converter_blk + * \ingroup byte_operators_blk * + * \details * input: stream of @I_TYPE@; output: stream of @O_TYPE@ * * This is the inverse of gr::blocks::unpacked_to_packed_XX. diff --git a/gr-blocks/include/blocks/patterned_interleaver.h b/gr-blocks/include/blocks/patterned_interleaver.h index cfcdac6e73..01e9a0d58f 100644 --- a/gr-blocks/include/blocks/patterned_interleaver.h +++ b/gr-blocks/include/blocks/patterned_interleaver.h @@ -1,3 +1,25 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + #ifndef INCLUDED_BLOCKS_PATTERNED_INTERLEAVER_H #define INCLUDED_BLOCKS_PATTERNED_INTERLEAVER_H @@ -7,17 +29,26 @@ namespace gr { namespace blocks { + /*! + * \brief Interleave items based on the provided vector \p pattern. + * \ingroup stream_operators_blk + */ class BLOCKS_API patterned_interleaver : virtual public gr_block { public: - typedef boost::shared_ptr<patterned_interleaver> sptr; + /*! + * Make a patterned interleaver block. + * + * \param itemsize stream itemsize + * \param pattern vector that represents the interleaving pattern + */ static sptr make(size_t itemsize, std::vector<int> pattern); }; } } -#endif +#endif /* INCLUDED_BLOCKS_PATTERNED_INTERLEAVER_H */ diff --git a/gr-blocks/include/blocks/pdu.h b/gr-blocks/include/blocks/pdu.h new file mode 100644 index 0000000000..de0999c574 --- /dev/null +++ b/gr-blocks/include/blocks/pdu.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_PDU_H +#define INCLUDED_BLOCKS_PDU_H + +#include <blocks/api.h> +#include <gr_complex.h> +#include <gruel/pmt.h> + +#define PDU_PORT_ID pmt::mp("pdus") +#define PDU_LENGTH_TAG pmt::mp("pdu_length") + +namespace gr { + namespace blocks { + namespace pdu { + + enum vector_type { byte_t, float_t, complex_t }; + + BLOCKS_API size_t itemsize(vector_type type); + BLOCKS_API bool type_matches(vector_type type, pmt::pmt_t v); + BLOCKS_API pmt::pmt_t make_vector(vector_type type, const uint8_t* buf, size_t items); + BLOCKS_API vector_type type_from_pmt(pmt::pmt_t vector); + + } /* namespace pdu */ + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_PDU_H */ diff --git a/gr-blocks/include/blocks/pdu_to_tagged_stream.h b/gr-blocks/include/blocks/pdu_to_tagged_stream.h new file mode 100644 index 0000000000..6a26673149 --- /dev/null +++ b/gr-blocks/include/blocks/pdu_to_tagged_stream.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H +#define INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H + +#include <blocks/api.h> +#include <blocks/pdu.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Turns received PDUs into a tagged stream of items + * \ingroup message_tools_blk + */ + class BLOCKS_API pdu_to_tagged_stream : virtual public gr_sync_block + { + public: + // gr::blocks::pdu_to_tagged_stream::sptr + typedef boost::shared_ptr<pdu_to_tagged_stream> sptr; + + /*! + * \brief Construct a pdu_to_tagged_stream block + * \param type PDU type of pdu::vector_type + */ + static sptr make(pdu::vector_type type); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_PDU_TO_TAGGED_STREAM_H */ diff --git a/gr-blocks/include/blocks/peak_detector2_fb.h b/gr-blocks/include/blocks/peak_detector2_fb.h index 71afc3287b..aa30d46a04 100644 --- a/gr-blocks/include/blocks/peak_detector2_fb.h +++ b/gr-blocks/include/blocks/peak_detector2_fb.h @@ -31,19 +31,12 @@ namespace gr { /*! * \brief Detect the peak of a signal - * \ingroup level_blk + * \ingroup peak_detectors_blk * + * \details * If a peak is detected, this block outputs a 1, or it outputs * 0's. A separate debug output may be connected, to view the * internal EWMA described below. - * - * \param threshold_factor_rise The threshold factor determins - * when a peak is present. An EWMA average of the signal is - * calculated and when the value of the signal goes over - * threshold_factor_rise*average, we call the peak. - * \param look_ahead The look-ahead value is used when the - * threshold is found to locate the peak within this range. - * \param alpha The gain value of a single-pole moving average filter. */ class BLOCKS_API peak_detector2_fb : virtual public gr_sync_block { @@ -51,6 +44,17 @@ namespace gr { // gr::blocks::peak_detector2_fb::sptr typedef boost::shared_ptr<peak_detector2_fb> sptr; + /*! + * Build a peak detector block with float in, byte out. + * + * \param threshold_factor_rise The threshold factor determins + * when a peak is present. An EWMA average of the signal is + * calculated and when the value of the signal goes over + * threshold_factor_rise*average, we call the peak. + * \param look_ahead The look-ahead value is used when the + * threshold is found to locate the peak within this range. + * \param alpha The gain value of a single-pole moving average filter. + */ static sptr make(float threshold_factor_rise=7, int look_ahead=1000, float alpha=0.001); diff --git a/gr-blocks/include/blocks/peak_detector_XX.h.t b/gr-blocks/include/blocks/peak_detector_XX.h.t new file mode 100644 index 0000000000..8d42f42ea8 --- /dev/null +++ b/gr-blocks/include/blocks/peak_detector_XX.h.t @@ -0,0 +1,118 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Detect the peak of a signal + * \ingroup peak_detectors_blk + * + * \details + * If a peak is detected, this block outputs a 1, + * or it outputs 0's. + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + /*! + * Make a peak detector block. + * + * \param threshold_factor_rise The threshold factor determins + * when a peak has started. An average of the signal is + * calculated and when the value of the signal goes over + * threshold_factor_rise*average, we start looking for a + * peak. + * \param threshold_factor_fall The threshold factor determins + * when a peak has ended. An average of the signal is + * calculated and when the value of the signal goes + * bellow threshold_factor_fall*average, we stop looking + * for a peak. + * \param look_ahead The look-ahead value is used when the + * threshold is found to look if there another peak + * within this step range. If there is a larger value, + * we set that as the peak and look ahead again. This is + * continued until the highest point is found with This + * look-ahead range. + * \param alpha The gain value of a moving average filter + */ + static sptr make(float threshold_factor_rise = 0.25, + float threshold_factor_fall = 0.40, + int look_ahead = 10, + float alpha = 0.001); + + /*! \brief Set the threshold factor value for the rise time + * \param thr new threshold factor + */ + virtual void set_threshold_factor_rise(float thr) = 0; + + /*! \brief Set the threshold factor value for the fall time + * \param thr new threshold factor + */ + virtual void set_threshold_factor_fall(float thr) = 0; + + /*! \brief Set the look-ahead factor + * \param look new look-ahead factor + */ + virtual void set_look_ahead(int look) = 0; + + /*! \brief Set the running average alpha + * \param alpha new alpha for running average + */ + virtual void set_alpha(int alpha) = 0; + + /*! \brief Get the threshold factor value for the rise time + * \return threshold factor + */ + virtual float threshold_factor_rise() = 0; + + /*! \brief Get the threshold factor value for the fall time + * \return threshold factor + */ + virtual float threshold_factor_fall() = 0; + + /*! \brief Get the look-ahead factor value + * \return look-ahead factor + */ + virtual int look_ahead() = 0; + + /*! \brief Get the alpha value of the running average + * \return alpha + */ + virtual float alpha() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/plateau_detector_fb.h b/gr-blocks/include/blocks/plateau_detector_fb.h new file mode 100644 index 0000000000..119262d396 --- /dev/null +++ b/gr-blocks/include/blocks/plateau_detector_fb.h @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + + +#ifndef INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_H +#define INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Detects a plateau and marks the middle. + * \ingroup peak_detectors_blk + * + * \details + * Detect a plateau of a-priori known height. Input is a stream of floats, + * the output is a stream of bytes. Whenever a plateau is detected, the + * middle of that plateau is marked with a '1' on the output stream (all + * other samples are left at zero). + * + * You can use this in a Schmidl & Cox synchronisation algorithm to interpret + * the output of the normalized correlator. Just pass the length of the cyclic + * prefix (in samples) as the max_len parameter). + * + * Unlike the peak detectors, you must the now the absolute height of the plateau. + * Whenever the amplitude exceeds the given threshold, it starts assuming the + * presence of a plateau. + * + * An implicit hysteresis is provided by the fact that after detecting one plateau, + * it waits at least max_len samples before the next plateau can be detected. + */ + class BLOCKS_API plateau_detector_fb : virtual public gr_sync_block + { + public: + typedef boost::shared_ptr<plateau_detector_fb> sptr; + + /*! + * \param max_len Maximum length of the plateau + * \param threshold Anything above this value is considered a plateau + */ + static sptr make(int max_len, float threshold=0.9); + }; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_H */ + diff --git a/gr-blocks/include/blocks/probe_rate.h b/gr-blocks/include/blocks/probe_rate.h new file mode 100644 index 0000000000..fc0b9f29d4 --- /dev/null +++ b/gr-blocks/include/blocks/probe_rate.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_BLOCKS_PROBE_RATE_H +#define INCLUDED_BLOCKS_PROBE_RATE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief throughput measurement + * \ingroup measurement_tools_blk + */ + class BLOCKS_API probe_rate : virtual public gr_sync_block + { + public: + // gr::blocks::probe_rate::sptr + typedef boost::shared_ptr<probe_rate> sptr; + + /*! + * \brief Make a throughput measurement block + * \param itemsize size of each stream item + * \param update_rate_ms minimum update time in milliseconds + * \param alpha gain for running average filter + */ + static sptr make(size_t itemsize, double update_rate_ms = 500.0, double alpha = 0.0001); + + virtual void set_alpha(double alpha) = 0; + + virtual double rate() = 0; + + virtual bool start() = 0; + virtual bool stop() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_PROBE_RATE_H */ diff --git a/gr-blocks/include/blocks/probe_signal_X.h.t b/gr-blocks/include/blocks/probe_signal_X.h.t new file mode 100644 index 0000000000..fb0d84bb41 --- /dev/null +++ b/gr-blocks/include/blocks/probe_signal_X.h.t @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Sink that allows a sample to be grabbed from Python. + * \ingroup measurement_tools_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(); + + virtual @TYPE@ level() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/probe_signal_vX.h.t b/gr-blocks/include/blocks/probe_signal_vX.h.t new file mode 100644 index 0000000000..77462dc658 --- /dev/null +++ b/gr-blocks/include/blocks/probe_signal_vX.h.t @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <vector> +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Sink that allows a vector of samples to be grabbed from Python. + * \ingroup sink_blk + * \ingroup measurement_tools_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(size_t size); + + virtual std::vector<@TYPE@> level() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/regenerate_bb.h b/gr-blocks/include/blocks/regenerate_bb.h index 3063e70a7f..a2cc76737e 100644 --- a/gr-blocks/include/blocks/regenerate_bb.h +++ b/gr-blocks/include/blocks/regenerate_bb.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief Detect the peak of a signal and repeat every period samples - * \ingroup level_blk + * \ingroup stream_operators_blk * + * \details * If a peak is detected, this block outputs a 1 repeated every * period samples until reset by detection of another 1 on the * input or stopped after max_regen regenerations have occurred. diff --git a/gr-blocks/include/blocks/repack_bits_bb.h b/gr-blocks/include/blocks/repack_bits_bb.h new file mode 100644 index 0000000000..f33d4bdf8e --- /dev/null +++ b/gr-blocks/include/blocks/repack_bits_bb.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +#ifndef INCLUDED_BLOCKS_REPACK_BITS_BB_H +#define INCLUDED_BLOCKS_REPACK_BITS_BB_H + +#include <blocks/api.h> +#include <gr_tagged_stream_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Pack \p k bits from the input stream onto \p l bits of the output stream. + * \ingroup byte_operators_blk + * + * \details + * No bits are lost here; any value for k and l (within [1, 8]) is allowed. + * On every fresh input byte, it starts reading on the LSB, and starts copying + * to the LSB as well. + * + * If a packet length tag is given, this block assumes a tagged stream. + * In this case, the tag with the packet length is updated accordingly. + * Also, the number of input bits is padded with zeros if the number of input + * bits is not an integer multiple of \p l, or bits are truncated from the input + * if \p align_output is set to true. + */ + class BLOCKS_API repack_bits_bb : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<repack_bits_bb> sptr; + + /*! + * \param k Number of relevant bits on the input stream + * \param l Number of relevant bits on the output stream + * \param len_tag_key If not empty, this is the key for the length tag. + * \param align_output If len_tag_key is given, this controls if the input + * or the output is aligned. + */ + static sptr make(int k, int l=8, const std::string &len_tag_key="", bool align_output=false); + }; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_BLOCKS_REPACK_BITS_BB_H */ + diff --git a/gr-blocks/include/blocks/repeat.h b/gr-blocks/include/blocks/repeat.h index 3f9f8e6fc2..b353205541 100644 --- a/gr-blocks/include/blocks/repeat.h +++ b/gr-blocks/include/blocks/repeat.h @@ -30,18 +30,21 @@ namespace gr { namespace blocks { /*! - * \brief repeat each input 'interp' times - * \ingroup slicedice_blk - * \param itemsize stream itemsize - * \param interp number of times to repeat + * \brief repeat each input \p repeat times + * \ingroup stream_operators_blk */ class BLOCKS_API repeat : virtual public gr_sync_interpolator { public: - // gr::blocks::repeat::sptr typedef boost::shared_ptr<repeat> sptr; + /*! + * Make a repeat block. + * + * \param itemsize stream itemsize + * \param repeat number of times to repeat the input + */ static sptr make(size_t itemsize, int repeat); }; diff --git a/gr-blocks/include/blocks/rms_cf.h b/gr-blocks/include/blocks/rms_cf.h index e73be6923a..94a17f7a67 100644 --- a/gr-blocks/include/blocks/rms_cf.h +++ b/gr-blocks/include/blocks/rms_cf.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief RMS average power - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API rms_cf : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/rms_ff.h b/gr-blocks/include/blocks/rms_ff.h index 19fb0016d4..e202d79f2c 100644 --- a/gr-blocks/include/blocks/rms_ff.h +++ b/gr-blocks/include/blocks/rms_ff.h @@ -19,6 +19,7 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_BLOCKS_RMS_FF_H #define INCLUDED_BLOCKS_RMS_FF_H @@ -30,7 +31,7 @@ namespace gr { /*! * \brief RMS average power - * \ingroup math_blk + * \ingroup math_operators_blk */ class BLOCKS_API rms_ff : virtual public gr_sync_block { diff --git a/gr-blocks/include/blocks/rotator.h b/gr-blocks/include/blocks/rotator.h new file mode 100644 index 0000000000..918e86edd2 --- /dev/null +++ b/gr-blocks/include/blocks/rotator.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2003,2008,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. + */ + +#ifndef _GR_ROTATOR_H_ +#define _GR_ROTATOR_H_ + +#include <blocks/api.h> +#include <gr_complex.h> + +namespace gr { + namespace blocks { + + class rotator + { + private: + gr_complex d_phase; + gr_complex d_phase_incr; + unsigned int d_counter; + + public: + rotator() : d_phase(1), d_phase_incr(1), d_counter(0) + { } + + void set_phase(gr_complex phase) { d_phase = phase / abs(phase); } + void set_phase_incr(gr_complex incr) { d_phase_incr = incr / abs(incr); } + + gr_complex rotate(gr_complex in) + { + d_counter++; + + gr_complex z = in * d_phase; // rotate in by phase + d_phase *= d_phase_incr; // incr our phase (complex mult == add phases) + + if((d_counter % 512) == 0) + d_phase /= abs(d_phase); // Normalize to ensure multiplication is rotation + + return z; + } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* _GR_ROTATOR_H_ */ diff --git a/gr-blocks/include/blocks/sample_and_hold_XX.h.t b/gr-blocks/include/blocks/sample_and_hold_XX.h.t new file mode 100644 index 0000000000..0d2ecdc5d7 --- /dev/null +++ b/gr-blocks/include/blocks/sample_and_hold_XX.h.t @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief sample and hold circuit + * \ingroup level_controllers_blk + * + * \details + * Samples the data stream (input stream 0) and holds the value if + * the control signal is 1 (intput stream 1). + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/short_to_char.h b/gr-blocks/include/blocks/short_to_char.h index eeb053b0ec..09e784f101 100644 --- a/gr-blocks/include/blocks/short_to_char.h +++ b/gr-blocks/include/blocks/short_to_char.h @@ -30,18 +30,20 @@ namespace gr { namespace blocks { /*! - * \brief Convert stream of shorts to a stream of chars - * \ingroup converter_blk - * - * \param vlen vector length of data streams. + * \brief Convert stream of shorts to a stream of chars. + * \ingroup type_converters_blk */ class BLOCKS_API short_to_char : virtual public gr_sync_block { public: - // gr::blocks::short_to_char_ff::sptr typedef boost::shared_ptr<short_to_char> sptr; + /*! + * Build a short to char block. + * + * \param vlen vector length of data streams. + */ static sptr make(size_t vlen=1); }; diff --git a/gr-blocks/include/blocks/short_to_float.h b/gr-blocks/include/blocks/short_to_float.h index c26addcd01..ec85e892ed 100644 --- a/gr-blocks/include/blocks/short_to_float.h +++ b/gr-blocks/include/blocks/short_to_float.h @@ -31,18 +31,20 @@ namespace gr { /*! * \brief Convert stream of shorts to a stream of floats - * \ingroup converter_blk - * - * \param vlen vector length of data streams. - * \param scale a scalar divider to change the output signal scale. + * \ingroup type_converters_blk */ class BLOCKS_API short_to_float : virtual public gr_sync_block { public: - // gr::blocks::short_to_float_ff::sptr typedef boost::shared_ptr<short_to_float> sptr; + /*! + * Build a short to float block. + * + * \param vlen vector length of data streams. + * \param scale a scalar divider to change the output signal scale. + */ static sptr make(size_t vlen=1, float scale=1.0); /*! diff --git a/gr-blocks/include/blocks/skiphead.h b/gr-blocks/include/blocks/skiphead.h new file mode 100644 index 0000000000..27a8afea92 --- /dev/null +++ b/gr-blocks/include/blocks/skiphead.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_SKIPHEAD_H +#define INCLUDED_GR_SKIPHEAD_H + +#include <blocks/api.h> +#include <gr_sync_block.h> +#include <stddef.h> // size_t + +namespace gr { + namespace blocks { + + /*! + * \brief skips the first N items, from then on copies items to the output + * \ingroup misc_blk + * + * \details + * Useful for building test cases and sources which have metadata + * or junk at the start + */ + class BLOCKS_API skiphead : virtual public gr_block + { + public: + // gr::blocks::skiphead::sptr + typedef boost::shared_ptr<skiphead> sptr; + + static sptr make(size_t itemsize, + uint64_t nitems_to_skip); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SKIPHEAD_H */ diff --git a/gr-blocks/include/blocks/socket_pdu.h b/gr-blocks/include/blocks/socket_pdu.h new file mode 100644 index 0000000000..8b3a196607 --- /dev/null +++ b/gr-blocks/include/blocks/socket_pdu.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_SOCKET_PDU_H +#define INCLUDED_BLOCKS_SOCKET_PDU_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Creates socket interface and translates traffic to PDUs + * \ingroup networking_tools_blk + */ + class BLOCKS_API socket_pdu : virtual public gr_block + { + public: + // gr::blocks::socket_pdu::sptr + typedef boost::shared_ptr<socket_pdu> sptr; + + /*! + * \brief Construct a SOCKET PDU interface + * \param type type of socket (TCP_SERVER, TCP_CLIENT, UDP_SERVER, UDP_CLIENT) + * \param addr address of host + * \param port port number to use + * \param MTU Maximum Transmission Unit size + */ + static sptr make(std::string type, std::string addr, std::string port, int MTU=10000); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_SOCKET_PDU_H */ diff --git a/gr-blocks/include/blocks/stream_mux.h b/gr-blocks/include/blocks/stream_mux.h index 58d564f9fe..0e29aab364 100644 --- a/gr-blocks/include/blocks/stream_mux.h +++ b/gr-blocks/include/blocks/stream_mux.h @@ -33,7 +33,9 @@ namespace gr { /*! * \brief Stream muxing block to multiplex many streams into * one with a specified format. + * \ingroup stream_operators_blk * + * \details * Muxes N streams together producing an output stream that * contains N0 items from the first stream, N1 items from the second, * etc. and repeats: @@ -50,7 +52,6 @@ namespace gr { /*! * \brief Creates a stream muxing block to multiplex many streams into * one with a specified format. - * \ingroup converter_blk * * \param itemsize the item size of the stream * \param lengths a vector (list/tuple) specifying the number of diff --git a/gr-blocks/include/blocks/stream_to_streams.h b/gr-blocks/include/blocks/stream_to_streams.h index fc39f1687f..e9b257575f 100644 --- a/gr-blocks/include/blocks/stream_to_streams.h +++ b/gr-blocks/include/blocks/stream_to_streams.h @@ -31,18 +31,24 @@ namespace gr { /*! * \brief convert a stream of items into a N streams of items - * \ingroup slicedice_blk + * \ingroup stream_operators_blk * + * \details * Converts a stream of N items into N streams of 1 item. * Repeat ad infinitum. */ class BLOCKS_API stream_to_streams : virtual public gr_sync_decimator { public: - // gr::blocks::stream_to_streams::sptr typedef boost::shared_ptr<stream_to_streams> sptr; + /*! + * Make a stream-to-streams block. + * + * \param itemsize the item size of the stream + * \param nstreams number of streams to split input into + */ static sptr make(size_t itemsize, size_t nstreams); }; diff --git a/gr-blocks/include/blocks/stream_to_vector.h b/gr-blocks/include/blocks/stream_to_vector.h index 8311eb3506..98325500b1 100644 --- a/gr-blocks/include/blocks/stream_to_vector.h +++ b/gr-blocks/include/blocks/stream_to_vector.h @@ -31,15 +31,20 @@ namespace gr { /*! * \brief convert a stream of items into a stream of blocks containing nitems_per_block - * \ingroup slicedice_blk + * \ingroup stream_operators_blk */ class BLOCKS_API stream_to_vector : virtual public gr_sync_decimator { public: - // gr::blocks::stream_to_vector::sptr typedef boost::shared_ptr<stream_to_vector> sptr; + /*! + * Make a stream-to-vector block. + * + * \param itemsize the item size of the stream + * \param nitems_per_block number of items to but into each vector (vector size) + */ static sptr make(size_t itemsize, size_t nitems_per_block); }; diff --git a/gr-blocks/include/blocks/streams_to_stream.h b/gr-blocks/include/blocks/streams_to_stream.h index 01dcd1be33..e677a18e2a 100644 --- a/gr-blocks/include/blocks/streams_to_stream.h +++ b/gr-blocks/include/blocks/streams_to_stream.h @@ -31,18 +31,24 @@ namespace gr { /*! * \brief Convert N streams of 1 item into a 1 stream of N items - * \ingroup slicedice_blk + * \ingroup stream_operators_blk * + * \details * Convert N streams of 1 item into 1 stream of N items. * Repeat ad infinitum. */ class BLOCKS_API streams_to_stream : virtual public gr_sync_interpolator { public: - // gr::blocks::streams_to_stream::sptr typedef boost::shared_ptr<streams_to_stream> sptr; + /*! + * Make a streams-to-stream block. + * + * \param itemsize the item size of the stream + * \param nstreams number of streams to combine + */ static sptr make(size_t itemsize, size_t nstreams); }; diff --git a/gr-blocks/include/blocks/streams_to_vector.h b/gr-blocks/include/blocks/streams_to_vector.h index ad55ac31f1..f4df16c9f4 100644 --- a/gr-blocks/include/blocks/streams_to_vector.h +++ b/gr-blocks/include/blocks/streams_to_vector.h @@ -31,15 +31,20 @@ namespace gr { /*! * \brief convert N streams of items to 1 stream of vector length N - * \ingroup slicedice_blk + * \ingroup stream_operators_blk */ class BLOCKS_API streams_to_vector : virtual public gr_sync_block { public: - // gr::blocks::streams_to_vector::sptr typedef boost::shared_ptr<streams_to_vector> sptr; + /*! + * Make a stream-to-vector block. + * + * \param itemsize the item size of the stream + * \param nstreams number of streams to combine into a vector (vector size) + */ static sptr make(size_t itemsize, size_t nstreams); }; diff --git a/gr-blocks/include/blocks/stretch_ff.h b/gr-blocks/include/blocks/stretch_ff.h index 5f98452a41..47bcb9ee87 100644 --- a/gr-blocks/include/blocks/stretch_ff.h +++ b/gr-blocks/include/blocks/stretch_ff.h @@ -33,7 +33,7 @@ namespace gr { * \brief adjust y-range of an input vector by mapping to range * (max-of-input, stipulated-min). Primarily for spectral * signature matching by normalizing spectrum dynamic ranges. - * \ingroup misc_blk + * \ingroup stream_operators_blk */ class BLOCKS_API stretch_ff : virtual public gr_sync_block { @@ -43,9 +43,10 @@ namespace gr { /*! * \brief Make a stretch block. + * * \param lo Set low value for range. * \param vlen vector length of input stream. - */ + */ static sptr make(float lo, size_t vlen=1); virtual float lo() const = 0; diff --git a/gr-blocks/include/blocks/sub_XX.h.t b/gr-blocks/include/blocks/sub_XX.h.t index 8202ac54b1..db854346f6 100644 --- a/gr-blocks/include/blocks/sub_XX.h.t +++ b/gr-blocks/include/blocks/sub_XX.h.t @@ -33,8 +33,9 @@ namespace gr { /*! * \brief output = input_0 - input_1 - ...) - * \ingroup math_blk + * \ingroup math_operators_blk * + * \details * Subtract across all input streams. */ class BLOCKS_API @NAME@ : virtual public gr_sync_block diff --git a/gr-blocks/include/blocks/tag_debug.h b/gr-blocks/include/blocks/tag_debug.h new file mode 100644 index 0000000000..8093a6152f --- /dev/null +++ b/gr-blocks/include/blocks/tag_debug.h @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_GR_TAG_DEBUG_H +#define INCLUDED_GR_TAG_DEBUG_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Bit bucket that prints out any tag received. + * \ingroup measurement_tools_blk + * \ingroup stream_tag_tools_blk + * \ingroup debug_tools_blk + * + * \details + * This block collects all tags sent to it on all input ports and + * displays them to stdout in a formatted way. The \p name + * parameter is used to identify which debug sink generated the + * tag, so when connecting a block to this debug sink, an + * appropriate name is something that identifies the input block. + * + * This block otherwise acts as a NULL sink in that items from the + * input stream are ignored. It is designed to be able to attach + * to any block and watch all tags streaming out of that block for + * debugging purposes. + * + * The tags from the last call to this work function are stored + * and can be retrieved using the function 'current_tags'. + */ + class BLOCKS_API tag_debug : virtual public gr_sync_block + { + public: + // gr::blocks::tag_debug::sptr + typedef boost::shared_ptr<tag_debug> sptr; + + /*! + * Build a tag debug block + * + * \param sizeof_stream_item size of the items in the incoming stream. + * \param name name to identify which debug sink generated the info. + */ + static sptr make(size_t sizeof_stream_item, + const std::string &name); + + /*! + * \brief Returns a vector of gr_tag_t items as of the last call to + * work. + */ + virtual std::vector<gr_tag_t> current_tags() = 0; + + /*! + * \brief Set the display of tags to stdout on/off. + */ + virtual void set_display(bool d) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_TAG_DEBUG_H */ diff --git a/gr-blocks/include/blocks/tag_gate.h b/gr-blocks/include/blocks/tag_gate.h new file mode 100644 index 0000000000..2c3d20d464 --- /dev/null +++ b/gr-blocks/include/blocks/tag_gate.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_TAG_GATE_H +#define INCLUDED_BLOCKS_TAG_GATE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Control tag propagation. + * \ingroup blocks + * + * Use this block to stop tags from propagating. + */ + class BLOCKS_API tag_gate : virtual public gr_sync_block + { + public: + typedef boost::shared_ptr<tag_gate> sptr; + + virtual void set_propagation(bool propagate_tags) = 0; + + /*! + * \param item_size Item size + * \param propagate_tags Set this to true to allow tags to pass through this block. + */ + static sptr make(size_t item_size, bool propagate_tags=false); + }; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_BLOCKS_TAG_GATE_H */ + diff --git a/gr-blocks/include/blocks/tagged_file_sink.h b/gr-blocks/include/blocks/tagged_file_sink.h new file mode 100644 index 0000000000..2014b66964 --- /dev/null +++ b/gr-blocks/include/blocks/tagged_file_sink.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_TAGGED_FILE_SINK_H +#define INCLUDED_GR_TAGGED_FILE_SINK_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief A file sink that uses tags to save files. + * \ingroup file_operators_blk + * \ingroup stream_tag_tools_blk + * + * \details + * The sink uses a tag with the key 'burst' to trigger the saving + * of the burst data to a new file. If the value of this tag is + * True, it will open a new file and start writing all incoming + * data to it. If the tag is False, it will close the file (if + * already opened). The file names are based on the time when the + * burst tag was seen. If there is an 'rx_time' tag (standard with + * UHD sources), that is used as the time. If no 'rx_time' tag is + * found, the new time is calculated based off the sample rate of + * the block. + */ + class BLOCKS_API tagged_file_sink : virtual public gr_sync_block + { + public: + // gr::blocks::tagged_file_sink::sptr + typedef boost::shared_ptr<tagged_file_sink> sptr; + + /*! + * \brief Build a tagged_file_sink block. + * + * \param itemsize The item size of the input data stream. + * \param samp_rate The sample rate used to determine the time + * difference between bursts + */ + static sptr make(size_t itemsize, double samp_rate); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_TAGGED_FILE_SINK_H */ diff --git a/gr-blocks/include/blocks/tagged_stream_mux.h b/gr-blocks/include/blocks/tagged_stream_mux.h new file mode 100644 index 0000000000..2fa9b3f01d --- /dev/null +++ b/gr-blocks/include/blocks/tagged_stream_mux.h @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_TAGGED_STREAM_MUX_H +#define INCLUDED_TAGGED_STREAM_MUX_H + +#include <blocks/api.h> +#include <gr_tagged_stream_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Combines tagged streams. + * \ingroup stream_operators_blk + * + * \details + * Takes N streams as input. Each stream is tagged with packet lengths. + * Packets are output sequentially from each input stream. + * + * The output signal has a new length tag, which is the sum of all + * individual length tags. The old length tags are discarded. + * + * All other tags are propagated as expected, i.e. they stay associated + * with the same input item. + */ + class BLOCKS_API tagged_stream_mux : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<tagged_stream_mux> sptr; + + /*! + * Make a tagged stream mux block. + * + * \param itemsize Items size (number of bytes per item) + * \param lengthtagname Length tag key + */ + static sptr make(size_t itemsize, const std::string &lengthtagname); + }; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_TAGGED_STREAM_MUX_H */ + diff --git a/gr-blocks/include/blocks/tagged_stream_to_pdu.h b/gr-blocks/include/blocks/tagged_stream_to_pdu.h new file mode 100644 index 0000000000..b990c44ab1 --- /dev/null +++ b/gr-blocks/include/blocks/tagged_stream_to_pdu.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H +#define INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H + +#include <blocks/api.h> +#include <blocks/pdu.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Turns received stream data and tags into PDUs + * \ingroup message_tools_blk + */ + class BLOCKS_API tagged_stream_to_pdu : virtual public gr_sync_block + { + public: + // gr::blocks::tagged_stream_to_pdu::sptr + typedef boost::shared_ptr<tagged_stream_to_pdu> sptr; + + /*! + * \brief Construct a tagged_stream_to_pdu block + * \param type PDU type of pdu::vector_type + */ + static sptr make(pdu::vector_type type); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_TAGGED_STREAM_TO_PDU_H */ diff --git a/gr-blocks/include/blocks/threshold_ff.h b/gr-blocks/include/blocks/threshold_ff.h index 900e5c5bdb..6a20e7ed43 100644 --- a/gr-blocks/include/blocks/threshold_ff.h +++ b/gr-blocks/include/blocks/threshold_ff.h @@ -31,8 +31,9 @@ namespace gr { /*! * \brief Output a 1 or zero based on a threshold value. - * \ingroup misc_blk + * \ingroup level_controllers_blk * + * \details * Test the incoming signal against a threshold. If the signal * excedes the \p hi value, it will output a 1 until the signal * falls below the \p lo value. diff --git a/gr-blocks/include/blocks/throttle.h b/gr-blocks/include/blocks/throttle.h index 20d8037e10..d9d9f311c4 100644 --- a/gr-blocks/include/blocks/throttle.h +++ b/gr-blocks/include/blocks/throttle.h @@ -34,6 +34,7 @@ namespace gr { * not exceed samples_per_sec. * \ingroup misc_blk * + * \details * input: one stream of itemsize; output: one stream of itemsize * * N.B. this should only be used in GUI apps where there is no diff --git a/gr-blocks/include/blocks/transcendental.h b/gr-blocks/include/blocks/transcendental.h index f8a0d5d805..a3a483e8f3 100644 --- a/gr-blocks/include/blocks/transcendental.h +++ b/gr-blocks/include/blocks/transcendental.h @@ -32,7 +32,9 @@ namespace gr { /*! * \brief A block that performs various transcendental math operations. + * \ingroup math_operators_blk * + * \details * Possible function names can be found in the cmath library. IO * may be either complex or real, double or single precision. * diff --git a/gr-blocks/include/blocks/tuntap_pdu.h b/gr-blocks/include/blocks/tuntap_pdu.h new file mode 100644 index 0000000000..afa03cfb82 --- /dev/null +++ b/gr-blocks/include/blocks/tuntap_pdu.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_TUNTAP_PDU_H +#define INCLUDED_BLOCKS_TUNTAP_PDU_H + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Creates TUNTAP interface and translates traffic to PDUs + * \ingroup networking_tools_blk + */ + class BLOCKS_API tuntap_pdu : virtual public gr_block + { + public: + // gr::blocks::tuntap_pdu::sptr + typedef boost::shared_ptr<tuntap_pdu> sptr; + + /*! + * \brief Construct a TUNTAP PDU interface + * \param dev Device name to create + * \param MTU Maximum Transmission Unit size + */ + static sptr make(std::string dev, int MTU=10000); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_H */ diff --git a/gr-blocks/include/blocks/uchar_to_float.h b/gr-blocks/include/blocks/uchar_to_float.h index 033037e498..725c4e5021 100644 --- a/gr-blocks/include/blocks/uchar_to_float.h +++ b/gr-blocks/include/blocks/uchar_to_float.h @@ -31,15 +31,17 @@ namespace gr { /*! * \brief Convert stream of unsigned chars to a stream of floats - * \ingroup converter_blk + * \ingroup type_converters_blk */ class BLOCKS_API uchar_to_float : virtual public gr_sync_block { public: - // gr::blocks::uchar_to_float_ff::sptr typedef boost::shared_ptr<uchar_to_float> sptr; + /*! + * Build a uchar to float block. + */ static sptr make(); }; diff --git a/gr-blocks/include/blocks/udp_sink.h b/gr-blocks/include/blocks/udp_sink.h new file mode 100644 index 0000000000..9530217515 --- /dev/null +++ b/gr-blocks/include/blocks/udp_sink.h @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,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. + */ + +#ifndef INCLUDED_GR_UDP_SINK_H +#define INCLUDED_GR_UDP_SINK_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Write stream to an UDP socket. + * \ingroup networking_tools_blk + */ + class BLOCKS_API udp_sink : virtual public gr_sync_block + { + public: + // gr::blocks::udp_sink::sptr + typedef boost::shared_ptr<udp_sink> sptr; + + /*! + * \brief UDP Sink Constructor + * + * \param itemsize The size (in bytes) of the item datatype + * \param host The name or IP address of the receiving host; use + * NULL or None for no connection + * \param port Destination port to connect to on receiving host + * \param payload_size UDP payload size by default set to + * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param eof Send zero-length packet on disconnect + */ + static sptr make(size_t itemsize, + const std::string &host, int port, + int payload_size=1472, bool eof=true); + + /*! \brief return the PAYLOAD_SIZE of the socket */ + virtual int payload_size() = 0; + + /*! \brief Change the connection to a new destination + * + * \param host The name or IP address of the receiving host; use + * NULL or None to break the connection without closing + * \param port Destination port to connect to on receiving host + * + * Calls disconnect() to terminate any current connection first. + */ + virtual void connect(const std::string &host, int port) = 0; + + /*! \brief Send zero-length packet (if eof is requested) then stop sending + * + * Zero-byte packets can be interpreted as EOF by gr_udp_source. + * Note that disconnect occurs automatically when the sink is + * destroyed, but not when its top_block stops.*/ + virtual void disconnect() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UDP_SINK_H */ diff --git a/gr-blocks/include/blocks/udp_source.h b/gr-blocks/include/blocks/udp_source.h new file mode 100644 index 0000000000..4681b0b54a --- /dev/null +++ b/gr-blocks/include/blocks/udp_source.h @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,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. + */ + +#ifndef INCLUDED_GR_UDP_SOURCE_H +#define INCLUDED_GR_UDP_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Read stream from an UDP socket. + * \ingroup networking_tools_blk + */ + class BLOCKS_API udp_source : virtual public gr_sync_block + { + public: + // gr::blocks::udp_source::sptr + typedef boost::shared_ptr<udp_source> sptr; + + /*! + * \brief UDP Source Constructor + * + * \param itemsize The size (in bytes) of the item datatype + * \param host The name or IP address of the receiving host; can be + * NULL, None, or "0.0.0.0" to allow reading from any + * interface on the host + * \param port The port number on which to receive data; use 0 to + * have the system assign an unused port number + * \param payload_size UDP payload size by default set to 1472 = + * (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param eof Interpret zero-length packet as EOF (default: true) + */ + static sptr make(size_t itemsize, + const std::string &host, int port, + int payload_size=1472, + bool eof=true); + + /*! \brief Change the connection to a new destination + * + * \param host The name or IP address of the receiving host; use + * NULL or None to break the connection without closing + * \param port Destination port to connect to on receiving host + * + * Calls disconnect() to terminate any current connection first. + */ + virtual void connect(const std::string &host, int port) = 0; + + /*! \brief Cut the connection if we have one set up. + */ + virtual void disconnect() = 0; + + /*! \brief return the PAYLOAD_SIZE of the socket */ + virtual int payload_size() = 0; + + /*! \brief return the port number of the socket */ + virtual int get_port() = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UDP_SOURCE_H */ diff --git a/gr-blocks/include/blocks/unpack_k_bits_bb.h b/gr-blocks/include/blocks/unpack_k_bits_bb.h new file mode 100644 index 0000000000..a36cfb50e4 --- /dev/null +++ b/gr-blocks/include/blocks/unpack_k_bits_bb.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_GR_UNPACK_K_BITS_BB_H +#define INCLUDED_GR_UNPACK_K_BITS_BB_H + +#include <blocks/api.h> +#include <gr_sync_interpolator.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Converts a byte with k relevent bits to k output bytes with 1 bit in the LSB. + * \ingroup byte_operators_blk + */ + class BLOCKS_API unpack_k_bits_bb : virtual public gr_sync_interpolator + { + public: + // gr::blocks::unpack_k_bits_bb::sptr + typedef boost::shared_ptr<unpack_k_bits_bb> sptr; + + /*! + * \brief Make an unpack_k_bits block. + * \param k number of bits to unpack. + */ + static sptr make(unsigned k); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UNPACK_K_BITS_BB_H */ diff --git a/gr-blocks/include/blocks/unpacked_to_packed_XX.h.t b/gr-blocks/include/blocks/unpacked_to_packed_XX.h.t index 749f0e00f9..84f660b845 100644 --- a/gr-blocks/include/blocks/unpacked_to_packed_XX.h.t +++ b/gr-blocks/include/blocks/unpacked_to_packed_XX.h.t @@ -34,8 +34,9 @@ namespace gr { /*! * \brief Convert a stream of unpacked bytes or shorts into a stream of packed bytes or shorts. - * \ingroup converter_blk + * \ingroup byte_operators_blk * + * \details * input: stream of @I_TYPE@; output: stream of @O_TYPE@ * * This is the inverse of gr::blocks::packed_to_unpacked_XX. diff --git a/gr-blocks/include/blocks/vco_f.h b/gr-blocks/include/blocks/vco_f.h new file mode 100644 index 0000000000..7245f4c96b --- /dev/null +++ b/gr-blocks/include/blocks/vco_f.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_VCO_F_H +#define INCLUDED_GR_VCO_F_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief VCO - Voltage controlled oscillator + * \ingroup modulators_blk + * \ingroup waveform_generators_blk + * + * \details + * input: float stream of control voltages; output: float oscillator output + */ + class BLOCKS_API vco_f : virtual public gr_sync_block + { + public: + // gr::blocks::vco_f::sptr + typedef boost::shared_ptr<vco_f> sptr; + + /*! + * \brief VCO - Voltage controlled oscillator + * + * \param sampling_rate sampling rate (Hz) + * \param sensitivity units are radians/sec/volt + * \param amplitude output amplitude + */ + static sptr make(double sampling_rate, double sensitivity, double amplitude); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_VCO_F_H */ diff --git a/gr-blocks/include/blocks/vector_insert_X.h.t b/gr-blocks/include/blocks/vector_insert_X.h.t new file mode 100644 index 0000000000..c45e5152fa --- /dev/null +++ b/gr-blocks/include/blocks/vector_insert_X.h.t @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief source of @TYPE@'s that gets its data from a vector + * \ingroup stream_operators_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + /*! + * Make vector insert block. + * + * \param data vector of data to insert + * \param periodicity number of samples between when to send \p data + * \param offset initial item offset of first insert + */ + static sptr make(const std::vector<@TYPE@> &data, + int periodicity, int offset=0); + + virtual void rewind() = 0; + virtual void set_data(const std::vector<@TYPE@> &data) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/vector_map.h b/gr-blocks/include/blocks/vector_map.h new file mode 100644 index 0000000000..77a7fc1865 --- /dev/null +++ b/gr-blocks/include/blocks/vector_map.h @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,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. + */ + +#ifndef INCLUDED_GR_VECTOR_MAP_H +#define INCLUDED_GR_VECTOR_MAP_H + +#include <blocks/api.h> +#include <vector> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Maps elements from a set of input vectors to a set of output vectors. + * \ingroup slicedice_blk + * + * \details + * If in[i] is the input vector in the i'th stream then the output + * vector in the j'th stream is: + * + * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]] + * + * That is mapping is of the form (out_stream1_mapping, + * out_stream2_mapping, ...) and out_stream1_mapping is of the + * form (element1_mapping, element2_mapping, ...) and + * element1_mapping is of the form (in_stream, in_element). + */ + class BLOCKS_API vector_map : virtual public gr_sync_block + { + public: + // gr::blocks::vector_map::sptr + typedef boost::shared_ptr<vector_map> sptr; + + /*! + * Build a vector map block. + * + * \param item_size (integer) size of vector elements + * \param in_vlens (vector of integers) number of elements in each + * input vector + * \param mapping (vector of vectors of vectors of integers) how to + * map elements from input to output vectors + */ + static sptr make(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping); + + virtual void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_VECTOR_MAP_H */ diff --git a/gr-blocks/include/blocks/vector_sink_X.h.t b/gr-blocks/include/blocks/vector_sink_X.h.t new file mode 100644 index 0000000000..1d17700f5f --- /dev/null +++ b/gr-blocks/include/blocks/vector_sink_X.h.t @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2009,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief @TYPE@ sink that writes to a vector + * \ingroup debug_tools_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(int vlen = 1); + + virtual void reset() = 0; + virtual std::vector<@TYPE@> data() const = 0; + virtual std::vector<gr_tag_t> tags() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/vector_source_X.h.t b/gr-blocks/include/blocks/vector_source_X.h.t new file mode 100644 index 0000000000..8d3693f3ee --- /dev/null +++ b/gr-blocks/include/blocks/vector_source_X.h.t @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2012-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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief source of @TYPE@'s that gets its data from a vector + * \ingroup misc_blk + */ + class BLOCKS_API @NAME@ : virtual public gr_sync_block + { + public: + // gr::blocks::@NAME@::sptr + typedef boost::shared_ptr<@NAME@> sptr; + + static sptr make(const std::vector<@TYPE@> &data, + bool repeat=false, int vlen=1, + const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()); + + virtual void rewind() = 0; + virtual void set_data(const std::vector<@TYPE@> &data, + const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>()) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME@ */ diff --git a/gr-blocks/include/blocks/vector_to_stream.h b/gr-blocks/include/blocks/vector_to_stream.h index 1e72f6d50b..2a02704287 100644 --- a/gr-blocks/include/blocks/vector_to_stream.h +++ b/gr-blocks/include/blocks/vector_to_stream.h @@ -31,15 +31,20 @@ namespace gr { /*! * \brief convert a stream of blocks of nitems_per_block items into a stream of items - * \ingroup slicedice_blk + * \ingroup stream_operators_blk */ class BLOCKS_API vector_to_stream : virtual public gr_sync_interpolator { public: - // gr::blocks::vector_to_stream::sptr typedef boost::shared_ptr<vector_to_stream> sptr; + /*! + * Make vector-to-stream block + * + * \param itemsize the item size of the stream + * \param nitems_per_block number of items per vector (vector size) + */ static sptr make(size_t itemsize, size_t nitems_per_block); }; diff --git a/gr-blocks/include/blocks/vector_to_streams.h b/gr-blocks/include/blocks/vector_to_streams.h index 1bc0758797..364bc9afbd 100644 --- a/gr-blocks/include/blocks/vector_to_streams.h +++ b/gr-blocks/include/blocks/vector_to_streams.h @@ -31,15 +31,21 @@ namespace gr { /*! * \brief Convert 1 stream of vectors of length N to N streams of items - * \ingroup slicedice_blk + * \ingroup stream_operators_blk */ class BLOCKS_API vector_to_streams : virtual public gr_sync_block { public: - // gr::blocks::vector_to_streams::sptr typedef boost::shared_ptr<vector_to_streams> sptr; + /*! + * Make vector-to-streams block + * + * \param itemsize the item size of the stream + * \param nstreams number of items per vector (vector size and + * number of streams produced) + */ static sptr make(size_t itemsize, size_t nstreams); }; diff --git a/gr-blocks/include/blocks/wavfile.h b/gr-blocks/include/blocks/wavfile.h new file mode 100644 index 0000000000..b1993fa85a --- /dev/null +++ b/gr-blocks/include/blocks/wavfile.h @@ -0,0 +1,104 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,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. + */ + +// This file stores all the RIFF file type knowledge for the gr_wavfile_* +// blocks. + +#include <blocks/api.h> +#include <cstdio> + +namespace gr { + namespace blocks { + + /*! + * \brief Read signal information from a given WAV file. + * + * \param[in] fp File pointer to an opened, empty file. + * \param[out] sample_rate Stores the sample rate [S/s] + * \param[out] nchans Number of channels + * \param[out] bytes_per_sample Bytes per sample, can either be 1 or 2 (corresponding o + * 8 or 16 bit samples, respectively) + * \param[out] first_sample_pos Number of the first byte containing a sample. Use this + * with fseek() to jump from the end of the file to the + * first sample when in repeat mode. + * \param[out] samples_per_chan Number of samples per channel + * \return True on a successful read, false if the file could not be read or is + * not a valid WAV file. + */ + bool + wavheader_parse(FILE *fp, + unsigned int &sample_rate, + int &nchans, + int &bytes_per_sample, + int &first_sample_pos, + unsigned int &samples_per_chan); + + /*! + * \brief Read one sample from an open WAV file at the current position. + * + * \details + * Takes care of endianness. + */ + short int + wav_read_sample(FILE *fp, int bytes_per_sample); + + + /*! + * \brief Write a valid RIFF file header + * + * Note: Some header values are kept blank because they're usually + * not known a-priori (file and chunk lengths). Use + * gri_wavheader_complete() to fill these in. + */ + bool + wavheader_write(FILE *fp, + unsigned int sample_rate, + int nchans, + int bytes_per_sample); + + /*! + * \brief Write one sample to an open WAV file at the current position. + * + * \details + * Takes care of endianness. + */ + void + wav_write_sample(FILE *fp, short int sample, int bytes_per_sample); + + + /*! + * \brief Complete a WAV header + * + * \details + * Note: The stream position is changed during this function. If + * anything needs to be written to the WAV file after calling this + * function (which shouldn't happen), you need to fseek() to the + * end of the file (or whereever). + * + * \param[in] fp File pointer to an open WAV file with a blank header + * \param[in] byte_count Length of all samples written to the file in bytes. + */ + bool + wavheader_complete(FILE *fp, unsigned int byte_count); + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/include/blocks/wavfile_sink.h b/gr-blocks/include/blocks/wavfile_sink.h new file mode 100644 index 0000000000..f380e055a2 --- /dev/null +++ b/gr-blocks/include/blocks/wavfile_sink.h @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,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. + */ + +#ifndef INCLUDED_GR_WAVFILE_SINK_H +#define INCLUDED_GR_WAVFILE_SINK_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Write stream to a Microsoft PCM (.wav) file. + * \ingroup audio_blk + * + * \details + * Values must be floats within [-1;1]. + * Check gr_make_wavfile_sink() for extra info. + */ + class BLOCKS_API wavfile_sink : virtual public gr_sync_block + { + public: + // gr::blocks::wavfile_sink::sptr + typedef boost::shared_ptr<wavfile_sink> sptr; + + /* + * \param filename The .wav file to be opened + * \param n_channels Number of channels (2 = stereo or I/Q output) + * \param sample_rate Sample rate [S/s] + * \param bits_per_sample 16 or 8 bit, default is 16 + */ + static sptr make(const char *filename, + int n_channels, + unsigned int sample_rate, + int bits_per_sample = 16); + + /*! + * \brief Opens a new file and writes a WAV header. Thread-safe. + */ + virtual bool open(const char* filename) = 0; + + /*! + * \brief Closes the currently active file and completes the WAV + * header. Thread-safe. + */ + virtual void close() = 0; + + /*! + * \brief Set the sample rate. This will not affect the WAV file + * currently opened. Any following open() calls will use this new + * sample rate. + */ + virtual void set_sample_rate(unsigned int sample_rate) = 0; + + /*! + * \brief Set bits per sample. This will not affect the WAV file + * currently opened (see set_sample_rate()). If the value is + * neither 8 nor 16, the call is ignored and the current value + * is kept. + */ + virtual void set_bits_per_sample(int bits_per_sample) = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_WAVFILE_SINK_H */ diff --git a/gr-blocks/include/blocks/wavfile_source.h b/gr-blocks/include/blocks/wavfile_source.h new file mode 100644 index 0000000000..5332a0c20e --- /dev/null +++ b/gr-blocks/include/blocks/wavfile_source.h @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,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. + */ + +#ifndef INCLUDED_GR_WAVFILE_SOURCE_H +#define INCLUDED_GR_WAVFILE_SOURCE_H + +#include <blocks/api.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + /*! + * \brief Read stream from a Microsoft PCM (.wav) file, output floats + * \ingroup audio_blk + * + * \details + * Unless otherwise called, values are within [-1;1]. + * Check gr_make_wavfile_source() for extra info. + */ + class BLOCKS_API wavfile_source : virtual public gr_sync_block + { + public: + // gr::blocks::wavfile_source::sptr + typedef boost::shared_ptr<wavfile_source> sptr; + + static sptr make(const char *filename, bool repeat = false); + + /*! + * \brief Read the sample rate as specified in the wav file header + */ + virtual unsigned int sample_rate() const = 0; + + /*! + * \brief Return the number of bits per sample as specified in + * the wav file header. Only 8 or 16 bit are supported here. + */ + virtual int bits_per_sample() const = 0; + + /*! + * \brief Return the number of channels in the wav file as + * specified in the wav file header. This is also the max number + * of outputs you can have. + */ + virtual int channels() const = 0; + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_WAVFILE_SOURCE_H */ diff --git a/gr-blocks/include/blocks/xor_XX.h.t b/gr-blocks/include/blocks/xor_XX.h.t index ba0c508f6e..a890dbaf89 100644 --- a/gr-blocks/include/blocks/xor_XX.h.t +++ b/gr-blocks/include/blocks/xor_XX.h.t @@ -33,7 +33,7 @@ namespace gr { /*! * \brief output = input_0 ^ input_1 ^ , ... ^ input_N) - * \ingroup math_blk + * \ingroup boolean_operators_blk * * Bitwise boolean xor across all input streams. */ diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index 20e3ae4aa6..57c1cd20df 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -95,17 +95,28 @@ expand_cc_h_impl(add_const_XX ss ii ff cc) expand_cc_h_impl(add_const_vXX ss ii ff cc) expand_cc_h_impl(and_XX bb ss ii) expand_cc_h_impl(and_const_XX bb ss ii) +expand_cc_h_impl(argmax_XX fs is ss) expand_cc_h_impl(divide_XX ss ii ff cc) expand_cc_h_impl(integrate_XX ss ii ff cc) +expand_cc_h_impl(max_XX ff ii ss) +expand_cc_h_impl(moving_average_XX ss ii ff cc) expand_cc_h_impl(multiply_XX ss ii) expand_cc_h_impl(multiply_const_XX ss ii) expand_cc_h_impl(multiply_const_vXX ss ii ff cc) +expand_cc_h_impl(mute_XX ss ii ff cc) expand_cc_h_impl(not_XX bb ss ii) expand_cc_h_impl(or_XX bb ss ii) +expand_cc_h_impl(peak_detector_XX fb ib sb) +expand_cc_h_impl(probe_signal_X b s i f c) +expand_cc_h_impl(probe_signal_vX b s i f c) +expand_cc_h_impl(sample_and_hold_XX bb ss ii ff) expand_cc_h_impl(sub_XX ss ii ff cc) expand_cc_h_impl(xor_XX bb ss ii) expand_cc_h_impl(packed_to_unpacked_XX bb ss ii) expand_cc_h_impl(unpacked_to_packed_XX bb ss ii) +expand_cc_h_impl(vector_insert_X b s i f c) +expand_cc_h_impl(vector_sink_X b s i f c) +expand_cc_h_impl(vector_source_X b s i f c) ######################################################################## # Setup the include and linker paths @@ -128,10 +139,19 @@ link_directories(${Boost_LIBRARY_DIRS}) ######################################################################## list(APPEND gr_blocks_sources ${generated_sources} + control_loop.cc count_bits.cc + file_sink_base.cc + wavfile.cc add_ff_impl.cc + annotator_1to1_impl.cc + annotator_alltoall_impl.cc + annotator_raw_impl.cc + bin_statistics_f_impl.cc + burst_tagger_impl.cc char_to_float_impl.cc char_to_short_impl.cc + check_lfsr_32k_s_impl.cc complex_to_interleaved_short_impl.cc complex_to_float_impl.cc complex_to_real_impl.cc @@ -140,8 +160,13 @@ list(APPEND gr_blocks_sources complex_to_mag_squared_impl.cc complex_to_arg_impl.cc conjugate_cc_impl.cc + copy_impl.cc deinterleave_impl.cc delay_impl.cc + endian_swap_impl.cc + file_descriptor_sink_impl.cc + file_descriptor_source_impl.cc + file_sink_impl.cc file_source_impl.cc file_meta_sink_impl.cc file_meta_source_impl.cc @@ -152,50 +177,132 @@ list(APPEND gr_blocks_sources float_to_short_impl.cc float_array_to_uchar.cc float_to_uchar_impl.cc + head_impl.cc int_to_float_impl.cc interleave_impl.cc interleaved_short_array_to_complex.cc interleaved_short_to_complex_impl.cc keep_m_in_n_impl.cc keep_one_in_n_impl.cc + lfsr_32k_source_s_impl.cc + message_debug_impl.cc + message_sink_impl.cc + message_source_impl.cc + message_strobe_impl.cc + message_burst_source_impl.cc multiply_cc_impl.cc multiply_ff_impl.cc multiply_conjugate_cc_impl.cc multiply_const_cc_impl.cc multiply_const_ff_impl.cc nlog10_ff_impl.cc + nop_impl.cc + null_sink_impl.cc + null_source_impl.cc + pack_k_bits_bb_impl.cc patterned_interleaver_impl.cc + pdu.cc + tag_debug_impl.cc + pdu_to_tagged_stream_impl.cc peak_detector2_fb_impl.cc + plateau_detector_fb_impl.cc + probe_rate_impl.cc regenerate_bb_impl.cc + repack_bits_bb_impl.cc repeat_impl.cc rms_cf_impl.cc rms_ff_impl.cc short_to_char_impl.cc short_to_float_impl.cc + skiphead_impl.cc + socket_pdu_impl.cc stream_mux_impl.cc + stream_pdu_base.cc stream_to_streams_impl.cc stream_to_vector_impl.cc streams_to_stream_impl.cc streams_to_vector_impl.cc stretch_ff_impl.cc + tagged_file_sink_impl.cc + tagged_stream_to_pdu_impl.cc threshold_ff_impl.cc throttle_impl.cc transcendental_impl.cc + tcp_connection.cc + tuntap_pdu_impl.cc + tagged_stream_mux_impl.cc uchar_array_to_float.cc uchar_to_float_impl.cc + udp_sink_impl.cc + udp_source_impl.cc + unpack_k_bits_bb_impl.cc + vco_f_impl.cc + vector_map_impl.cc vector_to_stream_impl.cc vector_to_streams_impl.cc + wavfile_sink_impl.cc + wavfile_source_impl.cc ) +#Add Windows DLL resource file if using MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-blocks.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-blocks.rc + @ONLY) + + list(APPEND gr_blocks_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-blocks.rc + ) +ENDIF(MSVC) + list(APPEND blocks_libs gnuradio-core volk ${Boost_LIBRARIES} ${BLOCKS_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) -add_library(gnuradio-blocks SHARED ${gr_blocks_sources}) +add_library(gnuradio-blocks SHARED ${gr_blocks_sources} + tag_gate_impl.cc) add_dependencies(gnuradio-blocks blocks_generated_includes) target_link_libraries(gnuradio-blocks ${blocks_libs}) GR_LIBRARY_FOO(gnuradio-blocks RUNTIME_COMPONENT "blocks_runtime" DEVEL_COMPONENT "blocks_devel") + +######################################################################## +# QA C++ Code for gr-filter +######################################################################## +if(ENABLE_TESTING) + include(GrTest) + + include_directories( + ${GR_FILTER_INCLUDE_DIRS} + ${CPPUNIT_INCLUDE_DIRS}) + link_directories(${CPPUNIT_LIBRARY_DIRS}) + + list(APPEND test_gr_blocks_sources + ${CMAKE_CURRENT_SOURCE_DIR}/test_gr_blocks.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_blocks.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_rotator.cc + ) + + add_executable(test-gr-blocks ${test_gr_blocks_sources}) + + list(APPEND GR_TEST_TARGET_DEPS test-gr-blocks gnuradio-blocks) + + target_link_libraries( + test-gr-blocks + gnuradio-core + gnuradio-blocks + gnuradio-filter + ${Boost_LIBRARIES} + ${CPPUNIT_LIBRARIES} + ) + + GR_ADD_TEST(test_gr_blocks test-gr-blocks) +endif(ENABLE_TESTING) diff --git a/gr-blocks/lib/ConfigChecks.cmake b/gr-blocks/lib/ConfigChecks.cmake index 72d6d1d8ab..7f60aed403 100644 --- a/gr-blocks/lib/ConfigChecks.cmake +++ b/gr-blocks/lib/ConfigChecks.cmake @@ -56,7 +56,7 @@ CHECK_INCLUDE_FILE_CXX(windows.h HAVE_WINDOWS_H) IF(HAVE_WINDOWS_H) ADD_DEFINITIONS(-DHAVE_WINDOWS_H -DUSING_WINSOCK) MESSAGE(STATUS "Adding windows libs to gr blocks libs...") - LIST(APPEND gnuradio_core_libs WS2_32.lib WSock32.lib) + LIST(APPEND blocks_libs WS2_32.lib WSock32.lib) ENDIF(HAVE_WINDOWS_H) ######################################################################## diff --git a/gr-blocks/lib/add_XX_impl.h.t b/gr-blocks/lib/add_XX_impl.h.t index a1c486b859..2e20ef5fe3 100644 --- a/gr-blocks/lib/add_XX_impl.h.t +++ b/gr-blocks/lib/add_XX_impl.h.t @@ -32,6 +32,7 @@ namespace gr { class BLOCKS_API @NAME_IMPL@ : public @NAME@ { + private: size_t d_vlen; public: diff --git a/gr-blocks/lib/annotator_1to1_impl.cc b/gr-blocks/lib/annotator_1to1_impl.cc new file mode 100644 index 0000000000..d3f4758684 --- /dev/null +++ b/gr-blocks/lib/annotator_1to1_impl.cc @@ -0,0 +1,113 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "annotator_1to1_impl.h" +#include <gr_io_signature.h> +#include <string.h> +#include <iostream> +#include <iomanip> + +namespace gr { + namespace blocks { + + annotator_1to1::sptr + annotator_1to1::make(int when, size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new annotator_1to1_impl(when, sizeof_stream_item)); + } + + annotator_1to1_impl::annotator_1to1_impl(int when, size_t sizeof_stream_item) + : gr_sync_block("annotator_1to1", + gr_make_io_signature(1, -1, sizeof_stream_item), + gr_make_io_signature(1, -1, sizeof_stream_item)), + d_itemsize(sizeof_stream_item), d_when((uint64_t)when) + { + set_tag_propagation_policy(TPP_ONE_TO_ONE); + + d_tag_counter = 0; + set_relative_rate(1.0); + } + + annotator_1to1_impl::~annotator_1to1_impl() + { + } + + int + annotator_1to1_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float*)input_items[0]; + float *out = (float*)output_items[0]; + + std::stringstream str; + str << name() << unique_id(); + + uint64_t abs_N = 0; + int ninputs = input_items.size(); + for(int i = 0; i < ninputs; i++) { + abs_N = nitems_read(i); + + std::vector<gr_tag_t> all_tags; + get_tags_in_range(all_tags, i, abs_N, abs_N + noutput_items); + + std::vector<gr_tag_t>::iterator itr; + for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { + d_stored_tags.push_back(*itr); + } + } + + // Storing the current noutput_items as the value to the "noutput_items" key + pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str()); + pmt::pmt_t key = pmt::pmt_string_to_symbol("seq"); + + // Work does nothing to the data stream; just copy all inputs to outputs + // Adds a new tag when the number of items read is a multiple of d_when + abs_N = nitems_read(0); + int noutputs = output_items.size(); + for(int j = 0; j < noutput_items; j++) { + // the min() is a hack to make sure this doesn't segfault if + // there are a different number of ins and outs. This is + // specifically designed to test the 1-to-1 propagation policy. + for(int i = 0; i < std::min(noutputs, ninputs); i++) { + if(abs_N % d_when == 0) { + pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); + add_item_tag(i, abs_N, key, value, srcid); + } + + in = (const float*)input_items[i]; + out = (float*)output_items[i]; + out[j] = in[j]; + } + abs_N++; + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/annotator_1to1_impl.h b/gr-blocks/lib/annotator_1to1_impl.h new file mode 100644 index 0000000000..3306602e2c --- /dev/null +++ b/gr-blocks/lib/annotator_1to1_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H +#define INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H + +#include <blocks/annotator_1to1.h> + +namespace gr { + namespace blocks { + + class annotator_1to1_impl : public annotator_1to1 + { + private: + size_t d_itemsize; + uint64_t d_when; + uint64_t d_tag_counter; + std::vector<gr_tag_t> d_stored_tags; + + public: + annotator_1to1_impl(int when, size_t sizeof_stream_item); + ~annotator_1to1_impl(); + + std::vector<gr_tag_t> data() const + { + return d_stored_tags; + } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_1TO1_IMPL_H */ diff --git a/gr-blocks/lib/annotator_alltoall_impl.cc b/gr-blocks/lib/annotator_alltoall_impl.cc new file mode 100644 index 0000000000..5af1a9c18e --- /dev/null +++ b/gr-blocks/lib/annotator_alltoall_impl.cc @@ -0,0 +1,117 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "annotator_alltoall_impl.h" +#include <gr_io_signature.h> +#include <string.h> +#include <iostream> +#include <iomanip> + +namespace gr { + namespace blocks { + + annotator_alltoall::sptr + annotator_alltoall::make(int when, size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new annotator_alltoall_impl(when, sizeof_stream_item)); + } + + annotator_alltoall_impl::annotator_alltoall_impl(int when, + size_t sizeof_stream_item) + : gr_sync_block("annotator_alltoall", + gr_make_io_signature(1, -1, sizeof_stream_item), + gr_make_io_signature(1, -1, sizeof_stream_item)), + d_itemsize(sizeof_stream_item), d_when((uint64_t)when) + { + set_tag_propagation_policy(TPP_ALL_TO_ALL); + + d_tag_counter = 0; + } + + annotator_alltoall_impl::~annotator_alltoall_impl() + { + } + + int + annotator_alltoall_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float*)input_items[0]; + float *out = (float*)output_items[0]; + + std::stringstream str; + str << name() << unique_id(); + + uint64_t abs_N = 0, end_N; + int ninputs = input_items.size(); + for(int i = 0; i < ninputs; i++) { + abs_N = nitems_read(i); + end_N = abs_N + (uint64_t)(noutput_items); + + std::vector<gr_tag_t> all_tags; + get_tags_in_range(all_tags, i, abs_N, end_N); + + std::vector<gr_tag_t>::iterator itr; + for(itr = all_tags.begin(); itr != all_tags.end(); itr++) { + d_stored_tags.push_back(*itr); + } + } + + // Source ID and key for any tag that might get applied from this block + pmt::pmt_t srcid = pmt::pmt_string_to_symbol(str.str()); + pmt::pmt_t key = pmt::pmt_string_to_symbol("seq"); + + // Work does nothing to the data stream; just copy all inputs to + // outputs Adds a new tag when the number of items read is a + // multiple of d_when + abs_N = nitems_written(0); + int noutputs = output_items.size(); + + for(int j = 0; j < noutput_items; j++) { + for(int i = 0; i < noutputs; i++) { + if(abs_N % d_when == 0) { + pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); + add_item_tag(i, abs_N, key, value, srcid); + } + + // Sum all of the inputs together for each output. Just 'cause. + out = (float*)output_items[i]; + out[j] = 0; + for(int ins = 0; ins < ninputs; ins++) { + in = (const float*)input_items[ins]; + out[j] += in[j]; + } + } + abs_N++; + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/annotator_alltoall_impl.h b/gr-blocks/lib/annotator_alltoall_impl.h new file mode 100644 index 0000000000..24c21948bc --- /dev/null +++ b/gr-blocks/lib/annotator_alltoall_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H +#define INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H + +#include <blocks/annotator_alltoall.h> + +namespace gr { + namespace blocks { + + class annotator_alltoall_impl : public annotator_alltoall + { + private: + size_t d_itemsize; + uint64_t d_when; + uint64_t d_tag_counter; + std::vector<gr_tag_t> d_stored_tags; + + public: + annotator_alltoall_impl(int when, size_t sizeof_stream_item); + ~annotator_alltoall_impl(); + + std::vector<gr_tag_t> data() const + { + return d_stored_tags; + } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_ALLTOALL_IMPL_H */ diff --git a/gr-blocks/lib/annotator_raw_impl.cc b/gr-blocks/lib/annotator_raw_impl.cc new file mode 100644 index 0000000000..1b92523089 --- /dev/null +++ b/gr-blocks/lib/annotator_raw_impl.cc @@ -0,0 +1,112 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "annotator_raw_impl.h" +#include <gr_io_signature.h> +#include <string.h> +#include <iostream> +#include <iomanip> +#include <stdexcept> + +using namespace pmt; + +namespace gr { + namespace blocks { + + annotator_raw::sptr + annotator_raw::make(size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new annotator_raw_impl(sizeof_stream_item)); + } + + annotator_raw_impl::annotator_raw_impl(size_t sizeof_stream_item) + : gr_sync_block("annotator_raw", + gr_make_io_signature(1, 1, sizeof_stream_item), + gr_make_io_signature(1, 1, sizeof_stream_item)), + d_itemsize(sizeof_stream_item) + { + set_tag_propagation_policy(TPP_ONE_TO_ONE); + set_relative_rate(1.0); + } + + void annotator_raw_impl::add_tag(uint64_t offset, pmt_t key, pmt_t val) + { + gruel::scoped_lock l(d_mutex); + + gr_tag_t tag; + tag.srcid = pmt::pmt_intern(name()); + tag.key = key; + tag.value = val; + tag.offset = offset; + + // add our new tag + d_queued_tags.push_back(tag); + // make sure our tags are in offset order + std::sort(d_queued_tags.begin(), d_queued_tags.end(), + gr_tag_t::offset_compare); + // make sure we are not adding an item in the past! + if(tag.offset > nitems_read(0)) { + throw std::runtime_error("annotator_raw::add_tag: item added too far in the past\n."); + } + } + + annotator_raw_impl::~annotator_raw_impl() + { + } + + int + annotator_raw_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gruel::scoped_lock l(d_mutex); + + const char *in = (const char*)input_items[0]; + char *out = (char*)output_items[0]; + + uint64_t start_N = nitems_read(0); + uint64_t end_N = start_N + (uint64_t)(noutput_items); + + // locate queued tags that fall in this range and insert them when appropriate + std::vector<gr_tag_t>::iterator i = d_queued_tags.begin(); + while( i != d_queued_tags.end() ) { + if( (*i).offset >= start_N && (*i).offset < end_N) { + add_item_tag(0, (*i).offset,(*i).key, (*i).value, (*i).srcid); + i = d_queued_tags.erase(i); + } + else { + break; + } + } + + // copy data across + memcpy(out, in, noutput_items*d_itemsize); + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/annotator_raw_impl.h b/gr-blocks/lib/annotator_raw_impl.h new file mode 100644 index 0000000000..2e349bfe33 --- /dev/null +++ b/gr-blocks/lib/annotator_raw_impl.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_ANNOTATOR_RAW_IMPL_H +#define INCLUDED_GR_ANNOTATOR_RAW_IMPL_H + +#include <blocks/annotator_raw.h> +#include <gruel/thread.h> + +namespace gr { + namespace blocks { + + class annotator_raw_impl : public annotator_raw + { + private: + size_t d_itemsize; + std::vector<gr_tag_t> d_queued_tags; + gruel::mutex d_mutex; + + public: + annotator_raw_impl(size_t sizeof_stream_item); + ~annotator_raw_impl(); + + // insert a tag to be added + void add_tag(uint64_t offset, pmt::pmt_t key, pmt::pmt_t val); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ANNOTATOR_RAW_IMPL_H */ diff --git a/gr-blocks/lib/argmax_XX_impl.cc.t b/gr-blocks/lib/argmax_XX_impl.cc.t new file mode 100644 index 0000000000..56673ef995 --- /dev/null +++ b/gr-blocks/lib/argmax_XX_impl.cc.t @@ -0,0 +1,86 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(size_t vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t vlen) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, -1, vlen*sizeof(@I_TYPE@)), + gr_make_io_signature(2, 2, sizeof(@O_TYPE@))), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + int ninputs = input_items.size (); + + @O_TYPE@ *x_optr = (@O_TYPE@ *)output_items[0]; + @O_TYPE@ *y_optr = (@O_TYPE@ *)output_items[1]; + + for(int i = 0; i < noutput_items; i++) { + @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen]; + int x = 0; + int y = 0; + + for(int j = 0; j < (int)d_vlen; j++ ) { + for(int k = 0; k < ninputs; k++) { + if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) { + max = ((@I_TYPE@ *)input_items[k])[i*d_vlen + j]; + x = j; + y = k; + } + } + } + + *x_optr++ = (@O_TYPE@)x; + *y_optr++ = (@O_TYPE@)y; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/argmax_XX_impl.h.t b/gr-blocks/lib/argmax_XX_impl.h.t new file mode 100644 index 0000000000..0f1643f6b9 --- /dev/null +++ b/gr-blocks/lib/argmax_XX_impl.h.t @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + size_t d_vlen; + + public: + @NAME_IMPL@(size_t vlen); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/bin_statistics_f_impl.cc b/gr-blocks/lib/bin_statistics_f_impl.cc new file mode 100644 index 0000000000..014222a63d --- /dev/null +++ b/gr-blocks/lib/bin_statistics_f_impl.cc @@ -0,0 +1,178 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "bin_statistics_f_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + bin_statistics_f::sptr + bin_statistics_f::make(unsigned int vlen, + gr_msg_queue_sptr msgq, + gr_feval_dd *tune, + size_t tune_delay, + size_t dwell_delay) + { + return gnuradio::get_initial_sptr + (new bin_statistics_f_impl(vlen, msgq, tune, + tune_delay, dwell_delay)); + } + + bin_statistics_f_impl::bin_statistics_f_impl(unsigned int vlen, + gr_msg_queue_sptr msgq, + gr_feval_dd *tune, + size_t tune_delay, + size_t dwell_delay) + : gr_sync_block("bin_statistics_f", + gr_make_io_signature(1, 1, sizeof(float) * vlen), + gr_make_io_signature(0, 0, 0)), + d_vlen(vlen), d_msgq(msgq), d_tune(tune), + d_tune_delay(tune_delay), d_dwell_delay(dwell_delay), + d_center_freq(0), d_delay(0), + d_max(vlen) + { + enter_init(); + } + + bin_statistics_f_impl::~bin_statistics_f_impl() + { + } + + void + bin_statistics_f_impl::enter_init() + { + d_state = ST_INIT; + d_delay = 0; + } + + void + bin_statistics_f_impl::enter_tune_delay() + { + d_state = ST_TUNE_DELAY; + d_delay = d_tune_delay; + d_center_freq = d_tune->calleval(0); + } + + void + bin_statistics_f_impl::enter_dwell_delay() + { + d_state = ST_DWELL_DELAY; + d_delay = d_dwell_delay; + reset_stats(); + } + + void + bin_statistics_f_impl::leave_dwell_delay() + { + send_stats(); + } + + int + bin_statistics_f_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *input = (const float*)input_items[0]; + size_t vlen = d_max.size(); + + int n = 0; + int t; + + while(n < noutput_items) { + switch(d_state) { + + case ST_INIT: + enter_tune_delay(); + break; + + case ST_TUNE_DELAY: + t = std::min(noutput_items - n, int(d_delay)); + n += t; + d_delay -= t; + assert(d_delay >= 0); + if(d_delay == 0) + enter_dwell_delay(); + break; + + case ST_DWELL_DELAY: + t = std::min(noutput_items - n, int(d_delay)); + for(int i = 0; i < t; i++) { + accrue_stats(&input[n * vlen]); + n++; + } + d_delay -= t; + assert(d_delay >= 0); + if(d_delay == 0) { + leave_dwell_delay(); + enter_tune_delay(); + } + break; + + default: + assert(0); + } + } + + return noutput_items; + } + + ////////////////////////////////////////////////////////////////////////// + // virtual methods for gathering stats + ////////////////////////////////////////////////////////////////////////// + + void + bin_statistics_f_impl::reset_stats() + { + for (size_t i = 0; i < vlen(); i++){ + d_max[i] = 0; + } + } + + void + bin_statistics_f_impl::accrue_stats(const float *input) + { + for(size_t i = 0; i < vlen(); i++) { + d_max[i] = std::max(d_max[i], input[i]); // compute per bin maxima + } + } + + void + bin_statistics_f_impl::send_stats() + { + if(msgq()->full_p()) // if the queue is full, don't block, drop the data... + return; + + // build & send a message + gr_message_sptr msg = gr_make_message(0, center_freq(), vlen(), vlen() * sizeof(float)); + memcpy(msg->msg(), &d_max[0], vlen() * sizeof(float)); + msgq()->insert_tail(msg); + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/bin_statistics_f_impl.h b/gr-blocks/lib/bin_statistics_f_impl.h new file mode 100644 index 0000000000..0abb60ed38 --- /dev/null +++ b/gr-blocks/lib/bin_statistics_f_impl.h @@ -0,0 +1,82 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_GR_BIN_STATISTICS_F_IMPL_H +#define INCLUDED_GR_BIN_STATISTICS_F_IMPL_H + +#include <blocks/bin_statistics_f.h> +#include <gr_feval.h> +#include <gr_message.h> +#include <gr_msg_queue.h> + +namespace gr { + namespace blocks { + + class bin_statistics_f_impl : public bin_statistics_f + { + private: + enum state_t { ST_INIT, ST_TUNE_DELAY, ST_DWELL_DELAY }; + + size_t d_vlen; + gr_msg_queue_sptr d_msgq; + gr_feval_dd *d_tune; + size_t d_tune_delay; + size_t d_dwell_delay; + double d_center_freq; + + state_t d_state; + size_t d_delay; // nsamples remaining to state transition + + void enter_init(); + void enter_tune_delay(); + void enter_dwell_delay(); + void leave_dwell_delay(); + + protected: + std::vector<float> d_max; // per bin maxima + + size_t vlen() const { return d_vlen; } + double center_freq() const { return d_center_freq; } + gr_msg_queue_sptr msgq() const { return d_msgq; } + + virtual void reset_stats(); + virtual void accrue_stats(const float *input); + virtual void send_stats(); + + public: + bin_statistics_f_impl(unsigned int vlen, + gr_msg_queue_sptr msgq, + gr_feval_dd *tune, + size_t tune_delay, + size_t dwell_delay); + ~bin_statistics_f_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_BIN_STATISTICS_F_IMPL_H */ diff --git a/gr-blocks/lib/burst_tagger_impl.cc b/gr-blocks/lib/burst_tagger_impl.cc new file mode 100644 index 0000000000..5d0691bde6 --- /dev/null +++ b/gr-blocks/lib/burst_tagger_impl.cc @@ -0,0 +1,116 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "burst_tagger_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + burst_tagger::sptr + burst_tagger::make(size_t itemsize) + { + return gnuradio::get_initial_sptr + (new burst_tagger_impl(itemsize)); + } + + burst_tagger_impl::burst_tagger_impl(size_t itemsize) + : gr_sync_block("burst_tagger", + gr_make_io_signature2(2, 2, itemsize, sizeof(short)), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_state(false) + { + std::stringstream str; + str << name() << unique_id(); + + d_true_key = pmt::pmt_string_to_symbol("burst"); + d_true_value = pmt::PMT_T; + + d_false_key = pmt::pmt_string_to_symbol("burst"); + d_false_value = pmt::PMT_F; + + d_id = pmt::pmt_string_to_symbol(str.str()); + } + + burst_tagger_impl::~burst_tagger_impl() + { + } + + void + burst_tagger_impl::set_true_tag(const std::string &key, bool value) + { + d_true_key = pmt::pmt_string_to_symbol(key); + if(value == true) { + d_true_value = pmt::PMT_T; + } + else { + d_true_value = pmt::PMT_F; + } + } + + void + burst_tagger_impl::set_false_tag (const std::string &key, bool value) + { + d_false_key = pmt::pmt_string_to_symbol(key); + if(value == true) { + d_false_value = pmt::PMT_T; + } + else { + d_false_value = pmt::PMT_F; + } + } + + int + burst_tagger_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *signal = (const char*)input_items[0]; + const short *trigger = (const short*)input_items[1]; + char *out = (char*)output_items[0]; + + memcpy(out, signal, noutput_items * d_itemsize); + + for(int i = 0; i < noutput_items; i++) { + if(trigger[i] > 0) { + if(d_state == false) { + d_state = true; + add_item_tag(0, nitems_written(0)+i, d_true_key, d_true_value, d_id); + } + } + else { + if(d_state == true) { + d_state = false; + add_item_tag(0, nitems_written(0)+i, d_false_key, d_false_value, d_id); + } + } + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/burst_tagger_impl.h b/gr-blocks/lib/burst_tagger_impl.h new file mode 100644 index 0000000000..80bdec12fb --- /dev/null +++ b/gr-blocks/lib/burst_tagger_impl.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_BURST_TAGGER_IMPL_H +#define INCLUDED_GR_BURST_TAGGER_IMPL_H + +#include <blocks/burst_tagger.h> + +namespace gr { + namespace blocks { + + class burst_tagger_impl : public burst_tagger + { + private: + size_t d_itemsize; + bool d_state; + pmt::pmt_t d_true_key; + pmt::pmt_t d_true_value; + + pmt::pmt_t d_false_key; + pmt::pmt_t d_false_value; + + pmt::pmt_t d_id; + + public: + burst_tagger_impl(size_t itemsize); + ~burst_tagger_impl(); + + void set_true_tag(const std::string &key, bool value); + void set_false_tag(const std::string &key, bool value); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_BURST_TAGGER_IMPL_H */ diff --git a/gr-blocks/lib/check_lfsr_32k_s_impl.cc b/gr-blocks/lib/check_lfsr_32k_s_impl.cc new file mode 100644 index 0000000000..b8e88003a2 --- /dev/null +++ b/gr-blocks/lib/check_lfsr_32k_s_impl.cc @@ -0,0 +1,179 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "check_lfsr_32k_s_impl.h" +#include <gr_io_signature.h> +#include <stdlib.h> +#include <stdio.h> + +namespace gr { + namespace blocks { + + check_lfsr_32k_s::sptr + check_lfsr_32k_s::make() + { + return gnuradio::get_initial_sptr + (new check_lfsr_32k_s_impl()); + } + + check_lfsr_32k_s_impl::check_lfsr_32k_s_impl() + : gr_sync_block("gr_check_lfsr_32k", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(0, 0, 0)), + d_state(SEARCHING), d_history(0), d_ntotal(0), d_nright(0), + d_runlength(0), d_index(0) + { + lfsr_32k lfsr; + + for(int i = 0; i < BUFSIZE; i++) + d_buffer[i] = lfsr.next_short(); + + enter_SEARCHING(); + } + + check_lfsr_32k_s_impl::~check_lfsr_32k_s_impl() + { + } + + int + check_lfsr_32k_s_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + unsigned short *in = (unsigned short*)input_items[0]; + + for(int i = 0; i < noutput_items; i++) { + unsigned short x = in[i]; + unsigned short expected; + + switch(d_state) { + case MATCH0: + if(x == d_buffer[0]) + enter_MATCH1(); + break; + + case MATCH1: + if(x == d_buffer[1]) + enter_MATCH2(); + else + enter_MATCH0(); + break; + + case MATCH2: + if(x == d_buffer[2]) + enter_LOCKED(); + else + enter_MATCH0(); + break; + + case LOCKED: + expected = d_buffer[d_index]; + d_index = d_index + 1; + if(d_index >= BUFSIZE) + d_index = 0; + + if(x == expected) + right(); + else { + wrong(); + log_error(expected, x); + if(wrong_three_times()) + enter_SEARCHING(); + } + break; + + default: + abort(); + } + + d_ntotal++; + } + + return noutput_items; + } + + void + check_lfsr_32k_s_impl::enter_SEARCHING() + { + d_state = SEARCHING; + wrong(); // reset history + wrong(); + wrong(); + + d_runlength = 0; + d_index = 0; // reset LFSR to beginning + + if(0) + fprintf(stdout, "gr_check_lfsr_32k: enter_SEARCHING at offset %8ld (0x%08lx)\n", + d_ntotal, d_ntotal); + + enter_MATCH0(); + } + + void + check_lfsr_32k_s_impl::enter_MATCH0() + { + d_state = MATCH0; + } + + void + check_lfsr_32k_s_impl::enter_MATCH1() + { + d_state = MATCH1; + } + + void + check_lfsr_32k_s_impl::enter_MATCH2() + { + d_state = MATCH2; + } + + void + check_lfsr_32k_s_impl::enter_LOCKED() + { + d_state = LOCKED; + right(); // setup history + right(); + right(); + + d_index = 3; // already matched first 3 items + + if(0) + fprintf(stdout, "gr_check_lfsr_32k: enter_LOCKED at offset %8ld (0x%08lx)\n", + d_ntotal, d_ntotal); + } + + void + check_lfsr_32k_s_impl::log_error(unsigned short expected, unsigned short actual) + { + if(0) + fprintf(stdout, + "gr_check_lfsr_32k: expected %5d (0x%04x) got %5d (0x%04x) offset %8ld (0x%08lx)\n", + expected, expected, actual, actual, d_ntotal, d_ntotal); + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/check_lfsr_32k_s_impl.h b/gr-blocks/lib/check_lfsr_32k_s_impl.h new file mode 100644 index 0000000000..f6d3c8daa2 --- /dev/null +++ b/gr-blocks/lib/check_lfsr_32k_s_impl.h @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GR_CHECK_LFSR_32K_S_IMPL_H +#define INCLUDED_GR_CHECK_LFSR_32K_S_IMPL_H + +#include <blocks/check_lfsr_32k_s.h> +#include <blocks/lfsr_32k.h> + +namespace gr { + namespace blocks { + + class check_lfsr_32k_s_impl : public check_lfsr_32k_s + { + private: + enum state { + SEARCHING, // searching for synchronization + MATCH0, + MATCH1, + MATCH2, + LOCKED // is locked + }; + + state d_state; + unsigned int d_history; // bitmask of decisions + + long d_ntotal; // total number of shorts + long d_nright; // # of correct shorts + long d_runlength; // # of correct shorts in a row + + static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned + int d_index; + unsigned short d_buffer[BUFSIZE]; + + void enter_SEARCHING(); + void enter_MATCH0(); + void enter_MATCH1(); + void enter_MATCH2(); + void enter_LOCKED(); + + void right() + { + d_history = (d_history << 1) | 0x1; + d_nright++; + d_runlength++; + } + + void wrong() + { + d_history = (d_history << 1) | 0x0; + d_runlength = 0; + } + + bool right_three_times() { return (d_history & 0x7) == 0x7; } + bool wrong_three_times() { return (d_history & 0x7) == 0x0; } + + void log_error(unsigned short expected, unsigned short actual); + + public: + check_lfsr_32k_s_impl(); + ~check_lfsr_32k_s_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + long ntotal() const { return d_ntotal; } + long nright() const { return d_nright; } + long runlength() const { return d_runlength; } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_CHECK_LFSR_32K_S_IMPL_H */ diff --git a/gr-blocks/lib/control_loop.cc b/gr-blocks/lib/control_loop.cc new file mode 100644 index 0000000000..44f4e53394 --- /dev/null +++ b/gr-blocks/lib/control_loop.cc @@ -0,0 +1,214 @@ +/* -*- c++ -*- */ +/* + * Copyright 2011,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <blocks/control_loop.h> +#include <gr_math.h> +#include <stdexcept> + +namespace gr { + namespace blocks { + +#define M_TWOPI (2.0f*M_PI) + + control_loop::control_loop(float loop_bw, + float max_freq, float min_freq) + : d_phase(0), d_freq(0), d_max_freq(max_freq), d_min_freq(min_freq) + { + // Set the damping factor for a critically damped system + d_damping = sqrtf(2.0f)/2.0f; + + // Set the bandwidth, which will then call update_gains() + set_loop_bandwidth(loop_bw); + } + + control_loop::~control_loop() + { + } + + void + control_loop::update_gains() + { + float denom = (1.0 + 2.0*d_damping*d_loop_bw + d_loop_bw*d_loop_bw); + d_alpha = (4*d_damping*d_loop_bw) / denom; + d_beta = (4*d_loop_bw*d_loop_bw) / denom; + } + + void + control_loop::advance_loop(float error) + { + d_freq = d_freq + d_beta * error; + d_phase = d_phase + d_freq + d_alpha * error; + } + + void + control_loop::phase_wrap() + { + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; + } + + void + control_loop::frequency_limit() + { + if(d_freq > d_max_freq) + d_freq = d_max_freq; + else if(d_freq < d_min_freq) + d_freq = d_min_freq; + } + + /******************************************************************* + * SET FUNCTIONS + *******************************************************************/ + + void + control_loop::set_loop_bandwidth(float bw) + { + if(bw < 0) { + throw std::out_of_range ("control_loop: invalid bandwidth. Must be >= 0."); + } + + d_loop_bw = bw; + update_gains(); + } + + void + control_loop::set_damping_factor(float df) + { + if(df < 0 || df > 1.0) { + throw std::out_of_range ("control_loop: invalid damping factor. Must be in [0,1]."); + } + + d_damping = df; + update_gains(); + } + + void + control_loop::set_alpha(float alpha) + { + if(alpha < 0 || alpha > 1.0) { + throw std::out_of_range ("control_loop: invalid alpha. Must be in [0,1]."); + } + d_alpha = alpha; + } + + void + control_loop::set_beta(float beta) + { + if(beta < 0 || beta > 1.0) { + throw std::out_of_range ("control_loop: invalid beta. Must be in [0,1]."); + } + d_beta = beta; + } + + void + control_loop::set_frequency(float freq) + { + if(freq > d_max_freq) + d_freq = d_min_freq; + else if(freq < d_min_freq) + d_freq = d_max_freq; + else + d_freq = freq; + } + + void + control_loop::set_phase(float phase) + { + d_phase = phase; + while(d_phase>M_TWOPI) + d_phase -= M_TWOPI; + while(d_phase<-M_TWOPI) + d_phase += M_TWOPI; + } + + void + control_loop::set_max_freq(float freq) + { + d_max_freq = freq; + } + + void + control_loop::set_min_freq(float freq) + { + d_min_freq = freq; + } + + /******************************************************************* + * GET FUNCTIONS + *******************************************************************/ + + float + control_loop::get_loop_bandwidth() const + { + return d_loop_bw; + } + + float + control_loop::get_damping_factor() const + { + return d_damping; + } + + float + control_loop::get_alpha() const + { + return d_alpha; + } + + float + control_loop::get_beta() const + { + return d_beta; + } + + float + control_loop::get_frequency() const + { + return d_freq; + } + + float + control_loop::get_phase() const + { + return d_phase; + } + + float + control_loop::get_max_freq() const + { + return d_max_freq; + } + + float + control_loop::get_min_freq() const + { + return d_min_freq; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/copy_impl.cc b/gr-blocks/lib/copy_impl.cc new file mode 100644 index 0000000000..929f22b7d3 --- /dev/null +++ b/gr-blocks/lib/copy_impl.cc @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "copy_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + copy::sptr + copy::make(size_t itemsize) + { + return gnuradio::get_initial_sptr + (new copy_impl(itemsize)); + } + + copy_impl::copy_impl(size_t itemsize) + : gr_block("copy", + gr_make_io_signature(1, -1, itemsize), + gr_make_io_signature(1, -1, itemsize)), + d_itemsize(itemsize), + d_enabled(true) + { + } + + copy_impl::~copy_impl() + { + } + + void + copy_impl::forecast(int noutput_items, gr_vector_int &ninput_items_required) + { + unsigned ninputs = ninput_items_required.size(); + for (unsigned i = 0; i < ninputs; i++) + ninput_items_required[i] = noutput_items; + } + + bool + copy_impl::check_topology(int ninputs, int noutputs) + { + return ninputs == noutputs; + } + + int + copy_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const uint8_t **in = (const uint8_t**)&input_items[0]; + uint8_t **out = (uint8_t**)&output_items[0]; + + int n = 0; + if(d_enabled) { + int ninputs = input_items.size(); + for(int i = 0; i < ninputs; i++) { + memcpy(out[i], in[i], noutput_items*d_itemsize); + } + n = noutput_items; + } + + consume_each(noutput_items); + return n; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/copy_impl.h b/gr-blocks/lib/copy_impl.h new file mode 100644 index 0000000000..1f0f1a655e --- /dev/null +++ b/gr-blocks/lib/copy_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,2009,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. + */ + +#ifndef INCLUDED_GR_COPY_IMPL_H +#define INCLUDED_GR_COPY_IMPL_H + +#include <blocks/copy.h> + +namespace gr { + namespace blocks { + + class copy_impl : public copy + { + private: + size_t d_itemsize; + bool d_enabled; + + public: + copy_impl(size_t itemsize); + ~copy_impl(); + + void forecast(int noutput_items, gr_vector_int &ninput_items_required); + bool check_topology(int ninputs, int noutputs); + + void set_enabled(bool enable) { d_enabled = enable; } + bool enabled() const { return d_enabled;} + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_COPY_IMPL_H */ diff --git a/gr-blocks/lib/endian_swap_impl.cc b/gr-blocks/lib/endian_swap_impl.cc new file mode 100644 index 0000000000..7e67c30147 --- /dev/null +++ b/gr-blocks/lib/endian_swap_impl.cc @@ -0,0 +1,110 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,2012,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "endian_swap_impl.h" +#include <gr_io_signature.h> +#include <volk/volk.h> + +namespace gr { + namespace blocks { + + endian_swap::sptr + endian_swap::make(size_t item_size_bytes) + { + return gnuradio::get_initial_sptr + (new endian_swap_impl(item_size_bytes)); + } + + endian_swap_impl::endian_swap_impl (size_t item_size_bytes) + : gr_sync_block("endian_swap_impl", + gr_make_io_signature(1, 1, item_size_bytes), + gr_make_io_signature(1, 1, item_size_bytes)) + { + const int alignment_multiple = volk_get_alignment(); + set_alignment(std::max(1, alignment_multiple)); + } + + endian_swap_impl::~endian_swap_impl() + { + } + + int + endian_swap_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char*)input_items[0]; + char *out = (char*)output_items[0]; + + int nbytes(output_signature()->sizeof_stream_item(0)); + if(is_unaligned()) { + switch(nbytes){ + case 1: + memcpy(out,in,noutput_items); + break; + case 2: + memcpy(out,in,2*noutput_items); + volk_16u_byteswap_u((uint16_t*)out,noutput_items); + break; + case 4: + memcpy(out,in,4*noutput_items); + volk_32u_byteswap_u((uint32_t*)out,noutput_items); + break; + case 8: + memcpy(out,in,8*noutput_items); + volk_64u_byteswap_u((uint64_t*)out,noutput_items); + break; + default: + throw std::runtime_error("itemsize is not valid for endian_swap!"); + } + } + else { + switch(nbytes) { + case 1: + memcpy(out,in,noutput_items); + break; + case 2: + memcpy(out,in,2*noutput_items); + volk_16u_byteswap_a((uint16_t*)out,noutput_items); + break; + case 4: + memcpy(out,in,4*noutput_items); + volk_32u_byteswap_a((uint32_t*)out,noutput_items); + break; + case 8: + memcpy(out,in,8*noutput_items); + volk_64u_byteswap_a((uint64_t*)out,noutput_items); + break; + default: + throw std::runtime_error("itemsize is not valid for endian_swap!"); + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/endian_swap_impl.h b/gr-blocks/lib/endian_swap_impl.h new file mode 100644 index 0000000000..517df44f17 --- /dev/null +++ b/gr-blocks/lib/endian_swap_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2012,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. + */ + +#ifndef INCLUDED_GR_ENDIAN_SWAP_IMPL_H +#define INCLUDED_GR_ENDIAN_SWAP_IMPL_H + +#include <blocks/endian_swap.h> + +namespace gr { + namespace blocks { + + class endian_swap_impl : public endian_swap + { + private: + size_t item_size_bytes; + + public: + endian_swap_impl(size_t item_size_bytes); + ~endian_swap_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_ENDIAN_SWAP_IMPL_H */ diff --git a/gr-blocks/lib/file_descriptor_sink_impl.cc b/gr-blocks/lib/file_descriptor_sink_impl.cc new file mode 100644 index 0000000000..a1f26220d2 --- /dev/null +++ b/gr-blocks/lib/file_descriptor_sink_impl.cc @@ -0,0 +1,94 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "file_descriptor_sink_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <stdio.h> + +#ifdef HAVE_IO_H +#include <io.h> +#endif + +namespace gr { + namespace blocks { + + file_descriptor_sink::sptr + file_descriptor_sink::make(size_t itemsize, int fd) + { + return gnuradio::get_initial_sptr + (new file_descriptor_sink_impl(itemsize, fd)); + } + + file_descriptor_sink_impl::file_descriptor_sink_impl(size_t itemsize, int fd) + : gr_sync_block("file_descriptor_sink", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(0, 0, 0)), + d_itemsize(itemsize), d_fd(fd) + { + } + + file_descriptor_sink_impl::~file_descriptor_sink_impl() + { + close(d_fd); + } + + int + file_descriptor_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *inbuf = (char*)input_items[0]; + unsigned long byte_size = noutput_items * d_itemsize; + + while(byte_size > 0) { + ssize_t r; + + r = write(d_fd, inbuf, byte_size); + if(r == -1) { + if(errno == EINTR) + continue; + else { + perror("file_descriptor_sink"); + return -1; // indicate we're done + } + } + else { + byte_size -= r; + inbuf += r; + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/file_descriptor_sink_impl.h b/gr-blocks/lib/file_descriptor_sink_impl.h new file mode 100644 index 0000000000..90b02f4163 --- /dev/null +++ b/gr-blocks/lib/file_descriptor_sink_impl.h @@ -0,0 +1,49 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GR_FILE_DESCRIPTOR_SINK_IMPL_H +#define INCLUDED_GR_FILE_DESCRIPTOR_SINK_IMPL_H + +#include <blocks/file_descriptor_sink.h> + +namespace gr { + namespace blocks { + + class file_descriptor_sink_impl : public file_descriptor_sink + { + private: + size_t d_itemsize; + int d_fd; + + public: + file_descriptor_sink_impl(size_t itemsize, int fd); + ~file_descriptor_sink_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SINK_IMPL_H */ diff --git a/gr-blocks/lib/file_descriptor_source_impl.cc b/gr-blocks/lib/file_descriptor_source_impl.cc new file mode 100644 index 0000000000..667e96b7fa --- /dev/null +++ b/gr-blocks/lib/file_descriptor_source_impl.cc @@ -0,0 +1,156 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2005,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "file_descriptor_source_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <stdio.h> +#include <string.h> + +#ifdef HAVE_IO_H +#include <io.h> +#endif + +namespace gr { + namespace blocks { + + file_descriptor_source::sptr + file_descriptor_source::make(size_t itemsize, int fd, bool repeat) + { + return gnuradio::get_initial_sptr + (new file_descriptor_source_impl(itemsize, fd, repeat)); + } + + file_descriptor_source_impl::file_descriptor_source_impl(size_t itemsize, + int fd, + bool repeat) + : gr_sync_block("file_descriptor_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_fd(fd), d_repeat(repeat), + d_residue(new unsigned char[itemsize]), d_residue_len (0) + { + } + + file_descriptor_source_impl::~file_descriptor_source_impl() + { + close(d_fd); + delete [] d_residue; + } + + int + file_descriptor_source_impl::read_items(char *buf, int nitems) + { + assert(nitems > 0); + assert(d_residue_len < d_itemsize); + + int nbytes_read = 0; + + if(d_residue_len > 0) { + memcpy(buf, d_residue, d_residue_len); + nbytes_read = d_residue_len; + d_residue_len = 0; + } + + int r = read(d_fd, buf + nbytes_read, + nitems * d_itemsize - nbytes_read); + if(r <= 0) { + handle_residue(buf, nbytes_read); + return r; + } + + r = handle_residue(buf, r + nbytes_read); + + if(r == 0) // block until we get something + return read_items(buf, nitems); + + return r; + } + + int + file_descriptor_source_impl::handle_residue(char *buf, int nbytes_read) + { + assert(nbytes_read >= 0); + int nitems_read = nbytes_read / d_itemsize; + d_residue_len = nbytes_read % d_itemsize; + if(d_residue_len > 0) { + // fprintf (stderr, "handle_residue: %d\n", d_residue_len); + memcpy(d_residue, buf + nbytes_read - d_residue_len, d_residue_len); + } + return nitems_read; + } + + int + file_descriptor_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + assert(noutput_items > 0); + + char *o = (char*)output_items[0]; + int nread = 0; + + while(1) { + int r = read_items(o, noutput_items - nread); + if(r == -1) { + if(errno == EINTR) + continue; + else { + perror("file_descriptor_source[read]"); + return -1; + } + } + else if(r == 0) { // end of file + if(!d_repeat) + break; + else { + flush_residue(); + if(lseek(d_fd, 0, SEEK_SET) == -1) { + perror("file_descriptor_source[lseek]"); + return -1; + } + } + } + else { + o += r * d_itemsize; + nread += r; + break; + } + } + + if(nread == 0) // EOF + return -1; + + return nread; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/file_descriptor_source_impl.h b/gr-blocks/lib/file_descriptor_source_impl.h new file mode 100644 index 0000000000..dd86e18af1 --- /dev/null +++ b/gr-blocks/lib/file_descriptor_source_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_IMPL_H +#define INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_IMPL_H + +#include <blocks/file_descriptor_source.h> + +namespace gr { + namespace blocks { + + class file_descriptor_source_impl : public file_descriptor_source + { + private: + size_t d_itemsize; + int d_fd; + bool d_repeat; + + unsigned char *d_residue; + unsigned long d_residue_len; + + protected: + int read_items(char *buf, int nitems); + int handle_residue(char *buf, int nbytes_read); + void flush_residue() { d_residue_len = 0; } + + public: + file_descriptor_source_impl(size_t itemsize, int fd, bool repeat); + ~file_descriptor_source_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FILE_DESCRIPTOR_SOURCE_IMPL_H */ diff --git a/gr-blocks/lib/file_sink_base.cc b/gr-blocks/lib/file_sink_base.cc new file mode 100644 index 0000000000..47c8f9882b --- /dev/null +++ b/gr-blocks/lib/file_sink_base.cc @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2007,2009,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <blocks/file_sink_base.h> +#include <cstdio> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <stdio.h> +#include <gruel/thread.h> + +// win32 (mingw/msvc) specific +#ifdef HAVE_IO_H +#include <io.h> +#endif +#ifdef O_BINARY +#define OUR_O_BINARY O_BINARY +#else +#define OUR_O_BINARY 0 +#endif + +// should be handled via configure +#ifdef O_LARGEFILE +#define OUR_O_LARGEFILE O_LARGEFILE +#else +#define OUR_O_LARGEFILE 0 +#endif + +namespace gr { + namespace blocks { + + file_sink_base::file_sink_base(const char *filename, bool is_binary) + : d_fp(0), d_new_fp(0), d_updated(false), d_is_binary(is_binary) + { + if (!open(filename)) + throw std::runtime_error ("can't open file"); + } + + file_sink_base::~file_sink_base() + { + close(); + if(d_fp) { + fclose(d_fp); + d_fp = 0; + } + } + + bool + file_sink_base::open(const char *filename) + { + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function + + // we use the open system call to get access to the O_LARGEFILE flag. + int fd; + if((fd = ::open(filename, + O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY, + 0664)) < 0){ + perror(filename); + return false; + } + if(d_new_fp) { // if we've already got a new one open, close it + fclose(d_new_fp); + d_new_fp = 0; + } + + if((d_new_fp = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL) { + perror (filename); + ::close(fd); // don't leak file descriptor if fdopen fails. + } + + d_updated = true; + return d_new_fp != 0; + } + + void + file_sink_base::close() + { + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function + + if(d_new_fp) { + fclose(d_new_fp); + d_new_fp = 0; + } + d_updated = true; + } + + void + file_sink_base::do_update() + { + if(d_updated) { + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block + if(d_fp) + fclose(d_fp); + d_fp = d_new_fp; // install new file pointer + d_new_fp = 0; + d_updated = false; + } + } + + void + file_sink_base::set_unbuffered(bool unbuffered) + { + d_unbuffered = unbuffered; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/file_sink_impl.cc b/gr-blocks/lib/file_sink_impl.cc new file mode 100644 index 0000000000..88dcb5a021 --- /dev/null +++ b/gr-blocks/lib/file_sink_impl.cc @@ -0,0 +1,90 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006,2007,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "file_sink_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace blocks { + + file_sink::sptr + file_sink::make(size_t itemsize, const char *filename) + { + return gnuradio::get_initial_sptr + (new file_sink_impl(itemsize, filename)); + } + + file_sink_impl::file_sink_impl(size_t itemsize, const char *filename) + : gr_sync_block("file_sink", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(0, 0, 0)), + file_sink_base(filename, true), + d_itemsize(itemsize) + { + } + + file_sink_impl::~file_sink_impl() + { + } + + int + file_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *inbuf = (char*)input_items[0]; + int nwritten = 0; + + do_update(); // update d_fp is reqd + + if(!d_fp) + return noutput_items; // drop output on the floor + + while(nwritten < noutput_items) { + int count = fwrite(inbuf, d_itemsize, noutput_items - nwritten, d_fp); + if(count == 0) { + if(ferror(d_fp)) { + std::stringstream s; + s << "file_sink write failed with error " << fileno(d_fp) << std::endl; + throw std::runtime_error(s.str()); + } + else { // is EOF + break; + } + } + nwritten += count; + inbuf += count * d_itemsize; + } + + if(d_unbuffered) + fflush (d_fp); + + return nwritten; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/file_sink_impl.h b/gr-blocks/lib/file_sink_impl.h new file mode 100644 index 0000000000..8e802ad88a --- /dev/null +++ b/gr-blocks/lib/file_sink_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,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. + */ + +#ifndef INCLUDED_GR_FILE_SINK_IMPL_H +#define INCLUDED_GR_FILE_SINK_IMPL_H + +#include <blocks/file_sink.h> + +namespace gr { + namespace blocks { + + class file_sink_impl : public file_sink + { + private: + size_t d_itemsize; + + public: + file_sink_impl(size_t itemsize, const char *filename); + ~file_sink_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_FILE_SINK_IMPL_H */ diff --git a/gr-blocks/lib/gen_sine_table.py b/gr-blocks/lib/gen_sine_table.py new file mode 100755 index 0000000000..d7d11eff11 --- /dev/null +++ b/gr-blocks/lib/gen_sine_table.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# +# Copyright 2004 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. +# + +import math +import sys + +def wrap (x): + if x >= 2**31: + return x - 2**32 + return x + +def gen_approx_table (f, nentries, min_x, max_x): + """return a list of nentries containing tuples of the form: + (m, c, abs_error). min_x and max_x specify the domain + of the table. + """ + r = [] + incx = float (max_x - min_x) / nentries + for i in range (nentries): + a = (i * incx) + min_x + b = ((i + 1) * incx) + min_x + m = (f(b)-f(a))/(b-a) + c = (3*a+b)*(f(a)-f(b))/(4*(b-a)) + (f((a+b)/2) + f(a))/2 + abs_error = c+m*a-f(a) + r.append ((m, c, abs_error)) + return r + +def scaled_sine (x): + return math.sin (x * math.pi / 2**31) + +def gen_sine_table (): + nbits = 10 + nentries = 2**nbits + + # min_x = -2**31 + # max_x = 2**31-1 + min_x = 0 + max_x = 2**32-1 + t = gen_approx_table (scaled_sine, nentries, min_x, max_x) + + max_error = 0 + for e in t: + max_error = max (max_error, abs (e[2])) + + # sys.stdout.write ('static const int WORDBITS = 32;\n') + # sys.stdout.write ('static const int NBITS = %d;\n' % (nbits,)) + + sys.stdout.write (' // max_error = %22.15e\n' % (max_error,)) + + # sys.stdout.write ('static const double sine_table[%d][2] = {\n'% (nentries,)) + + for e in t: + sys.stdout.write (' { %22.15e, %22.15e },\n' % (2 * e[0], e[1])) + + # sys.stdout.write ('};\n') + +if __name__ == '__main__': + gen_sine_table () diff --git a/gr-blocks/lib/gnuradio-blocks.rc.in b/gr-blocks/lib/gnuradio-blocks.rc.in new file mode 100644 index 0000000000..126db75091 --- /dev/null +++ b/gr-blocks/lib/gnuradio-blocks.rc.in @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-blocks" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-blocks.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-blocks.dll" + VALUE "ProductName", "gnuradio-blocks" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-blocks/lib/head_impl.cc b/gr-blocks/lib/head_impl.cc new file mode 100644 index 0000000000..7dfa36607c --- /dev/null +++ b/gr-blocks/lib/head_impl.cc @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2009,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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "head_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + head::sptr + head::make(size_t sizeof_stream_item, uint64_t nitems) + { + return gnuradio::get_initial_sptr + (new head_impl(sizeof_stream_item, nitems)); + } + + head_impl::head_impl(size_t sizeof_stream_item, uint64_t nitems) + : gr_sync_block("head", + gr_make_io_signature(1, 1, sizeof_stream_item), + gr_make_io_signature(1, 1, sizeof_stream_item)), + d_nitems(nitems), d_ncopied_items(0) + { + } + + head_impl::~head_impl() + { + } + + int + head_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + if(d_ncopied_items >= d_nitems) + return -1; // Done! + + unsigned n = std::min(d_nitems - d_ncopied_items, + (uint64_t)noutput_items); + + if(n == 0) + return 0; + + memcpy(output_items[0], input_items[0], + n * input_signature()->sizeof_stream_item (0)); + d_ncopied_items += n; + + return n; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/head_impl.h b/gr-blocks/lib/head_impl.h new file mode 100644 index 0000000000..a56acfbb27 --- /dev/null +++ b/gr-blocks/lib/head_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2009,2012,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. + */ + +#ifndef INCLUDED_GR_HEAD_IMPL_H +#define INCLUDED_GR_HEAD_IMPL_H + +#include <blocks/head.h> + +namespace gr { + namespace blocks { + + class head_impl : public head + { + private: + uint64_t d_nitems; + uint64_t d_ncopied_items; + + public: + head_impl(size_t sizeof_stream_item, uint64_t nitems); + ~head_impl(); + + void reset() { d_ncopied_items = 0; } + void set_length(int nitems) { d_nitems = nitems; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_HEAD_IMPL_H */ diff --git a/gr-blocks/lib/lfsr_32k_source_s_impl.cc b/gr-blocks/lib/lfsr_32k_source_s_impl.cc new file mode 100644 index 0000000000..738e732b49 --- /dev/null +++ b/gr-blocks/lib/lfsr_32k_source_s_impl.cc @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "lfsr_32k_source_s_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace blocks { + + lfsr_32k_source_s::sptr + lfsr_32k_source_s::make() + { + return gnuradio::get_initial_sptr + (new lfsr_32k_source_s_impl()); + } + + lfsr_32k_source_s_impl::lfsr_32k_source_s_impl() + : gr_sync_block("lfsr_32k_source_s", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof(short))), + d_index(0) + { + lfsr_32k lfsr; + + for(int i = 0; i < BUFSIZE; i++) + d_buffer[i] = lfsr.next_short(); + } + + lfsr_32k_source_s_impl::~lfsr_32k_source_s_impl() + { + } + + int + lfsr_32k_source_s_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + short *out = (short*)output_items[0]; + short *buf = d_buffer; + int index = d_index; + + for(int i = 0; i < noutput_items; i++) { + out[i] = buf[index]; + // index = (index + 1) & (BUFSIZE - 1); + index = index + 1; + if(index >= BUFSIZE) + index = 0; + } + + d_index = index; + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/lfsr_32k_source_s_impl.h b/gr-blocks/lib/lfsr_32k_source_s_impl.h new file mode 100644 index 0000000000..b8c684e8d6 --- /dev/null +++ b/gr-blocks/lib/lfsr_32k_source_s_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +#ifndef INCLUDED_GR_LFSR_32K_SOURCE_S_IMPL_H +#define INCLUDED_GR_LFSR_32K_SOURCE_S_IMPL_H + +#include <blocks/lfsr_32k_source_s.h> +#include <blocks/lfsr_32k.h> +#include <gr_sync_block.h> + +namespace gr { + namespace blocks { + + class lfsr_32k_source_s_impl : public lfsr_32k_source_s + { + private: + static const int BUFSIZE = 2048 - 1; // ensure pattern isn't packet aligned + int d_index; + short d_buffer[BUFSIZE]; + + public: + lfsr_32k_source_s_impl(); + ~lfsr_32k_source_s_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_LFSR_32K_SOURCE_S_IMPL_H */ diff --git a/gr-blocks/lib/max_XX_impl.cc.t b/gr-blocks/lib/max_XX_impl.cc.t new file mode 100644 index 0000000000..669e2fd30d --- /dev/null +++ b/gr-blocks/lib/max_XX_impl.cc.t @@ -0,0 +1,81 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007 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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(size_t vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t vlen) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, -1, vlen*sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; + + int ninputs = input_items.size(); + + for(int i = 0; i < noutput_items; i++) { + @I_TYPE@ max = ((@I_TYPE@ *)input_items[0])[i*d_vlen]; + + for(int j = 0; j < (int)d_vlen; j++ ) { + for(int k = 0; k < ninputs; k++) { + if(((@I_TYPE@ *)input_items[k])[i*d_vlen + j] > max) { + max = ((@I_TYPE@*)input_items[k])[i*d_vlen + j]; + } + } + } + + *optr++ = (@O_TYPE@)max; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/max_XX_impl.h.t b/gr-blocks/lib/max_XX_impl.h.t new file mode 100644 index 0000000000..0f1643f6b9 --- /dev/null +++ b/gr-blocks/lib/max_XX_impl.h.t @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + size_t d_vlen; + + public: + @NAME_IMPL@(size_t vlen); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/message_burst_source_impl.cc b/gr-blocks/lib/message_burst_source_impl.cc new file mode 100644 index 0000000000..f3c90eda31 --- /dev/null +++ b/gr-blocks/lib/message_burst_source_impl.cc @@ -0,0 +1,149 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_burst_source_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> +#include <gr_tags.h> + +namespace gr { + namespace blocks { + + message_burst_source::sptr + message_burst_source::make(size_t itemsize, int msgq_limit) + { + return gnuradio::get_initial_sptr + (new message_burst_source_impl(itemsize, msgq_limit)); + } + + message_burst_source::sptr + message_burst_source::make(size_t itemsize, gr_msg_queue_sptr msgq) + { + return gnuradio::get_initial_sptr + (new message_burst_source_impl(itemsize, msgq)); + } + + message_burst_source_impl::message_burst_source_impl(size_t itemsize, int msgq_limit) + : gr_sync_block("message_burst_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), + d_msg_offset(0), d_eof(false) + { + std::stringstream id; + id << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(id.str()); + } + + message_burst_source_impl::message_burst_source_impl(size_t itemsize, gr_msg_queue_sptr msgq) + : gr_sync_block("message_burst_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(msgq), + d_msg_offset(0), d_eof(false) + { + std::stringstream id; + id << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(id.str()); + } + + message_burst_source_impl::~message_burst_source_impl() + { + } + + int + message_burst_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *out = (char*)output_items[0]; + int nn = 0; + + uint64_t abs_sample_count = nitems_written(0); + + while(nn < noutput_items) { + if(d_msg) { + // + // Consume whatever we can from the current message + // + + int mm = std::min(noutput_items - nn, + (int)((d_msg->length() - d_msg_offset) / d_itemsize)); + memcpy(out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize); + + nn += mm; + out += mm * d_itemsize; + d_msg_offset += mm * d_itemsize; + assert(d_msg_offset <= d_msg->length()); + + if(d_msg_offset == d_msg->length()) { + if(d_msg->type() == 1) // type == 1 sets EOF + d_eof = true; + d_msg.reset(); + //tag end of burst + add_item_tag(0, //stream ID + abs_sample_count+nn-1, //sample number + pmt::pmt_string_to_symbol("tx_eob"), + pmt::pmt_from_bool(1), + d_me); //block src id + } + } + else { + // + // No current message + // + if(d_msgq->empty_p() && nn > 0) { // no more messages in the queue, return what we've got + break; + } + + if(d_eof) + return -1; + + d_msg = d_msgq->delete_head(); // block, waiting for a message + d_msg_offset = 0; + //tag start of burst + add_item_tag(0, //stream ID + abs_sample_count+nn, //sample number + pmt::pmt_string_to_symbol("tx_sob"), + pmt::pmt_from_bool(1), + d_me); //block src id + + if((d_msg->length() % d_itemsize) != 0) + throw std::runtime_error("msg length is not a multiple of d_itemsize"); + } + } + + return nn; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/message_burst_source_impl.h b/gr-blocks/lib/message_burst_source_impl.h new file mode 100644 index 0000000000..2d5e6a974f --- /dev/null +++ b/gr-blocks/lib/message_burst_source_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H +#define INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H + +#include <blocks/message_burst_source.h> +#include <gr_message.h> + +namespace gr { + namespace blocks { + + class message_burst_source_impl : public message_burst_source + { + private: + size_t d_itemsize; + gr_msg_queue_sptr d_msgq; + gr_message_sptr d_msg; + unsigned d_msg_offset; + bool d_eof; + + pmt::pmt_t d_me; + + public: + message_burst_source_impl(size_t itemsize, int msgq_limit); + message_burst_source_impl(size_t itemsize, gr_msg_queue_sptr msgq); + ~message_burst_source_impl(); + + gr_msg_queue_sptr msgq() const { return d_msgq; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_BURST_SOURCE_IMPL_H */ diff --git a/gr-blocks/lib/message_debug_impl.cc b/gr-blocks/lib/message_debug_impl.cc new file mode 100644 index 0000000000..d7b1e5db09 --- /dev/null +++ b/gr-blocks/lib/message_debug_impl.cc @@ -0,0 +1,120 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2012-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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_debug_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <iostream> + +namespace gr { + namespace blocks { + + message_debug::sptr + message_debug::make() + { + return gnuradio::get_initial_sptr + (new message_debug_impl()); + } + + void + message_debug_impl::print(pmt::pmt_t msg) + { + std::cout << "******* MESSAGE DEBUG PRINT ********\n"; + pmt::pmt_print(msg); + std::cout << "************************************\n"; + } + + void + message_debug_impl::store(pmt::pmt_t msg) + { + gruel::scoped_lock guard(d_mutex); + d_messages.push_back(msg); + } + + void + message_debug_impl::print_pdu(pmt::pmt_t pdu) + { + pmt::pmt_t meta = pmt::pmt_car(pdu); + pmt::pmt_t vector = pmt::pmt_cdr(pdu); + std::cout << "* MESSAGE DEBUG PRINT PDU VERBOSE *\n"; + pmt::pmt_print(meta); + size_t len = pmt::pmt_length(vector); + std::cout << "pdu_length = " << len << std::endl; + std::cout << "contents = " << std::endl; + size_t offset(0); + const uint8_t* d = (const uint8_t*) pmt_uniform_vector_elements(vector, offset); + for(size_t i=0; i<len; i+=16){ + printf("%04x: ", ((unsigned int)i)); + for(size_t j=i; j<std::min(i+16,len); j++){ + printf("%02x ",d[j] ); + } + + std::cout << std::endl; + } + + std::cout << "***********************************\n"; + } + + int + message_debug_impl::num_messages() + { + return (int)d_messages.size(); + } + + pmt::pmt_t + message_debug_impl::get_message(int i) + { + gruel::scoped_lock guard(d_mutex); + + if((size_t)i >= d_messages.size()) { + throw std::runtime_error("message_debug: index for message out of bounds.\n"); + } + + return d_messages[i]; + } + + message_debug_impl::message_debug_impl() + : gr_block("message_debug", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(0, 0, 0)) + { + message_port_register_in(pmt::mp("print")); + set_msg_handler(pmt::mp("print"), boost::bind(&message_debug_impl::print, this, _1)); + + message_port_register_in(pmt::mp("store")); + set_msg_handler(pmt::mp("store"), boost::bind(&message_debug_impl::store, this, _1)); + + message_port_register_in(pmt::mp("print_pdu")); + set_msg_handler(pmt::mp("print_pdu"), boost::bind(&message_debug_impl::print_pdu, this, _1)); + } + + message_debug_impl::~message_debug_impl() + { + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/message_debug_impl.h b/gr-blocks/lib/message_debug_impl.h new file mode 100644 index 0000000000..c9d82bd561 --- /dev/null +++ b/gr-blocks/lib/message_debug_impl.h @@ -0,0 +1,89 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-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. + */ + +#ifndef INCLUDED_GR_MESSAGE_DEBUG_IMPL_H +#define INCLUDED_GR_MESSAGE_DEBUG_IMPL_H + +#include <blocks/message_debug.h> +#include <gr_block.h> +#include <gruel/thread.h> +#include <gruel/pmt.h> + +namespace gr { + namespace blocks { + + class message_debug_impl : public message_debug + { + private: + + /*! + * \brief Messages received in this port are printed to stdout. + * + * This port receives messages from the scheduler's message + * handling mechanism and prints it to stdout. This message + * handler function is only meant to be used by the scheduler to + * handle messages posted to port 'print'. + * + * \param msg A pmt message passed from the scheduler's message handling. + */ + void print(pmt::pmt_t msg); + + /*! + * \brief PDU formatted messages received in this port are printed to stdout. + * + * This port receives messages from the scheduler's message + * handling mechanism and prints it to stdout. This message + * handler function is only meant to be used by the scheduler to + * handle messages posted to port 'print'. + * + * \param pdu A PDU message passed from the scheduler's message handling. + */ + void print_pdu(pmt::pmt_t pdu); + + /*! + * \brief Messages received in this port are stored in a vector. + * + * This port receives messages from the scheduler's message + * handling mechanism and stores it in a vector. Messages can be + * retrieved later using the 'get_message' function. This + * message handler function is only meant to be used by the + * scheduler to handle messages posted to port 'store'. + * + * \param msg A pmt message passed from the scheduler's message handling. + */ + void store(pmt::pmt_t msg); + + gruel::mutex d_mutex; + std::vector<pmt::pmt_t> d_messages; + + public: + message_debug_impl(); + ~message_debug_impl(); + + int num_messages(); + pmt::pmt_t get_message(int i); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_DEBUG_IMPL_H */ diff --git a/gr-blocks/lib/message_sink_impl.cc b/gr-blocks/lib/message_sink_impl.cc new file mode 100644 index 0000000000..a8dbfb4c71 --- /dev/null +++ b/gr-blocks/lib/message_sink_impl.cc @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_sink_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> + +namespace gr { + namespace blocks { + + message_sink::sptr + message_sink::make(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) + { + return gnuradio::get_initial_sptr + (new message_sink_impl(itemsize, msgq, dont_block)); + } + + message_sink_impl::message_sink_impl(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) + : gr_sync_block("message_sink", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(0, 0, 0)), + d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block) + { + } + + message_sink_impl::~message_sink_impl() + { + } + + int + message_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char*)input_items[0]; + + // if we'd block, drop the data on the floor and say everything is OK + if(d_dont_block && d_msgq->full_p()) + return noutput_items; + + // build a message to hold whatever we've got + gr_message_sptr msg = gr_make_message(0, // msg type + d_itemsize, // arg1 for other end + noutput_items, // arg2 for other end (redundant) + noutput_items * d_itemsize); // len of msg + memcpy(msg->msg(), in, noutput_items * d_itemsize); + + d_msgq->handle(msg); // send it + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/message_sink_impl.h b/gr-blocks/lib/message_sink_impl.h new file mode 100644 index 0000000000..a3106bc058 --- /dev/null +++ b/gr-blocks/lib/message_sink_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_MESSAGE_SINK_IMPL_H +#define INCLUDED_GR_MESSAGE_SINK_IMPL_H + +#include <blocks/message_sink.h> + +namespace gr { + namespace blocks { + + class message_sink_impl : public message_sink + { + private: + size_t d_itemsize; + gr_msg_queue_sptr d_msgq; + bool d_dont_block; + + public: + message_sink_impl(size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block); + ~message_sink_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_SINK_IMPL_H */ diff --git a/gr-blocks/lib/message_source_impl.cc b/gr-blocks/lib/message_source_impl.cc new file mode 100644 index 0000000000..cda4fc16c0 --- /dev/null +++ b/gr-blocks/lib/message_source_impl.cc @@ -0,0 +1,127 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_source_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> + +namespace gr { + namespace blocks { + + message_source::sptr + message_source::make(size_t itemsize, int msgq_limit) + { + return gnuradio::get_initial_sptr + (new message_source_impl(itemsize, msgq_limit)); + } + + message_source::sptr + message_source::make(size_t itemsize, gr_msg_queue_sptr msgq) + { + return gnuradio::get_initial_sptr + (new message_source_impl(itemsize, msgq)); + } + + message_source_impl::message_source_impl(size_t itemsize, int msgq_limit) + : gr_sync_block("message_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), + d_msg_offset(0), d_eof(false) + { + } + + message_source_impl::message_source_impl(size_t itemsize, gr_msg_queue_sptr msgq) + : gr_sync_block("message_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(msgq), + d_msg_offset(0), d_eof(false) + { + } + + message_source_impl::~message_source_impl() + { + } + + int + message_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *out = (char*)output_items[0]; + int nn = 0; + + while(nn < noutput_items) { + if(d_msg) { + // + // Consume whatever we can from the current message + // + int mm = std::min(noutput_items - nn, + (int)((d_msg->length() - d_msg_offset) / d_itemsize)); + memcpy(out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize); + + nn += mm; + out += mm * d_itemsize; + d_msg_offset += mm * d_itemsize; + assert(d_msg_offset <= d_msg->length()); + + if(d_msg_offset == d_msg->length()) { + if(d_msg->type() == 1) // type == 1 sets EOF + d_eof = true; + d_msg.reset(); + } + } + else { + // + // No current message + // + if(d_msgq->empty_p() && nn > 0) { // no more messages in the queue, return what we've got + break; + } + + if(d_eof) + return -1; + + d_msg = d_msgq->delete_head(); // block, waiting for a message + d_msg_offset = 0; + + if((d_msg->length() % d_itemsize) != 0) + throw std::runtime_error("msg length is not a multiple of d_itemsize"); + } + } + + return nn; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/message_source_impl.h b/gr-blocks/lib/message_source_impl.h new file mode 100644 index 0000000000..c420704478 --- /dev/null +++ b/gr-blocks/lib/message_source_impl.h @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_MESSAGE_SOURCE_IMPL_H +#define INCLUDED_GR_MESSAGE_SOURCE_IMPL_H + +#include <blocks/message_source.h> +#include <gr_message.h> + +namespace gr { + namespace blocks { + + class message_source_impl : public message_source + { + private: + size_t d_itemsize; + gr_msg_queue_sptr d_msgq; + gr_message_sptr d_msg; + unsigned d_msg_offset; + bool d_eof; + + public: + message_source_impl(size_t itemsize, int msgq_limit); + message_source_impl(size_t itemsize, gr_msg_queue_sptr msgq); + ~message_source_impl(); + + gr_msg_queue_sptr msgq() const { return d_msgq; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_SOURCE_IMPL_H */ diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc new file mode 100644 index 0000000000..c4b0e5d567 --- /dev/null +++ b/gr-blocks/lib/message_strobe_impl.cc @@ -0,0 +1,85 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "message_strobe_impl.h" +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> +#include <iostream> + +namespace gr { + namespace blocks { + + message_strobe::sptr + message_strobe::make(pmt::pmt_t msg, float period_ms) + { + return gnuradio::get_initial_sptr + (new message_strobe_impl(msg, period_ms)); + } + + message_strobe_impl::message_strobe_impl(pmt::pmt_t msg, float period_ms) + : gr_block("message_strobe", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(0, 0, 0)), + d_finished(false), + d_period_ms(period_ms), + d_msg(msg) + { + message_port_register_out(pmt::mp("strobe")); + d_thread = boost::shared_ptr<boost::thread> + (new boost::thread(boost::bind(&message_strobe_impl::run, this))); + + message_port_register_in(pmt::mp("set_msg")); + set_msg_handler(pmt::mp("set_msg"), + boost::bind(&message_strobe_impl::set_msg, this, _1)); + } + + message_strobe_impl::~message_strobe_impl() + { + d_finished = true; + d_thread->interrupt(); + d_thread->join(); + } + + void message_strobe_impl::run() + { + while(!d_finished) { + boost::this_thread::sleep(boost::posix_time::milliseconds(d_period_ms)); + if(d_finished) { + return; + } + + message_port_pub(pmt::mp("strobe"), d_msg); + } + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/message_strobe_impl.h b/gr-blocks/lib/message_strobe_impl.h new file mode 100644 index 0000000000..1b2edae593 --- /dev/null +++ b/gr-blocks/lib/message_strobe_impl.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_GR_MESSAGE_STROBE_IMPL_H +#define INCLUDED_GR_MESSAGE_STROBE_IMPL_H + +#include <blocks/message_strobe.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API message_strobe_impl : public message_strobe + { + private: + boost::shared_ptr<boost::thread> d_thread; + bool d_finished; + float d_period_ms; + pmt::pmt_t d_msg; + + void run(); + + public: + message_strobe_impl(pmt::pmt_t msg, float period_ms); + ~message_strobe_impl(); + + void set_msg(pmt::pmt_t msg) { d_msg = msg; } + pmt::pmt_t msg() const { return d_msg; } + void set_period(float period_ms) { d_period_ms = period_ms; } + float period() const { return d_period_ms; } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_MESSAGE_STROBE_IMPL_H */ diff --git a/gr-blocks/lib/moving_average_XX_impl.cc.t b/gr-blocks/lib/moving_average_XX_impl.cc.t new file mode 100644 index 0000000000..566deff116 --- /dev/null +++ b/gr-blocks/lib/moving_average_XX_impl.cc.t @@ -0,0 +1,114 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2010,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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "@NAME_IMPL@.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(int length, @O_TYPE@ scale, int max_iter) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(length, scale, max_iter)); + } + + @NAME_IMPL@::@NAME_IMPL@(int length, @O_TYPE@ scale, int max_iter) + : gr_sync_block("@NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_length(length), + d_scale(scale), + d_max_iter(max_iter), + d_new_length(length), + d_new_scale(scale), + d_updated(false) + { + set_history(length); + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + void + @NAME_IMPL@::set_length_and_scale(int length, @O_TYPE@ scale) + { + d_new_length = length; + d_new_scale = scale; + d_updated = true; + } + + void + @NAME_IMPL@::set_length(int length) + { + d_new_length = length; + d_updated = true; + } + + void + @NAME_IMPL@::set_scale(@O_TYPE@ scale) + { + d_new_scale = scale; + d_updated = true; + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + if(d_updated) { + d_length = d_new_length; + d_scale = d_new_scale; + set_history(d_length); + d_updated = false; + return 0; // history requirements might have changed + } + + const @I_TYPE@ *in = (const @I_TYPE@ *)input_items[0]; + @O_TYPE@ *out = (@O_TYPE@ *)output_items[0]; + + @I_TYPE@ sum = 0; + int num_iter = (noutput_items>d_max_iter) ? d_max_iter : noutput_items; + for(int i = 0; i < d_length-1; i++) { + sum += in[i]; + } + + for(int i = 0; i < num_iter; i++) { + sum += in[i+d_length-1]; + out[i] = sum * d_scale; + sum -= in[i]; + } + + return num_iter; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/moving_average_XX_impl.h.t b/gr-blocks/lib/moving_average_XX_impl.h.t new file mode 100644 index 0000000000..7234cbe139 --- /dev/null +++ b/gr-blocks/lib/moving_average_XX_impl.h.t @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + int d_length; + @O_TYPE@ d_scale; + int d_max_iter; + + int d_new_length; + @O_TYPE@ d_new_scale; + bool d_updated; + + public: + @NAME_IMPL@(int length, @O_TYPE@ scale, + int max_iter = 4096); + ~@NAME_IMPL@(); + + int length() const { return d_new_length; } + @O_TYPE@ scale() const { return d_new_scale; } + + void set_length_and_scale(int length, @O_TYPE@ scale); + void set_length(int length); + void set_scale(@O_TYPE@ scale); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/mute_XX_impl.cc.t b/gr-blocks/lib/mute_XX_impl.cc.t new file mode 100644 index 0000000000..b29e9edada --- /dev/null +++ b/gr-blocks/lib/mute_XX_impl.cc.t @@ -0,0 +1,89 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(bool mute) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(mute)); + } + + @NAME_IMPL@::@NAME_IMPL@(bool mute) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_mute(mute) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0]; + @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; + + int size = noutput_items; + + if(d_mute) { + memset(optr, 0, noutput_items * sizeof(@O_TYPE@)); + } + else { + while(size >= 8) { + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + *optr++ = *iptr++; + size -= 8; + } + + while(size-- > 0) + *optr++ = *iptr++; + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/mute_XX_impl.h.t b/gr-blocks/lib/mute_XX_impl.h.t new file mode 100644 index 0000000000..de93c8eb82 --- /dev/null +++ b/gr-blocks/lib/mute_XX_impl.h.t @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + bool d_mute; + + public: + @NAME_IMPL@(bool mute); + ~@NAME_IMPL@(); + + bool mute() const { return d_mute; } + void set_mute(bool mute) { d_mute = mute; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/nop_impl.cc b/gr-blocks/lib/nop_impl.cc new file mode 100644 index 0000000000..766f07e2b8 --- /dev/null +++ b/gr-blocks/lib/nop_impl.cc @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "nop_impl.h" +#include <gr_io_signature.h> +#include <boost/bind.hpp> + +namespace gr { + namespace blocks { + + nop::sptr + nop::make(size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new nop_impl(sizeof_stream_item)); + } + + nop_impl::nop_impl (size_t sizeof_stream_item) + : gr_block("nop", + gr_make_io_signature(0, -1, sizeof_stream_item), + gr_make_io_signature(0, -1, sizeof_stream_item)), + d_nmsgs_recvd(0) + { + // Arrange to have count_received_msgs called when messages are received. + message_port_register_in(pmt::mp("port")); + set_msg_handler(pmt::mp("port"), boost::bind(&nop_impl::count_received_msgs, this, _1)); + } + + nop_impl::~nop_impl() + { + } + + // Trivial message handler that just counts them. + // (N.B., This feature is used in qa_set_msg_handler) + void + nop_impl::count_received_msgs(pmt::pmt_t msg) + { + d_nmsgs_recvd++; + } + + int + nop_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + // eat any input that's available + for(unsigned i = 0; i < ninput_items.size (); i++) + consume(i, ninput_items[i]); + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/nop_impl.h b/gr-blocks/lib/nop_impl.h new file mode 100644 index 0000000000..b236abb7aa --- /dev/null +++ b/gr-blocks/lib/nop_impl.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifndef INCLUDED_GR_NOP_IMPL_H +#define INCLUDED_GR_NOP_IMPL_H + +#include <blocks/nop.h> + +namespace gr { + namespace blocks { + + class nop_impl : public nop + { + protected: + int d_nmsgs_recvd; + + // Method that just counts any received messages. + void count_received_msgs(pmt::pmt_t msg); + + public: + nop_impl(size_t sizeof_stream_item); + ~nop_impl(); + + int nmsgs_received() const { return d_nmsgs_recvd; } + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_NOP_IMPL_H */ diff --git a/gr-blocks/lib/null_sink_impl.cc b/gr-blocks/lib/null_sink_impl.cc new file mode 100644 index 0000000000..b780a2405a --- /dev/null +++ b/gr-blocks/lib/null_sink_impl.cc @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "null_sink_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + null_sink::sptr + null_sink::make(size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new null_sink_impl(sizeof_stream_item)); + } + + null_sink_impl::null_sink_impl(size_t sizeof_stream_item) + : gr_sync_block("null_sink", + gr_make_io_signature(1, 1, sizeof_stream_item), + gr_make_io_signature(0, 0, 0)) + { + } + + null_sink_impl::~null_sink_impl() + { + } + + int + null_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/null_sink_impl.h b/gr-blocks/lib/null_sink_impl.h new file mode 100644 index 0000000000..bb4c695c23 --- /dev/null +++ b/gr-blocks/lib/null_sink_impl.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifndef INCLUDED_GR_NULL_SINK_IMPL_H +#define INCLUDED_GR_NULL_SINK_IMPL_H + +#include <blocks/null_sink.h> + +namespace gr { + namespace blocks { + + class null_sink_impl : public null_sink + { + public: + null_sink_impl(size_t sizeof_stream_item); + ~null_sink_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_NULL_SINK_IMPL_H */ diff --git a/gr-blocks/lib/null_source_impl.cc b/gr-blocks/lib/null_source_impl.cc new file mode 100644 index 0000000000..81999d0501 --- /dev/null +++ b/gr-blocks/lib/null_source_impl.cc @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "null_source_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + null_source::sptr + null_source::make(size_t sizeof_stream_item) + { + return gnuradio::get_initial_sptr + (new null_source_impl(sizeof_stream_item)); + } + + null_source_impl::null_source_impl (size_t sizeof_stream_item) + : gr_sync_block("null_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof_stream_item)) + { + } + + null_source_impl::~null_source_impl() + { + } + + int + null_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + void *optr = (void*)output_items[0]; + memset(optr, 0, noutput_items * output_signature()->sizeof_stream_item(0)); + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/null_source_impl.h b/gr-blocks/lib/null_source_impl.h new file mode 100644 index 0000000000..36201d54b6 --- /dev/null +++ b/gr-blocks/lib/null_source_impl.h @@ -0,0 +1,45 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2010,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. + */ + +#ifndef INCLUDED_GR_NULL_SOURCE_IMPL_H +#define INCLUDED_GR_NULL_SOURCE_IMPL_H + +#include <blocks/null_source.h> + +namespace gr { + namespace blocks { + + class null_source_impl : public null_source + { + public: + null_source_impl(size_t sizeof_stream_item); + ~null_source_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_NULL_SOURCE_IMPL_H */ diff --git a/gr-blocks/lib/pack_k_bits_bb_impl.cc b/gr-blocks/lib/pack_k_bits_bb_impl.cc new file mode 100644 index 0000000000..2a7fcc04cb --- /dev/null +++ b/gr-blocks/lib/pack_k_bits_bb_impl.cc @@ -0,0 +1,76 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "pack_k_bits_bb_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <iostream> + +namespace gr { + namespace blocks { + + pack_k_bits_bb::sptr + pack_k_bits_bb::make(unsigned k) + { + return gnuradio::get_initial_sptr + (new pack_k_bits_bb_impl(k)); + } + + pack_k_bits_bb_impl::pack_k_bits_bb_impl(unsigned k) + : gr_sync_decimator("pack_k_bits_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char)), + k), + d_k(k) + { + if(d_k == 0) + throw std::out_of_range("interpolation must be > 0"); + } + + pack_k_bits_bb_impl::~pack_k_bits_bb_impl() + { + } + + int + pack_k_bits_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *)input_items[0]; + unsigned char *out = (unsigned char *)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + out[i] = 0x00; + for(unsigned int j = 0; j < d_k; j++) { + out[i] |= (0x01 & in[i*d_k+j])<<(d_k-j-1); + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/pack_k_bits_bb_impl.h b/gr-blocks/lib/pack_k_bits_bb_impl.h new file mode 100644 index 0000000000..668d438a46 --- /dev/null +++ b/gr-blocks/lib/pack_k_bits_bb_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_GR_PACK_K_BITS_BB_IMPL_H +#define INCLUDED_GR_PACK_K_BITS_BB_IMPL_H + +#include <blocks/pack_k_bits_bb.h> + +namespace gr { + namespace blocks { + + class pack_k_bits_bb_impl : public pack_k_bits_bb + { + private: + unsigned d_k; // number of relevent bits to pack from k input bytes + + public: + pack_k_bits_bb_impl(unsigned k); + ~pack_k_bits_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_PACK_K_BITS_BB_IMPL_H */ diff --git a/gr-blocks/lib/pdu.cc b/gr-blocks/lib/pdu.cc new file mode 100644 index 0000000000..41a2d88c3a --- /dev/null +++ b/gr-blocks/lib/pdu.cc @@ -0,0 +1,92 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <blocks/pdu.h> + +namespace gr { + namespace blocks { + namespace pdu { + + size_t + itemsize(vector_type type) + { + switch(type) { + case byte_t: + return sizeof(char); + case float_t: + return sizeof(float); + case complex_t: + return sizeof(gr_complex); + default: + throw std::runtime_error("bad PDU type"); + } + } + + bool + type_matches(vector_type type, pmt::pmt_t v) + { + switch(type) { + case byte_t: + return pmt::pmt_is_u8vector(v); + case float_t: + return pmt::pmt_is_f32vector(v); + case complex_t: + return pmt::pmt_is_c32vector(v); + default: + throw std::runtime_error("bad PDU type"); + } + } + + pmt::pmt_t + make_vector(vector_type type, const uint8_t *buf, size_t items) + { + switch(type) { + case byte_t: + return pmt::pmt_init_u8vector(items, buf); + case float_t: + return pmt::pmt_init_f32vector(items, (const float *)buf); + case complex_t: + return pmt::pmt_init_c32vector(items, (const gr_complex *)buf); + default: + throw std::runtime_error("bad PDU type"); + } + } + + vector_type + type_from_pmt(pmt::pmt_t vector) + { + if(pmt_is_u8vector(vector)) + return byte_t; + if(pmt_is_f32vector(vector)) + return float_t; + if(pmt_is_c32vector(vector)) + return complex_t; + throw std::runtime_error("bad PDU type"); + } + + } /* namespace pdu */ + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc new file mode 100644 index 0000000000..80785b4781 --- /dev/null +++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc @@ -0,0 +1,120 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "pdu_to_tagged_stream_impl.h" +#include <blocks/pdu.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + pdu_to_tagged_stream::sptr + pdu_to_tagged_stream::make(pdu::vector_type type) + { + return gnuradio::get_initial_sptr(new pdu_to_tagged_stream_impl(type)); + } + + pdu_to_tagged_stream_impl::pdu_to_tagged_stream_impl(pdu::vector_type type) + : gr_sync_block("pdu_to_tagged_stream", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, pdu::itemsize(type))), + d_itemsize(pdu::itemsize(type)), + d_type(type) + { + message_port_register_in(PDU_PORT_ID); + } + + int + pdu_to_tagged_stream_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *out = (char *)output_items[0]; + int nout = 0; + + // if we have remaining output, send it + if (d_remain.size() > 0) { + nout = std::min((size_t)d_remain.size()/d_itemsize, (size_t)noutput_items); + memcpy(out, &d_remain[0], nout*d_itemsize); + d_remain.erase(d_remain.begin(), d_remain.begin()+nout); + noutput_items -= nout; + out += nout*d_itemsize; + } + + // if we have space for at least one item output as much as we can + if (noutput_items > 0) { + + // grab a message if one exists + pmt::pmt_t msg(delete_head_blocking(PDU_PORT_ID)); + if (msg.get() == NULL) + return nout; + + // make sure type is valid + if (!pmt::pmt_is_pair(msg)) // TODO: implement pdu::is_valid() + throw std::runtime_error("received a malformed pdu message"); + + // grab the components of the pdu message + pmt::pmt_t meta(pmt::pmt_car(msg)); + pmt::pmt_t vect(pmt::pmt_cdr(msg)); + + // compute offset for output tag + uint64_t offset = nitems_written(0) + nout; + + // add a tag for pdu length + add_item_tag(0, offset, PDU_LENGTH_TAG, pmt::pmt_from_long(pmt::pmt_length(vect)), pmt::mp(alias())); + + // if we recieved metadata add it as tags + if (!pmt_eq(meta, pmt::PMT_NIL) ) { + pmt::pmt_t pair(pmt::pmt_dict_keys(meta)); + + while (!pmt_eq(pair, pmt::PMT_NIL) ) { + pmt::pmt_t k(pmt::pmt_cdr(pair)); + pmt::pmt_t v(pmt::pmt_dict_ref(meta, k, pmt::PMT_NIL)); + add_item_tag(0, offset, k, v, pmt::mp(alias())); + } + } + + // copy vector output + size_t ncopy = std::min((size_t)noutput_items, (size_t)pmt::pmt_length(vect)); + size_t nsave = pmt::pmt_length(vect) - ncopy; + + // copy output + size_t io(0); + nout += ncopy; + memcpy(out, pmt_uniform_vector_elements(vect,io), ncopy*d_itemsize); + + // save leftover items if needed for next work call + if (nsave > 0) { + d_remain.resize(nsave*d_itemsize, 0); + memcpy(&d_remain[0], pmt_uniform_vector_elements(vect,ncopy), nsave*d_itemsize); + } + } + + return nout; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.h b/gr-blocks/lib/pdu_to_tagged_stream_impl.h new file mode 100644 index 0000000000..ca1c6437bd --- /dev/null +++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H +#define INCLUDED_PDU_TO_TAGGED_STREAM_IMPL_H + +#include <blocks/pdu_to_tagged_stream.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API pdu_to_tagged_stream_impl : public pdu_to_tagged_stream + { + size_t d_itemsize; + pdu::vector_type d_type; + std::vector<uint8_t> d_remain; + + public: + pdu_to_tagged_stream_impl(pdu::vector_type type); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif diff --git a/gr-blocks/lib/peak_detector_XX_impl.cc.t b/gr-blocks/lib/peak_detector_XX_impl.cc.t new file mode 100644 index 0000000000..27518962f5 --- /dev/null +++ b/gr-blocks/lib/peak_detector_XX_impl.cc.t @@ -0,0 +1,122 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "@NAME_IMPL@.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(float threshold_factor_rise, + float threshold_factor_fall, + int look_ahead, float alpha) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(threshold_factor_rise, + threshold_factor_fall, + look_ahead, alpha)); + } + + @NAME_IMPL@::@NAME_IMPL@(float threshold_factor_rise, + float threshold_factor_fall, + int look_ahead, float alpha) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@I_TYPE@)), + gr_make_io_signature(1, 1, sizeof(char))), + d_threshold_factor_rise(threshold_factor_rise), + d_threshold_factor_fall(threshold_factor_fall), + d_look_ahead(look_ahead), d_avg_alpha(alpha), d_avg(0), d_found(0) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @I_TYPE@ *iptr = (@I_TYPE@*)input_items[0]; + char *optr = (char*)output_items[0]; + + memset(optr, 0, noutput_items*sizeof(char)); + + @I_TYPE@ peak_val = -(@I_TYPE@)INFINITY; + int peak_ind = 0; + unsigned char state = 0; + int i = 0; + + //printf("noutput_items %d\n",noutput_items); + while(i < noutput_items) { + if(state == 0) { // below threshold + if(iptr[i] > d_avg*d_threshold_factor_rise) { + state = 1; + } + else { + d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; + i++; + } + } + else if(state == 1) { // above threshold, have not found peak + //printf("Entered State 1: %f i: %d noutput_items: %d\n", iptr[i], i, noutput_items); + if(iptr[i] > peak_val) { + peak_val = iptr[i]; + peak_ind = i; + d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; + i++; + } + else if(iptr[i] > d_avg*d_threshold_factor_fall) { + d_avg = (d_avg_alpha)*iptr[i] + (1-d_avg_alpha)*d_avg; + i++; + } + else { + optr[peak_ind] = 1; + state = 0; + peak_val = -(@I_TYPE@)INFINITY; + //printf("Leaving State 1: Peak: %f Peak Ind: %d i: %d noutput_items: %d\n", + //peak_val, peak_ind, i, noutput_items); + } + } + } + + if(state == 0) { + //printf("Leave in State 0, produced %d\n",noutput_items); + return noutput_items; + } + else { // only return up to passing the threshold + //printf("Leave in State 1, only produced %d of %d\n",peak_ind,noutput_items); + return peak_ind+1; + } + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/peak_detector_XX_impl.h.t b/gr-blocks/lib/peak_detector_XX_impl.h.t new file mode 100644 index 0000000000..ef52f0f744 --- /dev/null +++ b/gr-blocks/lib/peak_detector_XX_impl.h.t @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + float d_threshold_factor_rise; + float d_threshold_factor_fall; + int d_look_ahead; + float d_avg_alpha; + float d_avg; + unsigned char d_found; + + public: + @NAME_IMPL@(float threshold_factor_rise, + float threshold_factor_fall, + int look_ahead, float alpha); + ~@NAME_IMPL@(); + + void set_threshold_factor_rise(float thr) { d_threshold_factor_rise = thr; } + void set_threshold_factor_fall(float thr) { d_threshold_factor_fall = thr; } + void set_look_ahead(int look) { d_look_ahead = look; } + void set_alpha(int alpha) { d_avg_alpha = alpha; } + float threshold_factor_rise() { return d_threshold_factor_rise; } + float threshold_factor_fall() { return d_threshold_factor_fall; } + int look_ahead() { return d_look_ahead; } + float alpha() { return d_avg_alpha; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/plateau_detector_fb_impl.cc b/gr-blocks/lib/plateau_detector_fb_impl.cc new file mode 100644 index 0000000000..f68ef6463f --- /dev/null +++ b/gr-blocks/lib/plateau_detector_fb_impl.cc @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "plateau_detector_fb_impl.h" + +namespace gr { + namespace blocks { + + plateau_detector_fb::sptr + plateau_detector_fb::make(int max_len, float threshold) + { + return gnuradio::get_initial_sptr + (new plateau_detector_fb_impl(max_len, threshold)); + } + + plateau_detector_fb_impl::plateau_detector_fb_impl(int max_len, float threshold) + : gr_sync_block("plateau_detector_fb", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(char))), + d_max_len(max_len), + d_threshold(threshold) + {} + + plateau_detector_fb_impl::~plateau_detector_fb_impl() + { + } + + int + plateau_detector_fb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + int flank_start; + + memset((void *) out, 0x00, noutput_items); + int i; + for(i = 0; i < noutput_items; i++) { + if(in[i] >= d_threshold) { + if(noutput_items-i < 2*d_max_len) { // If we can't finish, come back later + break; + } + flank_start = i; + while(i < noutput_items && in[i] >= d_threshold) + i++; + if((i - flank_start) > 1) { // 1 Sample is not a plateau + out[flank_start + (i-flank_start)/2] = 1; + i = std::min(i+d_max_len, noutput_items-1); + } + } + } + + return i; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/plateau_detector_fb_impl.h b/gr-blocks/lib/plateau_detector_fb_impl.h new file mode 100644 index 0000000000..67682d00f3 --- /dev/null +++ b/gr-blocks/lib/plateau_detector_fb_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_IMPL_H +#define INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_IMPL_H + +#include <blocks/plateau_detector_fb.h> + +namespace gr { + namespace blocks { + +class plateau_detector_fb_impl : public plateau_detector_fb +{ + private: + int d_max_len; + float d_threshold; + + public: + plateau_detector_fb_impl(int max_len, float threshold); + ~plateau_detector_fb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_BLOCKS_PLATEAU_DETECTOR_FB_IMPL_H */ + diff --git a/gr-blocks/lib/probe_rate_impl.cc b/gr-blocks/lib/probe_rate_impl.cc new file mode 100644 index 0000000000..37749c85e3 --- /dev/null +++ b/gr-blocks/lib/probe_rate_impl.cc @@ -0,0 +1,119 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "probe_rate_impl.h" +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + probe_rate::sptr + probe_rate::make(size_t itemsize, double update_rate_ms, double alpha) + { + return gnuradio::get_initial_sptr + (new probe_rate_impl(itemsize,update_rate_ms,alpha)); + } + + probe_rate_impl::probe_rate_impl(size_t itemsize, double update_rate_ms, double alpha) : + gr_sync_block("probe_rate", + gr_make_io_signature(1,1,itemsize), + gr_make_io_signature(0,0,itemsize)), + d_alpha(alpha), + d_beta(1.0-alpha), + d_avg(0), + d_min_update_time(update_rate_ms), + d_lastthru(0), + d_itemsize(itemsize) + { + } + + probe_rate_impl::~probe_rate_impl(){} + + int probe_rate_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items){ + d_lastthru += noutput_items; + boost::posix_time::ptime now(boost::posix_time::microsec_clock::local_time()); + boost::posix_time::time_duration diff = now - d_last_update; + double diff_ms = diff.total_milliseconds(); + if(diff_ms >= d_min_update_time){ + double rate_this_update = d_lastthru *1e3 / diff_ms; + d_lastthru = 0; + d_last_update = now; + if(d_avg == 0){ + d_avg = rate_this_update; + } else { + d_avg = rate_this_update*d_alpha + d_avg*d_beta; + } + } + return noutput_items; + } + + void probe_rate_impl::setup_rpc(){ +#ifdef GR_CTRLPORT + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<probe_rate_impl, double >( + alias(), "rate_items", + &probe_rate_impl::rate, + pmt::mp(0), pmt::mp(1e6), pmt::mp(1), + "items/sec", "Item rate", + RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); + add_rpc_variable( + rpcbasic_sptr(new rpcbasic_register_get<probe_rate_impl, double >( + alias(), "timesincelast", + &probe_rate_impl::timesincelast, + pmt::mp(0), pmt::mp(d_min_update_time*2), pmt::mp(0), + "ms", "Time since last update", + RPC_PRIVLVL_MIN, DISPTIME | DISPOPTSTRIP))); +#endif + } + + void probe_rate_impl::set_alpha(double alpha){ d_alpha = alpha; } + + double probe_rate_impl::rate(){ return d_avg; } + + double probe_rate_impl::timesincelast(){ + boost::posix_time::ptime now(boost::posix_time::microsec_clock::local_time()); + boost::posix_time::time_duration diff = now - d_last_update; + return diff.total_milliseconds(); + } + + bool probe_rate_impl::start(){ + d_avg = 0; + d_lastthru = 0; + d_last_update = boost::posix_time::microsec_clock::local_time(); + return true; + } + + bool probe_rate_impl::stop(){ + return true; + } + + + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/probe_rate_impl.h b/gr-blocks/lib/probe_rate_impl.h new file mode 100644 index 0000000000..139fc34876 --- /dev/null +++ b/gr-blocks/lib/probe_rate_impl.h @@ -0,0 +1,59 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_PROBE_RATE_IMPL_H +#define INCLUDED_GR_PROBE_RATE_IMPL_H + +#include <blocks/probe_rate.h> + +namespace gr { + namespace blocks { + + class probe_rate_impl : public probe_rate + { + private: + double d_alpha, d_beta, d_avg; + double d_min_update_time; + boost::posix_time::ptime d_last_update; + uint64_t d_lastthru; + size_t d_itemsize; + void setup_rpc(); + + public: + probe_rate_impl(size_t itemsize, double update_rate_ms, double alpha = 0.0001); + ~probe_rate_impl(); + void set_alpha(double alpha); + double rate(); + double timesincelast(); + bool start(); + bool stop(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + }; // end class + + } /* namespace blocks */ +} /* namespace gr */ + +#endif diff --git a/gr-blocks/lib/probe_signal_X_impl.cc.t b/gr-blocks/lib/probe_signal_X_impl.cc.t new file mode 100644 index 0000000000..4cda4e5273 --- /dev/null +++ b/gr-blocks/lib/probe_signal_X_impl.cc.t @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2012-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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @BASE_NAME@::make() + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@()); + } + + @NAME_IMPL@::@NAME_IMPL@() + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@TYPE@)), + gr_make_io_signature(0, 0, 0)), + d_level(0) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const @TYPE@ *in = (const @TYPE@ *)input_items[0]; + + if(noutput_items > 0) + d_level = in[noutput_items-1]; + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/probe_signal_X_impl.h.t b/gr-blocks/lib/probe_signal_X_impl.h.t new file mode 100644 index 0000000000..9c3d05becd --- /dev/null +++ b/gr-blocks/lib/probe_signal_X_impl.h.t @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + @TYPE@ d_level; + + public: + @NAME_IMPL@(); + ~@NAME_IMPL@(); + + @TYPE@ level() const { return d_level; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/probe_signal_vX_impl.cc.t b/gr-blocks/lib/probe_signal_vX_impl.cc.t new file mode 100644 index 0000000000..bd520b0bc8 --- /dev/null +++ b/gr-blocks/lib/probe_signal_vX_impl.cc.t @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,2012-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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @BASE_NAME@::make(size_t size) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(size)); + } + + @NAME_IMPL@::@NAME_IMPL@(size_t size) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(1, 1, size*sizeof(@TYPE@)), + gr_make_io_signature(0, 0, 0)), + d_level(size, 0), d_size(size) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const @TYPE@ *in = (const @TYPE@ *)input_items[0]; + + for(size_t i=0; i<d_size; i++) + d_level[i] = in[(noutput_items-1)*d_size+i]; + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/probe_signal_vX_impl.h.t b/gr-blocks/lib/probe_signal_vX_impl.h.t new file mode 100644 index 0000000000..1424334a7f --- /dev/null +++ b/gr-blocks/lib/probe_signal_vX_impl.h.t @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2012-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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <vector> +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<@TYPE@> d_level; + size_t d_size; + + public: + @NAME_IMPL@(size_t size); + ~@NAME_IMPL@(); + + std::vector<@TYPE@> level() const { return d_level; } + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/qa_block_tags.cc b/gr-blocks/lib/qa_block_tags.cc new file mode 100644 index 0000000000..ea9832ca68 --- /dev/null +++ b/gr-blocks/lib/qa_block_tags.cc @@ -0,0 +1,450 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qa_block_tags.h> +#include <gr_block.h> +#include <gr_top_block.h> +#include <gr_null_source.h> +#include <gr_null_sink.h> +#include <gr_head.h> +#include <blocks/annotator_alltoall.h> +#include <blocks/annotator_1to1.h> +#include <gr_keep_one_in_n.h> +#include <gr_tags.h> + + +// ---------------------------------------------------------------- + +using namespace pmt; + +// set to 1 to turn on debug output +// The debug output fully checks that the tags seen are what are expected. While +// this behavior currently works with our implementation, there is no guarentee +// that the tags will be coming in this specific order, so it's dangerous to +// rely on this as a test of the tag system working. We would really want to +// tags we know we should see and then test that they all occur once, but in no +// particular order. +#define QA_TAGS_DEBUG 0 + +void +qa_block_tags::t0() +{ + unsigned int N = 1000; + gr_top_block_sptr tb = gr_make_top_block("top"); + gr_block_sptr src (gr_make_null_source(sizeof(int))); + gr_block_sptr head (gr_make_head(sizeof(int), N)); + gr_block_sptr snk (gr_make_null_sink(sizeof(int))); + + tb->connect(src, 0, head, 0); + tb->connect(head, 0, snk, 0); + + //CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::runtime_error); + //CPPUNIT_ASSERT_THROW(src->nitems_written(0), std::runtime_error); + CPPUNIT_ASSERT_EQUAL(src->nitems_read(0), (uint64_t)0); + CPPUNIT_ASSERT_EQUAL(src->nitems_written(0), (uint64_t)0); + + tb->run(); + + CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::invalid_argument); + CPPUNIT_ASSERT(src->nitems_written(0) >= N); + CPPUNIT_ASSERT_EQUAL(snk->nitems_read(0), (uint64_t)1000); + CPPUNIT_ASSERT_THROW(snk->nitems_written(0), std::invalid_argument); +} + + +void +qa_block_tags::t1() +{ + int N = 40000; + gr_top_block_sptr tb = gr_make_top_block("top"); + gr_block_sptr src (gr_make_null_source(sizeof(int))); + gr_block_sptr head (gr_make_head(sizeof(int), N)); + gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann3(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann4(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); + gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); + + tb->connect(src, 0, head, 0); + tb->connect(head, 0, ann0, 0); + + tb->connect(ann0, 0, ann1, 0); + tb->connect(ann0, 1, ann2, 0); + tb->connect(ann1, 0, ann3, 0); + tb->connect(ann2, 0, ann4, 0); + + tb->connect(ann3, 0, snk0, 0); + tb->connect(ann4, 0, snk1, 0); + + tb->run(); + + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags3 = ann3->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); + + // The first annotator does not receive any tags from the null sink upstream + CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); + CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); + CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); + +#if QA_TAGS_DEBUG + // Kludge together the tags that we know should result from the above graph + std::stringstream str0, str1, str2; + str0 << ann0->name() << ann0->unique_id(); + str1 << ann1->name() << ann1->unique_id(); + str2 << ann2->name() << ann2->unique_id(); + + pmt_t expected_tags3[8]; + expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + + pmt_t expected_tags4[8]; + expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); + expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); + expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); + + std::cout << std::endl << "qa_block_tags::t1" << std::endl; + + // For annotator 3, we know it gets tags from ann0 and ann1, test this + for(size_t i = 0; i < tags3.size(); i++) { + std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i])); + } + + // For annotator 4, we know it gets tags from ann0 and ann2, test this + std::cout << std::endl; + for(size_t i = 0; i < tags4.size(); i++) { + std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); + } +#endif +} + +void +qa_block_tags::t2 () +{ + int N = 40000; + gr_top_block_sptr tb = gr_make_top_block("top"); + gr_block_sptr src (gr_make_null_source(sizeof(int))); + gr_block_sptr head (gr_make_head(sizeof(int), N)); + gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann3(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann4(gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); + gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); + gr_block_sptr snk2 (gr_make_null_sink(sizeof(int))); + + tb->connect(src, 0, head, 0); + tb->connect(head, 0, ann0, 0); + + tb->connect(ann0, 0, ann1, 0); + tb->connect(ann0, 1, ann1, 1); + tb->connect(ann1, 0, ann2, 0); + tb->connect(ann1, 1, ann3, 0); + tb->connect(ann1, 2, ann4, 0); + + tb->connect(ann2, 0, snk0, 0); + tb->connect(ann3, 0, snk1, 0); + tb->connect(ann4, 0, snk2, 0); + + tb->run(); + + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags1 = ann1->data(); + std::vector<gr_tag_t> tags2 = ann2->data(); + std::vector<gr_tag_t> tags3 = ann4->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); + + // The first annotator does not receive any tags from the null sink upstream + CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); + CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)8); + + // Make sure the rest all have 12 tags + CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)12); + CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)12); + CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)12); + + +#if QA_TAGS_DEBUG + // Kludge together the tags that we know should result from the above graph + std::stringstream str0, str1; + str0 << ann0->name() << ann0->unique_id(); + str1 << ann1->name() << ann1->unique_id(); + + pmt_t expected_tags2[12]; + expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags2[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags2[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags2[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags2[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags2[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(6)); + expected_tags2[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags2[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags2[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(9)); + expected_tags2[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + expected_tags2[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); + + pmt_t expected_tags4[12]; + expected_tags4[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(2)); + expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags4[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(5)); + expected_tags4[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(8)); + expected_tags4[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags4[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(11)); + expected_tags4[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + expected_tags4[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); + + std::cout << std::endl << "qa_block_tags::t2" << std::endl; + + // For annotator[2-4], we know it gets tags from ann0 and ann1 + // but the tags from the different outputs of ann1 are different for each. + // Just testing ann2 and ann4; if they are correct it would be + // inconceivable for ann3 to have it wrong. + for(size_t i = 0; i < tags2.size(); i++) { + std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i])); + } + + std::cout << std::endl; + for(size_t i = 0; i < tags4.size(); i++) { + std::cout << "tags2[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); + } +#endif +} + + +void +qa_block_tags::t3() +{ + int N = 40000; + gr_top_block_sptr tb = gr_make_top_block("top"); + gr_block_sptr src (gr_make_null_source(sizeof(int))); + gr_block_sptr head (gr_make_head(sizeof(int), N)); + gr::blocks::annotator_1to1::sptr ann0 (gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann1 (gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_alltoall::sptr ann2 (gr::blocks::annotator_alltoall::make(10000, sizeof(int))); + gr::blocks::annotator_1to1::sptr ann3 (gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr::blocks::annotator_1to1::sptr ann4 (gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); + gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); + + tb->connect(src, 0, head, 0); + tb->connect(head, 0, ann0, 0); + tb->connect(head, 0, ann0, 1); + + tb->connect(ann0, 0, ann1, 0); + tb->connect(ann0, 1, ann2, 0); + tb->connect(ann1, 0, ann3, 0); + tb->connect(ann2, 0, ann4, 0); + + tb->connect(ann3, 0, snk0, 0); + tb->connect(ann4, 0, snk1, 0); + + tb->run(); + + + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags3 = ann3->data(); + std::vector<gr_tag_t> tags4 = ann4->data(); + + // The first annotator does not receive any tags from the null sink upstream + CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); + CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); + CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); + +#if QA_TAGS_DEBUG + // Kludge together the tags that we know should result from the above graph + std::stringstream str0, str1, str2; + str0 << ann0->name() << ann0->unique_id(); + str1 << ann1->name() << ann1->unique_id(); + str2 << ann2->name() << ann2->unique_id(); + + pmt_t expected_tags3[8]; + expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + + pmt_t expected_tags4[8]; + expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); + expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); + expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); + + std::cout << std::endl << "qa_block_tags::t3" << std::endl; + + // For annotator 3, we know it gets tags from ann0 and ann1, test this + for(size_t i = 0; i < tags3.size(); i++) { + std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i])); + } + + // For annotator 4, we know it gets tags from ann0 and ann2, test this + std::cout << std::endl; + for(size_t i = 0; i < tags4.size(); i++) { + std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); + } +#endif +} + + +void +qa_block_tags::t4() +{ + int N = 40000; + gr_top_block_sptr tb = gr_make_top_block("top"); + gr_block_sptr src (gr_make_null_source(sizeof(int))); + gr_block_sptr head (gr_make_head(sizeof(int), N)); + gr::blocks::annotator_1to1::sptr ann0(gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr::blocks::annotator_1to1::sptr ann1(gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr::blocks::annotator_1to1::sptr ann2(gr::blocks::annotator_1to1::make(10000, sizeof(int))); + gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); + gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); + + // using 1-to-1 tag propagation without having equal number of + // ins and outs. Make sure this works; will just exit run early. + tb->connect(src, 0, head, 0); + tb->connect(head, 0, ann0, 0); + tb->connect(ann0, 0, ann1, 0); + tb->connect(ann0, 1, ann2, 0); + tb->connect(ann1, 0, snk0, 0); + tb->connect(ann2, 0, snk1, 0); + + std::cerr << std::endl + << "NOTE: This is supposed to produce an error from gr_block_executor" + << std::endl; + tb->run(); +} + + +void +qa_block_tags::t5() +{ + int N = 40000; + gr_top_block_sptr tb = gr_make_top_block("top"); + gr_block_sptr src (gr_make_null_source(sizeof(float))); + gr_block_sptr head (gr_make_head(sizeof(float), N)); + gr::blocks::annotator_alltoall::sptr ann0(gr::blocks::annotator_alltoall::make(10000, sizeof(float))); + gr::blocks::annotator_alltoall::sptr ann1(gr::blocks::annotator_alltoall::make(10000, sizeof(float))); + gr::blocks::annotator_alltoall::sptr ann2(gr::blocks::annotator_alltoall::make(1000, sizeof(float))); + gr_block_sptr snk0 (gr_make_null_sink(sizeof(float))); + + // Rate change blocks + gr_keep_one_in_n_sptr dec10 (gr_make_keep_one_in_n(sizeof(float), 10)); + + tb->connect(src, 0, head, 0); + tb->connect(head, 0, ann0, 0); + tb->connect(ann0, 0, ann1, 0); + tb->connect(ann1, 0, dec10, 0); + tb->connect(dec10, 0, ann2, 0); + tb->connect(ann2, 0, snk0, 0); + + tb->run(); + + std::vector<gr_tag_t> tags0 = ann0->data(); + std::vector<gr_tag_t> tags1 = ann1->data(); + std::vector<gr_tag_t> tags2 = ann2->data(); + + // The first annotator does not receive any tags from the null sink upstream + CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); + CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)4); + CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)8); + + +#if QA_TAGS_DEBUG + // Kludge together the tags that we know should result from the above graph + std::stringstream str0, str1, str2; + str0 << ann0->name() << ann0->unique_id(); + str1 << ann1->name() << ann1->unique_id(); + str2 << ann2->name() << ann2->unique_id(); + + pmt_t expected_tags1[5]; + expected_tags1[0] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags1[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); + expected_tags1[2] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags1[3] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(3)); + + pmt_t expected_tags2[10]; + expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags2[2] = mp(pmt_from_uint64(1000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags2[3] = mp(pmt_from_uint64(1000), mp(str0.str()), mp("seq"), mp(1)); + expected_tags2[4] = mp(pmt_from_uint64(2000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags2[5] = mp(pmt_from_uint64(2000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags2[6] = mp(pmt_from_uint64(3000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags2[7] = mp(pmt_from_uint64(3000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags2[8] = mp(pmt_from_uint64(4000), mp(str1.str()), mp("seq"), mp(4)); + expected_tags2[9] = mp(pmt_from_uint64(4000), mp(str0.str()), mp("seq"), mp(4)); + + std::cout << std::endl << "qa_block_tags::t5" << std::endl; + + // annotator 1 gets tags from annotator 0 + std::cout << "tags1.size(): " << tags1.size() << std::endl; + for(size_t i = 0; i < tags1.size(); i++) { + std::cout << "tags1[" << i << "] = " << tags1[i] << "\t\t" << expected_tags1[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags1[i]), pmt_write_string(expected_tags1[i])); + } + + // annotator 2 gets tags from annotators 0 and 1 + std::cout << std::endl; + std::cout << "tags2.size(): " << tags2.size() << std::endl; + for(size_t i = 0; i < tags2.size(); i++) { + std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i])); + } +#endif +} + diff --git a/gr-blocks/lib/qa_block_tags.h b/gr-blocks/lib/qa_block_tags.h new file mode 100644 index 0000000000..83bebe23f6 --- /dev/null +++ b/gr-blocks/lib/qa_block_tags.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_QA_BLOCK_TAGS_H +#define INCLUDED_QA_BLOCK_TAGS_H + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> +#include <stdexcept> + +class qa_block_tags : public CppUnit::TestCase +{ + CPPUNIT_TEST_SUITE(qa_block_tags); + CPPUNIT_TEST(t0); + CPPUNIT_TEST(t1); + CPPUNIT_TEST(t2); + CPPUNIT_TEST(t3); + CPPUNIT_TEST(t4); + CPPUNIT_TEST(t5); + CPPUNIT_TEST_SUITE_END(); + + private: + void t0(); + void t1(); + void t2(); + void t3(); + void t4(); + void t5(); +}; + +#endif /* INCLUDED_QA_BLOCK_TAGS_H */ diff --git a/gr-blocks/lib/qa_blocks.cc b/gr-blocks/lib/qa_blocks.cc new file mode 100644 index 0000000000..409b5d5762 --- /dev/null +++ b/gr-blocks/lib/qa_blocks.cc @@ -0,0 +1,41 @@ +/* + * Copyright 2012-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. + */ + +/* + * This class gathers together all the test cases for the gr-blocks + * directory into a single test suite. As you create new test cases, + * add them here. + */ + +#include <qa_blocks.h> +#include <qa_block_tags.h> +#include <qa_rotator.h> + +CppUnit::TestSuite * +qa_gr_blocks::suite() +{ + CppUnit::TestSuite *s = new CppUnit::TestSuite("gr-blocks"); + + s->addTest(qa_block_tags::suite()); + s->addTest(qa_rotator::suite()); + + return s; +} diff --git a/gr-blocks/lib/qa_blocks.h b/gr-blocks/lib/qa_blocks.h new file mode 100644 index 0000000000..88eac60426 --- /dev/null +++ b/gr-blocks/lib/qa_blocks.h @@ -0,0 +1,38 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef _QA_GR_BLOCKS_H_ +#define _QA_GR_BLOCKS_H_ + +#include <gruel/attributes.h> +#include <cppunit/TestSuite.h> + +//! collect all the tests for the gr-blocks directory + +class __GR_ATTR_EXPORT qa_gr_blocks +{ + public: + //! return suite of tests for all of gr-blocks directory + static CppUnit::TestSuite *suite(); +}; + +#endif /* _QA_GR_BLOCKS_H_ */ diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc new file mode 100644 index 0000000000..86bbdd5282 --- /dev/null +++ b/gr-blocks/lib/qa_rotator.cc @@ -0,0 +1,75 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <gruel/attributes.h> +#include <cppunit/TestAssert.h> +#include <qa_rotator.h> +#include <blocks/rotator.h> +#include <stdio.h> +#include <cmath> +#include <gr_expj.h> + +// error vector magnitude +__GR_ATTR_UNUSED static float +error_vector_mag(gr_complex a, gr_complex b) +{ + return abs(a-b); +} + +void +qa_rotator::t1() +{ + static const unsigned int N = 100000; + + gr::blocks::rotator r; + + double phase_incr = 2*M_PI / 1003; + double phase = 0; + + // Old code: We increment then return the rotated value, thus we + // need to start one tick back r.set_phase(gr_complex(1,0) * + // conj(gr_expj(phase_incr))); + + r.set_phase(gr_complex(1,0)); + r.set_phase_incr(gr_expj(phase_incr)); + + for(unsigned i = 0; i < N; i++) { + gr_complex expected = gr_expj(phase); + gr_complex actual = r.rotate(gr_complex(1, 0)); + +#if 0 + float evm = error_vector_mag(expected, actual); + printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n", + i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); +#endif + + CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); + + phase += phase_incr; + if(phase >= 2*M_PI) + phase -= 2*M_PI; + } +} diff --git a/gr-blocks/lib/qa_rotator.h b/gr-blocks/lib/qa_rotator.h new file mode 100644 index 0000000000..575ea506c7 --- /dev/null +++ b/gr-blocks/lib/qa_rotator.h @@ -0,0 +1,39 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,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. + */ + +#ifndef _QA_GR_ROTATOR_H_ +#define _QA_GR_ROTATOR_H_ + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> + +class qa_rotator : public CppUnit::TestCase +{ + CPPUNIT_TEST_SUITE(qa_rotator); + CPPUNIT_TEST(t1); + CPPUNIT_TEST_SUITE_END(); + + private: + void t1(); +}; + +#endif /* _QA_GR_ROTATOR_H_ */ diff --git a/gr-blocks/lib/repack_bits_bb_impl.cc b/gr-blocks/lib/repack_bits_bb_impl.cc new file mode 100644 index 0000000000..c7ed054c8a --- /dev/null +++ b/gr-blocks/lib/repack_bits_bb_impl.cc @@ -0,0 +1,123 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "repack_bits_bb_impl.h" + +namespace gr { + namespace blocks { + + repack_bits_bb::sptr + repack_bits_bb::make(int k, int l, const std::string &len_tag_key, bool align_output) + { + return gnuradio::get_initial_sptr (new repack_bits_bb_impl(k, l, len_tag_key, align_output)); + } + + repack_bits_bb_impl::repack_bits_bb_impl(int k, int l, const std::string &len_tag_key, bool align_output) + : gr_tagged_stream_block("repack_bits_bb", + gr_make_io_signature(1, 1, sizeof (char)), + gr_make_io_signature(1, 1, sizeof (char)), + len_tag_key), + d_k(k), d_l(l), + d_packet_mode(!len_tag_key.empty()), + d_in_index(0), d_out_index(0), + d_align_output(align_output) + { + if (d_k > 8 || d_k < 1 || d_l > 8 || d_l < 1) { + throw std::invalid_argument("k and l must be in [1, 8]"); + } + + set_relative_rate((double) d_k / d_l); + } + + repack_bits_bb_impl::~repack_bits_bb_impl() + { + } + + int + repack_bits_bb_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + int n_out_bytes_required = (ninput_items[0] * d_k) / d_l; + if ((ninput_items[0] * d_k) % d_l && (!d_packet_mode || (d_packet_mode && !d_align_output))) { + n_out_bytes_required++; + } + + return n_out_bytes_required; + } + + int + repack_bits_bb_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + int bytes_to_write = noutput_items; + + if (d_packet_mode) { // noutput_items could be larger than necessary + int bytes_to_read = ninput_items[0]; + bytes_to_write = bytes_to_read * d_k / d_l; + if (!d_align_output && (((bytes_to_read * d_k) % d_l) != 0)) { + bytes_to_write++; + } + } + + int n_read = 0; + int n_written = 0; + while(n_written < bytes_to_write && n_read < ninput_items[0]) { + if (d_out_index == 0) { // Starting a fresh byte + out[n_written] = 0; + } + out[n_written] |= ((in[n_read] >> d_in_index) & 0x01) << d_out_index; + + d_in_index = (d_in_index + 1) % d_k; + d_out_index = (d_out_index + 1) % d_l; + if (d_in_index == 0) { + n_read++; + d_in_index = 0; + } + if (d_out_index == 0) { + n_written++; + d_out_index = 0; + } + } + + if (d_packet_mode) { + if (d_out_index) { + n_written++; + d_out_index = 0; + } + } else { + consume_each(n_read); + } + + return n_written; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/repack_bits_bb_impl.h b/gr-blocks/lib/repack_bits_bb_impl.h new file mode 100644 index 0000000000..bf39f8cb0f --- /dev/null +++ b/gr-blocks/lib/repack_bits_bb_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +#ifndef INCLUDED_BLOCKS_REPACK_BITS_BB_IMPL_H +#define INCLUDED_BLOCKS_REPACK_BITS_BB_IMPL_H + +#include <blocks/repack_bits_bb.h> + +namespace gr { + namespace blocks { + + class repack_bits_bb_impl : public repack_bits_bb + { + private: + const int d_k; //! Bits on input stream + const int d_l; //! Bits on output stream + const bool d_packet_mode; + int d_in_index; // Current bit of input byte + int d_out_index; // Current bit of output byte + bool d_align_output; //! true if the output shall be aligned, false if the input shall be aligned + + protected: + int calculate_output_stream_length(const gr_vector_int &ninput_items); + + public: + repack_bits_bb_impl(int k, int l, const std::string &len_tag_key, bool align_output); + ~repack_bits_bb_impl(); + + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_BLOCKS_REPACK_BITS_BB_IMPL_H */ + diff --git a/gr-blocks/lib/sample_and_hold_XX_impl.cc.t b/gr-blocks/lib/sample_and_hold_XX_impl.cc.t new file mode 100644 index 0000000000..617b2d6ee5 --- /dev/null +++ b/gr-blocks/lib/sample_and_hold_XX_impl.cc.t @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,2010,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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make() + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@()); + } + + @NAME_IMPL@::@NAME_IMPL@() + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature2(2, 2, sizeof(@I_TYPE@), sizeof(char)), + gr_make_io_signature(1, 1, sizeof(@O_TYPE@))), + d_data(0) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + { + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @I_TYPE@ *iptr = (@I_TYPE@ *)input_items[0]; + const char *ctrl = (const char *)input_items[1]; + @O_TYPE@ *optr = (@O_TYPE@ *)output_items[0]; + + for(int i = 0; i < noutput_items; i++) { + if(ctrl[i]) { + d_data = iptr[i]; + } + optr[i] = d_data; + } + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/sample_and_hold_XX_impl.h.t b/gr-blocks/lib/sample_and_hold_XX_impl.h.t new file mode 100644 index 0000000000..048bf0d0e7 --- /dev/null +++ b/gr-blocks/lib/sample_and_hold_XX_impl.h.t @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + @O_TYPE@ d_data; + + public: + @NAME_IMPL@(); + ~@NAME_IMPL@(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/sine_table.h b/gr-blocks/lib/sine_table.h new file mode 100644 index 0000000000..69834943bc --- /dev/null +++ b/gr-blocks/lib/sine_table.h @@ -0,0 +1,1025 @@ + // max_error = 2.353084136763606e-06 + { 2.925817799165007e-09, 7.219194364267018e-09 }, + { 2.925707643778599e-09, 2.526699001579799e-07 }, + { 2.925487337153070e-09, 1.191140162167675e-06 }, + { 2.925156887582842e-09, 3.284585035595589e-06 }, + { 2.924716307509151e-09, 6.994872605695784e-06 }, + { 2.924165613519592e-09, 1.278374920658798e-05 }, + { 2.923504826347475e-09, 2.111280464718590e-05 }, + { 2.922733970871080e-09, 3.244343744537165e-05 }, + { 2.921853076112655e-09, 4.723682007436170e-05 }, + { 2.920862175237416e-09, 6.595386421935634e-05 }, + { 2.919761305552202e-09, 8.905518605213658e-05 }, + { 2.918550508504146e-09, 1.170010715193098e-04 }, + { 2.917229829679050e-09, 1.502514416517192e-04 }, + { 2.915799318799769e-09, 1.892658178912071e-04 }, + { 2.914259029724184e-09, 2.345032874456615e-04 }, + { 2.912609020443340e-09, 2.864224686607020e-04 }, + { 2.910849353079123e-09, 3.454814764261432e-04 }, + { 2.908980093882049e-09, 4.121378876027343e-04 }, + { 2.907001313228646e-09, 4.868487064877691e-04 }, + { 2.904913085618902e-09, 5.700703303049837e-04 }, + { 2.902715489673383e-09, 6.622585147355725e-04 }, + { 2.900408608130373e-09, 7.638683394782519e-04 }, + { 2.897992527842612e-09, 8.753541738578119e-04 }, + { 2.895467339774186e-09, 9.971696424604937e-04 }, + { 2.892833138996999e-09, 1.129767590823255e-03 }, + { 2.890090024687216e-09, 1.273600051161478e-03 }, + { 2.887238100121550e-09, 1.429118208142094e-03 }, + { 2.884277472673313e-09, 1.596772364709564e-03 }, + { 2.881208253808507e-09, 1.777011907950626e-03 }, + { 2.878030559081432e-09, 1.970285275029487e-03 }, + { 2.874744508130554e-09, 2.177039919152579e-03 }, + { 2.871350224673798e-09, 2.397722275614272e-03 }, + { 2.867847836504030e-09, 2.632777727878843e-03 }, + { 2.864237475484149e-09, 2.882650573737405e-03 }, + { 2.860519277542297e-09, 3.147783991507308e-03 }, + { 2.856693382666432e-09, 3.428620006328931e-03 }, + { 2.852759934899389e-09, 3.725599456482154e-03 }, + { 2.848719082333207e-09, 4.039161959812243e-03 }, + { 2.844570977103752e-09, 4.369745880190706e-03 }, + { 2.840315775384800e-09, 4.717788294077374e-03 }, + { 2.835953637382310e-09, 5.083724957128360e-03 }, + { 2.831484727328322e-09, 5.467990270896617e-03 }, + { 2.826909213474759e-09, 5.871017249604038e-03 }, + { 2.822227268087134e-09, 6.293237486988512e-03 }, + { 2.817439067438018e-09, 6.735081123237729e-03 }, + { 2.812544791800534e-09, 7.196976811989608e-03 }, + { 2.807544625441273e-09, 7.679351687456759e-03 }, + { 2.802438756613836e-09, 8.182631331563162e-03 }, + { 2.797227377551135e-09, 8.707239741274575e-03 }, + { 2.791910684458716e-09, 9.253599295902304e-03 }, + { 2.786488877507140e-09, 9.822130724578715e-03 }, + { 2.780962160824228e-09, 1.041325307382490e-02 }, + { 2.775330742487884e-09, 1.102738367513773e-02 }, + { 2.769594834517682e-09, 1.166493811278924e-02 }, + { 2.763754652867477e-09, 1.232633019159818e-02 }, + { 2.757810417416620e-09, 1.301197190494069e-02 }, + { 2.751762351962413e-09, 1.372227340270610e-02 }, + { 2.745610684210923e-09, 1.445764295952962e-02 }, + { 2.739355645769094e-09, 1.521848694296229e-02 }, + { 2.732997472135539e-09, 1.600520978188769e-02 }, + { 2.726536402691907e-09, 1.681821393496225e-02 }, + { 2.719972680693777e-09, 1.765789985920713e-02 }, + { 2.713306553261610e-09, 1.852466597868779e-02 }, + { 2.706538271371373e-09, 1.941890865333146e-02 }, + { 2.699668089844909e-09, 2.034102214787814e-02 }, + { 2.692696267340880e-09, 2.129139860085272e-02 }, + { 2.685623066344263e-09, 2.227042799383416e-02 }, + { 2.678448753157212e-09, 2.327849812064098e-02 }, + { 2.671173597888530e-09, 2.431599455681316e-02 }, + { 2.663797874443630e-09, 2.538330062913108e-02 }, + { 2.656321860514457e-09, 2.648079738524795e-02 }, + { 2.648745837568575e-09, 2.760886356354952e-02 }, + { 2.641070090839117e-09, 2.876787556300114e-02 }, + { 2.633294909313421e-09, 2.995820741329835e-02 }, + { 2.625420585722845e-09, 3.118023074495535e-02 }, + { 2.617447416531143e-09, 3.243431475972608e-02 }, + { 2.609375701923643e-09, 3.372082620101990e-02 }, + { 2.601205745795833e-09, 3.504012932452527e-02 }, + { 2.592937855741933e-09, 3.639258586895711e-02 }, + { 2.584572343043400e-09, 3.777855502693250e-02 }, + { 2.576109522656942e-09, 3.919839341605197e-02 }, + { 2.567549713203028e-09, 4.065245505002102e-02 }, + { 2.558893236953688e-09, 4.214109131001403e-02 }, + { 2.550140419820252e-09, 4.366465091617666e-02 }, + { 2.541291591341445e-09, 4.522347989919473e-02 }, + { 2.532347084670572e-09, 4.681792157215026e-02 }, + { 2.523307236563343e-09, 4.844831650239501e-02 }, + { 2.514172387364900e-09, 5.011500248369893e-02 }, + { 2.504942880997064e-09, 5.181831450849345e-02 }, + { 2.495619064945627e-09, 5.355858474024022e-02 }, + { 2.486201290246928e-09, 5.533614248606705e-02 }, + { 2.476689911475047e-09, 5.715131416942842e-02 }, + { 2.467085286727668e-09, 5.900442330315692e-02 }, + { 2.457387777613798e-09, 6.089579046229943e-02 }, + { 2.447597749239101e-09, 6.282573325755320e-02 }, + { 2.437715570192557e-09, 6.479456630859221e-02 }, + { 2.427741612532542e-09, 6.680260121764925e-02 }, + { 2.417676251773166e-09, 6.885014654319160e-02 }, + { 2.407519866869294e-09, 7.093750777401114e-02 }, + { 2.397272840203310e-09, 7.306498730310884e-02 }, + { 2.386935557569868e-09, 7.523288440214027e-02 }, + { 2.376508408161815e-09, 7.744149519577415e-02 }, + { 2.365991784555363e-09, 7.969111263635709e-02 }, + { 2.355386082695641e-09, 8.198202647865405e-02 }, + { 2.344691701881232e-09, 8.431452325495814e-02 }, + { 2.333909044749407e-09, 8.668888625021409e-02 }, + { 2.323038517261246e-09, 8.910539547731611e-02 }, + { 2.312080528685971e-09, 9.156432765274414e-02 }, + { 2.301035491585642e-09, 9.406595617227698e-02 }, + { 2.289903821799651e-09, 9.661055108691619e-02 }, + { 2.278685938428940e-09, 9.919837907903295e-02 }, + { 2.267382263820762e-09, 1.018297034385580e-01 }, + { 2.255993223551837e-09, 1.045047840397028e-01 }, + { 2.244519246413220e-09, 1.072238773174577e-01 }, + { 2.232960764393620e-09, 1.099872362446146e-01 }, + { 2.221318212663309e-09, 1.127951103088245e-01 }, + { 2.209592029557811e-09, 1.156477454898748e-01 }, + { 2.197782656561395e-09, 1.185453842371912e-01 }, + { 2.185890538290176e-09, 1.214882654476019e-01 }, + { 2.173916122475606e-09, 1.244766244431883e-01 }, + { 2.161859859947797e-09, 1.275106929493488e-01 }, + { 2.149722204618256e-09, 1.305906990731841e-01 }, + { 2.137503613462743e-09, 1.337168672820376e-01 }, + { 2.125204546504321e-09, 1.368894183821595e-01 }, + { 2.112825466795944e-09, 1.401085694976751e-01 }, + { 2.100366840402933e-09, 1.433745340497602e-01 }, + { 2.087829136385612e-09, 1.466875217359607e-01 }, + { 2.075212826781308e-09, 1.500477385098620e-01 }, + { 2.062518386587093e-09, 1.534553865607503e-01 }, + { 2.049746293741359e-09, 1.569106642937665e-01 }, + { 2.036897029106193e-09, 1.604137663100403e-01 }, + { 2.023971076449323e-09, 1.639648833871233e-01 }, + { 2.010968922425217e-09, 1.675642024598467e-01 }, + { 1.997891056557933e-09, 1.712119066008896e-01 }, + { 1.984737971221581e-09, 1.749081750021970e-01 }, + { 1.971510161622434e-09, 1.786531829561379e-01 }, + { 1.958208125780130e-09, 1.824471018371070e-01 }, + { 1.944832364508511e-09, 1.862900990834311e-01 }, + { 1.931383381397782e-09, 1.901823381790926e-01 }, + { 1.917861682794392e-09, 1.941239786363039e-01 }, + { 1.904267777782611e-09, 1.981151759777950e-01 }, + { 1.890602178165317e-09, 2.021560817195309e-01 }, + { 1.876865398444616e-09, 2.062468433536743e-01 }, + { 1.863057955802572e-09, 2.103876043317229e-01 }, + { 1.849180370081465e-09, 2.145785040479915e-01 }, + { 1.835233163764673e-09, 2.188196778231083e-01 }, + { 1.821216861956509e-09, 2.231112568880342e-01 }, + { 1.807131992362945e-09, 2.274533683680190e-01 }, + { 1.792979085271234e-09, 2.318461352671018e-01 }, + { 1.778758673530482e-09, 2.362896764525300e-01 }, + { 1.764471292530943e-09, 2.407841066397789e-01 }, + { 1.750117480184598e-09, 2.453295363773890e-01 }, + { 1.735697776904342e-09, 2.499260720324433e-01 }, + { 1.721212725583874e-09, 2.545738157760434e-01 }, + { 1.706662871577097e-09, 2.592728655691494e-01 }, + { 1.692048762677849e-09, 2.640233151485341e-01 }, + { 1.677370949099090e-09, 2.688252540131204e-01 }, + { 1.662629983452104e-09, 2.736787674105404e-01 }, + { 1.647826420726167e-09, 2.785839363237506e-01 }, + { 1.632960818266680e-09, 2.835408374583758e-01 }, + { 1.618033735755429e-09, 2.885495432295704e-01 }, + { 1.603045735188609e-09, 2.936101217498361e-01 }, + { 1.587997380855918e-09, 2.987226368167127e-01 }, + { 1.572889239319430e-09, 3.038871479007593e-01 }, + { 1.557721879392051e-09, 3.091037101339017e-01 }, + { 1.542495872116447e-09, 3.143723742978435e-01 }, + { 1.527211790743024e-09, 3.196931868130269e-01 }, + { 1.511870210708909e-09, 3.250661897274744e-01 }, + { 1.496471709615926e-09, 3.304914207062036e-01 }, + { 1.481016867208896e-09, 3.359689130207621e-01 }, + { 1.465506265353924e-09, 3.414986955389885e-01 }, + { 1.449940488016384e-09, 3.470807927151147e-01 }, + { 1.434320121238994e-09, 3.527152245800635e-01 }, + { 1.418645753119802e-09, 3.584020067320109e-01 }, + { 1.402917973789838e-09, 3.641411503272979e-01 }, + { 1.387137375391042e-09, 3.699326620714776e-01 }, + { 1.371304552054134e-09, 3.757765442106153e-01 }, + { 1.355420099875958e-09, 3.816727945230153e-01 }, + { 1.339484616897137e-09, 3.876214063110671e-01 }, + { 1.323498703079580e-09, 3.936223683933865e-01 }, + { 1.307462960283922e-09, 3.996756650972121e-01 }, + { 1.291377992246768e-09, 4.057812762511174e-01 }, + { 1.275244404558188e-09, 4.119391771778626e-01 }, + { 1.259062804638585e-09, 4.181493386877248e-01 }, + { 1.242833801715929e-09, 4.244117270719281e-01 }, + { 1.226558006803155e-09, 4.307263040962509e-01 }, + { 1.210236032674760e-09, 4.370930269951803e-01 }, + { 1.193868493843725e-09, 4.435118484661861e-01 }, + { 1.177456006538695e-09, 4.499827166641340e-01 }, + { 1.160999188680582e-09, 4.565055751961679e-01 }, + { 1.144498659859216e-09, 4.630803631168164e-01 }, + { 1.127955041310214e-09, 4.697070149232604e-01 }, + { 1.111368955891417e-09, 4.763854605510119e-01 }, + { 1.094741028059551e-09, 4.831156253697562e-01 }, + { 1.078071883846871e-09, 4.898974301794375e-01 }, + { 1.061362150836978e-09, 4.967307912069362e-01 }, + { 1.044612458142151e-09, 5.036156201023686e-01 }, + { 1.027823436378632e-09, 5.105518239364775e-01 }, + { 1.010995717643647e-09, 5.175393051975563e-01 }, + { 9.941299354913699e-10, 5.245779617890562e-01 }, + { 9.772267249089968e-10, 5.316676870274011e-01 }, + { 9.602867222926046e-10, 5.388083696401416e-01 }, + { 9.433105654240147e-10, 5.459998937639375e-01 }, + { 9.262988934458084e-10, 5.532421389435711e-01 }, + { 9.092523468378193e-10, 5.605349801305876e-01 }, + { 8.921715673928355e-10, 5.678782876825250e-01 }, + { 8.750571981926701e-10, 5.752719273622372e-01 }, + { 8.579098835836508e-10, 5.827157603377209e-01 }, + { 8.407302691522673e-10, 5.902096431821322e-01 }, + { 8.235190017016133e-10, 5.977534278737073e-01 }, + { 8.062767292259225e-10, 6.053469617967722e-01 }, + { 7.890041008871165e-10, 6.129900877421282e-01 }, + { 7.717017669898175e-10, 6.206826439083659e-01 }, + { 7.543703789572603e-10, 6.284244639030392e-01 }, + { 7.370105893063053e-10, 6.362153767444958e-01 }, + { 7.196230516231919e-10, 6.440552068636356e-01 }, + { 7.022084205389746e-10, 6.519437741060674e-01 }, + { 6.847673517046416e-10, 6.598808937346672e-01 }, + { 6.673005017664976e-10, 6.678663764322770e-01 }, + { 6.498085283416530e-10, 6.759000283046127e-01 }, + { 6.322920899929834e-10, 6.839816508836737e-01 }, + { 6.147518462045659e-10, 6.921110411311926e-01 }, + { 5.971884573565851e-10, 7.002879914425926e-01 }, + { 5.796025847007168e-10, 7.085122896509806e-01 }, + { 5.619948903351406e-10, 7.167837190315758e-01 }, + { 5.443660371796048e-10, 7.251020583063744e-01 }, + { 5.267166889504394e-10, 7.334670816491009e-01 }, + { 5.090475101356742e-10, 7.418785586903696e-01 }, + { 4.913591659698399e-10, 7.503362545232619e-01 }, + { 4.736523224091392e-10, 7.588399297089872e-01 }, + { 4.559276461062478e-10, 7.673893402829834e-01 }, + { 4.381858043851147e-10, 7.759842377612828e-01 }, + { 4.204274652161870e-10, 7.846243691469355e-01 }, + { 4.026532971908398e-10, 7.933094769370790e-01 }, + { 3.848639694963359e-10, 8.020392991300200e-01 }, + { 3.670601518910503e-10, 8.108135692324444e-01 }, + { 3.492425146784233e-10, 8.196320162675177e-01 }, + { 3.314117286825031e-10, 8.284943647824689e-01 }, + { 3.135684652223755e-10, 8.374003348569865e-01 }, + { 2.957133960867535e-10, 8.463496421118015e-01 }, + { 2.778471935089361e-10, 8.553419977173513e-01 }, + { 2.599705301412391e-10, 8.643771084029740e-01 }, + { 2.420840790301135e-10, 8.734546764660205e-01 }, + { 2.241885135902046e-10, 8.825743997817682e-01 }, + { 2.062845075795238e-10, 8.917359718130367e-01 }, + { 1.883727350736140e-10, 9.009390816205823e-01 }, + { 1.704538704408269e-10, 9.101834138731877e-01 }, + { 1.525285883160648e-10, 9.194686488588080e-01 }, + { 1.345975635762696e-10, 9.287944624950824e-01 }, + { 1.166614713141648e-10, 9.381605263410157e-01 }, + { 9.872098681369190e-11, 9.475665076080466e-01 }, + { 8.077678552380464e-11, 9.570120691722380e-01 }, + { 6.282954303364090e-11, 9.664968695860140e-01 }, + { 4.487993504668797e-11, 9.760205630906909e-01 }, + { 2.692863735553042e-11, 9.855827996289697e-01 }, + { 8.976325816439114e-12, 9.951832248577780e-01 }, + { -8.976323676304494e-12, 1.004821480161519e+00 }, + { -2.692863521550168e-11, 1.014497202665280e+00 }, + { -4.487993290681805e-11, 1.024210025248670e+00 }, + { -6.282954089398273e-11, 1.033959576559617e+00 }, + { -8.077678338451706e-11, 1.043745481028715e+00 }, + { -9.872098467477489e-11, 1.053567358883467e+00 }, + { -1.166614691757772e-10, 1.063424826163223e+00 }, + { -1.345975614383584e-10, 1.073317494734013e+00 }, + { -1.525285861788948e-10, 1.083244972303963e+00 }, + { -1.704538683042922e-10, 1.093206862438572e+00 }, + { -1.883727329379793e-10, 1.103202764576806e+00 }, + { -2.062845054446831e-10, 1.113232274046796e+00 }, + { -2.241885114563697e-10, 1.123294982082432e+00 }, + { -2.420840768973375e-10, 1.133390475839767e+00 }, + { -2.599705280096278e-10, 1.143518338413855e+00 }, + { -2.778471913784365e-10, 1.153678148855860e+00 }, + { -2.957133939575774e-10, 1.163869482190458e+00 }, + { -3.135684630945758e-10, 1.174091909433296e+00 }, + { -3.314117265561857e-10, 1.184344997608959e+00 }, + { -3.492425125535882e-10, 1.194628309769018e+00 }, + { -3.670601497678034e-10, 1.204941405010466e+00 }, + { -3.848639673748360e-10, 1.215283838494269e+00 }, + { -4.026532950710339e-10, 1.225655161464298e+00 }, + { -4.204274630982869e-10, 1.236054921266445e+00 }, + { -4.381858022691734e-10, 1.246482661367958e+00 }, + { -4.559276439922654e-10, 1.256937921377146e+00 }, + { -4.736523202972214e-10, 1.267420237063216e+00 }, + { -4.913591638600925e-10, 1.277929140376502e+00 }, + { -5.090475080282032e-10, 1.288464159468706e+00 }, + { -5.267166868452449e-10, 1.299024818713528e+00 }, + { -5.443660350768455e-10, 1.309610638727845e+00 }, + { -5.619948882348695e-10, 1.320221136392390e+00 }, + { -5.796025826029868e-10, 1.330855824873457e+00 }, + { -5.971884552615020e-10, 1.341514213644420e+00 }, + { -6.147518441122357e-10, 1.352195808507556e+00 }, + { -6.322920879034590e-10, 1.362900111616144e+00 }, + { -6.498085262549874e-10, 1.373626621496939e+00 }, + { -6.673004996827436e-10, 1.384374833072571e+00 }, + { -6.847673496239581e-10, 1.395144237684605e+00 }, + { -7.022084184613616e-10, 1.405934323116231e+00 }, + { -7.196230495488082e-10, 1.416744573616104e+00 }, + { -7.370105872352039e-10, 1.427574469921397e+00 }, + { -7.543703768894941e-10, 1.438423489281758e+00 }, + { -7.717017649255453e-10, 1.449291105483472e+00 }, + { -7.890040988262324e-10, 1.460176788873383e+00 }, + { -8.062767271686383e-10, 1.471080006383765e+00 }, + { -8.235189996479819e-10, 1.482000221556656e+00 }, + { -8.407302671024475e-10, 1.492936894569018e+00 }, + { -8.579098815375368e-10, 1.503889482257845e+00 }, + { -8.750571961505266e-10, 1.514857438145604e+00 }, + { -8.921715653546624e-10, 1.525840212465756e+00 }, + { -9.092523448036167e-10, 1.536837252188703e+00 }, + { -9.262988914157881e-10, 1.547848001047890e+00 }, + { -9.433105633981766e-10, 1.558871899565883e+00 }, + { -9.602867202711075e-10, 1.569908385081254e+00 }, + { -9.772267228916820e-10, 1.580956891774897e+00 }, + { -9.941299334786078e-10, 1.592016850697478e+00 }, + { -1.010995715635332e-09, 1.603087689796053e+00 }, + { -1.027823434374870e-09, 1.614168833942028e+00 }, + { -1.044612456143047e-09, 1.625259704958335e+00 }, + { -1.061362148842745e-09, 1.636359721647526e+00 }, + { -1.078071881857297e-09, 1.647468299819543e+00 }, + { -1.094741026074900e-09, 1.658584852320419e+00 }, + { -1.111368953911690e-09, 1.669708789060341e+00 }, + { -1.127955039335462e-09, 1.680839517042381e+00 }, + { -1.144498657889600e-09, 1.691976440391624e+00 }, + { -1.160999186716154e-09, 1.703118960383971e+00 }, + { -1.177456004579561e-09, 1.714266475475616e+00 }, + { -1.193868491889832e-09, 1.725418381332405e+00 }, + { -1.210236030726319e-09, 1.736574070859850e+00 }, + { -1.226558004860220e-09, 1.747732934232508e+00 }, + { -1.242833799778447e-09, 1.758894358924547e+00 }, + { -1.259062802706714e-09, 1.770057729740021e+00 }, + { -1.275244402631982e-09, 1.781222428842935e+00 }, + { -1.291377990326492e-09, 1.792387835788660e+00 }, + { -1.307462958369363e-09, 1.803553327553897e+00 }, + { -1.323498701170897e-09, 1.814718278568759e+00 }, + { -1.339484614994490e-09, 1.825882060747428e+00 }, + { -1.355420097979292e-09, 1.837044043519582e+00 }, + { -1.371304550163662e-09, 1.848203593862598e+00 }, + { -1.387137373506711e-09, 1.859360076332671e+00 }, + { -1.402917971911754e-09, 1.870512853097495e+00 }, + { -1.418645751248018e-09, 1.881661283967967e+00 }, + { -1.434320119373722e-09, 1.892804726431080e+00 }, + { -1.449940486157623e-09, 1.903942535681972e+00 }, + { -1.465506263501516e-09, 1.915074064656886e+00 }, + { -1.481016865363264e-09, 1.926198664066737e+00 }, + { -1.496471707776859e-09, 1.937315682428795e+00 }, + { -1.511870208876724e-09, 1.948424466101625e+00 }, + { -1.527211788917509e-09, 1.959524359317042e+00 }, + { -1.542495870297867e-09, 1.970614704215133e+00 }, + { -1.557721877580406e-09, 1.981694840876775e+00 }, + { -1.572889237514880e-09, 1.992764107358707e+00 }, + { -1.587997379058514e-09, 2.003821839726753e+00 }, + { -1.603045733398246e-09, 2.014867372090665e+00 }, + { -1.618033733972424e-09, 2.025900036638798e+00 }, + { -1.632960816490822e-09, 2.036919163671778e+00 }, + { -1.647826418957721e-09, 2.047924081638631e+00 }, + { -1.662629981691070e-09, 2.058914117170269e+00 }, + { -1.677370947345626e-09, 2.069888595116115e+00 }, + { -1.692048760931849e-09, 2.080846838577820e+00 }, + { -1.706662869838827e-09, 2.091788168946183e+00 }, + { -1.721212723853279e-09, 2.102711905935372e+00 }, + { -1.735697775181424e-09, 2.113617367619504e+00 }, + { -1.750117478469621e-09, 2.124503870468520e+00 }, + { -1.764471290823748e-09, 2.135370729383332e+00 }, + { -1.778758671831281e-09, 2.146217257733207e+00 }, + { -1.792979083579974e-09, 2.157042767390815e+00 }, + { -1.807131990679890e-09, 2.167846568770014e+00 }, + { -1.821216860281448e-09, 2.178627970860822e+00 }, + { -1.835233162097977e-09, 2.189386281268046e+00 }, + { -1.849180368423027e-09, 2.200120806246095e+00 }, + { -1.863057954152340e-09, 2.210830850737588e+00 }, + { -1.876865396802907e-09, 2.221515718409926e+00 }, + { -1.890602176531920e-09, 2.232174711691990e+00 }, + { -1.904267776157843e-09, 2.242807131812679e+00 }, + { -1.917861681178094e-09, 2.253412278837029e+00 }, + { -1.931383379790273e-09, 2.263989451705295e+00 }, + { -1.944832362909578e-09, 2.274537948269257e+00 }, + { -1.958208124189984e-09, 2.285057065331676e+00 }, + { -1.971510160041235e-09, 2.295546098682665e+00 }, + { -1.984737969649064e-09, 2.306004343138794e+00 }, + { -1.997891054994522e-09, 2.316431092581699e+00 }, + { -2.010968920870647e-09, 2.326825639994779e+00 }, + { -2.023971074903858e-09, 2.337187277503834e+00 }, + { -2.036897027569834e-09, 2.347515296413520e+00 }, + { -2.049746292214264e-09, 2.357808987247877e+00 }, + { -2.062518385069210e-09, 2.368067639787542e+00 }, + { -2.075212825272584e-09, 2.378290543109652e+00 }, + { -2.087829134886364e-09, 2.388476985626922e+00 }, + { -2.100366838912949e-09, 2.398626255125417e+00 }, + { -2.112825465315542e-09, 2.408737638805759e+00 }, + { -2.125204545033289e-09, 2.418810423320288e+00 }, + { -2.137503612001452e-09, 2.428843894814472e+00 }, + { -2.149722203166389e-09, 2.438837338964302e+00 }, + { -2.161859858505829e-09, 2.448790041018174e+00 }, + { -2.173916121043380e-09, 2.458701285834241e+00 }, + { -2.185890536867478e-09, 2.468570357921585e+00 }, + { -2.197782655148702e-09, 2.478396541480230e+00 }, + { -2.209592028154913e-09, 2.488179120439544e+00 }, + { -2.221318211270522e-09, 2.497917378500214e+00 }, + { -2.232960763010574e-09, 2.507610599172123e+00 }, + { -2.244519245040444e-09, 2.517258065817044e+00 }, + { -2.255993222189014e-09, 2.526859061686102e+00 }, + { -2.267382262468209e-09, 2.536412869962689e+00 }, + { -2.278685937086658e-09, 2.545918773800664e+00 }, + { -2.289903820467374e-09, 2.555376056366064e+00 }, + { -2.301035490263848e-09, 2.564784000877677e+00 }, + { -2.312080527374447e-09, 2.574141890646339e+00 }, + { -2.323038515960257e-09, 2.583449009117307e+00 }, + { -2.333909043458635e-09, 2.592704639909166e+00 }, + { -2.344691700601153e-09, 2.601908066856634e+00 }, + { -2.355386081425938e-09, 2.611058574048749e+00 }, + { -2.365991783296513e-09, 2.620155445872768e+00 }, + { -2.376508406913500e-09, 2.629197967052127e+00 }, + { -2.386935556332088e-09, 2.638185422689490e+00 }, + { -2.397272838976436e-09, 2.647117098307332e+00 }, + { -2.407519865653114e-09, 2.655992279887846e+00 }, + { -2.417676250567891e-09, 2.664810253915885e+00 }, + { -2.427741611338014e-09, 2.673570307418169e+00 }, + { -2.437715569009093e-09, 2.682271728006635e+00 }, + { -2.447597748066437e-09, 2.690913803917100e+00 }, + { -2.457387776452357e-09, 2.699495824053297e+00 }, + { -2.467085285577292e-09, 2.708017078025636e+00 }, + { -2.476689910335470e-09, 2.716476856194105e+00 }, + { -2.486201289118733e-09, 2.724874449709689e+00 }, + { -2.495619063828443e-09, 2.733209150554255e+00 }, + { -2.504942879891263e-09, 2.741480251583985e+00 }, + { -2.514172386270163e-09, 2.749687046568741e+00 }, + { -2.523307235480146e-09, 2.757828830235740e+00 }, + { -2.532347083598520e-09, 2.765904898308531e+00 }, + { -2.541291590280960e-09, 2.773914547551261e+00 }, + { -2.550140418771202e-09, 2.781857075807392e+00 }, + { -2.558893235915887e-09, 2.789731782043156e+00 }, + { -2.567549712176927e-09, 2.797537966388929e+00 }, + { -2.576109521642196e-09, 2.805274930179221e+00 }, + { -2.584572342040407e-09, 2.812941975996573e+00 }, + { -2.592937854750428e-09, 2.820538407710556e+00 }, + { -2.601205744816134e-09, 2.828063530521908e+00 }, + { -2.609375700955458e-09, 2.835516651001539e+00 }, + { -2.617447415574869e-09, 2.842897077134583e+00 }, + { -2.625420584778350e-09, 2.850204118359573e+00 }, + { -2.633294908380520e-09, 2.857437085611509e+00 }, + { -2.641070089918234e-09, 2.864595291363663e+00 }, + { -2.648745836659391e-09, 2.871678049666939e+00 }, + { -2.656321859617343e-09, 2.878684676194483e+00 }, + { -2.663797873558322e-09, 2.885614488280000e+00 }, + { -2.671173597015318e-09, 2.892466804962122e+00 }, + { -2.678448752295859e-09, 2.899240947023252e+00 }, + { -2.685623065495139e-09, 2.905936237033475e+00 }, + { -2.692696266503800e-09, 2.912551999389617e+00 }, + { -2.699668089019767e-09, 2.919087560358171e+00 }, + { -2.706538270558513e-09, 2.925542248116882e+00 }, + { -2.713306552460767e-09, 2.931915392794031e+00 }, + { -2.719972679905295e-09, 2.938206326512581e+00 }, + { -2.726536401915442e-09, 2.944414383428562e+00 }, + { -2.732997471371516e-09, 2.950538899775061e+00 }, + { -2.739355645017194e-09, 2.956579213900666e+00 }, + { -2.745610683471516e-09, 2.962534666313284e+00 }, + { -2.751762351235315e-09, 2.968404599718795e+00 }, + { -2.757810416701751e-09, 2.974188359063684e+00 }, + { -2.763754652165128e-09, 2.979885291576143e+00 }, + { -2.769594833827588e-09, 2.985494746805227e+00 }, + { -2.775330741810390e-09, 2.991016076664491e+00 }, + { -2.780962160159068e-09, 2.996448635469842e+00 }, + { -2.786488876854607e-09, 3.001791779983262e+00 }, + { -2.791910683818570e-09, 3.007044869450794e+00 }, + { -2.797227376923695e-09, 3.012207265645876e+00 }, + { -2.802438755998943e-09, 3.017278332907412e+00 }, + { -2.807544624838820e-09, 3.022257438182037e+00 }, + { -2.812544791210840e-09, 3.027143951064684e+00 }, + { -2.817439066860792e-09, 3.031937243837070e+00 }, + { -2.822227267522746e-09, 3.036636691510884e+00 }, + { -2.826909212922864e-09, 3.041241671864994e+00 }, + { -2.831484726789317e-09, 3.045751565488710e+00 }, + { -2.835953636855826e-09, 3.050165755818853e+00 }, + { -2.840315774871260e-09, 3.054483629182857e+00 }, + { -2.844570976602957e-09, 3.058704574835744e+00 }, + { -2.848719081844986e-09, 3.062827985002047e+00 }, + { -2.852759934424164e-09, 3.066853254915581e+00 }, + { -2.856693382203833e-09, 3.070779782857041e+00 }, + { -2.860519277092708e-09, 3.074606970196721e+00 }, + { -2.864237475047239e-09, 3.078334221430809e+00 }, + { -2.867847836080156e-09, 3.081960944223928e+00 }, + { -2.871350224262603e-09, 3.085486549445314e+00 }, + { -2.874744507732462e-09, 3.088910451211251e+00 }, + { -2.878030558696270e-09, 3.092232066921130e+00 }, + { -2.881208253436038e-09, 3.095450817298478e+00 }, + { -2.884277472313999e-09, 3.098566126429974e+00 }, + { -2.887238099774968e-09, 3.101577421802070e+00 }, + { -2.890090024353816e-09, 3.104484134342861e+00 }, + { -2.892833138676371e-09, 3.107285698457308e+00 }, + { -2.895467339466766e-09, 3.109981552069083e+00 }, + { -2.897992527547963e-09, 3.112571136655481e+00 }, + { -2.900408607848946e-09, 3.115053897289195e+00 }, + { -2.902715489404992e-09, 3.117429282673042e+00 }, + { -2.904913085363323e-09, 3.119696745180238e+00 }, + { -2.907001312986328e-09, 3.121855740892224e+00 }, + { -2.908980093652563e-09, 3.123905729634218e+00 }, + { -2.910849352862924e-09, 3.125846175016163e+00 }, + { -2.912609020239985e-09, 3.127676544466606e+00 }, + { -2.914259029534118e-09, 3.129396309273659e+00 }, + { -2.915799318622574e-09, 3.131004944618667e+00 }, + { -2.917229829515169e-09, 3.132501929616775e+00 }, + { -2.918550508353347e-09, 3.133886747350606e+00 }, + { -2.919761305414294e-09, 3.135158884909254e+00 }, + { -2.920862175112829e-09, 3.136317833424958e+00 }, + { -2.921853076000972e-09, 3.137363088107359e+00 }, + { -2.922733970772719e-09, 3.138294148283254e+00 }, + { -2.923504826262027e-09, 3.139110517429204e+00 }, + { -2.924165613447473e-09, 3.139811703211207e+00 }, + { -2.924716307449950e-09, 3.140397217517018e+00 }, + { -2.925156887536978e-09, 3.140866576495489e+00 }, + { -2.925487337120335e-09, 3.141219300588825e+00 }, + { -2.925707643758784e-09, 3.141454914570261e+00 }, + { -2.925817799158535e-09, 3.141572947579352e+00 }, + { -2.925817799171455e-09, 3.141572933154836e+00 }, + { -2.925707643798390e-09, 3.141454409272987e+00 }, + { -2.925487337185779e-09, 3.141216918378770e+00 }, + { -2.925156887628892e-09, 3.140860007424112e+00 }, + { -2.924716307568119e-09, 3.140383227898687e+00 }, + { -2.924165613591896e-09, 3.139786135867868e+00 }, + { -2.923504826432903e-09, 3.139068292003385e+00 }, + { -2.922733970969412e-09, 3.138229261619561e+00 }, + { -2.921853076224321e-09, 3.137268614707029e+00 }, + { -2.920862175361976e-09, 3.136185925964038e+00 }, + { -2.919761305690083e-09, 3.134980774833275e+00 }, + { -2.918550508654911e-09, 3.133652745531368e+00 }, + { -2.917229829843137e-09, 3.132201427085629e+00 }, + { -2.915799318976726e-09, 3.130626413363146e+00 }, + { -2.914259029914435e-09, 3.128927303107136e+00 }, + { -2.912609020646661e-09, 3.127103699965947e+00 }, + { -2.910849353295315e-09, 3.125155212527586e+00 }, + { -2.908980094111509e-09, 3.123081454351802e+00 }, + { -2.907001313470937e-09, 3.120882043999591e+00 }, + { -2.904913085874448e-09, 3.118556605068443e+00 }, + { -2.902715489941767e-09, 3.116104766219928e+00 }, + { -2.900408608411958e-09, 3.113526161214776e+00 }, + { -2.897992528137022e-09, 3.110820428940251e+00 }, + { -2.895467340081818e-09, 3.107987213444579e+00 }, + { -2.892833139317615e-09, 3.105026163964191e+00 }, + { -2.890090025020589e-09, 3.101936934956479e+00 }, + { -2.887238100468092e-09, 3.098719186130021e+00 }, + { -2.884277473032614e-09, 3.095372582472161e+00 }, + { -2.881208254180937e-09, 3.091896794282404e+00 }, + { -2.878030559466594e-09, 3.088291497198199e+00 }, + { -2.874744508528832e-09, 3.084556372228054e+00 }, + { -2.871350225084755e-09, 3.080691105776848e+00 }, + { -2.867847836928063e-09, 3.076695389678615e+00 }, + { -2.864237475921086e-09, 3.072568921221621e+00 }, + { -2.860519277991847e-09, 3.068311403179147e+00 }, + { -2.856693383129018e-09, 3.063922543837792e+00 }, + { -2.852759935374575e-09, 3.059402057023109e+00 }, + { -2.848719082821403e-09, 3.054749662130841e+00 }, + { -2.844570977604520e-09, 3.049965084150782e+00 }, + { -2.840315775898525e-09, 3.045048053697736e+00 }, + { -2.835953637908582e-09, 3.039998307034967e+00 }, + { -2.831484727867511e-09, 3.034815586104635e+00 }, + { -2.826909214026628e-09, 3.029499638550941e+00 }, + { -2.822227268651470e-09, 3.024050217748861e+00 }, + { -2.817439068015245e-09, 3.018467082830179e+00 }, + { -2.812544792390175e-09, 3.012749998707001e+00 }, + { -2.807544626043751e-09, 3.006898736100911e+00 }, + { -2.802438757228650e-09, 3.000913071564665e+00 }, + { -2.797227378178760e-09, 2.994792787510961e+00 }, + { -2.791910685098702e-09, 2.988537672233504e+00 }, + { -2.786488878159805e-09, 2.982147519935565e+00 }, + { -2.780962161489413e-09, 2.975622130750641e+00 }, + { -2.775330743165298e-09, 2.968961310769028e+00 }, + { -2.769594835207775e-09, 2.962164872061613e+00 }, + { -2.763754653569747e-09, 2.955232632701135e+00 }, + { -2.757810418131543e-09, 2.948164416789036e+00 }, + { -2.751762352689432e-09, 2.940960054474719e+00 }, + { -2.745610684950541e-09, 2.933619381982341e+00 }, + { -2.739355646520809e-09, 2.926142241629213e+00 }, + { -2.732997472899722e-09, 2.918528481852205e+00 }, + { -2.726536403468318e-09, 2.910777957226018e+00 }, + { -2.719972681482232e-09, 2.902890528487386e+00 }, + { -2.713306554062453e-09, 2.894866062556452e+00 }, + { -2.706538272184154e-09, 2.886704432555728e+00 }, + { -2.699668090670078e-09, 2.878405517834426e+00 }, + { -2.692696268177908e-09, 2.869969203985464e+00 }, + { -2.685623067193599e-09, 2.861395382869544e+00 }, + { -2.678448754018380e-09, 2.852683952631486e+00 }, + { -2.671173598761847e-09, 2.843834817723832e+00 }, + { -2.663797875328991e-09, 2.834847888922988e+00 }, + { -2.656321861411517e-09, 2.825723083350459e+00 }, + { -2.648745838477759e-09, 2.816460324492298e+00 }, + { -2.641070091759922e-09, 2.807059542215146e+00 }, + { -2.633294910246296e-09, 2.797520672788269e+00 }, + { -2.625420586667340e-09, 2.787843658897949e+00 }, + { -2.617447417487602e-09, 2.778028449668942e+00 }, + { -2.609375702891616e-09, 2.768075000678399e+00 }, + { -2.601205746775692e-09, 2.757983273976943e+00 }, + { -2.592937856733464e-09, 2.747753238101915e+00 }, + { -2.584572344046340e-09, 2.737384868096553e+00 }, + { -2.576109523671634e-09, 2.726878145526201e+00 }, + { -2.567549714229129e-09, 2.716233058492422e+00 }, + { -2.558893237991435e-09, 2.705449601651722e+00 }, + { -2.550140420869302e-09, 2.694527776227857e+00 }, + { -2.541291592402089e-09, 2.683467590030445e+00 }, + { -2.532347085742440e-09, 2.672269057466213e+00 }, + { -2.523307237646751e-09, 2.660932199557362e+00 }, + { -2.514172388459584e-09, 2.649457043952206e+00 }, + { -2.504942882102813e-09, 2.637843624941622e+00 }, + { -2.495619066062810e-09, 2.626091983472908e+00 }, + { -2.486201291375123e-09, 2.614202167160335e+00 }, + { -2.476689912614465e-09, 2.602174230302269e+00 }, + { -2.467085287878098e-09, 2.590008233889805e+00 }, + { -2.457387778775451e-09, 2.577704245623143e+00 }, + { -2.447597750411553e-09, 2.565262339920002e+00 }, + { -2.437715571376127e-09, 2.552682597931055e+00 }, + { -2.427741613727123e-09, 2.539965107548168e+00 }, + { -2.417676252978335e-09, 2.527109963417675e+00 }, + { -2.407519868085581e-09, 2.514117266951687e+00 }, + { -2.397272841430131e-09, 2.500987126335739e+00 }, + { -2.386935558807595e-09, 2.487719656543254e+00 }, + { -2.376508409410024e-09, 2.474314979341178e+00 }, + { -2.365991785814531e-09, 2.460773223303822e+00 }, + { -2.355386083965131e-09, 2.447094523817833e+00 }, + { -2.344691703161363e-09, 2.433279023095734e+00 }, + { -2.333909046040126e-09, 2.419326870180582e+00 }, + { -2.323038518562289e-09, 2.405238220956597e+00 }, + { -2.312080529997549e-09, 2.391013238157397e+00 }, + { -2.301035492907384e-09, 2.376652091371587e+00 }, + { -2.289903823131822e-09, 2.362154957053137e+00 }, + { -2.278685939771276e-09, 2.347522018525197e+00 }, + { -2.267382265173420e-09, 2.332753465990296e+00 }, + { -2.255993224914501e-09, 2.317849496533128e+00 }, + { -2.244519247786155e-09, 2.302810314130351e+00 }, + { -2.232960765776561e-09, 2.287636129652823e+00 }, + { -2.221318214056095e-09, 2.272327160873552e+00 }, + { -2.209592030960763e-09, 2.256883632472565e+00 }, + { -2.197782657974034e-09, 2.241305776039511e+00 }, + { -2.185890539712767e-09, 2.225593830081461e+00 }, + { -2.173916123907886e-09, 2.209748040023618e+00 }, + { -2.161859861389976e-09, 2.193768658216360e+00 }, + { -2.149722206070124e-09, 2.177655943935795e+00 }, + { -2.137503614923981e-09, 2.161410163388424e+00 }, + { -2.125204547975352e-09, 2.145031589714984e+00 }, + { -2.112825468276292e-09, 2.128520502989477e+00 }, + { -2.100366841892917e-09, 2.111877190225612e+00 }, + { -2.087829137884807e-09, 2.095101945374541e+00 }, + { -2.075212828290086e-09, 2.078195069329960e+00 }, + { -2.062518388104923e-09, 2.061156869925600e+00 }, + { -2.049746295268559e-09, 2.043987661939897e+00 }, + { -2.036897030642658e-09, 2.026687767092888e+00 }, + { -2.023971077994576e-09, 2.009257514048162e+00 }, + { -2.010968923979840e-09, 1.991697238413571e+00 }, + { -1.997891058121344e-09, 1.974007282737320e+00 }, + { -1.984737972794098e-09, 1.956187996511354e+00 }, + { -1.971510163203686e-09, 1.938239736166060e+00 }, + { -1.958208127370276e-09, 1.920162865072273e+00 }, + { -1.944832366107339e-09, 1.901957753535934e+00 }, + { -1.931383383005451e-09, 1.883624778799427e+00 }, + { -1.917861684410531e-09, 1.865164325035177e+00 }, + { -1.904267779407432e-09, 1.846576783346324e+00 }, + { -1.890602179798714e-09, 1.827862551760622e+00 }, + { -1.876865400086483e-09, 1.809022035228338e+00 }, + { -1.863057957452539e-09, 1.790055645617624e+00 }, + { -1.849180371740008e-09, 1.770963801711725e+00 }, + { -1.835233165431475e-09, 1.751746929201178e+00 }, + { -1.821216863631569e-09, 1.732405460681919e+00 }, + { -1.807131994045840e-09, 1.712939835648088e+00 }, + { -1.792979086962494e-09, 1.693350500488565e+00 }, + { -1.778758675229683e-09, 1.673637908477153e+00 }, + { -1.764471294238191e-09, 1.653802519770021e+00 }, + { -1.750117481899733e-09, 1.633844801396848e+00 }, + { -1.735697778626995e-09, 1.613765227254186e+00 }, + { -1.721212727314574e-09, 1.593564278099856e+00 }, + { -1.706662873315474e-09, 1.573242441540939e+00 }, + { -1.692048764423848e-09, 1.552800212030258e+00 }, + { -1.677370950852395e-09, 1.532238090855187e+00 }, + { -1.662629985213192e-09, 1.511556586131055e+00 }, + { -1.647826422494560e-09, 1.490756212788764e+00 }, + { -1.632960820042537e-09, 1.469837492568651e+00 }, + { -1.618033737538645e-09, 1.448800954008929e+00 }, + { -1.603045736978760e-09, 1.427647132435469e+00 }, + { -1.587997382653428e-09, 1.406376569953373e+00 }, + { -1.572889241124034e-09, 1.384989815432507e+00 }, + { -1.557721881203696e-09, 1.363487424499449e+00 }, + { -1.542495873934815e-09, 1.341869959524515e+00 }, + { -1.527211792568486e-09, 1.320137989611176e+00 }, + { -1.511870212541253e-09, 1.298292090581491e+00 }, + { -1.496471711454994e-09, 1.276332844965754e+00 }, + { -1.481016869054634e-09, 1.254260841988828e+00 }, + { -1.465506267206068e-09, 1.232076677556547e+00 }, + { -1.449940489875303e-09, 1.209780954243628e+00 }, + { -1.434320123104372e-09, 1.187374281276747e+00 }, + { -1.418645754991533e-09, 1.164857274523495e+00 }, + { -1.402917975667710e-09, 1.142230556475749e+00 }, + { -1.387137377275425e-09, 1.119494756236361e+00 }, + { -1.371304553944712e-09, 1.096650509501278e+00 }, + { -1.355420101772623e-09, 1.073698458546610e+00 }, + { -1.339484618799891e-09, 1.050639252211352e+00 }, + { -1.323498704988051e-09, 1.027473545880543e+00 }, + { -1.307462962198534e-09, 1.004202001471034e+00 }, + { -1.291377994167204e-09, 9.808252874104182e-01 }, + { -1.275244406484394e-09, 9.573440786237052e-01 }, + { -1.259062806570190e-09, 9.337590565128454e-01 }, + { -1.242833803653464e-09, 9.100709089414796e-01 }, + { -1.226558008746195e-09, 8.862803302125812e-01 }, + { -1.210236034623253e-09, 8.623880210538113e-01 }, + { -1.193868495797618e-09, 8.383946885959868e-01 }, + { -1.177456008497777e-09, 8.143010463544786e-01 }, + { -1.160999190645010e-09, 7.901078142102129e-01 }, + { -1.144498661828833e-09, 7.658157183877095e-01 }, + { -1.127955043284965e-09, 7.414254914366063e-01 }, + { -1.111368957870986e-09, 7.169378722095157e-01 }, + { -1.094741030044308e-09, 6.923536058430697e-01 }, + { -1.078071885836393e-09, 6.676734437331688e-01 }, + { -1.061362152831423e-09, 6.428981435165511e-01 }, + { -1.044612460141255e-09, 6.180284690466404e-01 }, + { -1.027823438382183e-09, 5.930651903718045e-01 }, + { -1.010995719652015e-09, 5.680090837138436e-01 }, + { -9.941299375042378e-10, 5.428609314418970e-01 }, + { -9.772267269262058e-10, 5.176215220520872e-01 }, + { -9.602867243141016e-10, 4.922916501421032e-01 }, + { -9.433105674499058e-10, 4.668721163885412e-01 }, + { -9.262988954758817e-10, 4.413637275202624e-01 }, + { -9.092523488719689e-10, 4.157672962958654e-01 }, + { -8.921715694311144e-10, 3.900836414778084e-01 }, + { -8.750572002347607e-10, 3.643135878065193e-01 }, + { -8.579098856296589e-10, 3.384579659762392e-01 }, + { -8.407302712022458e-10, 3.125176126069478e-01 }, + { -8.235190037551917e-10, 2.864933702193017e-01 }, + { -8.062767312831008e-10, 2.603860872080448e-01 }, + { -7.890041029479477e-10, 2.341966178147619e-01 }, + { -7.717017690542486e-10, 2.079258220999725e-01 }, + { -7.543703810250266e-10, 1.815745659161734e-01 }, + { -7.370105913774597e-10, 1.551437208801425e-01 }, + { -7.196230536974697e-10, 1.286341643433767e-01 }, + { -7.022084226165876e-10, 1.020467793657360e-01 }, + { -6.847673537853251e-10, 7.538245468350446e-02 }, + { -6.673005038502516e-10, 4.864208468284503e-02 }, + { -6.498085304282128e-10, 2.182656936863137e-02 }, + { -6.322920920826137e-10, -5.063185663820913e-03 }, + { -6.147518482969490e-10, -3.202626926150343e-02 }, + { -5.971884594516681e-10, -5.906176474160862e-02 }, + { -5.796025867984469e-10, -8.616874992366363e-02 }, + { -5.619948924353588e-10, -1.133462971605448e-01 }, + { -5.443660392823640e-10, -1.405934733692621e-01 }, + { -5.267166910556339e-10, -1.679093400638023e-01 }, + { -5.090475122431451e-10, -1.952929533862739e-01 }, + { -4.913591680795342e-10, -2.227433641394564e-01 }, + { -4.736523245210571e-10, -2.502596178194491e-01 }, + { -4.559276482202303e-10, -2.778407546490776e-01 }, + { -4.381858065011618e-10, -3.054858096104932e-01 }, + { -4.204274673340870e-10, -3.331938124792702e-01 }, + { -4.026532993105397e-10, -3.609637878577768e-01 }, + { -3.848639716178888e-10, -3.887947552098022e-01 }, + { -3.670601540142443e-10, -4.166857288948674e-01 }, + { -3.492425168032583e-10, -4.446357182029681e-01 }, + { -3.314117308088734e-10, -4.726437273896633e-01 }, + { -3.135684673501752e-10, -5.007087557112619e-01 }, + { -2.957133982159296e-10, -5.288297974607742e-01 }, + { -2.778471956393828e-10, -5.570058420037128e-01 }, + { -2.599705322729564e-10, -5.852358738143247e-01 }, + { -2.420840811628366e-10, -6.135188725122560e-01 }, + { -2.241885157240923e-10, -6.418538128986450e-01 }, + { -2.062845097142585e-10, -6.702396649949099e-01 }, + { -1.883727372093546e-10, -6.986753940779493e-01 }, + { -1.704538725773087e-10, -7.271599607197149e-01 }, + { -1.525285904532877e-10, -7.556923208240308e-01 }, + { -1.345975657140748e-10, -7.842714256651911e-01 }, + { -1.166614734526054e-10, -8.128962219265712e-01 }, + { -9.872098895260891e-11, -8.415656517393372e-01 }, + { -8.077678766314517e-11, -8.702786527215916e-01 }, + { -6.282954517324612e-11, -8.990341580176152e-01 }, + { -4.487993718655790e-11, -9.278310963373758e-01 }, + { -2.692863949561210e-11, -9.566683919968972e-01 }, + { -8.976327956520795e-12, -9.855449649582175e-01 }, + { 8.976321536169872e-12, -1.014459730869357e+00 }, + { 2.692863307547294e-11, -1.043411601105914e+00 }, + { 4.487993076694813e-11, -1.072399482811314e+00 }, + { 6.282953875437751e-11, -1.101422278938424e+00 }, + { 8.077678124517653e-11, -1.130478888291020e+00 }, + { 9.872098253591082e-11, -1.159568205565684e+00 }, + { 1.166614670373367e-10, -1.188689121393192e+00 }, + { 1.345975593005002e-10, -1.217840522381901e+00 }, + { 1.525285840416718e-10, -1.247021291159495e+00 }, + { 1.704538661678104e-10, -1.276230306415868e+00 }, + { 1.883727308022916e-10, -1.305466442946703e+00 }, + { 2.062845033098954e-10, -1.334728571696106e+00 }, + { 2.241885093225349e-10, -1.364015559800721e+00 }, + { 2.420840747645085e-10, -1.393326270633325e+00 }, + { 2.599705258779635e-10, -1.422659563847049e+00 }, + { 2.778471892479898e-10, -1.452014295419243e+00 }, + { 2.957133918284542e-10, -1.481389317696831e+00 }, + { 3.135684609667761e-10, -1.510783479440191e+00 }, + { 3.314117244297624e-10, -1.540195625869043e+00 }, + { 3.492425104288060e-10, -1.569624598707558e+00 }, + { 3.670601476445565e-10, -1.599069236228850e+00 }, + { 3.848639652533361e-10, -1.628528373302631e+00 }, + { 4.026532929512281e-10, -1.658000841439269e+00 }, + { 4.204274609803869e-10, -1.687485468837799e+00 }, + { 4.381858001531792e-10, -1.716981080430596e+00 }, + { 4.559276418782829e-10, -1.746486497931567e+00 }, + { 4.736523181853565e-10, -1.776000539882225e+00 }, + { 4.913591617503452e-10, -1.805522021699094e+00 }, + { 5.090475059206794e-10, -1.835049755721194e+00 }, + { 5.267166847401562e-10, -1.864582551257262e+00 }, + { 5.443660329740862e-10, -1.894119214633676e+00 }, + { 5.619948861345454e-10, -1.923658549242818e+00 }, + { 5.796025805053097e-10, -1.953199355591180e+00 }, + { 5.971884531664190e-10, -1.982740431347091e+00 }, + { 6.147518420199055e-10, -2.012280571390674e+00 }, + { 6.322920858139346e-10, -2.041818567861395e+00 }, + { 6.498085241682158e-10, -2.071353210208005e+00 }, + { 6.673004975990425e-10, -2.100883285238127e+00 }, + { 6.847673475432746e-10, -2.130407577166309e+00 }, + { 7.022084163838545e-10, -2.159924867664933e+00 }, + { 7.196230474743716e-10, -2.189433935913779e+00 }, + { 7.370105851640495e-10, -2.218933558650552e+00 }, + { 7.543703748217808e-10, -2.248422510220072e+00 }, + { 7.717017628611672e-10, -2.277899562625407e+00 }, + { 7.890040967654542e-10, -2.307363485579104e+00 }, + { 8.062767251113011e-10, -2.336813046552684e+00 }, + { 8.235189975944034e-10, -2.366247010829556e+00 }, + { 8.407302650525749e-10, -2.395664141553858e+00 }, + { 8.579098794915287e-10, -2.425063199784153e+00 }, + { 8.750571941082773e-10, -2.454442944543319e+00 }, + { 8.921715633164894e-10, -2.483802132872044e+00 }, + { 9.092523427695200e-10, -2.513139519878584e+00 }, + { 9.262988893857148e-10, -2.542453858792682e+00 }, + { 9.433105613723914e-10, -2.571743901017465e+00 }, + { 9.602867182493987e-10, -2.601008396180870e+00 }, + { 9.772267208744730e-10, -2.630246092190425e+00 }, + { 9.941299314658458e-10, -2.659455735283526e+00 }, + { 1.010995713627070e-09, -2.688636070081818e+00 }, + { 1.027823432371055e-09, -2.717785839644439e+00 }, + { 1.044612454143997e-09, -2.746903785521352e+00 }, + { 1.061362146848353e-09, -2.775988647805256e+00 }, + { 1.078071879867828e-09, -2.805039165187255e+00 }, + { 1.094741024090249e-09, -2.834054075009077e+00 }, + { 1.111368951931856e-09, -2.863032113318052e+00 }, + { 1.127955037360817e-09, -2.891972014920939e+00 }, + { 1.144498655920037e-09, -2.920872513436805e+00 }, + { 1.160999184751779e-09, -2.949732341353290e+00 }, + { 1.177456002620215e-09, -2.978550230079517e+00 }, + { 1.193868489936097e-09, -3.007324910002949e+00 }, + { 1.210236028777826e-09, -3.036055110540183e+00 }, + { 1.226558002917232e-09, -3.064739560196251e+00 }, + { 1.242833797841123e-09, -3.093376986616735e+00 }, + { 1.259062800774685e-09, -3.121966116643377e+00 }, + { 1.275244400705935e-09, -3.150505676371791e+00 }, + { 1.291377988406056e-09, -3.178994391202159e+00 }, + { 1.307462956454857e-09, -3.207430985899192e+00 }, + { 1.323498699262108e-09, -3.235814184645077e+00 }, + { 1.339484613091842e-09, -3.264142711097884e+00 }, + { 1.355420096082785e-09, -3.292415288443373e+00 }, + { 1.371304548273191e-09, -3.320630639454825e+00 }, + { 1.387137371622433e-09, -3.348787486547389e+00 }, + { 1.402917970033511e-09, -3.376884551834256e+00 }, + { 1.418645749376393e-09, -3.404920557184582e+00 }, + { 1.434320117508396e-09, -3.432894224276359e+00 }, + { 1.449940484298756e-09, -3.460804274656981e+00 }, + { 1.465506261649108e-09, -3.488649429796768e+00 }, + { 1.481016863517580e-09, -3.516428411149154e+00 }, + { 1.496471705937951e-09, -3.544139940202303e+00 }, + { 1.511870207044433e-09, -3.571782738540999e+00 }, + { 1.527211787092206e-09, -3.599355527901174e+00 }, + { 1.542495868479076e-09, -3.626857030226671e+00 }, + { 1.557721875768920e-09, -3.654285967729458e+00 }, + { 1.572889235710329e-09, -3.681641062941412e+00 }, + { 1.587997377261005e-09, -3.708921038776707e+00 }, + { 1.603045731607830e-09, -3.736124618586623e+00 }, + { 1.618033732189314e-09, -3.763250526218862e+00 }, + { 1.632960814715177e-09, -3.790297486071938e+00 }, + { 1.647826417189275e-09, -3.817264223155802e+00 }, + { 1.662629979930247e-09, -3.844149463148589e+00 }, + { 1.677370945591844e-09, -3.870951932452996e+00 }, + { 1.692048759186008e-09, -3.897670358257890e+00 }, + { 1.706662868100504e-09, -3.924303468590212e+00 }, + { 1.721212722122685e-09, -3.950849992378278e+00 }, + { 1.735697773458400e-09, -3.977308659506432e+00 }, + { 1.750117476754591e-09, -4.003678200876669e+00 }, + { 1.764471289116712e-09, -4.029957348461003e+00 }, + { 1.778758670132079e-09, -4.056144835364877e+00 }, + { 1.792979081888926e-09, -4.082239395882965e+00 }, + { 1.807131988996465e-09, -4.108239765556996e+00 }, + { 1.821216858606652e-09, -4.134144681236933e+00 }, + { 1.835233160431175e-09, -4.159952881133585e+00 }, + { 1.849180366764537e-09, -4.185663104882633e+00 }, + { 1.863057952502055e-09, -4.211274093599509e+00 }, + { 1.876865395161145e-09, -4.236784589940537e+00 }, + { 1.890602174898734e-09, -4.262193338157148e+00 }, + { 1.904267774533022e-09, -4.287499084158302e+00 }, + { 1.917861679562008e-09, -4.312700575567174e+00 }, + { 1.931383378182392e-09, -4.337796561778708e+00 }, + { 1.944832361310856e-09, -4.362785794021793e+00 }, + { 1.958208122599839e-09, -4.387667025411434e+00 }, + { 1.971510158459931e-09, -4.412439011013396e+00 }, + { 1.984737968076495e-09, -4.437100507898339e+00 }, + { 1.997891053431005e-09, -4.461650275204912e+00 }, + { 2.010968919316289e-09, -4.486087074191693e+00 }, + { 2.023971073358447e-09, -4.510409668301784e+00 }, + { 2.036897026033634e-09, -4.534616823217992e+00 }, + { 2.049746290686799e-09, -4.558707306921882e+00 }, + { 2.062518383551274e-09, -4.582679889754607e+00 }, + { 2.075212823764071e-09, -4.606533344469879e+00 }, + { 2.087829133387063e-09, -4.630266446298172e+00 }, + { 2.100366837422912e-09, -4.653877973001258e+00 }, + { 2.112825463835087e-09, -4.677366704934605e+00 }, + { 2.125204543562522e-09, -4.700731425099899e+00 }, + { 2.137503610540056e-09, -4.723970919208608e+00 }, + { 2.149722201714786e-09, -4.747083975738060e+00 }, + { 2.161859857063438e-09, -4.770069385989595e+00 }, + { 2.173916119610994e-09, -4.792925944149308e+00 }, + { 2.185890535445098e-09, -4.815652447340950e+00 }, + { 2.197782653735957e-09, -4.838247695689436e+00 }, + { 2.209592026751962e-09, -4.860710492376411e+00 }, + { 2.221318209877576e-09, -4.883039643700314e+00 }, + { 2.232960761627846e-09, -4.905233959130168e+00 }, + { 2.244519243667616e-09, -4.927292251368517e+00 }, + { 2.255993220826402e-09, -4.949213336406265e+00 }, + { 2.267382261115285e-09, -4.970996033581527e+00 }, + { 2.278685935744269e-09, -4.992639165639563e+00 }, + { 2.289903819135414e-09, -5.014141558784778e+00 }, + { 2.301035488942000e-09, -5.035502042744443e+00 }, + { 2.312080526062763e-09, -5.056719450823151e+00 }, + { 2.323038514659161e-09, -5.077792619963239e+00 }, + { 2.333909042168180e-09, -5.098720390796817e+00 }, + { 2.344691699320969e-09, -5.119501607709159e+00 }, + { 2.355386080156553e-09, -5.140135118892792e+00 }, + { 2.365991782037187e-09, -5.160619776404897e+00 }, + { 2.376508405665132e-09, -5.180954436227641e+00 }, + { 2.386935555094626e-09, -5.201137958319343e+00 }, + { 2.397272837749508e-09, -5.221169206676762e+00 }, + { 2.407519864436774e-09, -5.241047049389645e+00 }, + { 2.417676249362563e-09, -5.260770358700167e+00 }, + { 2.427741610143750e-09, -5.280338011053974e+00 }, + { 2.437715567825576e-09, -5.299748887163106e+00 }, + { 2.447597746894037e-09, -5.319001872058887e+00 }, + { 2.457387775290440e-09, -5.338095855149190e+00 }, + { 2.467085284426756e-09, -5.357029730277389e+00 }, + { 2.476689909196263e-09, -5.375802395772283e+00 }, + { 2.486201287990485e-09, -5.394412754510426e+00 }, + { 2.495619062711154e-09, -5.412859713968929e+00 }, + { 2.504942878785408e-09, -5.431142186284682e+00 }, + { 2.514172385175743e-09, -5.449259088303476e+00 }, + { 2.523307234396791e-09, -5.467209341642627e+00 }, + { 2.532347082526785e-09, -5.484991872743321e+00 }, + { 2.541291589219998e-09, -5.502605612925014e+00 }, + { 2.550140417722072e-09, -5.520049498445633e+00 }, + { 2.558893234878378e-09, -5.537322470548212e+00 }, + { 2.567549711150773e-09, -5.554423475524196e+00 }, + { 2.576109520627371e-09, -5.571351464763084e+00 }, + { 2.584572341037361e-09, -5.588105394812198e+00 }, + { 2.592937853759161e-09, -5.604684227423386e+00 }, + { 2.601205743836355e-09, -5.621086929615246e+00 }, + { 2.609375699987564e-09, -5.637312473723475e+00 }, + { 2.617447414618146e-09, -5.653359837454964e+00 }, + { 2.625420583833750e-09, -5.669228003945694e+00 }, + { 2.633294907447937e-09, -5.684915961806963e+00 }, + { 2.641070088997271e-09, -5.700422705186584e+00 }, + { 2.648745835750128e-09, -5.715747233817712e+00 }, + { 2.656321858720176e-09, -5.730888553077074e+00 }, + { 2.663797872673252e-09, -5.745845674030161e+00 }, + { 2.671173596142054e-09, -5.760617613492118e+00 }, + { 2.678448751434797e-09, -5.775203394076705e+00 }, + { 2.685623064645538e-09, -5.789602044248679e+00 }, + { 2.692696265666640e-09, -5.803812598380606e+00 }, + { 2.699668088194915e-09, -5.817834096797069e+00 }, + { 2.706538269745573e-09, -5.831665585834668e+00 }, + { 2.713306551659817e-09, -5.845306117889361e+00 }, + { 2.719972679116734e-09, -5.858754751472542e+00 }, + { 2.726536401139295e-09, -5.872010551255358e+00 }, + { 2.732997470607439e-09, -5.885072588127400e+00 }, + { 2.739355644265558e-09, -5.897939939244211e+00 }, + { 2.745610682731633e-09, -5.910611688078208e+00 }, + { 2.751762350508137e-09, -5.923086924473290e+00 }, + { 2.757810415987146e-09, -5.935364744687794e+00 }, + { 2.763754651462700e-09, -5.947444251452243e+00 }, + { 2.769594833137415e-09, -5.959324554015538e+00 }, + { 2.775330741132843e-09, -5.971004768198829e+00 }, + { 2.780962159494174e-09, -5.982484016437981e+00 }, + { 2.786488876202047e-09, -5.993761427840588e+00 }, + { 2.791910683178690e-09, -6.004836138231525e+00 }, + { 2.797227376295779e-09, -6.015707290202086e+00 }, + { 2.802438755383971e-09, -6.026374033162623e+00 }, + { 2.807544624236659e-09, -6.036835523383457e+00 }, + { 2.812544790621093e-09, -6.047090924050914e+00 }, + { 2.817439066283459e-09, -6.057139405311101e+00 }, + { 2.822227266958278e-09, -6.066980144322601e+00 }, + { 2.826909212371261e-09, -6.076612325295799e+00 }, + { 2.831484726250221e-09, -6.086035139548830e+00 }, + { 2.835953636329660e-09, -6.095247785550617e+00 }, + { 2.840315774357203e-09, -6.104249468967751e+00 }, + { 2.844570976102082e-09, -6.113039402715685e+00 }, + { 2.848719081357095e-09, -6.121616806996519e+00 }, + { 2.852759933948860e-09, -6.129980909353977e+00 }, + { 2.856693381741114e-09, -6.138130944714082e+00 }, + { 2.860519276643053e-09, -6.146066155436312e+00 }, + { 2.864237474610633e-09, -6.153785791350256e+00 }, + { 2.867847835656203e-09, -6.161289109809551e+00 }, + { 2.871350223851726e-09, -6.168575375732642e+00 }, + { 2.874744507333867e-09, -6.175643861647406e+00 }, + { 2.878030558310989e-09, -6.182493847739853e+00 }, + { 2.881208253063899e-09, -6.189124621889823e+00 }, + { 2.884277471954592e-09, -6.195535479723423e+00 }, + { 2.887238099428306e-09, -6.201725724651554e+00 }, + { 2.890090024020323e-09, -6.207694667918394e+00 }, + { 2.892833138356060e-09, -6.213441628635915e+00 }, + { 2.895467339159240e-09, -6.218965933835304e+00 }, + { 2.897992527253659e-09, -6.224266918505075e+00 }, + { 2.900408607567016e-09, -6.229343925633495e+00 }, + { 2.902715489136496e-09, -6.234196306254763e+00 }, + { 2.904913085108075e-09, -6.238823419482017e+00 }, + { 2.907001312743911e-09, -6.243224632557377e+00 }, + { 2.908980093422997e-09, -6.247399320887848e+00 }, + { 2.910849352646620e-09, -6.251346868091392e+00 }, + { 2.912609020036956e-09, -6.255066666028537e+00 }, + { 2.914259029343965e-09, -6.258558114851525e+00 }, + { 2.915799318445710e-09, -6.261820623039620e+00 }, + { 2.917229829350759e-09, -6.264853607438842e+00 }, + { 2.918550508202463e-09, -6.267656493305673e+00 }, + { 2.919761305276718e-09, -6.270228714337005e+00 }, + { 2.920862174988150e-09, -6.272569712717951e+00 }, + { 2.921853075889193e-09, -6.274678939154603e+00 }, + { 2.922733970674264e-09, -6.276555852917634e+00 }, + { 2.923504826176907e-09, -6.278199921870962e+00 }, + { 2.924165613375264e-09, -6.279610622518139e+00 }, + { 2.924716307391075e-09, -6.280787440034993e+00 }, + { 2.925156887490598e-09, -6.281729868306345e+00 }, + { 2.925487337087508e-09, -6.282437409966992e+00 }, + { 2.925707643739298e-09, -6.282909576428774e+00 }, + { 2.925817799151970e-09, -6.283145887925411e+00 }, diff --git a/gr-blocks/lib/skiphead_impl.cc b/gr-blocks/lib/skiphead_impl.cc new file mode 100644 index 0000000000..feb39eb8f4 --- /dev/null +++ b/gr-blocks/lib/skiphead_impl.cc @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2007,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "skiphead_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + skiphead::sptr + skiphead::make(size_t itemsize, uint64_t nitems_to_skip) + { + return gnuradio::get_initial_sptr + (new skiphead_impl(itemsize, nitems_to_skip)); + } + + skiphead_impl::skiphead_impl(size_t itemsize, uint64_t nitems_to_skip) + : gr_block("skiphead", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(1, 1, itemsize)), + d_nitems_to_skip(nitems_to_skip), d_nitems(0) + { + } + + skiphead_impl::~skiphead_impl() + { + } + + int + skiphead_impl::general_work(int noutput_items, + gr_vector_int &ninput_items_, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char*)input_items[0]; + char *out = (char*)output_items[0]; + + int ninput_items = std::min(ninput_items_[0], noutput_items); + int ii = 0; // input index + + while (ii < ninput_items) { + uint64_t ni_total = ii + d_nitems; // total items processed so far + if(ni_total < d_nitems_to_skip) { // need to skip some more + + int n_to_skip = (int)std::min(d_nitems_to_skip - ni_total, + (uint64_t)(ninput_items - ii)); + ii += n_to_skip; + } + + else { // nothing left to skip. copy away + int n_to_copy = ninput_items - ii; + if(n_to_copy > 0) { + size_t itemsize = output_signature()->sizeof_stream_item(0); + memcpy(out, in + (ii*itemsize), n_to_copy*itemsize); + } + + d_nitems += ninput_items; + consume_each(ninput_items); + return n_to_copy; + } + } + + d_nitems += ninput_items; + consume_each(ninput_items); + return 0; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/skiphead_impl.h b/gr-blocks/lib/skiphead_impl.h new file mode 100644 index 0000000000..d8e0870cb1 --- /dev/null +++ b/gr-blocks/lib/skiphead_impl.h @@ -0,0 +1,50 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_SKIPHEAD_IMPL_H +#define INCLUDED_GR_SKIPHEAD_IMPL_H + +#include <blocks/skiphead.h> + +namespace gr { + namespace blocks { + + class skiphead_impl : public skiphead + { + private: + uint64_t d_nitems_to_skip; + uint64_t d_nitems; // total items seen + + public: + skiphead_impl(size_t itemsize, uint64_t nitems_to_skip); + ~skiphead_impl(); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_SKIPHEAD_IMPL_H */ diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc new file mode 100644 index 0000000000..0a48c2b9f4 --- /dev/null +++ b/gr-blocks/lib/socket_pdu_impl.cc @@ -0,0 +1,198 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "socket_pdu_impl.h" +#include "tcp_connection.h" +#include <gr_io_signature.h> +#include <gr_pdu.h> + +namespace gr { + namespace blocks { + + socket_pdu::sptr + socket_pdu::make(std::string type, std::string addr, std::string port, int MTU) + { + return gnuradio::get_initial_sptr(new socket_pdu_impl(type, addr, port, MTU)); + } + + socket_pdu_impl::socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU) + : gr_block("socket_pdu", + gr_make_io_signature (0, 0, 0), + gr_make_io_signature (0, 0, 0)) + { + message_port_register_in(PDU_PORT_ID); + message_port_register_out(PDU_PORT_ID); + + if ((type == "TCP_SERVER") || (type == "TCP_CLIENT")) { + boost::asio::ip::tcp::resolver resolver(d_io_service); + boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), addr, port); + d_tcp_endpoint = *resolver.resolve(query); + } + + if ((type == "UDP_SERVER") || (type == "UDP_CLIENT")) { + boost::asio::ip::udp::resolver resolver(d_io_service); + boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), addr, port); + + if (type == "UDP_SERVER") + d_udp_endpoint = *resolver.resolve(query); + else + d_udp_endpoint_other = *resolver.resolve(query); + } + + if (type == "TCP_SERVER") { + d_acceptor_tcp.reset(new boost::asio::ip::tcp::acceptor(d_io_service, d_tcp_endpoint)); + d_acceptor_tcp->set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); + start_tcp_accept(); + set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::tcp_server_send, this, _1)); + + } + else if (type =="TCP_CLIENT") { + boost::system::error_code error = boost::asio::error::host_not_found; + d_tcp_socket.reset(new boost::asio::ip::tcp::socket(d_io_service)); + d_tcp_socket->connect(d_tcp_endpoint, error); + if (error) + throw boost::system::system_error(error); + + set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::tcp_client_send, this, _1)); + + d_tcp_socket->async_read_some( + boost::asio::buffer(d_rxbuf), + boost::bind(&socket_pdu_impl::handle_tcp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred) + ); + } + else if (type =="UDP_SERVER") { + d_udp_socket.reset(new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint)); + d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other, + boost::bind(&socket_pdu_impl::handle_udp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::udp_send, this, _1)); + } + else if (type =="UDP_CLIENT") { + d_udp_socket.reset(new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint)); + d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other, + boost::bind(&socket_pdu_impl::handle_udp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::udp_send, this, _1)); + } + else + throw std::runtime_error("gr::blocks:socket_pdu: unknown socket type"); + + d_thread = gruel::thread(boost::bind(&socket_pdu_impl::run_io_service, this)); + d_started = true; + } + + void + socket_pdu_impl::handle_tcp_read(const boost::system::error_code& error, size_t bytes_transferred) + { + if (!error) { + pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t *)&d_rxbuf[0]); + pmt::pmt_t pdu = pmt::pmt_cons(pmt::PMT_NIL, vector); + message_port_pub(PDU_PORT_ID, pdu); + + d_tcp_socket->async_read_some(boost::asio::buffer(d_rxbuf), + boost::bind(&socket_pdu_impl::handle_tcp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + else + throw boost::system::system_error(error); + } + + void + socket_pdu_impl::start_tcp_accept() + { + tcp_connection::sptr new_connection = tcp_connection::make(d_acceptor_tcp->get_io_service()); + + d_acceptor_tcp->async_accept(new_connection->socket(), + boost::bind(&socket_pdu_impl::handle_tcp_accept, this, + new_connection, boost::asio::placeholders::error)); + } + + void + socket_pdu_impl::tcp_server_send(pmt::pmt_t msg) + { + pmt::pmt_t vector = pmt::pmt_cdr(msg); + for(size_t i = 0; i < d_tcp_connections.size(); i++) + d_tcp_connections[i]->send(vector); + } + + void + socket_pdu_impl::handle_tcp_accept(tcp_connection::sptr new_connection, const boost::system::error_code& error) + { + if (!error) { + new_connection->start(this); + d_tcp_connections.push_back(new_connection); + start_tcp_accept(); + } + else + std::cout << error << std::endl; + } + + void + socket_pdu_impl::tcp_client_send(pmt::pmt_t msg) + { + pmt::pmt_t vector = pmt::pmt_cdr(msg); + size_t len = pmt::pmt_length(vector); + size_t offset(0); + boost::array<char, 10000> txbuf; + memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); + d_tcp_socket->send(boost::asio::buffer(txbuf,len)); + } + + void + socket_pdu_impl::udp_send(pmt::pmt_t msg) + { + pmt::pmt_t vector = pmt::pmt_cdr(msg); + size_t len = pmt::pmt_length(vector); + size_t offset(0); + boost::array<char, 10000> txbuf; + memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); + if (d_udp_endpoint_other.address().to_string() != "0.0.0.0") + d_udp_socket->send_to(boost::asio::buffer(txbuf,len), d_udp_endpoint_other); + } + + void + socket_pdu_impl::handle_udp_read(const boost::system::error_code& error, size_t bytes_transferred) + { + if (!error) { + pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]); + pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector); + + message_port_pub(PDU_PORT_ID, pdu); + + d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other, + boost::bind(&socket_pdu_impl::handle_udp_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + } + + } /* namespace blocks */ +}/* namespace gr */ diff --git a/gr-blocks/lib/socket_pdu_impl.h b/gr-blocks/lib/socket_pdu_impl.h new file mode 100644 index 0000000000..78602754c7 --- /dev/null +++ b/gr-blocks/lib/socket_pdu_impl.h @@ -0,0 +1,69 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H +#define INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H + +#include <blocks/socket_pdu.h> +#include "stream_pdu_base.h" +#include "tcp_connection.h" + +namespace gr { + namespace blocks { + + class socket_pdu_impl : public socket_pdu, public stream_pdu_base + { + private: + boost::asio::io_service d_io_service; + boost::array<char, 10000> d_rxbuf; + void run_io_service() { d_io_service.run(); } + + // TCP specific + boost::asio::ip::tcp::endpoint d_tcp_endpoint; + std::vector<tcp_connection::sptr> d_tcp_connections; + void handle_tcp_read(const boost::system::error_code& error, size_t bytes_transferred); + + // TCP server specific + boost::shared_ptr<boost::asio::ip::tcp::acceptor> d_acceptor_tcp; + void start_tcp_accept(); + void tcp_server_send(pmt::pmt_t msg); + void handle_tcp_accept(tcp_connection::sptr new_connection, const boost::system::error_code& error); + + // TCP client specific + boost::shared_ptr<boost::asio::ip::tcp::socket> d_tcp_socket; + void tcp_client_send(pmt::pmt_t msg); + + // UDP specific + boost::asio::ip::udp::endpoint d_udp_endpoint; + boost::asio::ip::udp::endpoint d_udp_endpoint_other; + boost::shared_ptr<boost::asio::ip::udp::socket> d_udp_socket; + void handle_udp_read(const boost::system::error_code& error, size_t bytes_transferred); + void udp_send(pmt::pmt_t msg); + + public: + socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H */ diff --git a/gr-blocks/lib/stream_pdu_base.cc b/gr-blocks/lib/stream_pdu_base.cc new file mode 100644 index 0000000000..21fbb5eabe --- /dev/null +++ b/gr-blocks/lib/stream_pdu_base.cc @@ -0,0 +1,130 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_IO_H +#include <io.h> +#endif + +#ifdef HAVE_WINDOWS_H +#include <winsock2.h> +#endif + +#include <blocks/pdu.h> +#include <gr_basic_block.h> +#include "stream_pdu_base.h" +#include <boost/format.hpp> + +static const long timeout_us = 100*1000; //100ms + +namespace gr { + namespace blocks { + + stream_pdu_base::stream_pdu_base(int MTU) + : d_fd(-1), + d_started(false), + d_finished(false) + { + // reserve space for rx buffer + d_rxbuf.resize(MTU,0); + } + + stream_pdu_base::~stream_pdu_base() + { + stop_rxthread(); + } + + void + stream_pdu_base::start_rxthread(gr_basic_block *blk, pmt::pmt_t port) + { + d_blk = blk; + d_port = port; + d_thread = gruel::thread(boost::bind(&stream_pdu_base::run, this)); + d_started = true; + } + + void + stream_pdu_base::stop_rxthread() + { + d_finished = true; + + if (d_started) { + d_thread.interrupt(); + d_thread.join(); + } + } + + void + stream_pdu_base::run() + { + while(!d_finished) { + if (!wait_ready()) + continue; + + const int result = read(d_fd, &d_rxbuf[0], d_rxbuf.size()); + if (result <= 0) + throw std::runtime_error("stream_pdu_base, bad socket read!"); + + pmt::pmt_t vector = pmt::pmt_init_u8vector(result, &d_rxbuf[0]); + pmt::pmt_t pdu = pmt::pmt_cons(pmt::PMT_NIL, vector); + + d_blk->message_port_pub(d_port, pdu); + } + } + + bool + stream_pdu_base::wait_ready() + { + //setup timeval for timeout + timeval tv; + tv.tv_sec = 0; + tv.tv_usec = timeout_us; + + //setup rset for timeout + fd_set rset; + FD_ZERO(&rset); + FD_SET(d_fd, &rset); + + //call select with timeout on receive socket + return ::select(d_fd+1, &rset, NULL, NULL, &tv) > 0; + } + + void + stream_pdu_base::send(pmt::pmt_t msg) + { + pmt::pmt_t vector = pmt::pmt_cdr(msg); + size_t offset(0); + size_t itemsize(pdu::itemsize(pdu::type_from_pmt(vector))); + int len(pmt::pmt_length(vector)*itemsize); + + const int rv = write(d_fd, pmt::pmt_uniform_vector_elements(vector, offset), len); + if (rv != len) { + std::cerr << boost::format("WARNING: stream_pdu_base::send(pdu) write failed! (d_fd=%d, len=%d, rv=%d)") + % d_fd % len % rv << std::endl; + } + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/stream_pdu_base.h b/gr-blocks/lib/stream_pdu_base.h new file mode 100644 index 0000000000..66eaaf0c04 --- /dev/null +++ b/gr-blocks/lib/stream_pdu_base.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_STREAM_PDU_BASE_H +#define INCLUDED_STREAM_PDU_BASE_H + +#include <gruel/thread.h> +#include <gruel/pmt.h> + +class gr_basic_block; + +namespace gr { + namespace blocks { + + class stream_pdu_base + { + public: + stream_pdu_base(int MTU=10000); + ~stream_pdu_base(); + + protected: + int d_fd; + bool d_started; + bool d_finished; + std::vector<uint8_t> d_rxbuf; + gruel::thread d_thread; + + pmt::pmt_t d_port; + gr_basic_block *d_blk; + + void run(); + void send(pmt::pmt_t msg); + bool wait_ready(); + void start_rxthread(gr_basic_block *blk, pmt::pmt_t rxport); + void stop_rxthread(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_STREAM_PDU_BASE_H */ diff --git a/gr-blocks/lib/tag_debug_impl.cc b/gr-blocks/lib/tag_debug_impl.cc new file mode 100644 index 0000000000..a216879637 --- /dev/null +++ b/gr-blocks/lib/tag_debug_impl.cc @@ -0,0 +1,118 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tag_debug_impl.h" +#include <gr_io_signature.h> +#include <iostream> +#include <iomanip> + +namespace gr { + namespace blocks { + + tag_debug::sptr + tag_debug::make(size_t sizeof_stream_item, + const std::string &name) + { + return gnuradio::get_initial_sptr + (new tag_debug_impl(sizeof_stream_item, name)); + } + + tag_debug_impl::tag_debug_impl(size_t sizeof_stream_item, + const std::string &name) + : gr_sync_block("tag_debug", + gr_make_io_signature(1, -1, sizeof_stream_item), + gr_make_io_signature(0, 0, 0)), + d_name(name), d_display(true) + { + } + + tag_debug_impl::~tag_debug_impl() + { + } + + std::vector<gr_tag_t> + tag_debug_impl::current_tags() + { + gruel::scoped_lock l(d_mutex); + return d_tags; + } + + void + tag_debug_impl::set_display(bool d) + { + gruel::scoped_lock l(d_mutex); + d_display = d; + } + + int + tag_debug_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gruel::scoped_lock l(d_mutex); + + std::stringstream sout; + if(d_display) { + sout << std::endl + << "----------------------------------------------------------------------"; + sout << std::endl << "Tag Debug: " << d_name << std::endl; + } + + uint64_t abs_N, end_N; + for(size_t i = 0; i < input_items.size(); i++) { + abs_N = nitems_read(i); + end_N = abs_N + (uint64_t)(noutput_items); + + d_tags.clear(); + get_tags_in_range(d_tags, i, abs_N, end_N); + + if(d_display) { + sout << "Input Stream: " << std::setw(2) << std::setfill('0') + << i << std::setfill(' ') << std::endl; + for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { + sout << std::setw(10) << "Offset: " << d_tags_itr->offset + << std::setw(10) << "Source: " + << (pmt::pmt_is_symbol(d_tags_itr->srcid) ? pmt::pmt_symbol_to_string(d_tags_itr->srcid) : "n/a") + << std::setw(10) << "Key: " << pmt::pmt_symbol_to_string(d_tags_itr->key) + << std::setw(10) << "Value: "; + sout << d_tags_itr->value << std::endl; + } + } + } + + if(d_display) { + sout << "----------------------------------------------------------------------"; + sout << std::endl; + + if(d_tags.size() > 0) + std::cout << sout.str(); + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/tag_debug_impl.h b/gr-blocks/lib/tag_debug_impl.h new file mode 100644 index 0000000000..988d0e1103 --- /dev/null +++ b/gr-blocks/lib/tag_debug_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#ifndef INCLUDED_GR_TAG_DEBUG_IMPL_H +#define INCLUDED_GR_TAG_DEBUG_IMPL_H + +#include <blocks/tag_debug.h> +#include <gruel/thread.h> +#include <stddef.h> + +namespace gr { + namespace blocks { + + class tag_debug_impl : public tag_debug + { + private: + std::string d_name; + std::vector<gr_tag_t> d_tags; + std::vector<gr_tag_t>::iterator d_tags_itr; + bool d_display; + gruel::mutex d_mutex; + + public: + tag_debug_impl(size_t sizeof_stream_item, const std::string &name); + ~tag_debug_impl(); + + std::vector<gr_tag_t> current_tags(); + + void set_display(bool d); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_TAG_DEBUG_IMPL_H */ diff --git a/gr-blocks/lib/tag_gate_impl.cc b/gr-blocks/lib/tag_gate_impl.cc new file mode 100644 index 0000000000..854031bf8b --- /dev/null +++ b/gr-blocks/lib/tag_gate_impl.cc @@ -0,0 +1,79 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "tag_gate_impl.h" + +namespace gr { + namespace blocks { + + tag_gate::sptr + tag_gate::make(size_t item_size, bool propagate_tags) + { + return gnuradio::get_initial_sptr (new tag_gate_impl(item_size, propagate_tags)); + } + + tag_gate_impl::tag_gate_impl(size_t item_size, bool propagate_tags) + : gr_sync_block("tag_gate", + gr_make_io_signature(1, 1, item_size), + gr_make_io_signature(1, 1, item_size)), + d_item_size(item_size), + d_propagate_tags(propagate_tags) + { + if (!d_propagate_tags) { + set_tag_propagation_policy(TPP_DONT); + } + } + + tag_gate_impl::~tag_gate_impl() + { + } + + void tag_gate_impl::set_propagation(bool propagate_tags) + { + if (propagate_tags) { + set_tag_propagation_policy(TPP_ALL_TO_ALL); + } else { + set_tag_propagation_policy(TPP_DONT); + } + } + + int + tag_gate_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + + memcpy((void *) out, (void *) in, d_item_size * noutput_items); + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/tag_gate_impl.h b/gr-blocks/lib/tag_gate_impl.h new file mode 100644 index 0000000000..4b61b62036 --- /dev/null +++ b/gr-blocks/lib/tag_gate_impl.h @@ -0,0 +1,52 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_TAG_GATE_IMPL_H +#define INCLUDED_BLOCKS_TAG_GATE_IMPL_H + +#include <blocks/tag_gate.h> + +namespace gr { + namespace blocks { + + class tag_gate_impl : public tag_gate + { + private: + size_t d_item_size; + bool d_propagate_tags; + + public: + tag_gate_impl(size_t item_size, bool propagate_tags); + ~tag_gate_impl(); + + void set_propagation(bool propagate_tags); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace blocks +} // namespace gr + +#endif /* INCLUDED_BLOCKS_TAG_GATE_IMPL_H */ + diff --git a/gr-blocks/lib/tagged_file_sink_impl.cc b/gr-blocks/lib/tagged_file_sink_impl.cc new file mode 100644 index 0000000000..a2e9ab3853 --- /dev/null +++ b/gr-blocks/lib/tagged_file_sink_impl.cc @@ -0,0 +1,235 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tagged_file_sink_impl.h" +#include <gr_io_signature.h> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <iostream> + +#ifdef HAVE_IO_H +#include <io.h> +#endif + +#ifdef O_BINARY +#define OUR_O_BINARY O_BINARY +#else +#define OUR_O_BINARY 0 +#endif + +// should be handled via configure +#ifdef O_LARGEFILE +#define OUR_O_LARGEFILE O_LARGEFILE +#else +#define OUR_O_LARGEFILE 0 +#endif + +namespace gr { + namespace blocks { + + tagged_file_sink::sptr + tagged_file_sink::make(size_t itemsize, double samp_rate) + { + return gnuradio::get_initial_sptr + (new tagged_file_sink_impl(itemsize, samp_rate)); + } + + tagged_file_sink_impl::tagged_file_sink_impl(size_t itemsize, double samp_rate) + : gr_sync_block("tagged_file_sink", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(0, 0, 0)), + d_itemsize (itemsize), d_n(0), d_sample_rate(samp_rate) + { + d_state = NOT_IN_BURST; + d_last_N = 0; + d_timeval = 0; + } + + tagged_file_sink_impl::~tagged_file_sink_impl() + { + } + + int + tagged_file_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + char *inbuf = (char*)input_items[0]; + + uint64_t start_N = nitems_read(0); + uint64_t end_N = start_N + (uint64_t)(noutput_items); + pmt::pmt_t bkey = pmt::pmt_string_to_symbol("burst"); + pmt::pmt_t tkey = pmt::pmt_string_to_symbol("rx_time"); // use gr_tags::key_time + + std::vector<gr_tag_t> all_tags; + get_tags_in_range(all_tags, 0, start_N, end_N); + + std::sort(all_tags.begin(), all_tags.end(), gr_tag_t::offset_compare); + + std::vector<gr_tag_t>::iterator vitr = all_tags.begin(); + + // Look for a time tag and initialize d_timeval. + std::vector<gr_tag_t> time_tags_outer; + get_tags_in_range(time_tags_outer, 0, start_N, end_N, tkey); + if(time_tags_outer.size() > 0) { + const gr_tag_t tag = time_tags_outer[0]; + uint64_t offset = tag.offset; + pmt::pmt_t time = tag.value; + uint64_t tsecs = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(time, 0)); + double tfrac = pmt::pmt_to_double(pmt::pmt_tuple_ref(time, 1)); + double delta = (double)offset / d_sample_rate; + d_timeval = (double)tsecs + tfrac + delta; + d_last_N = offset; + } + + int idx = 0, idx_stop = 0; + while(idx < noutput_items) { + if(d_state == NOT_IN_BURST) { + while(vitr != all_tags.end()) { + if((pmt::pmt_eqv((*vitr).key, bkey)) && + pmt::pmt_is_true((*vitr).value)) { + + uint64_t N = (*vitr).offset; + idx = (int)(N - start_N); + + //std::cout << std::endl << "Found start of burst: " + // << idx << ", " << N << std::endl; + + // Find time burst occurred by getting latest time tag and extrapolating + // to new time based on sample rate of this block. + std::vector<gr_tag_t> time_tags; + //get_tags_in_range(time_tags, 0, d_last_N, N, gr_tags::key_time); + get_tags_in_range(time_tags, 0, d_last_N, N, tkey); + if(time_tags.size() > 0) { + const gr_tag_t tag = time_tags[time_tags.size()-1]; + + uint64_t time_nitems = tag.offset; + + // Get time based on last time tag from USRP + pmt::pmt_t time = tag.value; + uint64_t tsecs = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(time, 0)); + double tfrac = pmt::pmt_to_double(pmt::pmt_tuple_ref(time, 1)); + + // Get new time from last time tag + difference in time to when + // burst tag occured based on the sample rate + double delta = (double)(N - time_nitems) / d_sample_rate; + d_timeval = (double)tsecs + tfrac + delta; + + //std::cout.setf(std::ios::fixed, std::ios::floatfield); + //std::cout.precision(8); + //std::cout << "Time found: " << (double)tsecs + tfrac << std::endl; + //std::cout << " time: " << d_timeval << std::endl; + //std::cout << " time at N = " << time_nitems << " burst N = " << N << std::endl; + } + else { + // if no time tag, use last seen tag and update time based on + // sample rate of the block + d_timeval += (double)(N - d_last_N) / d_sample_rate; + //std::cout << "Time not found" << std::endl; + //std::cout << " time: " << d_timeval << std::endl; + } + d_last_N = N; + + std::stringstream filename; + filename.setf(std::ios::fixed, std::ios::floatfield); + filename.precision(8); + filename << "file" << unique_id() << "_" << d_n << "_" << d_timeval << ".dat"; + d_n++; + + int fd; + if((fd = ::open(filename.str().c_str(), + O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY, + 0664)) < 0){ + perror(filename.str().c_str()); + return -1; + } + + // FIXME: + //if((d_handle = fdopen (fd, d_is_binary ? "wb" : "w")) == NULL) { + if((d_handle = fdopen (fd, "wb")) == NULL) { + perror(filename.str().c_str()); + ::close(fd); // don't leak file descriptor if fdopen fails. + } + + //std::cout << "Created new file: " << filename.str() << std::endl; + + d_state = IN_BURST; + break; + } + + vitr++; + } + if(d_state == NOT_IN_BURST) + return noutput_items; + } + else { // In burst + while(vitr != all_tags.end()) { + if((pmt::pmt_eqv((*vitr).key, bkey)) && + pmt::pmt_is_false((*vitr).value)) { + uint64_t N = (*vitr).offset; + idx_stop = (int)N - start_N; + + //std::cout << "Found end of burst: " + // << idx_stop << ", " << N << std::endl; + + int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize, + idx_stop-idx, d_handle); + if(count == 0) { + if(ferror(d_handle)) { + perror("tagged_file_sink: error writing file"); + } + } + idx = idx_stop; + d_state = NOT_IN_BURST; + vitr++; + fclose(d_handle); + break; + } + else { + vitr++; + } + } + if(d_state == IN_BURST) { + int count = fwrite (&inbuf[d_itemsize*idx], d_itemsize, + noutput_items-idx, d_handle); + if (count == 0) { + if(ferror(d_handle)) { + perror("tagged_file_sink: error writing file"); + } + } + idx = noutput_items; + } + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/tagged_file_sink_impl.h b/gr-blocks/lib/tagged_file_sink_impl.h new file mode 100644 index 0000000000..f64cedf2f9 --- /dev/null +++ b/gr-blocks/lib/tagged_file_sink_impl.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010,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. + */ + +#ifndef INCLUDED_GR_TAGGED_FILE_SINK_IMPL_H +#define INCLUDED_GR_TAGGED_FILE_SINK_IMPL_H + +#include <blocks/tagged_file_sink.h> +#include <cstdio> // for FILE + +namespace gr { + namespace blocks { + + class tagged_file_sink_impl : public tagged_file_sink + { + private: + enum { + NOT_IN_BURST = 0, + IN_BURST + }; + + size_t d_itemsize; + int d_state; + FILE *d_handle; + int d_n; + double d_sample_rate; + uint64_t d_last_N; + double d_timeval; + + public: + tagged_file_sink_impl(size_t itemsize, double samp_rate); + ~tagged_file_sink_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + + +#endif /* INCLUDED_GR_TAGGED_FILE_SINK_IMPL_H */ diff --git a/gr-blocks/lib/tagged_stream_mux_impl.cc b/gr-blocks/lib/tagged_stream_mux_impl.cc new file mode 100644 index 0000000000..59e36fa07e --- /dev/null +++ b/gr-blocks/lib/tagged_stream_mux_impl.cc @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "tagged_stream_mux_impl.h" + +namespace gr { + namespace blocks { + + tagged_stream_mux::sptr + tagged_stream_mux::make(size_t itemsize, const std::string &lengthtagname) + { + return gnuradio::get_initial_sptr (new tagged_stream_mux_impl(itemsize, lengthtagname)); + } + + tagged_stream_mux_impl::tagged_stream_mux_impl(size_t itemsize, const std::string &lengthtagname) + : gr_tagged_stream_block("tagged_stream_mux", + gr_make_io_signature(1, -1, itemsize), + gr_make_io_signature(1, 1, itemsize), + lengthtagname), + d_itemsize(itemsize) + { + set_tag_propagation_policy(TPP_DONT); + } + + tagged_stream_mux_impl::~tagged_stream_mux_impl() + { + } + + int + tagged_stream_mux_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + int nout = 0; + for (unsigned i = 0; i < ninput_items.size(); i++) { + nout += ninput_items[i]; + } + return nout; + } + + int + tagged_stream_mux_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + unsigned char *out = (unsigned char *) output_items[0]; + int n_produced = 0; + + set_relative_rate(ninput_items.size()); + + for (unsigned int i = 0; i < input_items.size(); i++) { + const unsigned char *in = (const unsigned char *) input_items[i]; + + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, i, nitems_read(i), nitems_read(i)+ninput_items[i]); + for (unsigned int j = 0; j < tags.size(); j++) { + const uint64_t offset = tags[j].offset - nitems_read(i) + nitems_written(0) + n_produced; + add_item_tag(0, offset, tags[j].key, tags[j].value); + } + memcpy((void *) out, (const void *) in, ninput_items[i] * d_itemsize); + out += ninput_items[i] * d_itemsize; + n_produced += ninput_items[i]; + } + + return n_produced; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/tagged_stream_mux_impl.h b/gr-blocks/lib/tagged_stream_mux_impl.h new file mode 100644 index 0000000000..19862e6868 --- /dev/null +++ b/gr-blocks/lib/tagged_stream_mux_impl.h @@ -0,0 +1,54 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +#ifndef INCLUDED_TAGGED_STREAM_MUX_IMPL_H +#define INCLUDED_TAGGED_STREAM_MUX_IMPL_H + +#include <vector> +#include <blocks/tagged_stream_mux.h> + +namespace gr { + namespace blocks { + + class tagged_stream_mux_impl : public tagged_stream_mux + { + private: + size_t d_itemsize; + + protected: + int calculate_output_stream_length(const std::vector<int> &ninput_items); + + public: + tagged_stream_mux_impl(size_t itemsize, const std::string &lengthtagname); + ~tagged_stream_mux_impl(); + + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace blocks +} // namespace gr + +#endif + diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc new file mode 100644 index 0000000000..acd07292f4 --- /dev/null +++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc @@ -0,0 +1,136 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tagged_stream_to_pdu_impl.h" +#include <blocks/pdu.h> +#include <gr_io_signature.h> + +namespace gr { + namespace blocks { + + tagged_stream_to_pdu::sptr + tagged_stream_to_pdu::make(pdu::vector_type type) + { + return gnuradio::get_initial_sptr(new tagged_stream_to_pdu_impl(type)); + } + + tagged_stream_to_pdu_impl::tagged_stream_to_pdu_impl(pdu::vector_type type) + : gr_sync_block("tagged_stream_to_pdu", + gr_make_io_signature(1, 1, pdu::itemsize(type)), + gr_make_io_signature(0, 0, 0)), + d_itemsize(pdu::itemsize(type)), + d_inpdu(false), + d_type(type), + d_pdu_meta(pmt::PMT_NIL), + d_pdu_vector(pmt::PMT_NIL) + { + message_port_register_out(PDU_PORT_ID); + } + + int + tagged_stream_to_pdu_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const uint8_t *in = (const uint8_t*) input_items[0]; + uint64_t abs_N = nitems_read(0); + + // if we are not in a pdu already, start a new one + if (!d_inpdu) { + bool found_length_tag(false); + + get_tags_in_range(d_tags, 0, abs_N, abs_N+1); + + for (d_tags_itr = d_tags.begin(); (d_tags_itr != d_tags.end()) && (!found_length_tag); d_tags_itr++) { + if (pmt::pmt_equal((*d_tags_itr).key, PDU_LENGTH_TAG )) { + + if ((*d_tags_itr).offset != abs_N ) + throw std::runtime_error("expected next pdu length tag on a different item..."); + + found_length_tag = true; + d_pdu_length = pmt::pmt_to_long((*d_tags_itr).value); + d_pdu_remain = d_pdu_length; + d_pdu_meta = pmt::pmt_make_dict(); + break; + } // if have length tag + } // iter over tags + + if (!found_length_tag) + throw std::runtime_error("tagged stream does not contain a pdu_length tag"); + } + + size_t ncopy = std::min((size_t)noutput_items, d_pdu_remain); + + // copy any tags in this range into our meta object + get_tags_in_range(d_tags, 0, abs_N, abs_N+ncopy); + for (d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) + if(!pmt_equal((*d_tags_itr).key, PDU_LENGTH_TAG )) + d_pdu_meta = pmt_dict_add(d_pdu_meta, (*d_tags_itr).key, (*d_tags_itr).value); + + // copy samples for this vector into either a pmt or our save buffer + if (ncopy == d_pdu_remain) { // we will send this pdu + if (d_save.size() == 0) { + d_pdu_vector = pdu::make_vector(d_type, in, ncopy); + send_message(); + } + else { + size_t oldsize = d_save.size(); + d_save.resize((oldsize + ncopy)*d_itemsize, 0); + memcpy(&d_save[oldsize*d_itemsize], in, ncopy*d_itemsize); + d_pdu_vector = pdu::make_vector(d_type, &d_save[0], d_pdu_length); + send_message(); + d_save.clear(); + } + } + else { + d_inpdu = true; + size_t oldsize = d_save.size(); + d_save.resize((oldsize+ncopy)*d_itemsize); + memcpy(&d_save[oldsize*d_itemsize], in, ncopy*d_itemsize); + d_pdu_remain -= ncopy; + } + + return ncopy; + } + + void + tagged_stream_to_pdu_impl::send_message() + { + if (pmt::pmt_length(d_pdu_vector) != d_pdu_length) + throw std::runtime_error("msg length not correct"); + + pmt::pmt_t msg = pmt::pmt_cons(d_pdu_meta, d_pdu_vector); + message_port_pub(PDU_PORT_ID, msg); + + d_pdu_meta = pmt::PMT_NIL; + d_pdu_vector = pmt::PMT_NIL; + d_pdu_length = 0; + d_pdu_remain = 0; + d_inpdu = false; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.h b/gr-blocks/lib/tagged_stream_to_pdu_impl.h new file mode 100644 index 0000000000..84d7f6c3cb --- /dev/null +++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.h @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_TAGGED_STREAM_TO_PDU_IMPL_H +#define INCLUDED_TAGGED_STREAM_TO_PDU_IMPL_H + +#include <blocks/tagged_stream_to_pdu.h> + +namespace gr { + namespace blocks { + + class BLOCKS_API tagged_stream_to_pdu_impl : public tagged_stream_to_pdu + { + size_t d_itemsize; + size_t d_pdu_length; + size_t d_pdu_remain; + bool d_inpdu; + pdu::vector_type d_type; + std::vector<uint8_t> d_save; + pmt::pmt_t d_pdu_meta; + pmt::pmt_t d_pdu_vector; + + std::vector<gr_tag_t>::iterator d_tags_itr; + std::vector<gr_tag_t> d_tags; + + public: + tagged_stream_to_pdu_impl(pdu::vector_type type); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + void send_message(); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc new file mode 100644 index 0000000000..4ead6442d8 --- /dev/null +++ b/gr-blocks/lib/tcp_connection.cc @@ -0,0 +1,87 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tcp_connection.h" +#include <gr_basic_block.h> +#include <gr_pdu.h> +//#include <boost/asio.hpp> +//#include <boost/bind.hpp> + +namespace gr { + namespace blocks { + + tcp_connection::sptr tcp_connection::make(boost::asio::io_service& io_service) + { + return sptr(new tcp_connection(io_service)); + } + + tcp_connection::tcp_connection(boost::asio::io_service& io_service) + : d_socket(io_service) + { + } + + void + tcp_connection::send(pmt::pmt_t vector) + { + size_t len = pmt::pmt_length(vector); + size_t offset(0); + boost::array<char, 10000> txbuf; + memcpy(&txbuf[0], pmt::pmt_uniform_vector_elements(vector, offset), len); + boost::asio::async_write(d_socket, boost::asio::buffer(txbuf, len), + boost::bind(&tcp_connection::handle_write, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + + void + tcp_connection::start(gr_basic_block *block) + { + d_block = block; + d_socket.async_read_some(boost::asio::buffer(d_buf), + boost::bind(&tcp_connection::handle_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + + void + tcp_connection::handle_read(const boost::system::error_code& error, size_t bytes_transferred) + { + if (!error) { + pmt::pmt_t vector = pmt::pmt_init_u8vector(bytes_transferred, (const uint8_t*)&d_buf[0]); + pmt::pmt_t pdu = pmt::pmt_cons( pmt::PMT_NIL, vector); + + d_block->message_port_pub(PDU_PORT_ID, pdu); + + d_socket.async_read_some(boost::asio::buffer(d_buf), + boost::bind(&tcp_connection::handle_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + + } + } + + } /* namespace blocks */ +}/* namespace gr */ diff --git a/gr-blocks/lib/tcp_connection.h b/gr-blocks/lib/tcp_connection.h new file mode 100644 index 0000000000..ba57de0783 --- /dev/null +++ b/gr-blocks/lib/tcp_connection.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_TCP_CONNECTION_H +#define INCLUDED_TCP_CONNECTION_H + +#include <boost/array.hpp> +#include <boost/asio.hpp> +#include <gruel/pmt.h> + +class gr_basic_block; + +namespace gr { + namespace blocks { + + class tcp_connection + { + private: + boost::asio::ip::tcp::socket d_socket; + boost::array<char, 10000> d_buf; + std::string d_message; + gr_basic_block *d_block; + + tcp_connection(boost::asio::io_service& io_service); + + public: + typedef boost::shared_ptr<tcp_connection> sptr; + + static sptr make(boost::asio::io_service& io_service); + + boost::asio::ip::tcp::socket& socket() { return d_socket; }; + + void start(gr_basic_block *block); + void send(pmt::pmt_t vector); + void handle_read(const boost::system::error_code& error, size_t bytes_transferred); + void handle_write(const boost::system::error_code& error, size_t bytes_transferred) { } + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_TCP_CONNECTION_H */ diff --git a/gr-blocks/lib/test_gr_blocks.cc b/gr-blocks/lib/test_gr_blocks.cc new file mode 100644 index 0000000000..f03745dc99 --- /dev/null +++ b/gr-blocks/lib/test_gr_blocks.cc @@ -0,0 +1,43 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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 <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> +#include <qa_blocks.h> +#include <iostream> + +int +main(int argc, char **argv) +{ + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(get_unittest_path("gr_blocks.xml").c_str()); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); + + runner.addTest(qa_gr_blocks::suite()); + runner.setOutputter(xmlout); + + bool was_successful = runner.run("", false); + + return was_successful ? 0 : 1; +} diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc new file mode 100644 index 0000000000..8de817738f --- /dev/null +++ b/gr-blocks/lib/tuntap_pdu_impl.cc @@ -0,0 +1,139 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "tuntap_pdu_impl.h" +#include <gr_io_signature.h> +#include <blocks/pdu.h> +#include <boost/format.hpp> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#if (defined(linux) || defined(__linux) || defined(__linux__)) +#include <sys/ioctl.h> +#include <arpa/inet.h> +#include <linux/if.h> +#endif + +namespace gr { + namespace blocks { + + tuntap_pdu::sptr + tuntap_pdu::make(std::string dev, int MTU) + { +#if (defined(linux) || defined(__linux) || defined(__linux__)) + return gnuradio::get_initial_sptr(new tuntap_pdu_impl(dev, MTU)); +#else + throw std::runtime_error("tuntap_pdu not implemented on this platform"); +#endif + } + +#if (defined(linux) || defined(__linux) || defined(__linux__)) + tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU) + : gr_block("tuntap_pdu", + gr_make_io_signature (0, 0, 0), + gr_make_io_signature (0, 0, 0)), + stream_pdu_base(MTU), + d_dev(dev) + { + // make the tuntap + char dev_cstr[1024]; + memset(dev_cstr, 0x00, 1024); + strncpy(dev_cstr, dev.c_str(), std::min(sizeof(dev_cstr), dev.size())); + + d_fd = tun_alloc(dev_cstr); + if (d_fd <= 0) + throw std::runtime_error("gr::tuntap_pdu::make: tun_alloc failed (are you running as root?)"); + + std::cout << boost::format( + "Allocated virtual ethernet interface: %s\n" + "You must now use ifconfig to set its IP address. E.g.,\n" + " $ sudo ifconfig %s 192.168.200.1\n" + "Be sure to use a different address in the same subnet for each machine.\n" + ) % dev % dev << std::endl; + + // set up output message port + message_port_register_out(PDU_PORT_ID); + start_rxthread(this, PDU_PORT_ID); + + // set up input message port + message_port_register_in(PDU_PORT_ID); + set_msg_handler(PDU_PORT_ID, boost::bind(&tuntap_pdu_impl::send, this, _1)); + } + + int + tuntap_pdu_impl::tun_alloc(char *dev, int flags) + { + struct ifreq ifr; + int fd, err; + const char *clonedev = "/dev/net/tun"; + + /* Arguments taken by the function: + * + * char *dev: the name of an interface (or '\0'). MUST have enough + * space to hold the interface name if '\0' is passed + * int flags: interface flags (eg, IFF_TUN etc.) + */ + + /* open the clone device */ + if ((fd = open(clonedev, O_RDWR)) < 0) + return fd; + + /* preparation of the struct ifr, of type "struct ifreq" */ + memset(&ifr, 0, sizeof(ifr)); + + ifr.ifr_flags = flags; /* IFF_TUN or IFF_TAP, plus maybe IFF_NO_PI */ + + /* if a device name was specified, put it in the structure; otherwise, + * the kernel will try to allocate the "next" device of the + * specified type + */ + if (*dev) + strncpy(ifr.ifr_name, dev, IFNAMSIZ); + + /* try to create the device */ + if ((err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0) { + close(fd); + return err; + } + + /* if the operation was successful, write back the name of the + * interface to the variable "dev", so the caller can know + * it. Note that the caller MUST reserve space in *dev (see calling + * code below) + */ + strcpy(dev, ifr.ifr_name); + + /* this is the special file descriptor that the caller will use to talk + * with the virtual interface + */ + return fd; + } +#endif + + } /* namespace blocks */ +}/* namespace gr */ diff --git a/gr-blocks/lib/tuntap_pdu_impl.h b/gr-blocks/lib/tuntap_pdu_impl.h new file mode 100644 index 0000000000..396d9d51c8 --- /dev/null +++ b/gr-blocks/lib/tuntap_pdu_impl.h @@ -0,0 +1,51 @@ +/* -*- c++ -*- */ +/* + * 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. + */ + +#ifndef INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H +#define INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H + +#include <blocks/tuntap_pdu.h> +#include "stream_pdu_base.h" + +#if (defined(linux) || defined(__linux) || defined(__linux__)) +#include <linux/if_tun.h> +#endif + +namespace gr { + namespace blocks { + + class tuntap_pdu_impl : public tuntap_pdu, public stream_pdu_base + { +#if (defined(linux) || defined(__linux) || defined(__linux__)) + private: + std::string d_dev; + int tun_alloc(char *dev, int flags = IFF_TAP | IFF_NO_PI); + + public: + tuntap_pdu_impl(std::string dev, int MTU); +#endif + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_BLOCKS_TUNTAP_PDU_IMPL_H */ diff --git a/gr-blocks/lib/udp_sink_impl.cc b/gr-blocks/lib/udp_sink_impl.cc new file mode 100644 index 0000000000..db5b7fd1f5 --- /dev/null +++ b/gr-blocks/lib/udp_sink_impl.cc @@ -0,0 +1,149 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "udp_sink_impl.h" +#include <gr_io_signature.h> +#include <boost/array.hpp> +#include <boost/asio.hpp> +#include <boost/format.hpp> +#include <gruel/thread.h> +#include <stdexcept> +#include <stdio.h> +#include <string.h> + +namespace gr { + namespace blocks { + + udp_sink::sptr + udp_sink::make(size_t itemsize, + const std::string &host, int port, + int payload_size, bool eof) + { + return gnuradio::get_initial_sptr + (new udp_sink_impl(itemsize, host, port, + payload_size, eof)); + } + + udp_sink_impl::udp_sink_impl(size_t itemsize, + const std::string &host, int port, + int payload_size, bool eof) + : gr_sync_block("udp_sink", + gr_make_io_signature(1, 1, itemsize), + gr_make_io_signature(0, 0, 0)), + d_itemsize(itemsize), d_payload_size(payload_size), d_eof(eof), + d_connected(false) + { + // Get the destination address + connect(host, port); + } + + // public constructor that returns a shared_ptr + udp_sink_impl::~udp_sink_impl() + { + if(d_connected) + disconnect(); + } + + void + udp_sink_impl::connect(const std::string &host, int port) + { + if(d_connected) + disconnect(); + + std::string s_port = (boost::format("%d")%port).str(); + if(host.size() > 0) { + boost::asio::ip::udp::resolver resolver(d_io_service); + boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), + host, s_port); + d_endpoint = *resolver.resolve(query); + + d_socket = new boost::asio::ip::udp::socket(d_io_service); + d_socket->open(boost::asio::ip::udp::v4()); + + boost::asio::socket_base::reuse_address roption(true); + d_socket->set_option(roption); + + d_connected = true; + } + } + + void + udp_sink_impl::disconnect() + { + if(!d_connected) + return; + + gruel::scoped_lock guard(d_mutex); // protect d_socket from work() + + // Send a few zero-length packets to signal receiver we are done + boost::array<char, 1> send_buf = {{ 0 }}; + if(d_eof) { + int i; + for(i = 0; i < 3; i++) + d_socket->send_to(boost::asio::buffer(send_buf), d_endpoint); + } + + d_socket->close(); + delete d_socket; + + d_connected = false; + } + + int + udp_sink_impl::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char *in = (const char *) input_items[0]; + ssize_t r=0, bytes_sent=0, bytes_to_send=0; + ssize_t total_size = noutput_items*d_itemsize; + + gruel::scoped_lock guard(d_mutex); // protect d_socket + + while(bytes_sent < total_size) { + bytes_to_send = std::min((ssize_t)d_payload_size, (total_size-bytes_sent)); + + if(d_connected) { + try { + r = d_socket->send_to(boost::asio::buffer((void*)(in+bytes_sent), bytes_to_send), + d_endpoint); + } + catch(std::exception& e) { + GR_LOG_ERROR(d_logger, boost::format("send error: %s") % e.what()); + return -1; + } + } + else + r = bytes_to_send; // discarded for lack of connection + bytes_sent += r; + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ + diff --git a/gr-blocks/lib/udp_sink_impl.h b/gr-blocks/lib/udp_sink_impl.h new file mode 100644 index 0000000000..243d499b60 --- /dev/null +++ b/gr-blocks/lib/udp_sink_impl.h @@ -0,0 +1,65 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,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. + */ + +#ifndef INCLUDED_GR_UDP_SINK_IMPL_H +#define INCLUDED_GR_UDP_SINK_IMPL_H + +#include <blocks/udp_sink.h> +#include <boost/asio.hpp> + +namespace gr { + namespace blocks { + + class udp_sink_impl : public udp_sink + { + private: + size_t d_itemsize; + + int d_payload_size; // maximum transmission unit (packet length) + bool d_eof; // send zero-length packet on disconnect + bool d_connected; // are we connected? + gruel::mutex d_mutex; // protects d_socket and d_connected + + boost::asio::ip::udp::socket *d_socket; // handle to socket + boost::asio::ip::udp::endpoint d_endpoint; + boost::asio::io_service d_io_service; + + public: + udp_sink_impl(size_t itemsize, + const std::string &host, int port, + int payload_size, bool eof); + ~udp_sink_impl(); + + int payload_size() { return d_payload_size; } + + void connect(const std::string &host, int port); + void disconnect(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UDP_SINK_IMPL_H */ diff --git a/gr-blocks/lib/udp_source_impl.cc b/gr-blocks/lib/udp_source_impl.cc new file mode 100644 index 0000000000..e6e9caf8ad --- /dev/null +++ b/gr-blocks/lib/udp_source_impl.cc @@ -0,0 +1,215 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "udp_source_impl.h" +#include <gr_io_signature.h> +#include <gr_math.h> +#include <stdexcept> +#include <errno.h> +#include <stdio.h> +#include <string.h> + +namespace gr { + namespace blocks { + + udp_source::sptr + udp_source::make(size_t itemsize, + const std::string &ipaddr, int port, + int payload_size, bool eof) + { + return gnuradio::get_initial_sptr + (new udp_source_impl(itemsize, ipaddr, port, + payload_size, eof)); + } + + udp_source_impl::udp_source_impl(size_t itemsize, + const std::string &host, int port, + int payload_size, bool eof) + : gr_sync_block("udp_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_payload_size(payload_size), + d_eof(eof), d_connected(false), d_residual(0), d_sent(0), d_offset(0) + { + // Give us some more room to play. + d_rxbuf = new char[4*d_payload_size]; + d_residbuf = new char[50*d_payload_size]; + + connect(host, port); + } + + udp_source_impl::~udp_source_impl() + { + if(d_connected) + disconnect(); + + delete [] d_rxbuf; + delete [] d_residbuf; + } + + void + udp_source_impl::connect(const std::string &host, int port) + { + if(d_connected) + disconnect(); + + d_host = host; + d_port = static_cast<unsigned short>(port); + + std::string s_port; + s_port = (boost::format("%d")%d_port).str(); + + if(host.size() > 0) { + boost::asio::ip::udp::resolver resolver(d_io_service); + boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), + host, s_port); + d_endpoint = *resolver.resolve(query); + + d_socket = new boost::asio::ip::udp::socket(d_io_service); + d_socket->open(d_endpoint.protocol()); + + boost::asio::socket_base::linger loption(true, 0); + d_socket->set_option(loption); + + boost::asio::socket_base::reuse_address roption(true); + d_socket->set_option(roption); + + d_socket->bind(d_endpoint); + + start_receive(); + d_udp_thread = gruel::thread(boost::bind(&udp_source_impl::run_io_service, this)); + d_connected = true; + } + } + + void + udp_source_impl::disconnect() + { + gruel::scoped_lock lock(d_setlock); + + if(!d_connected) + return; + + d_io_service.stop(); + + d_socket->close(); + delete d_socket; + + d_connected = false; + } + + // Return port number of d_socket + int + udp_source_impl::get_port(void) + { + //return d_endpoint.port(); + return d_socket->local_endpoint().port(); + } + + void + udp_source_impl::start_receive() + { + d_socket->async_receive_from(boost::asio::buffer((void*)d_rxbuf, d_payload_size), d_endpoint_rcvd, + boost::bind(&udp_source_impl::handle_read, this, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + + void + udp_source_impl::handle_read(const boost::system::error_code& error, + size_t bytes_transferred) + { + if(!error) { + { + boost::lock_guard<gruel::mutex> lock(d_udp_mutex); + if(d_eof && (bytes_transferred == 1) && (d_rxbuf[0] == 0x00)) { + // If we are using EOF notification, test for it and don't + // add anything to the output. + d_residual = -1; + d_cond_wait.notify_one(); + return; + } + else { + // Make sure we never go beyond the boundary of the + // residual buffer. This will just drop the last bit of + // data in the buffer if we've run out of room. + if((int)(d_residual + bytes_transferred) > (50*d_payload_size)) { + GR_LOG_WARN(d_logger, "Too much data; dropping packet."); + } + else { + // otherwise, copy receid data into local buffer for + // copying later. + memcpy(d_residbuf+d_residual, d_rxbuf, bytes_transferred); + d_residual += bytes_transferred; + } + } + d_cond_wait.notify_one(); + } + } + start_receive(); + } + + int + udp_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + gruel::scoped_lock l(d_setlock); + + char *out = (char*)output_items[0]; + + // Use async receive_from to get data from UDP buffer and wait + // on a conditional signal before proceeding. We use this + // because the conditional wait is interruptable while a + // synchronous receive_from is not. + boost::unique_lock<boost::mutex> lock(d_udp_mutex); + d_cond_wait.wait(lock); + + if(d_residual < 0) + return -1; + + int to_be_sent = (int)(d_residual - d_sent); + int to_send = std::min(noutput_items, to_be_sent); + + // Copy the received data in the residual buffer to the output stream + memcpy(out, d_residbuf+d_sent, to_send); + int nitems = to_send/d_itemsize; + + // Keep track of where we are if we don't have enough output + // space to send all the data in the residbuf. + if(to_send == to_be_sent) { + d_residual = 0; + d_sent = 0; + } + else { + d_sent += to_send; + } + + return nitems; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/udp_source_impl.h b/gr-blocks/lib/udp_source_impl.h new file mode 100644 index 0000000000..8927f5f933 --- /dev/null +++ b/gr-blocks/lib/udp_source_impl.h @@ -0,0 +1,84 @@ +/* -*- c++ -*- */ +/* + * Copyright 2007-2010,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. + */ + +#ifndef INCLUDED_GR_UDP_SOURCE_IMPL_H +#define INCLUDED_GR_UDP_SOURCE_IMPL_H + +#include <blocks/udp_source.h> +#include <boost/asio.hpp> +#include <boost/format.hpp> +#include <gruel/thread.h> + +namespace gr { + namespace blocks { + + class udp_source_impl : public udp_source + { + private: + size_t d_itemsize; + int d_payload_size; // maximum transmission unit (packet length) + bool d_eof; // look for an EOF signal + bool d_connected; // are we connected? + char *d_rxbuf; // get UDP buffer items + char *d_residbuf; // hold buffer between calls + ssize_t d_residual; // hold information about number of bytes stored in residbuf + ssize_t d_sent; // track how much of d_residbuf we've outputted + size_t d_offset; // point to residbuf location offset + + std::string d_host; + unsigned short d_port; + + boost::asio::ip::udp::socket *d_socket; + boost::asio::ip::udp::endpoint d_endpoint; + boost::asio::ip::udp::endpoint d_endpoint_rcvd; + boost::asio::io_service d_io_service; + + gruel::condition_variable d_cond_wait; + gruel::mutex d_udp_mutex; + gruel::thread d_udp_thread; + + void start_receive(); + void handle_read(const boost::system::error_code& error, + size_t bytes_transferred); + void run_io_service() { d_io_service.run(); } + + public: + udp_source_impl(size_t itemsize, + const std::string &host, int port, + int payload_size, bool eof); + ~udp_source_impl(); + + void connect(const std::string &host, int port); + void disconnect(); + + int payload_size() { return d_payload_size; } + int get_port(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UDP_SOURCE_H */ diff --git a/gr-blocks/lib/unpack_k_bits_bb_impl.cc b/gr-blocks/lib/unpack_k_bits_bb_impl.cc new file mode 100644 index 0000000000..367100be84 --- /dev/null +++ b/gr-blocks/lib/unpack_k_bits_bb_impl.cc @@ -0,0 +1,77 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,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. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "unpack_k_bits_bb_impl.h" +#include <gr_io_signature.h> +#include <stdexcept> +#include <iostream> + +namespace gr { + namespace blocks { + + unpack_k_bits_bb::sptr + unpack_k_bits_bb::make(unsigned k) + { + return gnuradio::get_initial_sptr + (new unpack_k_bits_bb_impl(k)); + } + + unpack_k_bits_bb_impl::unpack_k_bits_bb_impl(unsigned k) + : gr_sync_interpolator("unpack_k_bits_bb", + gr_make_io_signature(1, 1, sizeof(unsigned char)), + gr_make_io_signature(1, 1, sizeof(unsigned char)), + k), + d_k(k) + { + if(d_k == 0) + throw std::out_of_range("interpolation must be > 0"); + } + + unpack_k_bits_bb_impl::~unpack_k_bits_bb_impl() + { + } + + int + unpack_k_bits_bb_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *)input_items[0]; + unsigned char *out = (unsigned char *)output_items[0]; + + int n = 0; + for(unsigned int i = 0; i < noutput_items/d_k; i++) { + unsigned int t = in[i]; + for(int j = d_k - 1; j >= 0; j--) + out[n++] = (t >> j) & 0x01; + } + + assert(n == noutput_items); + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/unpack_k_bits_bb_impl.h b/gr-blocks/lib/unpack_k_bits_bb_impl.h new file mode 100644 index 0000000000..c72d16ebf8 --- /dev/null +++ b/gr-blocks/lib/unpack_k_bits_bb_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* + * Copyright 2006,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. + */ + +#ifndef INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H +#define INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H + +#include <blocks/unpack_k_bits_bb.h> + +namespace gr { + namespace blocks { + + class unpack_k_bits_bb_impl : public unpack_k_bits_bb + { + private: + unsigned d_k; // number of relevent bits to unpack into k output bytes + + public: + unpack_k_bits_bb_impl(unsigned k); + ~unpack_k_bits_bb_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_UNPACK_K_BITS_BB_IMPL_H */ diff --git a/gr-blocks/lib/vco_f_impl.cc b/gr-blocks/lib/vco_f_impl.cc new file mode 100644 index 0000000000..21e7d0a0f2 --- /dev/null +++ b/gr-blocks/lib/vco_f_impl.cc @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "vco_f_impl.h" +#include <gr_io_signature.h> +#include <math.h> + +namespace gr { + namespace blocks { + + vco_f::sptr + vco_f::make(double sampling_rate, double sensitivity, double amplitude) + { + return gnuradio::get_initial_sptr + (new vco_f_impl(sampling_rate, sensitivity, amplitude)); + } + + vco_f_impl::vco_f_impl(double sampling_rate, double sensitivity, double amplitude) + : gr_sync_block("vco_f", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(float))), + d_sampling_rate(sampling_rate), d_sensitivity(sensitivity), + d_amplitude(amplitude), d_k(d_sensitivity/d_sampling_rate) + { + } + + vco_f_impl::~vco_f_impl() + { + } + + int + vco_f_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *input = (const float*)input_items[0]; + float *output = (float*)output_items[0]; + + d_vco.cos(output, input, noutput_items, d_k, d_amplitude); + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/vco_f_impl.h b/gr-blocks/lib/vco_f_impl.h new file mode 100644 index 0000000000..37435b7736 --- /dev/null +++ b/gr-blocks/lib/vco_f_impl.h @@ -0,0 +1,53 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005,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. + */ + +#ifndef INCLUDED_GR_VCO_F_IMPL_H +#define INCLUDED_GR_VCO_F_IMPL_H + +#include <blocks/vco_f.h> +#include <gr_fxpt_vco.h> + +namespace gr { + namespace blocks { + + class vco_f_impl : public vco_f + { + private: + double d_sampling_rate; + double d_sensitivity; + double d_amplitude; + double d_k; + gr_fxpt_vco d_vco; + + public: + vco_f_impl(double sampling_rate, double sensitivity, double amplitude); + ~vco_f_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_VCO_F_H */ diff --git a/gr-blocks/lib/vector_insert_X_impl.cc.t b/gr-blocks/lib/vector_insert_X_impl.cc.t new file mode 100644 index 0000000000..adf31fe05a --- /dev/null +++ b/gr-blocks/lib/vector_insert_X_impl.cc.t @@ -0,0 +1,109 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <@NAME_IMPL@.h> +#include <algorithm> +#include <gr_io_signature.h> +#include <stdexcept> +#include <stdio.h> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(const std::vector<@TYPE@> &data, int periodicity, int offset) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(data, periodicity, offset)); + } + + @NAME_IMPL@::@NAME_IMPL@(const std::vector<@TYPE@> &data, + int periodicity, int offset) + : gr_block("@BASE_NAME@", + gr_make_io_signature(1, 1, sizeof(@TYPE@)), + gr_make_io_signature(1, 1, sizeof(@TYPE@))), + d_data(data), + d_offset(offset), + d_periodicity(periodicity) + { + //printf("INITIAL: periodicity = %d, offset = %d\n", periodicity, offset); + // some sanity checks + assert(offset < periodicity); + assert(offset >= 0); + assert((size_t)periodicity > data.size()); + } + + @NAME_IMPL@::~@NAME_IMPL@() + {} + + int + @NAME_IMPL@::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @TYPE@ *out = (@TYPE@ *)output_items[0]; + const @TYPE@ *in = (const @TYPE@ *)input_items[0]; + + int ii(0), oo(0); + + while((oo < noutput_items) && (ii < ninput_items[0])) { + //printf("oo = %d, ii = %d, d_offset = %d, noutput_items = %d, ninput_items[0] = %d", oo, ii, d_offset, noutput_items, ninput_items[0]); + //printf(", d_periodicity = %d\n", d_periodicity); + + if(d_offset >= ((int)d_data.size())) { // if we are in the copy region + int max_copy = std::min(std::min(noutput_items - oo, ninput_items[0] - ii), + d_periodicity - d_offset); + //printf("copy %d from input\n", max_copy); + memcpy( &out[oo], &in[ii], sizeof(@TYPE@)*max_copy ); + //printf(" * memcpy returned.\n"); + ii += max_copy; + oo += max_copy; + d_offset = (d_offset + max_copy)%d_periodicity; + } + else { // if we are in the insertion region + int max_copy = std::min(noutput_items - oo, ((int)d_data.size()) - d_offset); + //printf("copy %d from d_data[%d] to out[%d]\n", max_copy, d_offset, oo); + memcpy(&out[oo], &d_data[d_offset], sizeof(@TYPE@)*max_copy); + //printf(" * memcpy returned.\n"); + oo += max_copy; + d_offset = (d_offset + max_copy)%d_periodicity; + //printf(" ## (inelse) oo = %d, d_offset = %d\n", oo, d_offset); + } + + //printf(" # exit else, on to next loop.\n"); + } + //printf(" # got out of loop\n"); + + //printf("consume = %d, produce = %d\n", ii, oo); + consume_each(ii); + return oo; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/vector_insert_X_impl.h.t b/gr-blocks/lib/vector_insert_X_impl.h.t new file mode 100644 index 0000000000..f447ef1e80 --- /dev/null +++ b/gr-blocks/lib/vector_insert_X_impl.h.t @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<@TYPE@> d_data; + int d_offset; + int d_periodicity; + + public: + @NAME_IMPL@(const std::vector<@TYPE@> &data, + int periodicity, int offset); + ~@NAME_IMPL@(); + + void rewind() { d_offset=0; } + void set_data(const std::vector<@TYPE@> &data) { + d_data = data; rewind(); } + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/vector_map_impl.cc b/gr-blocks/lib/vector_map_impl.cc new file mode 100644 index 0000000000..cefaaeea35 --- /dev/null +++ b/gr-blocks/lib/vector_map_impl.cc @@ -0,0 +1,127 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "vector_map_impl.h" +#include <gr_io_signature.h> +#include <string.h> + +namespace gr { + namespace blocks { + + std::vector<int> + get_in_sizeofs(size_t item_size, std::vector<size_t> in_vlens) + { + std::vector<int> in_sizeofs; + for(unsigned int i = 0; i < in_vlens.size(); i++) { + in_sizeofs.push_back(in_vlens[i]*item_size); + } + return in_sizeofs; + } + + std::vector<int> + get_out_sizeofs(size_t item_size, + std::vector< std::vector< std::vector<size_t> > > mapping) + { + std::vector<int> out_sizeofs; + for(unsigned int i = 0; i < mapping.size(); i++) { + out_sizeofs.push_back(mapping[i].size()*item_size); + } + return out_sizeofs; + } + + vector_map::sptr + vector_map::make(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping) + { + return gnuradio::get_initial_sptr + (new vector_map_impl(item_size, in_vlens, mapping)); + } + + vector_map_impl::vector_map_impl(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping) + : gr_sync_block("vector_map", + gr_make_io_signaturev(in_vlens.size(), in_vlens.size(), + get_in_sizeofs(item_size, in_vlens)), + gr_make_io_signaturev(mapping.size(), mapping.size(), + get_out_sizeofs(item_size, mapping))), + d_item_size(item_size), d_in_vlens(in_vlens) + { + set_mapping(mapping); + } + + vector_map_impl::~vector_map_impl() + { + } + + void + vector_map_impl::set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping) + { + // Make sure the contents of the mapping vectors are possible. + for(unsigned int i=0; i<mapping.size(); i++) { + for(unsigned int j=0; j<mapping[i].size(); j++) { + if(mapping[i][j].size() != 2) { + throw std::runtime_error("Mapping must be of the form (out_mapping_stream1, out_mapping_stream2, ...), where out_mapping_stream1 is of the form (mapping_element1, mapping_element2, ...), where mapping_element1 is of the form (input_stream, input_element). This error is raised because a mapping_element vector does not contain exactly 2 items."); + } + unsigned int s = mapping[i][j][0]; + unsigned int index = mapping[i][j][1]; + if(s >= d_in_vlens.size()) { + throw std::runtime_error("Stream numbers in mapping must be less than the number of input streams."); + } + if((index < 0) || (index >= d_in_vlens[s])) { + throw std::runtime_error ("Indices in mapping must be greater than 0 and less than the input vector lengths."); + } + } + } + gruel::scoped_lock guard(d_mutex); + d_mapping = mapping; + } + + int + vector_map_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const char **inv = (const char**)&input_items[0]; + char **outv = (char**)&output_items[0]; + + for(unsigned int n = 0; n < (unsigned int)(noutput_items); n++) { + for(unsigned int i = 0; i < d_mapping.size(); i++) { + unsigned int out_vlen = d_mapping[i].size(); + for(unsigned int j = 0; j < out_vlen; j++) { + unsigned int s = d_mapping[i][j][0]; + unsigned int k = d_mapping[i][j][1]; + memcpy(outv[i] + out_vlen*d_item_size*n + + d_item_size*j, inv[s] + d_in_vlens[s]*d_item_size*n + + k*d_item_size, d_item_size); + } + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/vector_map_impl.h b/gr-blocks/lib/vector_map_impl.h new file mode 100644 index 0000000000..e27b3b9cec --- /dev/null +++ b/gr-blocks/lib/vector_map_impl.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012,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. + */ + +#ifndef INCLUDED_GR_VECTOR_MAP_IMPL_H +#define INCLUDED_GR_VECTOR_MAP_IMPL_H + +#include <blocks/vector_map.h> +#include <gruel/thread.h> + +namespace gr { + namespace blocks { + + class vector_map_impl : public vector_map + { + private: + size_t d_item_size; + std::vector<size_t> d_in_vlens; + std::vector< std::vector< std::vector<size_t> > > d_mapping; + gruel::mutex d_mutex; // mutex to protect set/work access + + public: + vector_map_impl(size_t item_size, std::vector<size_t> in_vlens, + std::vector< std::vector< std::vector<size_t> > > mapping); + ~vector_map_impl(); + + void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_VECTOR_MAP_IMPL_H */ diff --git a/gr-blocks/lib/vector_sink_X_impl.cc.t b/gr-blocks/lib/vector_sink_X_impl.cc.t new file mode 100644 index 0000000000..3be2861025 --- /dev/null +++ b/gr-blocks/lib/vector_sink_X_impl.cc.t @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2010,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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <@NAME_IMPL@.h> +#include <gr_io_signature.h> +#include <algorithm> +#include <iostream> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @BASE_NAME@::make(int vlen) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(vlen)); + } + + @NAME_IMPL@::@NAME_IMPL@(int vlen) + : gr_sync_block("@NAME@", + gr_make_io_signature(1, 1, sizeof(@TYPE@) * vlen), + gr_make_io_signature(0, 0, 0)), + d_vlen(vlen) + { + } + + @NAME_IMPL@::~@NAME_IMPL@() + {} + + std::vector<@TYPE@> + @NAME_IMPL@::data() const + { + return d_data; + } + + std::vector<gr_tag_t> + @NAME_IMPL@::tags() const + { + return d_tags; + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @TYPE@ *iptr = (@TYPE@*)input_items[0]; + + for(int i = 0; i < noutput_items * d_vlen; i++) + d_data.push_back (iptr[i]); + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0) + noutput_items); + d_tags.insert(d_tags.end(), tags.begin(), tags.end()); + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/vector_sink_X_impl.h.t b/gr-blocks/lib/vector_sink_X_impl.h.t new file mode 100644 index 0000000000..60d21e0c8c --- /dev/null +++ b/gr-blocks/lib/vector_sink_X_impl.h.t @@ -0,0 +1,56 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2009,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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<@TYPE@> d_data; + std::vector<gr_tag_t> d_tags; + int d_vlen; + + public: + @NAME_IMPL@(int vlen); + ~@NAME_IMPL@(); + + void reset() { d_data.clear(); } + std::vector<@TYPE@> data() const; + std::vector<gr_tag_t> tags() const; + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/vector_source_X_impl.cc.t b/gr-blocks/lib/vector_source_X_impl.cc.t new file mode 100644 index 0000000000..9c1c63a213 --- /dev/null +++ b/gr-blocks/lib/vector_source_X_impl.cc.t @@ -0,0 +1,144 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2010,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. + */ + +// @WARNING@ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <@NAME_IMPL@.h> +#include <algorithm> +#include <gr_io_signature.h> +#include <stdexcept> + +namespace gr { + namespace blocks { + + @NAME@::sptr + @NAME@::make(const std::vector<@TYPE@> &data, + bool repeat, int vlen, + const std::vector<gr_tag_t> &tags) + { + return gnuradio::get_initial_sptr + (new @NAME_IMPL@(data, repeat, vlen, tags)); + } + + @NAME_IMPL@::@NAME_IMPL@(const std::vector<@TYPE@> &data, + bool repeat, int vlen, + const std::vector<gr_tag_t> &tags) + : gr_sync_block("@BASE_NAME@", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, sizeof(@TYPE@) * vlen)), + d_data(data), + d_repeat(repeat), + d_offset(0), + d_vlen(vlen), + d_tags(tags), + d_tagpos(0) + { + if(tags.size() == 0) { + d_settags = 0; + } + else { + d_settags = 1; + set_output_multiple(data.size() / vlen); + } + if((data.size() % vlen) != 0) + throw std::invalid_argument("data length must be a multiple of vlen"); + } + + @NAME_IMPL@::~@NAME_IMPL@() + {} + + void + @NAME_IMPL@::set_data (const std::vector<@TYPE@> &data, + const std::vector<gr_tag_t> &tags) + { + d_data = data; + d_tags = tags; + rewind(); + if(tags.size() == 0) { + d_settags = false; + } + else { + d_settags = true; + } + } + + int + @NAME_IMPL@::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + @TYPE@ *optr = (@TYPE@ *) output_items[0]; + + if(d_repeat) { + unsigned int size = d_data.size (); + unsigned int offset = d_offset; + if(size == 0) + return -1; + + if(d_settags) { + int n_outputitems_per_vector = d_data.size() / d_vlen; + for(int i = 0; i < noutput_items; i += n_outputitems_per_vector) { + // FIXME do proper vector copy + memcpy((void *) optr, (const void*)&d_data[0], size*sizeof (@TYPE@)); + optr += size; + for(unsigned t = 0; t < d_tags.size(); t++) { + add_item_tag(0, nitems_written(0)+i+d_tags[t].offset, + d_tags[t].key, d_tags[t].value); + } + } + } + else { + for(int i = 0; i < noutput_items*d_vlen; i++) { + optr[i] = d_data[offset++]; + if(offset >= size) { + offset = 0; + } + } + } + + d_offset = offset; + return noutput_items; + } + else { + if(d_offset >= d_data.size ()) + return -1; // Done! + + unsigned n = std::min((unsigned)d_data.size() - d_offset, + (unsigned)noutput_items*d_vlen); + for(unsigned i = 0; i < n; i++) { + optr[i] = d_data[d_offset + i]; + } + for(unsigned t = 0; t < d_tags.size(); t++) { + if((d_tags[t].offset >= d_offset) && (d_tags[t].offset < d_offset+n)) + add_item_tag(0, d_tags[t].offset, d_tags[t].key, d_tags[t].value); + } + d_offset += n; + return n/d_vlen; + } + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/vector_source_X_impl.h.t b/gr-blocks/lib/vector_source_X_impl.h.t new file mode 100644 index 0000000000..78ec52bacf --- /dev/null +++ b/gr-blocks/lib/vector_source_X_impl.h.t @@ -0,0 +1,62 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2012-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. + */ + +// @WARNING@ + +#ifndef @GUARD_NAME_IMPL@ +#define @GUARD_NAME_IMPL@ + +#include <blocks/@NAME@.h> + +namespace gr { + namespace blocks { + + class @NAME_IMPL@ : public @NAME@ + { + private: + std::vector<@TYPE@> d_data; + bool d_repeat; + unsigned int d_offset; + int d_vlen; + bool d_settags; + std::vector<gr_tag_t> d_tags; + unsigned int d_tagpos; + + public: + @NAME_IMPL@(const std::vector<@TYPE@> &data, + bool repeat, int vlen, + const std::vector<gr_tag_t> &tags); + ~@NAME_IMPL@(); + + void rewind() { d_offset=0; } + void set_data(const std::vector<@TYPE@> &data, + const std::vector<gr_tag_t> &tags); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* @GUARD_NAME_IMPL@ */ diff --git a/gr-blocks/lib/wavfile.cc b/gr-blocks/lib/wavfile.cc new file mode 100644 index 0000000000..16d80adc83 --- /dev/null +++ b/gr-blocks/lib/wavfile.cc @@ -0,0 +1,258 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2012-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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <blocks/wavfile.h> +#include <cstring> +#include <stdint.h> +#include <boost/detail/endian.hpp> //BOOST_BIG_ENDIAN + +namespace gr { + namespace blocks { + +#define VALID_COMPRESSION_TYPE 0x0001 + + // Basically, this is the opposite of htonx() and ntohx() + // Define host to/from worknet (little endian) short and long +#ifdef BOOST_BIG_ENDIAN + + static inline uint16_t __wav_bs16(uint16_t x) + { + return (x>>8) | (x<<8); + } + + static inline uint32_t __wav_bs32(uint32_t x) + { + return (uint32_t(__wav_bs16(uint16_t(x&0xfffful)))<<16) | (__wav_bs16(uint16_t(x>>16))); + } + + #define htowl(x) __gri_wav_bs32(x) + #define wtohl(x) __gri_wav_bs32(x) + #define htows(x) __gri_wav_bs16(x) + #define wtohs(x) __gri_wav_bs16(x) + +#else + + #define htowl(x) uint32_t(x) + #define wtohl(x) uint32_t(x) + #define htows(x) uint16_t(x) + #define wtohs(x) uint16_t(x) + +#endif // BOOST_BIG_ENDIAN + + // WAV files are always little-endian, so we need some byte switching macros + static inline uint32_t host_to_wav(uint32_t x) { return htowl(x); } + static inline uint16_t host_to_wav(uint16_t x) { return htows(x); } + static inline int16_t host_to_wav(int16_t x) { return htows(x); } + static inline uint32_t wav_to_host(uint32_t x) { return wtohl(x); } + static inline uint16_t wav_to_host(uint16_t x) { return wtohs(x); } + static inline int16_t wav_to_host(int16_t x) { return wtohs(x); } + + bool + wavheader_parse(FILE *fp, + unsigned int &sample_rate_o, + int &nchans_o, + int &bytes_per_sample_o, + int &first_sample_pos_o, + unsigned int &samples_per_chan_o) + { + // _o variables take return values + char str_buf[8] = {0}; + + uint32_t file_size; + uint32_t fmt_hdr_skip; + uint16_t compression_type; + uint16_t nchans; + uint32_t sample_rate; + uint32_t avg_bytes_per_sec; + uint16_t block_align; + uint16_t bits_per_sample; + uint32_t chunk_size; + + size_t fresult; + + fresult = fread(str_buf, 1, 4, fp); + if(fresult != 4 || strncmp(str_buf, "RIFF", 4) || feof(fp)) { + return false; + } + + fresult = fread(&file_size, 1, 4, fp); + + fresult = fread(str_buf, 1, 8, fp); + if(fresult != 8 || strncmp(str_buf, "WAVEfmt ", 8) || feof(fp)) { + return false; + } + + fresult = fread(&fmt_hdr_skip, 1, 4, fp); + + fresult = fread(&compression_type, 1, 2, fp); + if(wav_to_host(compression_type) != VALID_COMPRESSION_TYPE) { + return false; + } + + fresult = fread(&nchans, 1, 2, fp); + fresult = fread(&sample_rate, 1, 4, fp); + fresult = fread(&avg_bytes_per_sec, 1, 4, fp); + fresult = fread(&block_align, 1, 2, fp); + fresult = fread(&bits_per_sample, 1, 2, fp); + + if(ferror(fp)) { + return false; + } + + fmt_hdr_skip = wav_to_host(fmt_hdr_skip); + nchans = wav_to_host(nchans); + sample_rate = wav_to_host(sample_rate); + bits_per_sample = wav_to_host(bits_per_sample); + + if(bits_per_sample != 8 && bits_per_sample != 16) { + return false; + } + + fmt_hdr_skip -= 16; + if(fmt_hdr_skip) { + fseek(fp, fmt_hdr_skip, SEEK_CUR); + } + + // data chunk + fresult = fread(str_buf, 1, 4, fp); + if(strncmp(str_buf, "data", 4)) { + return false; + } + + fresult = fread(&chunk_size, 1, 4, fp); + if(ferror(fp)) { + return false; + } + + // More byte swapping + chunk_size = wav_to_host(chunk_size); + + // Output values + sample_rate_o = (unsigned)sample_rate; + nchans_o = (int)nchans; + bytes_per_sample_o = (int)(bits_per_sample / 8); + first_sample_pos_o = (int)ftell(fp); + samples_per_chan_o = (unsigned)(chunk_size / (bytes_per_sample_o * nchans)); + return true; + } + + + short int + wav_read_sample(FILE *fp, int bytes_per_sample) + { + int16_t buf_16bit; + + if(!fread(&buf_16bit, bytes_per_sample, 1, fp)) { + return 0; + } + if(bytes_per_sample == 1) { + return (short)buf_16bit; + } + return (short)wav_to_host(buf_16bit); + } + + + bool + wavheader_write(FILE *fp, + unsigned int sample_rate, + int nchans, + int bytes_per_sample) + { + const int header_len = 44; + char wav_hdr[header_len] = "RIFF\0\0\0\0WAVEfmt \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0data\0\0\0"; + uint16_t nchans_f = (uint16_t) nchans; + uint32_t sample_rate_f = (uint32_t) sample_rate; + uint16_t block_align = bytes_per_sample * nchans; + uint32_t avg_bytes = sample_rate * block_align; + uint16_t bits_per_sample = bytes_per_sample * 8; + + nchans_f = host_to_wav(nchans_f); + sample_rate_f = host_to_wav(sample_rate_f); + block_align = host_to_wav(block_align); + avg_bytes = host_to_wav(avg_bytes); + bits_per_sample = host_to_wav(bits_per_sample); + + wav_hdr[16] = 0x10; // no extra bytes + wav_hdr[20] = 0x01; // no compression + memcpy((void*)(wav_hdr + 22), (void*)&nchans_f, 2); + memcpy((void*)(wav_hdr + 24), (void*)&sample_rate_f, 4); + memcpy((void*)(wav_hdr + 28), (void*)&avg_bytes, 4); + memcpy((void*)(wav_hdr + 32), (void*)&block_align, 2); + memcpy((void*)(wav_hdr + 34), (void*)&bits_per_sample, 2); + + fwrite(&wav_hdr, 1, header_len, fp); + if(ferror(fp)) { + return false; + } + + return true; + } + + + void + wav_write_sample(FILE *fp, short int sample, int bytes_per_sample) + { + void *data_ptr; + unsigned char buf_8bit; + int16_t buf_16bit; + + if(bytes_per_sample == 1) { + buf_8bit = (unsigned char)sample; + data_ptr = (void*)&buf_8bit; + } + else { + buf_16bit = host_to_wav((int16_t) sample); + data_ptr = (void *) &buf_16bit; + } + + fwrite(data_ptr, 1, bytes_per_sample, fp); + } + + + bool + wavheader_complete(FILE *fp, unsigned int byte_count) + { + uint32_t chunk_size = (uint32_t)byte_count; + chunk_size = host_to_wav(chunk_size); + + fseek(fp, 40, SEEK_SET); + fwrite(&chunk_size, 1, 4, fp); + + chunk_size = (uint32_t)byte_count + 36; // fmt chunk and data header + chunk_size = host_to_wav(chunk_size); + fseek(fp, 4, SEEK_SET); + + fwrite(&chunk_size, 1, 4, fp); + + if(ferror(fp)) { + return false; + } + + return true; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/wavfile_sink_impl.cc b/gr-blocks/lib/wavfile_sink_impl.cc new file mode 100644 index 0000000000..f8b09a114b --- /dev/null +++ b/gr-blocks/lib/wavfile_sink_impl.cc @@ -0,0 +1,293 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2006-2011,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "wavfile_sink_impl.h" +#include <blocks/wavfile.h> +#include <gr_io_signature.h> +#include <stdexcept> +#include <climits> +#include <cstring> +#include <cmath> +#include <fcntl.h> +#include <gruel/thread.h> +#include <boost/math/special_functions/round.hpp> + +// win32 (mingw/msvc) specific +#ifdef HAVE_IO_H +#include <io.h> +#endif +#ifdef O_BINARY +#define OUR_O_BINARY O_BINARY +#else +#define OUR_O_BINARY 0 +#endif + +// should be handled via configure +#ifdef O_LARGEFILE +#define OUR_O_LARGEFILE O_LARGEFILE +#else +#define OUR_O_LARGEFILE 0 +#endif + +namespace gr { + namespace blocks { + + wavfile_sink::sptr + wavfile_sink::make(const char *filename, + int n_channels, + unsigned int sample_rate, + int bits_per_sample) + { + return gnuradio::get_initial_sptr + (new wavfile_sink_impl(filename, n_channels, + sample_rate, bits_per_sample)); + } + + wavfile_sink_impl::wavfile_sink_impl(const char *filename, + int n_channels, + unsigned int sample_rate, + int bits_per_sample) + : gr_sync_block("wavfile_sink", + gr_make_io_signature(1, n_channels, sizeof(float)), + gr_make_io_signature(0, 0, 0)), + d_sample_rate(sample_rate), d_nchans(n_channels), + d_fp(0), d_new_fp(0), d_updated(false) + { + if(bits_per_sample != 8 && bits_per_sample != 16) { + throw std::runtime_error("Invalid bits per sample (supports 8 and 16)"); + } + d_bytes_per_sample = bits_per_sample / 8; + d_bytes_per_sample_new = d_bytes_per_sample; + + if(!open(filename)) { + throw std::runtime_error("can't open file"); + } + + if(bits_per_sample == 8) { + d_max_sample_val = 0xFF; + d_min_sample_val = 0; + d_normalize_fac = d_max_sample_val/2; + d_normalize_shift = 1; + } + else { + d_max_sample_val = 0x7FFF; + d_min_sample_val = -0x7FFF; + d_normalize_fac = d_max_sample_val; + d_normalize_shift = 0; + if(bits_per_sample != 16) { + fprintf(stderr, "Invalid bits per sample value requested, using 16"); + } + } + } + + bool + wavfile_sink_impl::open(const char* filename) + { + gruel::scoped_lock guard(d_mutex); + + // we use the open system call to get access to the O_LARGEFILE flag. + int fd; + if((fd = ::open(filename, + O_WRONLY|O_CREAT|O_TRUNC|OUR_O_LARGEFILE|OUR_O_BINARY, + 0664)) < 0) { + perror(filename); + return false; + } + + if(d_new_fp) { // if we've already got a new one open, close it + fclose(d_new_fp); + d_new_fp = 0; + } + + if((d_new_fp = fdopen (fd, "wb")) == NULL) { + perror(filename); + ::close(fd); // don't leak file descriptor if fdopen fails. + return false; + } + d_updated = true; + + if(!wavheader_write(d_new_fp, + d_sample_rate, + d_nchans, + d_bytes_per_sample_new)) { + fprintf(stderr, "[%s] could not write to WAV file\n", __FILE__); + exit(-1); + } + + return true; + } + + void + wavfile_sink_impl::close() + { + gruel::scoped_lock guard(d_mutex); + + if(!d_fp) + return; + + close_wav(); + } + + void + wavfile_sink_impl::close_wav() + { + unsigned int byte_count = d_sample_count * d_bytes_per_sample; + + wavheader_complete(d_fp, byte_count); + + fclose(d_fp); + d_fp = NULL; + } + + wavfile_sink_impl::~wavfile_sink_impl() + { + if(d_new_fp) { + fclose(d_new_fp); + } + + close(); + } + + int + wavfile_sink_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + float **in = (float**)&input_items[0]; + int n_in_chans = input_items.size(); + + short int sample_buf_s; + + int nwritten; + + gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this block + do_update(); // update: d_fp is reqd + if(!d_fp) // drop output on the floor + return noutput_items; + + for(nwritten = 0; nwritten < noutput_items; nwritten++) { + for(int chan = 0; chan < d_nchans; chan++) { + // Write zeros to channels which are in the WAV file + // but don't have any inputs here + if(chan < n_in_chans) { + sample_buf_s = + convert_to_short(in[chan][nwritten]); + } + else { + sample_buf_s = 0; + } + + wav_write_sample(d_fp, sample_buf_s, d_bytes_per_sample); + + if(feof(d_fp) || ferror(d_fp)) { + fprintf(stderr, "[%s] file i/o error\n", __FILE__); + close(); + exit(-1); + } + d_sample_count++; + } + } + + return nwritten; + } + + short int + wavfile_sink_impl::convert_to_short(float sample) + { + sample += d_normalize_shift; + sample *= d_normalize_fac; + if(sample > d_max_sample_val) { + sample = d_max_sample_val; + } + else if(sample < d_min_sample_val) { + sample = d_min_sample_val; + } + + return (short int)boost::math::iround(sample); + } + + void + wavfile_sink_impl::set_bits_per_sample(int bits_per_sample) + { + gruel::scoped_lock guard(d_mutex); + if(bits_per_sample == 8 || bits_per_sample == 16) { + d_bytes_per_sample_new = bits_per_sample / 8; + } + } + + void + wavfile_sink_impl::set_sample_rate(unsigned int sample_rate) + { + gruel::scoped_lock guard(d_mutex); + d_sample_rate = sample_rate; + } + + int + wavfile_sink_impl::bits_per_sample() + { + return d_bytes_per_sample_new; + } + + unsigned int + wavfile_sink_impl::sample_rate() + { + return d_sample_rate; + } + + void + wavfile_sink_impl::do_update() + { + if(!d_updated) { + return; + } + + if(d_fp) { + close_wav(); + } + + d_fp = d_new_fp; // install new file pointer + d_new_fp = 0; + d_sample_count = 0; + d_bytes_per_sample = d_bytes_per_sample_new; + + if(d_bytes_per_sample == 1) { + d_max_sample_val = UCHAR_MAX; + d_min_sample_val = 0; + d_normalize_fac = d_max_sample_val/2; + d_normalize_shift = 1; + } + else if(d_bytes_per_sample == 2) { + d_max_sample_val = SHRT_MAX; + d_min_sample_val = SHRT_MIN; + d_normalize_fac = d_max_sample_val; + d_normalize_shift = 0; + } + + d_updated = false; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/wavfile_sink_impl.h b/gr-blocks/lib/wavfile_sink_impl.h new file mode 100644 index 0000000000..8a364f2b90 --- /dev/null +++ b/gr-blocks/lib/wavfile_sink_impl.h @@ -0,0 +1,95 @@ +/* -*- c++ -*- */ +/* + * Copyright 2008,2009,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. + */ + +#ifndef INCLUDED_GR_WAVFILE_SINK_IMPL_H +#define INCLUDED_GR_WAVFILE_SINK_IMPL_H + +#include <blocks/wavfile_sink.h> +#include <gr_file_sink_base.h> + +namespace gr { + namespace blocks { + + class wavfile_sink_impl : public wavfile_sink + { + private: + unsigned d_sample_rate; + int d_nchans; + unsigned d_sample_count; + int d_bytes_per_sample; + int d_bytes_per_sample_new; + int d_max_sample_val; + int d_min_sample_val; + int d_normalize_shift; + int d_normalize_fac; + + FILE *d_fp; + FILE *d_new_fp; + bool d_updated; + boost::mutex d_mutex; + + /*! + * \brief Convert a sample value within [-1;+1] to a corresponding + * short integer value + */ + short convert_to_short(float sample); + + /*! + * \brief If any file changes have occurred, update now. This is called + * internally by work() and thus doesn't usually need to be called by + * hand. + */ + void do_update(); + + /*! + * \brief Writes information to the WAV header which is not available + * a-priori (chunk size etc.) and closes the file. Not thread-safe and + * assumes d_fp is a valid file pointer, should thus only be called by + * other methods. + */ + void close_wav(); + + public: + wavfile_sink_impl(const char *filename, + int n_channels, + unsigned int sample_rate, + int bits_per_sample); + ~wavfile_sink_impl(); + + bool open(const char* filename); + void close(); + + void set_sample_rate(unsigned int sample_rate); + void set_bits_per_sample(int bits_per_sample); + + int bits_per_sample(); + unsigned int sample_rate(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_WAVFILE_SINK_IMPL_H */ diff --git a/gr-blocks/lib/wavfile_source_impl.cc b/gr-blocks/lib/wavfile_source_impl.cc new file mode 100644 index 0000000000..2e3b0e240c --- /dev/null +++ b/gr-blocks/lib/wavfile_source_impl.cc @@ -0,0 +1,174 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "wavfile_source_impl.h" +#include <gr_io_signature.h> +#include <blocks/wavfile.h> +#include <sys/types.h> +#include <fcntl.h> +#include <stdexcept> + +// win32 (mingw/msvc) specific +#ifdef HAVE_IO_H +#include <io.h> +#endif +#ifdef O_BINARY +#define OUR_O_BINARY O_BINARY +#else +#define OUR_O_BINARY 0 +#endif +// should be handled via configure +#ifdef O_LARGEFILE +#define OUR_O_LARGEFILE O_LARGEFILE +#else +#define OUR_O_LARGEFILE 0 +#endif + +namespace gr { + namespace blocks { + + wavfile_source::sptr + wavfile_source::make(const char *filename, bool repeat) + { + return gnuradio::get_initial_sptr + (new wavfile_source_impl(filename, repeat)); + } + + wavfile_source_impl::wavfile_source_impl (const char *filename, bool repeat) + : gr_sync_block("wavfile_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 2, sizeof(float))), + d_fp(NULL), d_repeat(repeat), + d_sample_rate(1), d_nchans(1), d_bytes_per_sample(2), d_first_sample_pos(0), + d_samples_per_chan(0), d_sample_idx(0) + { + // we use "open" to use to the O_LARGEFILE flag + + int fd; + if((fd = open (filename, O_RDONLY | OUR_O_LARGEFILE | OUR_O_BINARY)) < 0) { + perror(filename); + throw std::runtime_error("can't open file"); + } + + if((d_fp = fdopen(fd, "rb")) == NULL) { + perror(filename); + throw std::runtime_error("can't open file"); + } + + // Scan headers, check file validity + if(!wavheader_parse(d_fp, + d_sample_rate, + d_nchans, + d_bytes_per_sample, + d_first_sample_pos, + d_samples_per_chan)) { + throw std::runtime_error("is not a valid wav file"); + } + + if(d_samples_per_chan == 0) { + throw std::runtime_error("WAV file does not contain any samples"); + } + + if(d_bytes_per_sample == 1) { + d_normalize_fac = 128; + d_normalize_shift = 1; + } + else { + d_normalize_fac = 0x7FFF; + d_normalize_shift = 0; + } + + // Re-set the output signature + set_output_signature(gr_make_io_signature(1, d_nchans, sizeof(float))); + } + + wavfile_source_impl::~wavfile_source_impl () + { + fclose(d_fp); + } + + float + wavfile_source_impl::convert_to_float(short int sample) + { + float sample_out = (float)sample; + sample_out /= d_normalize_fac; + sample_out -= d_normalize_shift; + return sample_out; + } + + int + wavfile_source_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + float **out = (float**)&output_items[0]; + int n_out_chans = output_items.size(); + + int i; + short sample; + + for(i = 0; i < noutput_items; i++) { + if(d_sample_idx >= d_samples_per_chan) { + if(!d_repeat) { + // if nothing was read at all, say we're done. + return i ? i : -1; + } + + if(fseek (d_fp, d_first_sample_pos, SEEK_SET) == -1) { + fprintf(stderr, "[%s] fseek failed\n", __FILE__); + exit(-1); + } + + d_sample_idx = 0; + } + + for(int chan = 0; chan < d_nchans; chan++) { + sample = wav_read_sample(d_fp, d_bytes_per_sample); + + if(chan < n_out_chans) { + out[chan][i] = convert_to_float(sample); + } + } + + d_sample_idx++; + + // OK, EOF is not necessarily an error. But we're not going to + // deal with handling corrupt wav files, so if they give us any + // trouble they won't be processed. Serves them bloody right. + if(feof(d_fp) || ferror(d_fp)) { + if(i == 0) { + fprintf(stderr, "[%s] WAV file has corrupted header or i/o error\n", __FILE__); + return -1; + } + return i; + } + } + + return noutput_items; + } + + } /* namespace blocks */ +} /* namespace gr */ diff --git a/gr-blocks/lib/wavfile_source_impl.h b/gr-blocks/lib/wavfile_source_impl.h new file mode 100644 index 0000000000..4875731a08 --- /dev/null +++ b/gr-blocks/lib/wavfile_source_impl.h @@ -0,0 +1,70 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2008,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. + */ + +#ifndef INCLUDED_GR_WAVFILE_SOURCE_IMPL_H +#define INCLUDED_GR_WAVFILE_SOURCE_IMPL_H + +#include <blocks/wavfile_source.h> +#include <cstdio> // for FILE + +namespace gr { + namespace blocks { + + class wavfile_source_impl : public wavfile_source + { + private: + FILE *d_fp; + bool d_repeat; + + unsigned d_sample_rate; + int d_nchans; + int d_bytes_per_sample; + int d_first_sample_pos; + unsigned d_samples_per_chan; + unsigned d_sample_idx; + int d_normalize_shift; + int d_normalize_fac; + + /*! + * \brief Convert an integer sample value to a float value within [-1;1] + */ + float convert_to_float(short int sample); + + public: + wavfile_source_impl(const char *filename, bool repeat); + ~wavfile_source_impl(); + + unsigned int sample_rate() const { return d_sample_rate; }; + + int bits_per_sample() const { return d_bytes_per_sample * 8; }; + + int channels() const { return d_nchans; }; + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } /* namespace blocks */ +} /* namespace gr */ + +#endif /* INCLUDED_GR_WAVFILE_SOURCE_IMPL_H */ diff --git a/gr-blocks/python/qa_argmax.py b/gr-blocks/python/qa_argmax.py new file mode 100644 index 0000000000..ec82b71cd4 --- /dev/null +++ b/gr-blocks/python/qa_argmax.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math + +class test_arg_max(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + tb = self.tb + + src1_data = (0,0.2,-0.3,0,12,0) + src2_data = (0,0.0,3.0,0,10,0) + src3_data = (0,0.0,3.0,0,1,0) + + src1 = gr.vector_source_f(src1_data) + s2v1 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) + tb.connect(src1, s2v1) + + src2 = gr.vector_source_f(src2_data) + s2v2 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) + tb.connect(src2, s2v2) + + src3 = gr.vector_source_f(src3_data) + s2v3 = blocks.stream_to_vector(gr.sizeof_float, len(src1_data)) + tb.connect(src3, s2v3) + + dst1 = gr.vector_sink_s() + dst2 = gr.vector_sink_s() + argmax = blocks.argmax_fs(len(src1_data)) + + tb.connect(s2v1, (argmax, 0)) + tb.connect(s2v2, (argmax, 1)) + tb.connect(s2v3, (argmax, 2)) + + tb.connect((argmax,0), dst1) + tb.connect((argmax,1), dst2) + + tb.run() + index = dst1.data() + source = dst2.data() + self.assertEqual(index, (4,)) + self.assertEqual(source, (0,)) + +if __name__ == '__main__': + gr_unittest.run(test_arg_max, "test_arg_max.xml") + diff --git a/gr-blocks/python/qa_bin_statistics.py b/gr-blocks/python/qa_bin_statistics.py new file mode 100755 index 0000000000..c1b3072530 --- /dev/null +++ b/gr-blocks/python/qa_bin_statistics.py @@ -0,0 +1,227 @@ +#!/usr/bin/env python +# +# Copyright 2006,2007,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import random +import struct + +""" +Note: There has been an issue with this block in the past, see Issue +#199. This looks like it might have fixed itself over the years. I am +leaving these tests disabled on our master branch for v3.6 for now, +though, just in case. TWR. +""" + +class counter(gr.feval_dd): + def __init__(self, step_size=1): + gr.feval_dd.__init__(self) + self.step_size = step_size + self.count = 0 + + def eval(self, input): + #print "eval: self.count =", self.count + t = self.count + self.count = self.count + self.step_size + return t + + +class counter3(gr.feval_dd): + def __init__(self, f, step_size): + gr.feval_dd.__init__(self) + self.f = f + self.step_size = step_size + self.count = 0 + + def eval(self, input): + try: + #print "eval: self.count =", self.count + t = self.count + self.count = self.count + self.step_size + self.f(self.count) + except Exception, e: + print "Exception: ", e + return t + +def foobar3(new_t): + #print "foobar3: new_t =", new_t + pass + + +class counter4(gr.feval_dd): + def __init__(self, obj_instance, step_size): + gr.feval_dd.__init__(self) + self.obj_instance = obj_instance + self.step_size = step_size + self.count = 0 + + def eval(self, input): + try: + #print "eval: self.count =", self.count + t = self.count + self.count = self.count + self.step_size + self.obj_instance.foobar4(self.count) + except Exception, e: + print "Exception: ", e + return t + + +class parse_msg(object): + def __init__(self, msg): + self.center_freq = msg.arg1() + self.vlen = int(msg.arg2()) + assert(msg.length() == self.vlen * gr.sizeof_float) + self.data = struct.unpack('%df' % (self.vlen,), msg.to_string()) + +class test_bin_statistics(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block () + + def tearDown(self): + self.tb = None + + def xtest_001(self): + vlen = 4 + tune = counter(1) + tune_delay = 0 + dwell_delay = 1 + msgq = gr.msg_queue() + + src_data = tuple([float(x) for x in + ( 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + )]) + + expected_results = tuple([float(x) for x in + ( 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16 + )]) + + src = gr.vector_source_f(src_data, False) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) + stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) + self.tb.connect(src, s2v, stats) + self.tb.run() + self.assertEqual(4, msgq.count()) + for i in range(4): + m = parse_msg(msgq.delete_head()) + #print "m =", m.center_freq, m.data + self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data) + + def xtest_002(self): + vlen = 4 + tune = counter(1) + tune_delay = 1 + dwell_delay = 2 + msgq = gr.msg_queue() + + src_data = tuple([float(x) for x in + ( 1, 2, 3, 4, + 9, 6, 11, 8, + 5, 10, 7, 12, + 13, 14, 15, 16 + )]) + + expected_results = tuple([float(x) for x in + ( 9, 10, 11, 12)]) + + src = gr.vector_source_f(src_data, False) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) + stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) + self.tb.connect(src, s2v, stats) + self.tb.run() + self.assertEqual(1, msgq.count()) + for i in range(1): + m = parse_msg(msgq.delete_head()) + #print "m =", m.center_freq, m.data + self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data) + + + + def xtest_003(self): + vlen = 4 + tune = counter3(foobar3, 1) + tune_delay = 1 + dwell_delay = 2 + msgq = gr.msg_queue() + + src_data = tuple([float(x) for x in + ( 1, 2, 3, 4, + 9, 6, 11, 8, + 5, 10, 7, 12, + 13, 14, 15, 16 + )]) + + expected_results = tuple([float(x) for x in + ( 9, 10, 11, 12)]) + + src = gr.vector_source_f(src_data, False) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) + stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) + self.tb.connect(src, s2v, stats) + self.tb.run() + self.assertEqual(1, msgq.count()) + for i in range(1): + m = parse_msg(msgq.delete_head()) + #print "m =", m.center_freq, m.data + self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data) + + def foobar4(self, new_t): + #print "foobar4: new_t =", new_t + pass + + def xtest_004(self): + vlen = 4 + tune = counter4(self, 1) + tune_delay = 1 + dwell_delay = 2 + msgq = gr.msg_queue() + + src_data = tuple([float(x) for x in + ( 1, 2, 3, 4, + 9, 6, 11, 8, + 5, 10, 7, 12, + 13, 14, 15, 16 + )]) + + expected_results = tuple([float(x) for x in + ( 9, 10, 11, 12)]) + + src = gr.vector_source_f(src_data, False) + s2v = blocks.stream_to_vector(gr.sizeof_float, vlen) + stats = blocks.bin_statistics_f(vlen, msgq, tune, tune_delay, dwell_delay) + self.tb.connect(src, s2v, stats) + self.tb.run() + self.assertEqual(1, msgq.count()) + for i in range(1): + m = parse_msg(msgq.delete_head()) + #print "m =", m.center_freq, m.data + self.assertEqual(expected_results[vlen*i:vlen*i + vlen], m.data) + + +if __name__ == '__main__': + gr_unittest.run(test_bin_statistics, "test_bin_statistics.xml") diff --git a/gr-blocks/python/qa_burst_tagger.py b/gr-blocks/python/qa_burst_tagger.py new file mode 100644 index 0000000000..c89ece4e15 --- /dev/null +++ b/gr-blocks/python/qa_burst_tagger.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import pmt + +class test_burst_tagger(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1) + src = gr.vector_source_i(src_data) + trg = gr.vector_source_s(trg_data) + op = blocks.burst_tagger(gr.sizeof_int) + snk = blocks.tag_debug(gr.sizeof_int, "burst tagger QA") + self.tb.connect(src, (op,0)) + self.tb.connect(trg, (op,1)) + self.tb.connect(op, snk) + self.tb.run() + + x = snk.current_tags() + self.assertEqual(2, x[0].offset) + self.assertEqual(4, x[1].offset) + self.assertEqual(6, x[2].offset) + self.assertEqual(8, x[3].offset) + + self.assertEqual(True, pmt.pmt_to_bool(x[0].value)) + self.assertEqual(False, pmt.pmt_to_bool(x[1].value)) + self.assertEqual(True, pmt.pmt_to_bool(x[2].value)) + self.assertEqual(False, pmt.pmt_to_bool(x[3].value)) + +if __name__ == '__main__': + gr_unittest.run(test_burst_tagger, "test_burst_tagger.xml") diff --git a/gr-blocks/python/qa_copy.py b/gr-blocks/python/qa_copy.py new file mode 100755 index 0000000000..012d790609 --- /dev/null +++ b/gr-blocks/python/qa_copy.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# +# Copyright 2009,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_copy(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_copy(self): + src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + expected_result = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + src = blocks.vector_source_b(src_data) + op = blocks.copy(gr.sizeof_char) + dst = blocks.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + dst_data = dst.data() + self.assertEqual(expected_result, dst_data) + + def test_copy_drop (self): + src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + expected_result = () + src = blocks.vector_source_b(src_data) + op = gr.copy(gr.sizeof_char) + op.set_enabled(False) + dst = blocks.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + dst_data = dst.data() + self.assertEqual(expected_result, dst_data) + +if __name__ == '__main__': + gr_unittest.run(test_copy, "test_copy.xml") diff --git a/gr-blocks/python/qa_endian_swap.py b/gr-blocks/python/qa_endian_swap.py new file mode 100644 index 0000000000..5180293052 --- /dev/null +++ b/gr-blocks/python/qa_endian_swap.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# +# Copyright 2011-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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import ctypes + +class test_endian_swap(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = [1,2,3,4] + expected_result = [256, 512, 768, 1024]; + + src = blocks.vector_source_s(src_data) + op = blocks.endian_swap(2) + dst = blocks.vector_sink_s() + + self.tb.connect(src, op, dst) + self.tb.run() + result_data = list(dst.data()) + + self.assertEqual(expected_result, result_data) + + def test_002(self): + + src_data = [1,2,3,4] + expected_result = [16777216, 33554432, 50331648, 67108864]; + + src = blocks.vector_source_i(src_data) + op = blocks.endian_swap(4) + dst = blocks.vector_sink_i() + + self.tb.connect(src, op, dst) + self.tb.run() + result_data = list(dst.data()) + + self.assertEqual(expected_result, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_endian_swap, "test_endian_swap.xml") + diff --git a/gr-blocks/python/qa_file_source_sink.py b/gr-blocks/python/qa_file_source_sink.py new file mode 100644 index 0000000000..d1d67074d5 --- /dev/null +++ b/gr-blocks/python/qa_file_source_sink.py @@ -0,0 +1,93 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import os + +class test_file_source_sink(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001(self): + src_data = range(1000) + expected_result = range(1000) + + filename = "tmp.32f" + src = gr.vector_source_f(src_data) + snk = blocks.file_sink(gr.sizeof_float, filename) + snk.set_unbuffered(True) + + src2 = blocks.file_source(gr.sizeof_float, filename) + snk2 = gr.vector_sink_f() + + self.tb.connect(src, snk) + self.tb.run() + + self.tb.disconnect(src, snk) + self.tb.connect(src2, snk2) + self.tb.run() + + os.remove(filename) + + result_data = snk2.data() + self.assertFloatTuplesAlmostEqual(expected_result, result_data) + + def test_descriptor_001(self): + src_data = range(1000) + expected_result = range(1000) + + filename = "tmp.32f" + fhandle0 = open(filename, "wb") + fd0 = fhandle0.fileno() + + src = gr.vector_source_f(src_data) + snk = blocks.file_descriptor_sink(gr.sizeof_float, fd0) + + self.tb.connect(src, snk) + self.tb.run() + os.fsync(fd0) + fhandle0.close() + + fhandle1 = open(filename, "rb") + fd1 = fhandle1.fileno() + src2 = blocks.file_descriptor_source(gr.sizeof_float, fd1, False) + snk2 = gr.vector_sink_f() + + self.tb.disconnect(src, snk) + self.tb.connect(src2, snk2) + self.tb.run() + os.fsync(fd1) + fhandle1.close() + + os.remove(filename) + + result_data = snk2.data() + self.assertFloatTuplesAlmostEqual(expected_result, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_file_source_sink, "test_file_source_sink.xml") + diff --git a/gr-blocks/python/qa_head.py b/gr-blocks/python/qa_head.py new file mode 100755 index 0000000000..39b1255978 --- /dev/null +++ b/gr-blocks/python/qa_head.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# +# Copyright 2004,2007,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_head(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_head(self): + src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + expected_result = (1, 2, 3, 4) + src1 = blocks.vector_source_i(src_data) + op = blocks.head(gr.sizeof_int, 4) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op) + self.tb.connect(op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + +if __name__ == '__main__': + gr_unittest.run(test_head, "test_head.xml") diff --git a/gr-blocks/python/qa_max.py b/gr-blocks/python/qa_max.py new file mode 100755 index 0000000000..4af70bd4be --- /dev/null +++ b/gr-blocks/python/qa_max.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math + +class test_max(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = (0,0.2,-0.3,0,12,0) + expected_result = (float(max(src_data)),) + + src = gr.vector_source_f(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) + op = blocks.max_ff(len(src_data)) + dst = gr.vector_sink_f() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def test_002(self): + src_data=(-100,-99,-98,-97,-96,-1) + expected_result = (float(max(src_data)),) + + src = gr.vector_source_f(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_float, len(src_data)) + op = blocks.max_ff(len(src_data)) + dst = gr.vector_sink_f() + + self.tb.connect(src, s2v, op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + +if __name__ == '__main__': + gr_unittest.run(test_max, "test_max.xml") + diff --git a/gr-blocks/python/qa_message.py b/gr-blocks/python/qa_message.py new file mode 100755 index 0000000000..551fdd6259 --- /dev/null +++ b/gr-blocks/python/qa_message.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python +# +# Copyright 2004,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import pmt +import time + +def all_counts(): + return (gr.block_ncurrently_allocated(), + gr.block_detail_ncurrently_allocated(), + gr.buffer_ncurrently_allocated(), + gr.buffer_reader_ncurrently_allocated(), + gr.message_ncurrently_allocated()) + + +class test_message(gr_unittest.TestCase): + + def setUp(self): + self.msgq = gr.msg_queue() + + def tearDown(self): + self.msgq = None + + def leak_check(self, fct): + begin = all_counts() + fct() + # tear down early so we can check for leaks + self.tearDown() + end = all_counts() + self.assertEqual(begin, end) + + def test_100(self): + msg = gr.message(0, 1.5, 2.3) + self.assertEquals(0, msg.type()) + self.assertAlmostEqual(1.5, msg.arg1()) + self.assertAlmostEqual(2.3, msg.arg2()) + self.assertEquals(0, msg.length()) + + def test_101(self): + s = 'This is a test' + msg = gr.message_from_string(s) + self.assertEquals(s, msg.to_string()) + + def test_200(self): + self.leak_check(self.body_200) + + def body_200(self): + self.msgq.insert_tail(gr.message(0)) + self.assertEquals(1, self.msgq.count()) + self.msgq.insert_tail(gr.message(1)) + self.assertEquals(2, self.msgq.count()) + msg0 = self.msgq.delete_head() + self.assertEquals(0, msg0.type()) + msg1 = self.msgq.delete_head() + self.assertEquals(1, msg1.type()) + self.assertEquals(0, self.msgq.count()) + + def test_201(self): + self.leak_check(self.body_201) + + def body_201(self): + self.msgq.insert_tail(gr.message(0)) + self.assertEquals(1, self.msgq.count()) + self.msgq.insert_tail(gr.message(1)) + self.assertEquals(2, self.msgq.count()) + + def test_202(self): + self.leak_check(self.body_202) + + def body_202(self): + # global msg + msg = gr.message(666) + + def test_300(self): + input_data = (0,1,2,3,4,5,6,7,8,9) + src = gr.vector_source_b(input_data) + dst = gr.vector_sink_b() + tb = gr.top_block() + tb.connect(src, dst) + tb.run() + self.assertEquals(input_data, dst.data()) + + def test_301(self): + # Use itemsize, limit constructor + src = blocks.message_source(gr.sizeof_char) + dst = gr.vector_sink_b() + tb = gr.top_block() + tb.connect(src, dst) + src.msgq().insert_tail(gr.message_from_string('01234')) + src.msgq().insert_tail(gr.message_from_string('5')) + src.msgq().insert_tail(gr.message_from_string('')) + src.msgq().insert_tail(gr.message_from_string('6789')) + src.msgq().insert_tail(gr.message(1)) # send EOF + tb.run() + self.assertEquals(tuple(map(ord, '0123456789')), dst.data()) + + def test_302(self): + # Use itemsize, msgq constructor + msgq = gr.msg_queue() + src = blocks.message_source(gr.sizeof_char, msgq) + dst = gr.vector_sink_b() + tb = gr.top_block() + tb.connect(src, dst) + src.msgq().insert_tail(gr.message_from_string('01234')) + src.msgq().insert_tail(gr.message_from_string('5')) + src.msgq().insert_tail(gr.message_from_string('')) + src.msgq().insert_tail(gr.message_from_string('6789')) + src.msgq().insert_tail(gr.message(1)) # send EOF + tb.run() + self.assertEquals(tuple(map(ord, '0123456789')), dst.data()) + + def test_debug_401(self): + msg = pmt.pmt_intern("TESTING") + src = blocks.message_strobe(msg, 500) + snk = blocks.message_debug() + + tb = gr.top_block() + tb.msg_connect(src, "strobe", snk, "store") + tb.start() + time.sleep(1) + tb.stop() + tb.wait() + + rec_msg = snk.get_message(0) + self.assertTrue(pmt.pmt_eqv(rec_msg, msg)) + + +if __name__ == '__main__': + gr_unittest.run(test_message, "test_message.xml") diff --git a/gr-blocks/python/qa_moving_average.py b/gr-blocks/python/qa_moving_average.py new file mode 100644 index 0000000000..169b4746c2 --- /dev/null +++ b/gr-blocks/python/qa_moving_average.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math, random + +def make_random_complex_tuple(L, scale=1): + result = [] + for x in range(L): + result.append(scale*complex(2*random.random()-1, + 2*random.random()-1)) + return tuple(result) + +def make_random_float_tuple(L, scale=1): + result = [] + for x in range(L): + result.append(scale*(2*random.random()-1)) + return tuple(result) + +class test_moving_average(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_01(self): + tb = self.tb + + N = 10000 + seed = 0 + data = make_random_float_tuple(N, 1) + expected_result = N*[0,] + + src = gr.vector_source_f(data, False) + op = blocks.moving_average_ff(100, 0.001) + dst = gr.vector_sink_f() + + tb.connect(src, op) + tb.connect(op, dst) + tb.run() + + dst_data = dst.data() + + # make sure result is close to zero + self.assertFloatTuplesAlmostEqual(expected_result, dst_data, 1) + + def test_02(self): + tb = self.tb + + N = 10000 + seed = 0 + data = make_random_complex_tuple(N, 1) + expected_result = N*[0,] + + src = gr.vector_source_c(data, False) + op = blocks.moving_average_cc(100, 0.001) + dst = gr.vector_sink_c() + + tb.connect(src, op) + tb.connect(op, dst) + tb.run() + + dst_data = dst.data() + + # make sure result is close to zero + self.assertComplexTuplesAlmostEqual(expected_result, dst_data, 1) + +if __name__ == '__main__': + gr_unittest.run(test_moving_average, "test_moving_average.xml") diff --git a/gr-blocks/python/qa_mute.py b/gr-blocks/python/qa_mute.py new file mode 100755 index 0000000000..96c57b2ed1 --- /dev/null +++ b/gr-blocks/python/qa_mute.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python +# +# Copyright 2004,2005,2007,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_mute(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def help_ii(self, src_data, exp_data, op): + for s in zip(range(len(src_data)), src_data): + src = gr.vector_source_i(s[1]) + self.tb.connect(src, (op, s[0])) + dst = gr.vector_sink_i() + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def help_ff(self, src_data, exp_data, op): + for s in zip(range(len(src_data)), src_data): + src = gr.vector_source_f(s[1]) + self.tb.connect(src, (op, s[0])) + dst = gr.vector_sink_f() + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def help_cc(self, src_data, exp_data, op): + for s in zip(range(len(src_data)), src_data): + src = gr.vector_source_c(s[1]) + self.tb.connect(src, (op, s[0])) + dst = gr.vector_sink_c() + self.tb.connect(op, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(exp_data, result_data) + + def test_unmute_ii(self): + src_data = (1, 2, 3, 4, 5) + expected_result = (1, 2, 3, 4, 5) + op = blocks.mute_ii(False) + self.help_ii((src_data,), expected_result, op) + + def test_mute_ii(self): + src_data = (1, 2, 3, 4, 5) + expected_result = (0, 0, 0, 0, 0) + op = blocks.mute_ii(True) + self.help_ii((src_data,), expected_result, op) + + def test_unmute_cc(self): + src_data = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j) + expected_result = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j) + op = blocks.mute_cc(False) + self.help_cc((src_data,), expected_result, op) + + def test_unmute_cc(self): + src_data = (1+5j, 2+5j, 3+5j, 4+5j, 5+5j) + expected_result =(0+0j, 0+0j, 0+0j, 0+0j, 0+0j) + op = blocks.mute_cc(True) + self.help_cc((src_data,), expected_result, op) + +if __name__ == '__main__': + gr_unittest.run(test_mute, "test_mute.xml") diff --git a/gr-blocks/python/qa_null_sink_source.py b/gr-blocks/python/qa_null_sink_source.py new file mode 100644 index 0000000000..60552cb207 --- /dev/null +++ b/gr-blocks/python/qa_null_sink_source.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math + +class test_null_sink_source(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + # Just running some data through null source/sink + src = blocks.null_source(gr.sizeof_float) + hed = blocks.head(gr.sizeof_float, 100) + dst = blocks.null_sink(gr.sizeof_float) + + self.tb.connect(src, hed, dst) + self.tb.run() + +if __name__ == '__main__': + gr_unittest.run(test_null_sink_source, "test_null_sink_source.xml") + diff --git a/gr-blocks/python/qa_pack_k_bits.py b/gr-blocks/python/qa_pack_k_bits.py new file mode 100755 index 0000000000..cd55d2f200 --- /dev/null +++ b/gr-blocks/python/qa_pack_k_bits.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# +# Copyright 2006,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import random + +class test_pack(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = (1,0,1,1,0,1,1,0) + expected_results = (1,0,1,1,0,1,1,0) + src = gr.vector_source_b(src_data,False) + op = blocks.pack_k_bits_bb(1) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertEqual(expected_results, dst.data()) + + def test_002(self): + src_data = (1,0,1,1,0,0,0,1) + expected_results = ( 2, 3, 0, 1) + src = gr.vector_source_b(src_data,False) + op = blocks.pack_k_bits_bb(2) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + #self.assertEqual(expected_results, dst.data()) + self.assertEqual(expected_results, dst.data()) + + def test_003(self): + src_data = expected_results = map(lambda x: random.randint(0,3), range(10)); + src = gr.vector_source_b( src_data ); + pack = blocks.pack_k_bits_bb(2); + unpack = blocks.unpack_k_bits_bb(2); + snk = gr.vector_sink_b(); + self.tb.connect(src,unpack,pack,snk); + self.tb.run() + self.assertEqual(list(expected_results), list(snk.data())); + +if __name__ == '__main__': + gr_unittest.run(test_pack, "test_pack.xml") + diff --git a/gr-blocks/python/qa_pdu.py b/gr-blocks/python/qa_pdu.py new file mode 100755 index 0000000000..3f7675ce4a --- /dev/null +++ b/gr-blocks/python/qa_pdu.py @@ -0,0 +1,91 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import pmt +import time + +class test_pdu(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_000(self): + # Just run some data through and make sure it doesn't puke. + src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + + src = blocks.pdu_to_tagged_stream(blocks.byte_t) + snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t) + snk2 = gr.vector_sink_b() + snk = gr.tag_debug(1, "test") + snk.set_display(False) + + dbg = gr.message_debug() + + # Test that the right number of ports exist. + pi = snk3.message_ports_in() + po = snk3.message_ports_out() + self.assertEqual(pmt.pmt_length(pi), 0) + self.assertEqual(pmt.pmt_length(po), 1) + + self.tb.connect(src, snk) + self.tb.connect(src, snk2) + self.tb.connect(src, snk3) + self.tb.msg_connect(snk3, "pdus", dbg, "store") + self.tb.start() + + # make our reference and message pmts + port = pmt.pmt_intern("pdus") + msg = pmt.pmt_cons( pmt.PMT_NIL, pmt.pmt_make_u8vector(16, 0xFF)) + + # post the message + src.to_basic_block()._post(port, msg) # eww, what's that smell? + + while dbg.num_messages() < 1: + time.sleep(0.1) + self.tb.stop() + self.tb.wait() + + # Get the vector of data from the vector sink + result_data = snk2.data() + + # Get the vector of data from the message sink + # Convert the message PMT as a pair into its vector + result_msg = dbg.get_message(0) + msg_vec = pmt.pmt_cdr(result_msg) + #pmt.pmt_print(msg_vec) + + # Convert the PMT vector into a Python list + msg_data = [] + for i in xrange(16): + msg_data.append(pmt.pmt_u8vector_ref(msg_vec, i)) + + actual_data = 16*[0xFF,] + self.assertEqual(actual_data, list(result_data)) + self.assertEqual(actual_data, msg_data) + +if __name__ == '__main__': + gr_unittest.run(test_pdu, "test_pdu.xml") diff --git a/gr-blocks/python/qa_peak_detector.py b/gr-blocks/python/qa_peak_detector.py new file mode 100644 index 0000000000..c3ff2548c4 --- /dev/null +++ b/gr-blocks/python/qa_peak_detector.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_peak_detector(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_01(self): + tb = self.tb + + data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] + + expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + src = gr.vector_source_f(data, False) + regen = blocks.peak_detector_fb() + dst = gr.vector_sink_b() + + tb.connect(src, regen) + tb.connect(regen, dst) + tb.run() + + dst_data = dst.data() + + self.assertEqual(expected_result, dst_data) + + def test_02(self): + tb = self.tb + + data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] + + expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + src = gr.vector_source_i(data, False) + regen = blocks.peak_detector_ib() + dst = gr.vector_sink_b() + + tb.connect(src, regen) + tb.connect(regen, dst) + tb.run() + + dst_data = dst.data() + + self.assertEqual(expected_result, dst_data) + + def test_03(self): + tb = self.tb + + data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 9, 8, 7, 6, 5, 4, 3, 2, 1, 0] + + expected_result = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + + src = gr.vector_source_s(data, False) + regen = blocks.peak_detector_sb() + dst = gr.vector_sink_b() + + tb.connect(src, regen) + tb.connect(regen, dst) + tb.run() + + dst_data = dst.data() + + self.assertEqual(expected_result, dst_data) + +if __name__ == '__main__': + gr_unittest.run(test_peak_detector, "test_peak_detector.xml") diff --git a/gr-blocks/python/qa_peak_detector2.py b/gr-blocks/python/qa_peak_detector2.py index 4b864e4d70..b2d8e318dd 100644 --- a/gr-blocks/python/qa_peak_detector2.py +++ b/gr-blocks/python/qa_peak_detector2.py @@ -50,7 +50,6 @@ class test_peak_detector2(gr_unittest.TestCase): tb.run() dst_data = dst.data() - print dst_data self.assertEqual(expected_result, dst_data) diff --git a/gr-blocks/python/qa_plateau_detector_fb.py b/gr-blocks/python/qa_plateau_detector_fb.py new file mode 100755 index 0000000000..e45fe028dd --- /dev/null +++ b/gr-blocks/python/qa_plateau_detector_fb.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python +# +# Copyright 2012-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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class qa_plateau_detector_fb (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_t (self): + # | Spur spike 1 | Plateau | Spur spike 2 + test_signal = (0, 1, .2, .4, .6, .8, 1, 1, 1, 1, 1, .8, .6, .4, 1, 0) + expected_sig = (0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0) + # | Center of Plateau + sink = gr.vector_sink_b() + self.tb.connect(gr.vector_source_f(test_signal), blocks.plateau_detector_fb(5), sink) + self.tb.run () + self.assertEqual(expected_sig, sink.data()) + + +if __name__ == '__main__': + gr_unittest.run(qa_plateau_detector_fb, "qa_plateau_detector_fb.xml") diff --git a/gr-blocks/python/qa_probe_signal.py b/gr-blocks/python/qa_probe_signal.py new file mode 100644 index 0000000000..a420df71e5 --- /dev/null +++ b/gr-blocks/python/qa_probe_signal.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# +# Copyright 2012-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. +# + +import time +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_probe_signal(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + value = 12.3 + repeats = 100 + src_data = [value] * repeats + + src = gr.vector_source_f(src_data) + dst = blocks.probe_signal_f() + + self.tb.connect(src, dst) + self.tb.run() + output = dst.level() + self.assertAlmostEqual(value, output, places=6) + + def test_002(self): + vector_length = 10 + repeats = 10 + value = [0.5+i for i in range(0, vector_length)] + src_data = value * repeats + + src = gr.vector_source_f(src_data) + s2v = blocks.stream_to_vector(gr.sizeof_float, vector_length) + dst = blocks.probe_signal_vf(vector_length) + + self.tb.connect(src, s2v, dst) + self.tb.run() + output = dst.level() + self.assertEqual(len(output), vector_length) + self.assertAlmostEqual(value[3], output[3], places=6) + +if __name__ == '__main__': + gr_unittest.run(test_probe_signal, "test_probe_signal.xml") diff --git a/gr-blocks/python/qa_repack_bits_bb.py b/gr-blocks/python/qa_repack_bits_bb.py new file mode 100755 index 0000000000..e71f7621e3 --- /dev/null +++ b/gr-blocks/python/qa_repack_bits_bb.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +# +# 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. +# + +import random +from gnuradio import gr, gr_unittest +import pmt +import blocks_swig as blocks + +class qa_repack_bits_bb (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_simple (self): + """ Very simple test, 2 bits -> 1 """ + src_data = (0b11, 0b01, 0b10) + expected_data = (0b1, 0b1, 0b1, 0b0, 0b0, 0b1) + k = 2 + l = 1 + src = gr.vector_source_b(src_data, False, 1) + repack = blocks.repack_bits_bb(k, l) + sink = gr.vector_sink_b() + self.tb.connect(src, repack, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_data) + + def test_002_three (self): + """ 8 -> 3 """ + src_data = (0b11111101, 0b11111111, 0b11111111) + expected_data = (0b101,) + (0b111,) * 7 + k = 8 + l = 3 + src = gr.vector_source_b(src_data, False, 1) + repack = blocks.repack_bits_bb(k, l) + sink = gr.vector_sink_b() + self.tb.connect(src, repack, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_data) + + def test_003_lots_of_bytes (self): + """ Lots and lots of bytes, multiple packer stages """ + src_data = tuple([random.randint(0, 255) for x in range(3*5*7*8 * 10)]) + src = gr.vector_source_b(src_data, False, 1) + repack1 = blocks.repack_bits_bb(8, 3) + repack2 = blocks.repack_bits_bb(3, 5) + repack3 = blocks.repack_bits_bb(5, 7) + repack4 = blocks.repack_bits_bb(7, 8) + sink = gr.vector_sink_b() + self.tb.connect(src, repack1, repack2, repack3, repack4, sink) + self.tb.run () + self.assertEqual(sink.data(), src_data) + + def test_004_three_with_tags (self): + """ 8 -> 3 """ + src_data = (0b11111101, 0b11111111) + expected_data = (0b101,) + (0b111,) * 4 + (0b001,) + k = 8 + l = 3 + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(src_data)) + src = gr.vector_source_b(src_data, False, 1, (tag,)) + repack = blocks.repack_bits_bb(k, l, tag_name) + sink = gr.vector_sink_b() + self.tb.connect(src, repack, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_data) + try: + out_tag = sink.tags()[0] + except: + self.assertFail() + self.assertEqual(out_tag.offset, 0) + self.assertEqual(pmt.pmt_symbol_to_string(out_tag.key), tag_name) + self.assertEqual(pmt.pmt_to_long(out_tag.value), len(expected_data)) + + def test_005_three_with_tags_trailing (self): + """ 3 -> 8, trailing bits """ + src_data = (0b101,) + (0b111,) * 4 + (0b001,) + expected_data = (0b11111101, 0b11111111) + k = 3 + l = 8 + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(src_data)) + src = gr.vector_source_b(src_data, False, 1, (tag,)) + repack = blocks.repack_bits_bb(k, l, tag_name, True) + sink = gr.vector_sink_b() + self.tb.connect(src, repack, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_data) + try: + out_tag = sink.tags()[0] + except: + self.assertFail() + self.assertEqual(out_tag.offset, 0) + self.assertEqual(pmt.pmt_symbol_to_string(out_tag.key), tag_name) + self.assertEqual(pmt.pmt_to_long(out_tag.value), len(expected_data)) + +if __name__ == '__main__': + gr_unittest.run(qa_repack_bits_bb, "qa_repack_bits_bb.xml") + diff --git a/gr-blocks/python/qa_sample_and_hold.py b/gr-blocks/python/qa_sample_and_hold.py new file mode 100644 index 0000000000..59628090d1 --- /dev/null +++ b/gr-blocks/python/qa_sample_and_hold.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# +# 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. +# + +import time +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_sample_and_hold(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = 10*[0,1,2,3,4,5,6,7,8,9,8,7,6,5,4,3,2,1] + ctrl_data = 10*[1,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0] + expected_result = 10*(0,0,0,0,4,5,6,7,8,9,9,9,9,9,9,9,9,9) + + src = gr.vector_source_f(src_data) + ctrl = gr.vector_source_b(ctrl_data) + op = blocks.sample_and_hold_ff() + dst = gr.vector_sink_f() + + self.tb.connect(src, (op,0)) + self.tb.connect(ctrl, (op,1)) + self.tb.connect(op, dst) + self.tb.run() + + result = dst.data() + self.assertFloatTuplesAlmostEqual(expected_result, result, places=6) + +if __name__ == '__main__': + gr_unittest.run(test_sample_and_hold, "test_sample_and_hold.xml") diff --git a/gr-blocks/python/qa_skiphead.py b/gr-blocks/python/qa_skiphead.py new file mode 100755 index 0000000000..50a9bbc639 --- /dev/null +++ b/gr-blocks/python/qa_skiphead.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_skiphead(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + self.src_data = [int(x) for x in range(65536)] + + def tearDown(self): + self.tb = None + + def test_skip_0(self): + skip_cnt = 0 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_1(self): + skip_cnt = 1 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_1023(self): + skip_cnt = 1023 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_6339(self): + skip_cnt = 6339 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_12678(self): + skip_cnt = 12678 + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + def test_skip_all(self): + skip_cnt = len(self.src_data) + expected_result = tuple(self.src_data[skip_cnt:]) + src1 = blocks.vector_source_i(self.src_data) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + + +if __name__ == '__main__': + gr_unittest.run(test_skiphead, "test_skiphead.xml") diff --git a/gr-blocks/python/qa_tag_debug.py b/gr-blocks/python/qa_tag_debug.py new file mode 100755 index 0000000000..ad85daebcc --- /dev/null +++ b/gr-blocks/python/qa_tag_debug.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# +# Copyright 2012-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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +class test_tag_debug(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + # Just run some data through and make sure it doesn't puke. + src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + src = gr.vector_source_i(src_data) + op = blocks.tag_debug(gr.sizeof_int, "tag QA") + self.tb.connect(src, op) + self.tb.run() + x = op.current_tags() + +if __name__ == '__main__': + gr_unittest.run(test_tag_debug, "test_tag_debug.xml") diff --git a/gr-blocks/python/qa_tag_file_sink.py b/gr-blocks/python/qa_tag_file_sink.py new file mode 100644 index 0000000000..80e41a7dd0 --- /dev/null +++ b/gr-blocks/python/qa_tag_file_sink.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import os, struct + +class test_tag_file_sink(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10) + trg_data = (-1, -1, 1, 1, -1, -1, 1, 1, -1, -1) + src = gr.vector_source_i(src_data) + trg = gr.vector_source_s(trg_data) + op = blocks.burst_tagger(gr.sizeof_int) + snk = blocks.tagged_file_sink(gr.sizeof_int, 1) + self.tb.connect(src, (op,0)) + self.tb.connect(trg, (op,1)) + self.tb.connect(op, snk) + self.tb.run() + + # Tagged file sink gets 2 burst tags at index 2 and index 5. + # Creates two new files, each with two integers in them from + # src_data at these indexes (3,4) and (7,8). + file0 = "file{0}_0_2.00000000.dat".format(snk.unique_id()) + file1 = "file{0}_1_6.00000000.dat".format(snk.unique_id()) + + # Open the files and read in the data, then remove the files + # to clean up the directory. + outfile0 = file(file0, 'rb') + outfile1 = file(file1, 'rb') + data0 = outfile0.read(8) + data1 = outfile1.read(8) + outfile0.close() + outfile1.close() + os.remove(file0) + os.remove(file1) + + # Convert the 8 bytes from the files into a tuple of 2 ints. + idata0 = struct.unpack('ii', data0) + idata1 = struct.unpack('ii', data1) + + self.assertEqual(idata0, (3, 4)) + self.assertEqual(idata1, (7, 8)) + +if __name__ == '__main__': + gr_unittest.run(test_tag_file_sink, "test_tag_file_sink.xml") diff --git a/gr-blocks/python/qa_tag_gate.py b/gr-blocks/python/qa_tag_gate.py new file mode 100755 index 0000000000..fa3c501fb4 --- /dev/null +++ b/gr-blocks/python/qa_tag_gate.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import pmt +import blocks_swig as blocks + + +class qa_tag_gate (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_t (self): + tag = gr.gr_tag_t() + tag.key = pmt.pmt_string_to_symbol('key') + tag.value = pmt.pmt_from_long(42) + tag.offset = 0 + src = blocks.vector_source_f(range(20), False, 1, (tag,)) + gate = blocks.tag_gate(gr.sizeof_float, False) + sink = blocks.vector_sink_f() + self.tb.run () + self.assertEqual(len(sink.tags()), 0) + +if __name__ == '__main__': + gr_unittest.run(qa_tag_gate, "qa_tag_gate.xml") + diff --git a/gr-blocks/python/qa_tagged_stream_mux.py b/gr-blocks/python/qa_tagged_stream_mux.py new file mode 100755 index 0000000000..ac0731756b --- /dev/null +++ b/gr-blocks/python/qa_tagged_stream_mux.py @@ -0,0 +1,111 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import pmt +import blocks_swig as blocks +import numpy + +def make_len_tags(tupl, key): + tags = [] + tag = gr.gr_tag_t() + tag.key = pmt.pmt_string_to_symbol(key) + n_read = 0 + for element in tupl: + tag.offset = n_read + n_read += len(element) + tag.value = pmt.to_pmt(len(element)) + tags.append(tag) + return tags + +def make_len_tag(offset, key, value): + tag = gr.gr_tag_t() + tag.offset = offset + tag.key = pmt.pmt_string_to_symbol(key) + tag.value = pmt.to_pmt(value) + return tag + + +class qa_tagged_stream_mux (gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_1(self): + datas = ( + 0, 1, 2, 5, 6, 10, 14, 15, 16, + 3, 4, 7, 8, 9, 11, 12, 13, 17 + ) + expected = tuple(range(18)) + + tagname = "packet_length" + len_tags_0 = ( + make_len_tag(0, tagname, 3), + make_len_tag(3, tagname, 2), + make_len_tag(5, tagname, 1), + make_len_tag(6, tagname, 3) + ) + len_tags_1 = ( + make_len_tag(0, tagname, 2), + make_len_tag(2, tagname, 3), + make_len_tag(5, tagname, 3), + make_len_tag(8, tagname, 1) + ) + test_tag_0 = gr.gr_tag_t() + test_tag_0.key = pmt.pmt_string_to_symbol('spam') + test_tag_0.offset = 4 # On the second '1' + test_tag_0.value = pmt.to_pmt(42) + test_tag_1 = gr.gr_tag_t() + test_tag_1.key = pmt.pmt_string_to_symbol('eggs') + test_tag_1.offset = 3 # On the first '3' of the 2nd stream + test_tag_1.value = pmt.to_pmt(23) + + src0 = gr.vector_source_b(datas[0:9], False, 1, len_tags_0 + (test_tag_0,)) + src1 = gr.vector_source_b(datas[9:], False, 1, len_tags_1 + (test_tag_1,)) + tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_char, tagname) + snk = gr.vector_sink_b() + self.tb.connect(src0, (tagged_stream_mux, 0)) + self.tb.connect(src1, (tagged_stream_mux, 1)) + self.tb.connect(tagged_stream_mux, snk) + self.tb.run() + + self.assertEqual(expected, snk.data()) + + tags = [gr.tag_to_python(x) for x in snk.tags()] + tags = sorted([(x.offset, x.key, x.value) for x in tags]) + tags_expected = [ + (0, 'packet_length', 5), + (5, 'packet_length', 5), + (6, 'spam', 42), + (8, 'eggs', 23), + (10, 'packet_length', 4), + (14, 'packet_length', 4) + ] + self.assertEqual(tags, tags_expected) + + +if __name__ == '__main__': + gr_unittest.run(qa_tagged_stream_mux, "qa_tagged_stream_mux.xml") + diff --git a/gr-blocks/python/qa_udp_source_sink.py b/gr-blocks/python/qa_udp_source_sink.py new file mode 100644 index 0000000000..4ab1430b09 --- /dev/null +++ b/gr-blocks/python/qa_udp_source_sink.py @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# +# Copyright 2008,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import os + +from threading import Timer + +class test_udp_sink_source(gr_unittest.TestCase): + + def setUp(self): + self.tb_snd = gr.top_block() + self.tb_rcv = gr.top_block() + + def tearDown(self): + self.tb_rcv = None + self.tb_snd = None + + def test_001(self): + # Tests calling disconnect/reconnect. + + port = 65500 + + n_data = 16 + src_data = [x for x in range(n_data)] + expected_result = tuple(src_data) + src = gr.vector_source_s(src_data, False) + udp_snd = blocks.udp_sink(gr.sizeof_short, 'localhost', port) + self.tb_snd.connect(src, udp_snd) + + self.tb_snd.run() + udp_snd.disconnect() + + udp_snd.connect('localhost', port+1) + src.rewind() + self.tb_snd.run() + + def test_002(self): + port = 65500 + + n_data = 100 + src_data = [float(x) for x in range(n_data)] + expected_result = tuple(src_data) + src = gr.vector_source_f(src_data, False) + udp_snd = blocks.udp_sink(gr.sizeof_float, 'localhost', port) + self.tb_snd.connect(src, udp_snd) + + udp_rcv = blocks.udp_source(gr.sizeof_float, 'localhost', port) + dst = gr.vector_sink_f() + self.tb_rcv.connect(udp_rcv, dst) + + self.tb_rcv.start() + self.tb_snd.run() + udp_snd.disconnect() + self.timeout = False + q = Timer(2.0,self.stop_rcv) + q.start() + self.tb_rcv.wait() + q.cancel() + + result_data = dst.data() + self.assertEqual(expected_result, result_data) + self.assert_(not self.timeout) + + def test_003(self): + udp_rcv = blocks.udp_source(gr.sizeof_float, '0.0.0.0', 0, eof=False) + rcv_port = udp_rcv.get_port() + + udp_snd = blocks.udp_sink(gr.sizeof_float, '127.0.0.1', 65500) + udp_snd.connect('localhost', rcv_port) + + n_data = 16 + src_data = [float(x) for x in range(n_data)] + expected_result = tuple(src_data) + src = gr.vector_source_f(src_data) + dst = gr.vector_sink_f() + + self.tb_snd.connect(src, udp_snd) + self.tb_rcv.connect(udp_rcv, dst) + + self.tb_rcv.start() + self.tb_snd.run() + udp_snd.disconnect() + self.timeout = False + q = Timer(2.0,self.stop_rcv) + q.start() + self.tb_rcv.wait() + q.cancel() + + result_data = dst.data() + self.assertEqual(expected_result, result_data) + self.assert_(self.timeout) # source ignores EOF? + + def stop_rcv(self): + self.timeout = True + self.tb_rcv.stop() + #print "tb_rcv stopped by Timer" + +if __name__ == '__main__': + gr_unittest.run(test_udp_sink_source, "test_udp_sink_source.xml") + diff --git a/gr-blocks/python/qa_unpack_k_bits.py b/gr-blocks/python/qa_unpack_k_bits.py new file mode 100755 index 0000000000..e038d5a03a --- /dev/null +++ b/gr-blocks/python/qa_unpack_k_bits.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python +# +# Copyright 2006,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import random + +class test_unpack(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block () + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = (1,0,1,1,0,1,1,0) + expected_results = (1,0,1,1,0,1,1,0) + src = gr.vector_source_b(src_data,False) + op = blocks.unpack_k_bits_bb(1) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertEqual(expected_results, dst.data()) + + def test_002(self): + src_data = ( 2, 3, 0, 1) + expected_results = (1,0,1,1,0,0,0,1) + src = gr.vector_source_b(src_data,False) + op = blocks.unpack_k_bits_bb(2) + dst = gr.vector_sink_b() + self.tb.connect(src, op, dst) + self.tb.run() + self.assertEqual(expected_results, dst.data()) + +if __name__ == '__main__': + gr_unittest.run(test_unpack, "test_unpack.xml") + diff --git a/gr-blocks/python/qa_vco.py b/gr-blocks/python/qa_vco.py new file mode 100644 index 0000000000..721eb9471b --- /dev/null +++ b/gr-blocks/python/qa_vco.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# 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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig +import math + +def sig_source_f(samp_rate, freq, amp, N): + t = map(lambda x: float(x)/samp_rate, xrange(N)) + y = map(lambda x: amp*math.cos(2.*math.pi*freq*x), t) + return y + +class test_vco(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001(self): + src_data = 200*[0,] + 200*[0.5,] + 200*[1,] + expected_result = 200*[1,] + \ + sig_source_f(1, 0.125, 1, 200) + \ + sig_source_f(1, 0.25, 1, 200) + + src = gr.vector_source_f(src_data) + op = blocks_swig.vco_f(1, math.pi/2.0, 1) + dst = gr.vector_sink_f() + + self.tb.connect(src, op, dst) + self.tb.run() + + result_data = dst.data() + self.assertFloatTuplesAlmostEqual(expected_result, result_data, 5) + + +if __name__ == '__main__': + gr_unittest.run(test_vco, "test_vco.xml") + diff --git a/gr-blocks/python/qa_vector_insert.py b/gr-blocks/python/qa_vector_insert.py new file mode 100755 index 0000000000..428a0031ba --- /dev/null +++ b/gr-blocks/python/qa_vector_insert.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python +# +# Copyright 2012-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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math + +class test_vector_insert(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + + period = 9177; + offset = 0; + + src = gr.null_source(1) + head = gr.head(1, 10000000); + ins = blocks.vector_insert_b([1], period, offset); + dst = blocks.vector_sink_b() + + self.tb.connect(src, head, ins, dst) + self.tb.run() + result_data = dst.data() + + for i in range(10000): + if(i%period == offset): + self.assertEqual(1, result_data[i]) + else: + self.assertEqual(0, result_data[i]) + +if __name__ == '__main__': + gr_unittest.run(test_vector_insert, "test_vector_insert.xml") + diff --git a/gr-blocks/python/qa_vector_map.py b/gr-blocks/python/qa_vector_map.py new file mode 100644 index 0000000000..54565fe443 --- /dev/null +++ b/gr-blocks/python/qa_vector_map.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python +# +# Copyright 2012,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math + +class test_vector_map(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_reversing(self): + # Chunk data in blocks of N and reverse the block contents. + N = 5 + src_data = range(0, 20) + expected_result = [] + for i in range(N-1, len(src_data), N): + for j in range(0, N): + expected_result.append(1.0*(i-j)) + mapping = [list(reversed([(0, i) for i in range(0, N)]))] + src = blocks.vector_source_f(src_data, False, N) + vmap = blocks.vector_map(gr.sizeof_float, (N, ), mapping) + dst = blocks.vector_sink_f(N) + self.tb.connect(src, vmap, dst) + self.tb.run() + result_data = list(dst.data()) + self.assertEqual(expected_result, result_data) + + def test_vector_to_streams(self): + # Split an input vector into N streams. + N = 5 + M = 20 + src_data = range(0, M) + expected_results = [] + for n in range(0, N): + expected_results.append(range(n, M, N)) + mapping = [[(0, n)] for n in range(0, N)] + src = blocks.vector_source_f(src_data, False, N) + vmap = blocks.vector_map(gr.sizeof_float, (N, ), mapping) + dsts = [blocks.vector_sink_f(1) for n in range(0, N)] + self.tb.connect(src, vmap) + for n in range(0, N): + self.tb.connect((vmap, n), dsts[n]) + self.tb.run() + for n in range(0, N): + result_data = list(dsts[n].data()) + self.assertEqual(expected_results[n], result_data) + + def test_interleaving(self): + # Takes 3 streams (a, b and c) + # Outputs 2 streams. + # First (d) is interleaving of a and b. + # Second (e) is interleaving of a and b and c. c is taken in + # chunks of 2 which are reversed. + A = (1, 2, 3, 4, 5) + B = (11, 12, 13, 14, 15) + C = (99, 98, 97, 96, 95, 94, 93, 92, 91, 90) + expected_D = (1, 11, 2, 12, 3, 13, 4, 14, 5, 15) + expected_E = (1, 11, 98, 99, 2, 12, 96, 97, 3, 13, 94, 95, + 4, 14, 92, 93, 5, 15, 90, 91) + mapping = [[(0, 0), (1, 0)], # mapping to produce D + [(0, 0), (1, 0), (2, 1), (2, 0)], # mapping to produce E + ] + srcA = blocks.vector_source_f(A, False, 1) + srcB = blocks.vector_source_f(B, False, 1) + srcC = blocks.vector_source_f(C, False, 2) + vmap = blocks.vector_map(gr.sizeof_int, (1, 1, 2), mapping) + dstD = blocks.vector_sink_f(2) + dstE = blocks.vector_sink_f(4) + self.tb.connect(srcA, (vmap, 0)) + self.tb.connect(srcB, (vmap, 1)) + self.tb.connect(srcC, (vmap, 2)) + self.tb.connect((vmap, 0), dstD) + self.tb.connect((vmap, 1), dstE) + self.tb.run() + self.assertEqual(expected_D, dstD.data()) + self.assertEqual(expected_E, dstE.data()) + +if __name__ == '__main__': + gr_unittest.run(test_vector_map, "test_vector_map.xml") + diff --git a/gr-blocks/python/qa_vector_sink_source.py b/gr-blocks/python/qa_vector_sink_source.py new file mode 100755 index 0000000000..169e6a4450 --- /dev/null +++ b/gr-blocks/python/qa_vector_sink_source.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# +# Copyright 2008,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import math + +class test_vector_sink_source(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001(self): + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + + src = blocks.vector_source_f(src_data) + dst = blocks.vector_sink_f() + + self.tb.connect(src, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def test_002(self): + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + + src = blocks.vector_source_f(src_data, False, 2) + dst = blocks.vector_sink_f(2) + + self.tb.connect(src, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def test_003(self): + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + self.assertRaises(RuntimeError, lambda : blocks.vector_source_f(src_data, False, 3)) + +if __name__ == '__main__': + gr_unittest.run(test_vector_sink_source, "test_vector_sink_source.xml") + diff --git a/gr-blocks/python/qa_wavfile.py b/gr-blocks/python/qa_wavfile.py new file mode 100755 index 0000000000..b40b9b7ec3 --- /dev/null +++ b/gr-blocks/python/qa_wavfile.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# Copyright 2008,2010,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. +# + +from gnuradio import gr, gr_unittest +import blocks_swig as blocks + +import os +from os.path import getsize + +g_in_file = os.path.join(os.getenv("srcdir"), "test_16bit_1chunk.wav") + +class test_wavefile(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001_checkwavread(self): + wf = blocks.wavfile_source(g_in_file) + self.assertEqual(wf.sample_rate(), 8000) + + def test_002_checkwavcopy(self): + infile = g_in_file + outfile = "test_out.wav" + + wf_in = blocks.wavfile_source(infile) + wf_out = blocks.wavfile_sink(outfile, + wf_in.channels(), + wf_in.sample_rate(), + wf_in.bits_per_sample()) + self.tb.connect(wf_in, wf_out) + self.tb.run() + wf_out.close() + + self.assertEqual(getsize(infile), getsize(outfile)) + + in_f = file(infile, 'rb') + out_f = file(outfile, 'rb') + + in_data = in_f.read() + out_data = out_f.read() + out_f.close() + os.remove(outfile) + + self.assertEqual(in_data, out_data) + +if __name__ == '__main__': + gr_unittest.run(test_wavefile, "test_wavefile.xml") diff --git a/gr-blocks/python/test_16bit_1chunk.wav b/gr-blocks/python/test_16bit_1chunk.wav Binary files differnew file mode 100644 index 0000000000..0fe12a7a13 --- /dev/null +++ b/gr-blocks/python/test_16bit_1chunk.wav diff --git a/gr-blocks/swig/CMakeLists.txt b/gr-blocks/swig/CMakeLists.txt index 84ab5b660f..64fca9fe3c 100644 --- a/gr-blocks/swig/CMakeLists.txt +++ b/gr-blocks/swig/CMakeLists.txt @@ -31,23 +31,51 @@ set(GR_SWIG_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ) -set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/blocks_swig_doc.i) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/blocks_swig.py.in + ${CMAKE_CURRENT_BINARY_DIR}/blocks_swig.py +@ONLY) + set(GR_SWIG_DOC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/../lib) set(GR_SWIG_TARGET_DEPS blocks_generated_includes) set(GR_SWIG_LIBRARIES gnuradio-blocks) -GR_SWIG_MAKE(blocks_swig blocks_swig.i) +# We split up the swig files into multiple sections to minimize the +# memory overhead. If a .i file grows too large, create a new file +# named 'blocks_swigN.i' and add it to this list. +# +# Also add the line "from swig_blocksN import *" line to +# blocks_swig.py.in. +set(GR_SWIG_BLOCK_IFILES + blocks_swig0 + blocks_swig1 + blocks_swig2 +) + +foreach(swigfile ${GR_SWIG_BLOCK_IFILES}) + set(GR_SWIG_DOC_FILE ${CMAKE_CURRENT_BINARY_DIR}/${swigfile}_doc.i) + GR_SWIG_MAKE(${swigfile} ${swigfile}.i) -GR_SWIG_INSTALL( - TARGETS blocks_swig + GR_SWIG_INSTALL( + TARGETS ${swigfile} DESTINATION ${GR_PYTHON_DIR}/gnuradio/blocks - COMPONENT "blocks_python" -) + COMPONENT "blocks_python") + + list(APPEND SWIGFILES ${swigfile}.i) + list(APPEND SWIGDOCFILES ${CMAKE_CURRENT_BINARY_DIR}/${swigfile}_doc.i) +endforeach(swigfile) install( FILES - blocks_swig.i - ${CMAKE_CURRENT_BINARY_DIR}/blocks_swig_doc.i + ${SWIGFILES} + ${SWIGDOCFILES} DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig COMPONENT "blocks_swig" ) + +# Install the Python file that pulls in the swig built files. +GR_PYTHON_INSTALL( + FILES ${CMAKE_CURRENT_BINARY_DIR}/blocks_swig.py + DESTINATION ${GR_PYTHON_DIR}/gnuradio/blocks + COMPONENT "blocks_python" +) diff --git a/gr-blocks/swig/blocks_swig.py.in b/gr-blocks/swig/blocks_swig.py.in new file mode 100644 index 0000000000..287413b594 --- /dev/null +++ b/gr-blocks/swig/blocks_swig.py.in @@ -0,0 +1,24 @@ +# +# 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. +# + +from blocks_swig0 import * +from blocks_swig1 import * +from blocks_swig2 import * diff --git a/gr-blocks/swig/blocks_swig0.i b/gr-blocks/swig/blocks_swig0.i new file mode 100644 index 0000000000..912adcfd0c --- /dev/null +++ b/gr-blocks/swig/blocks_swig0.i @@ -0,0 +1,181 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#define BLOCKS_API + +%include "gnuradio.i" + +%include "blocks_swig0_doc.i" + +%template() std::vector<size_t>; +%template() std::vector< std::vector< std::vector<size_t> > >; + +%{ +#include "blocks/copy.h" +#include "blocks/delay.h" +#include "blocks/endian_swap.h" +#include "blocks/file_descriptor_sink.h" +#include "blocks/file_descriptor_source.h" +#include "blocks/file_sink_base.h" +#include "blocks/file_sink.h" +#include "blocks/file_source.h" +#include "blocks/file_meta_sink.h" +#include "blocks/file_meta_source.h" +#include "blocks/head.h" +#include "blocks/message_debug.h" +#include "blocks/message_sink.h" +#include "blocks/message_source.h" +#include "blocks/message_strobe.h" +#include "blocks/message_burst_source.h" +#include "blocks/nop.h" +#include "blocks/null_sink.h" +#include "blocks/null_source.h" +#include "blocks/skiphead.h" +#include "blocks/stream_mux.h" +#include "blocks/stream_to_streams.h" +#include "blocks/stream_to_vector.h" +#include "blocks/streams_to_stream.h" +#include "blocks/streams_to_vector.h" +#include "blocks/tag_debug.h" +#include "blocks/tag_gate.h" +#include "blocks/tagged_file_sink.h" +#include "blocks/throttle.h" +#include "blocks/vector_map.h" +#include "blocks/vector_to_stream.h" +#include "blocks/vector_to_streams.h" +#include "blocks/vector_insert_b.h" +#include "blocks/vector_insert_s.h" +#include "blocks/vector_insert_i.h" +#include "blocks/vector_insert_f.h" +#include "blocks/vector_insert_c.h" +#include "blocks/vector_sink_b.h" +#include "blocks/vector_sink_s.h" +#include "blocks/vector_sink_i.h" +#include "blocks/vector_sink_f.h" +#include "blocks/vector_sink_c.h" +#include "blocks/vector_source_b.h" +#include "blocks/vector_source_s.h" +#include "blocks/vector_source_i.h" +#include "blocks/vector_source_f.h" +#include "blocks/vector_source_c.h" +#include "blocks/wavfile_sink.h" +#include "blocks/wavfile_source.h" +%} + +%include "blocks/copy.h" +%include "blocks/delay.h" +%include "blocks/endian_swap.h" +%include "blocks/file_descriptor_sink.h" +%include "blocks/file_descriptor_source.h" +%include "blocks/file_sink_base.h" +%include "blocks/file_sink.h" +%include "blocks/file_source.h" +%include "blocks/file_meta_sink.h" +%include "blocks/file_meta_source.h" +%include "blocks/head.h" +%include "blocks/message_debug.h" +%include "blocks/message_sink.h" +%include "blocks/message_source.h" +%include "blocks/message_strobe.h" +%include "blocks/message_burst_source.h" +%include "blocks/nop.h" +%include "blocks/null_sink.h" +%include "blocks/null_source.h" +%include "blocks/skiphead.h" +%include "blocks/stream_mux.h" +%include "blocks/stream_to_streams.h" +%include "blocks/stream_to_vector.h" +%include "blocks/streams_to_stream.h" +%include "blocks/streams_to_vector.h" +%include "blocks/tag_debug.h" +%include "blocks/tag_gate.h" +%include "blocks/tagged_file_sink.h" +%include "blocks/throttle.h" +%include "blocks/vector_map.h" +%include "blocks/vector_to_stream.h" +%include "blocks/vector_to_streams.h" +%include "blocks/vector_insert_b.h" +%include "blocks/vector_insert_s.h" +%include "blocks/vector_insert_i.h" +%include "blocks/vector_insert_f.h" +%include "blocks/vector_insert_c.h" +%include "blocks/vector_sink_b.h" +%include "blocks/vector_sink_s.h" +%include "blocks/vector_sink_i.h" +%include "blocks/vector_sink_f.h" +%include "blocks/vector_sink_c.h" +%include "blocks/vector_source_b.h" +%include "blocks/vector_source_s.h" +%include "blocks/vector_source_i.h" +%include "blocks/vector_source_f.h" +%include "blocks/vector_source_c.h" +%include "blocks/wavfile_sink.h" +%include "blocks/wavfile_source.h" + +GR_SWIG_BLOCK_MAGIC2(blocks, copy); +GR_SWIG_BLOCK_MAGIC2(blocks, delay); +GR_SWIG_BLOCK_MAGIC2(blocks, endian_swap); +GR_SWIG_BLOCK_MAGIC2(blocks, file_descriptor_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, file_descriptor_source); +GR_SWIG_BLOCK_MAGIC2(blocks, file_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, file_source); +GR_SWIG_BLOCK_MAGIC2(blocks, file_meta_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, file_meta_source); +GR_SWIG_BLOCK_MAGIC2(blocks, head); +GR_SWIG_BLOCK_MAGIC2(blocks, message_debug); +GR_SWIG_BLOCK_MAGIC2(blocks, message_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, message_source); +GR_SWIG_BLOCK_MAGIC2(blocks, message_strobe); +GR_SWIG_BLOCK_MAGIC2(blocks, message_burst_source); +GR_SWIG_BLOCK_MAGIC2(blocks, nop); +GR_SWIG_BLOCK_MAGIC2(blocks, null_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, null_source); +GR_SWIG_BLOCK_MAGIC2(blocks, skiphead); +GR_SWIG_BLOCK_MAGIC2(blocks, stream_mux); +GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_streams); +GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_vector); +GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_stream); +GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_vector); +GR_SWIG_BLOCK_MAGIC2(blocks, tag_debug); +GR_SWIG_BLOCK_MAGIC2(blocks, tag_gate); +GR_SWIG_BLOCK_MAGIC2(blocks, tagged_file_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, throttle); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_map); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_stream); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_streams); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_b); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_s); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_i); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_f); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_insert_c); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_b); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_s); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_i); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_f); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_sink_c); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_b); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_s); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_i); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_f); +GR_SWIG_BLOCK_MAGIC2(blocks, vector_source_c); +GR_SWIG_BLOCK_MAGIC2(blocks, wavfile_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, wavfile_source); diff --git a/gr-blocks/swig/blocks_swig.i b/gr-blocks/swig/blocks_swig1.i index db8af34368..09fa6c5b42 100644 --- a/gr-blocks/swig/blocks_swig.i +++ b/gr-blocks/swig/blocks_swig1.i @@ -25,9 +25,7 @@ %include "gnuradio.i" //load generated python docstrings -%include "blocks_swig_doc.i" - -%include <gr_endianness.h> +%include "blocks_swig1_doc.i" %{ #include "blocks/add_ff.h" @@ -48,8 +46,14 @@ #include "blocks/and_const_bb.h" #include "blocks/and_const_ss.h" #include "blocks/and_const_ii.h" +#include "blocks/argmax_fs.h" +#include "blocks/argmax_is.h" +#include "blocks/argmax_ss.h" +#include "blocks/bin_statistics_f.h" +#include "blocks/burst_tagger.h" #include "blocks/char_to_float.h" #include "blocks/char_to_short.h" +#include "blocks/check_lfsr_32k_s.h" #include "blocks/complex_to_interleaved_short.h" #include "blocks/complex_to_float.h" #include "blocks/complex_to_real.h" @@ -59,14 +63,10 @@ #include "blocks/complex_to_arg.h" #include "blocks/conjugate_cc.h" #include "blocks/deinterleave.h" -#include "blocks/delay.h" #include "blocks/divide_ff.h" #include "blocks/divide_ss.h" #include "blocks/divide_ii.h" #include "blocks/divide_cc.h" -#include "blocks/file_source.h" -#include "blocks/file_meta_sink.h" -#include "blocks/file_meta_source.h" #include "blocks/float_to_char.h" #include "blocks/float_to_complex.h" #include "blocks/float_to_int.h" @@ -81,6 +81,14 @@ #include "blocks/interleaved_short_to_complex.h" #include "blocks/keep_m_in_n.h" #include "blocks/keep_one_in_n.h" +#include "blocks/lfsr_32k_source_s.h" +#include "blocks/max_ff.h" +#include "blocks/max_ii.h" +#include "blocks/max_ss.h" +#include "blocks/moving_average_cc.h" +#include "blocks/moving_average_ff.h" +#include "blocks/moving_average_ii.h" +#include "blocks/moving_average_ss.h" #include "blocks/multiply_ss.h" #include "blocks/multiply_ii.h" #include "blocks/multiply_ff.h" @@ -94,46 +102,10 @@ #include "blocks/multiply_const_vii.h" #include "blocks/multiply_const_vff.h" #include "blocks/multiply_const_vcc.h" -#include "blocks/nlog10_ff.h" -#include "blocks/not_bb.h" -#include "blocks/not_ss.h" -#include "blocks/not_ii.h" -#include "blocks/patterned_interleaver.h" -#include "blocks/packed_to_unpacked_bb.h" -#include "blocks/packed_to_unpacked_ss.h" -#include "blocks/packed_to_unpacked_ii.h" -#include "blocks/peak_detector2_fb.h" -#include "blocks/or_bb.h" -#include "blocks/or_ss.h" -#include "blocks/or_ii.h" -#include "blocks/regenerate_bb.h" -#include "blocks/repeat.h" -#include "blocks/rms_cf.h" -#include "blocks/rms_ff.h" -#include "blocks/short_to_char.h" -#include "blocks/short_to_float.h" -#include "blocks/stream_mux.h" -#include "blocks/stream_to_streams.h" -#include "blocks/stream_to_vector.h" -#include "blocks/streams_to_stream.h" -#include "blocks/streams_to_vector.h" -#include "blocks/stretch_ff.h" -#include "blocks/sub_ff.h" -#include "blocks/sub_ss.h" -#include "blocks/sub_ii.h" -#include "blocks/sub_cc.h" -#include "blocks/threshold_ff.h" -#include "blocks/throttle.h" -#include "blocks/transcendental.h" -#include "blocks/uchar_to_float.h" -#include "blocks/unpacked_to_packed_bb.h" -#include "blocks/unpacked_to_packed_ss.h" -#include "blocks/unpacked_to_packed_ii.h" -#include "blocks/vector_to_stream.h" -#include "blocks/vector_to_streams.h" -#include "blocks/xor_bb.h" -#include "blocks/xor_ss.h" -#include "blocks/xor_ii.h" +#include "blocks/mute_ss.h" +#include "blocks/mute_ii.h" +#include "blocks/mute_ff.h" +#include "blocks/mute_cc.h" %} %include "blocks/add_ff.h" @@ -154,8 +126,14 @@ %include "blocks/and_const_bb.h" %include "blocks/and_const_ss.h" %include "blocks/and_const_ii.h" +%include "blocks/argmax_fs.h" +%include "blocks/argmax_is.h" +%include "blocks/argmax_ss.h" %include "blocks/char_to_float.h" +%include "blocks/bin_statistics_f.h" +%include "blocks/burst_tagger.h" %include "blocks/char_to_short.h" +%include "blocks/check_lfsr_32k_s.h" %include "blocks/complex_to_interleaved_short.h" %include "blocks/complex_to_float.h" %include "blocks/complex_to_real.h" @@ -165,10 +143,6 @@ %include "blocks/complex_to_arg.h" %include "blocks/conjugate_cc.h" %include "blocks/deinterleave.h" -%include "blocks/delay.h" -%include "blocks/file_source.h" -%include "blocks/file_meta_sink.h" -%include "blocks/file_meta_source.h" %include "blocks/divide_ff.h" %include "blocks/divide_ss.h" %include "blocks/divide_ii.h" @@ -187,6 +161,14 @@ %include "blocks/interleaved_short_to_complex.h" %include "blocks/keep_m_in_n.h" %include "blocks/keep_one_in_n.h" +%include "blocks/lfsr_32k_source_s.h" +%include "blocks/max_ff.h" +%include "blocks/max_ii.h" +%include "blocks/max_ss.h" +%include "blocks/moving_average_cc.h" +%include "blocks/moving_average_ff.h" +%include "blocks/moving_average_ii.h" +%include "blocks/moving_average_ss.h" %include "blocks/multiply_ss.h" %include "blocks/multiply_ii.h" %include "blocks/multiply_ff.h" @@ -200,46 +182,10 @@ %include "blocks/multiply_const_vii.h" %include "blocks/multiply_const_vff.h" %include "blocks/multiply_const_vcc.h" -%include "blocks/nlog10_ff.h" -%include "blocks/not_bb.h" -%include "blocks/not_ss.h" -%include "blocks/not_ii.h" -%include "blocks/patterned_interleaver.h" -%include "blocks/packed_to_unpacked_bb.h" -%include "blocks/packed_to_unpacked_ss.h" -%include "blocks/packed_to_unpacked_ii.h" -%include "blocks/peak_detector2_fb.h" -%include "blocks/or_bb.h" -%include "blocks/or_ss.h" -%include "blocks/or_ii.h" -%include "blocks/regenerate_bb.h" -%include "blocks/repeat.h" -%include "blocks/rms_cf.h" -%include "blocks/rms_ff.h" -%include "blocks/short_to_char.h" -%include "blocks/short_to_float.h" -%include "blocks/stream_mux.h" -%include "blocks/stream_to_streams.h" -%include "blocks/stream_to_vector.h" -%include "blocks/streams_to_stream.h" -%include "blocks/streams_to_vector.h" -%include "blocks/stretch_ff.h" -%include "blocks/sub_ff.h" -%include "blocks/sub_ss.h" -%include "blocks/sub_ii.h" -%include "blocks/sub_cc.h" -%include "blocks/threshold_ff.h" -%include "blocks/throttle.h" -%include "blocks/transcendental.h" -%include "blocks/uchar_to_float.h" -%include "blocks/unpacked_to_packed_bb.h" -%include "blocks/unpacked_to_packed_ss.h" -%include "blocks/unpacked_to_packed_ii.h" -%include "blocks/vector_to_stream.h" -%include "blocks/vector_to_streams.h" -%include "blocks/xor_bb.h" -%include "blocks/xor_ss.h" -%include "blocks/xor_ii.h" +%include "blocks/mute_ss.h" +%include "blocks/mute_ii.h" +%include "blocks/mute_ff.h" +%include "blocks/mute_cc.h" GR_SWIG_BLOCK_MAGIC2(blocks, add_ff); GR_SWIG_BLOCK_MAGIC2(blocks, add_ss); @@ -259,8 +205,14 @@ GR_SWIG_BLOCK_MAGIC2(blocks, and_ii); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_bb); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ss); GR_SWIG_BLOCK_MAGIC2(blocks, and_const_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_fs); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_is); +GR_SWIG_BLOCK_MAGIC2(blocks, argmax_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, bin_statistics_f); +GR_SWIG_BLOCK_MAGIC2(blocks, burst_tagger); GR_SWIG_BLOCK_MAGIC2(blocks, char_to_float); GR_SWIG_BLOCK_MAGIC2(blocks, char_to_short); +GR_SWIG_BLOCK_MAGIC2(blocks, check_lfsr_32k_s); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_interleaved_short); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_float); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_real); @@ -270,14 +222,10 @@ GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_mag_squared); GR_SWIG_BLOCK_MAGIC2(blocks, complex_to_arg); GR_SWIG_BLOCK_MAGIC2(blocks, conjugate_cc); GR_SWIG_BLOCK_MAGIC2(blocks, deinterleave); -GR_SWIG_BLOCK_MAGIC2(blocks, delay); GR_SWIG_BLOCK_MAGIC2(blocks, divide_ff); GR_SWIG_BLOCK_MAGIC2(blocks, divide_ss); GR_SWIG_BLOCK_MAGIC2(blocks, divide_ii); GR_SWIG_BLOCK_MAGIC2(blocks, divide_cc); -GR_SWIG_BLOCK_MAGIC2(blocks, file_source); -GR_SWIG_BLOCK_MAGIC2(blocks, file_meta_sink); -GR_SWIG_BLOCK_MAGIC2(blocks, file_meta_source); GR_SWIG_BLOCK_MAGIC2(blocks, float_to_char); GR_SWIG_BLOCK_MAGIC2(blocks, float_to_complex); GR_SWIG_BLOCK_MAGIC2(blocks, float_to_int); @@ -292,6 +240,14 @@ GR_SWIG_BLOCK_MAGIC2(blocks, interleave); GR_SWIG_BLOCK_MAGIC2(blocks, interleaved_short_to_complex); GR_SWIG_BLOCK_MAGIC2(blocks, keep_m_in_n); GR_SWIG_BLOCK_MAGIC2(blocks, keep_one_in_n); +GR_SWIG_BLOCK_MAGIC2(blocks, lfsr_32k_source_s); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, max_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_cc); +GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, moving_average_ss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ii); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_ff); @@ -305,43 +261,7 @@ GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vss); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vii); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vff); GR_SWIG_BLOCK_MAGIC2(blocks, multiply_const_vcc); -GR_SWIG_BLOCK_MAGIC2(blocks, nlog10_ff); -GR_SWIG_BLOCK_MAGIC2(blocks, not_bb); -GR_SWIG_BLOCK_MAGIC2(blocks, not_ss); -GR_SWIG_BLOCK_MAGIC2(blocks, not_ii); -GR_SWIG_BLOCK_MAGIC2(blocks, patterned_interleaver); -GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_bb); -GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_ss); -GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_ii); -GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector2_fb); -GR_SWIG_BLOCK_MAGIC2(blocks, or_bb); -GR_SWIG_BLOCK_MAGIC2(blocks, or_ss); -GR_SWIG_BLOCK_MAGIC2(blocks, or_ii); -GR_SWIG_BLOCK_MAGIC2(blocks, regenerate_bb); -GR_SWIG_BLOCK_MAGIC2(blocks, repeat); -GR_SWIG_BLOCK_MAGIC2(blocks, rms_cf); -GR_SWIG_BLOCK_MAGIC2(blocks, rms_ff); -GR_SWIG_BLOCK_MAGIC2(blocks, short_to_char); -GR_SWIG_BLOCK_MAGIC2(blocks, short_to_float); -GR_SWIG_BLOCK_MAGIC2(blocks, stream_mux); -GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_streams); -GR_SWIG_BLOCK_MAGIC2(blocks, stream_to_vector); -GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_stream); -GR_SWIG_BLOCK_MAGIC2(blocks, streams_to_vector); -GR_SWIG_BLOCK_MAGIC2(blocks, stretch_ff); -GR_SWIG_BLOCK_MAGIC2(blocks, sub_ff); -GR_SWIG_BLOCK_MAGIC2(blocks, sub_ss); -GR_SWIG_BLOCK_MAGIC2(blocks, sub_ii); -GR_SWIG_BLOCK_MAGIC2(blocks, sub_cc); -GR_SWIG_BLOCK_MAGIC2(blocks, threshold_ff); -GR_SWIG_BLOCK_MAGIC2(blocks, throttle); -GR_SWIG_BLOCK_MAGIC2(blocks, transcendental); -GR_SWIG_BLOCK_MAGIC2(blocks, uchar_to_float); -GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_bb); -GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ss); -GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ii); -GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_stream); -GR_SWIG_BLOCK_MAGIC2(blocks, vector_to_streams); -GR_SWIG_BLOCK_MAGIC2(blocks, xor_bb); -GR_SWIG_BLOCK_MAGIC2(blocks, xor_ss); -GR_SWIG_BLOCK_MAGIC2(blocks, xor_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, mute_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, mute_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, mute_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, mute_cc); diff --git a/gr-blocks/swig/blocks_swig2.i b/gr-blocks/swig/blocks_swig2.i new file mode 100644 index 0000000000..0c02ab7f0e --- /dev/null +++ b/gr-blocks/swig/blocks_swig2.i @@ -0,0 +1,222 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012-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. + */ + +#define BLOCKS_API + +%include "gnuradio.i" +%include "blocks/pdu.h" + +%include <gr_endianness.h> + +//load generated python docstrings +%include "blocks_swig1_doc.i" + +%{ +#include "blocks/nlog10_ff.h" +#include "blocks/not_bb.h" +#include "blocks/not_ss.h" +#include "blocks/not_ii.h" +#include "blocks/patterned_interleaver.h" +#include "blocks/pack_k_bits_bb.h" +#include "blocks/packed_to_unpacked_bb.h" +#include "blocks/packed_to_unpacked_ss.h" +#include "blocks/packed_to_unpacked_ii.h" +#include "blocks/pdu_to_tagged_stream.h" +#include "blocks/peak_detector_fb.h" +#include "blocks/peak_detector_ib.h" +#include "blocks/peak_detector_sb.h" +#include "blocks/peak_detector2_fb.h" +#include "blocks/plateau_detector_fb.h" +#include "blocks/probe_rate.h" +#include "blocks/probe_signal_b.h" +#include "blocks/probe_signal_s.h" +#include "blocks/probe_signal_i.h" +#include "blocks/probe_signal_f.h" +#include "blocks/probe_signal_c.h" +#include "blocks/probe_signal_vb.h" +#include "blocks/probe_signal_vs.h" +#include "blocks/probe_signal_vi.h" +#include "blocks/probe_signal_vf.h" +#include "blocks/probe_signal_vc.h" +#include "blocks/or_bb.h" +#include "blocks/or_ss.h" +#include "blocks/or_ii.h" +#include "blocks/regenerate_bb.h" +#include "blocks/repack_bits_bb.h" +#include "blocks/repeat.h" +#include "blocks/rms_cf.h" +#include "blocks/rms_ff.h" +#include "blocks/sample_and_hold_bb.h" +#include "blocks/sample_and_hold_ss.h" +#include "blocks/sample_and_hold_ii.h" +#include "blocks/sample_and_hold_ff.h" +#include "blocks/short_to_char.h" +#include "blocks/short_to_float.h" +#include "blocks/socket_pdu.h" +#include "blocks/stretch_ff.h" +#include "blocks/sub_ff.h" +#include "blocks/sub_ss.h" +#include "blocks/sub_ii.h" +#include "blocks/sub_cc.h" +#include "blocks/tagged_stream_mux.h" +#include "blocks/tagged_stream_to_pdu.h" +#include "blocks/threshold_ff.h" +#include "blocks/transcendental.h" +#include "blocks/tuntap_pdu.h" +#include "blocks/uchar_to_float.h" +#include "blocks/udp_sink.h" +#include "blocks/udp_source.h" +#include "blocks/unpack_k_bits_bb.h" +#include "blocks/unpacked_to_packed_bb.h" +#include "blocks/unpacked_to_packed_ss.h" +#include "blocks/unpacked_to_packed_ii.h" +#include "blocks/vco_f.h" +#include "blocks/xor_bb.h" +#include "blocks/xor_ss.h" +#include "blocks/xor_ii.h" +%} + +%include "blocks/nlog10_ff.h" +%include "blocks/not_bb.h" +%include "blocks/not_ss.h" +%include "blocks/not_ii.h" +%include "blocks/probe_signal_b.h" +%include "blocks/probe_signal_s.h" +%include "blocks/probe_signal_i.h" +%include "blocks/probe_signal_f.h" +%include "blocks/probe_signal_c.h" +%include "blocks/probe_signal_vb.h" +%include "blocks/probe_signal_vs.h" +%include "blocks/probe_signal_vi.h" +%include "blocks/probe_signal_vf.h" +%include "blocks/probe_signal_vc.h" +%include "blocks/or_bb.h" +%include "blocks/or_ss.h" +%include "blocks/or_ii.h" +%include "blocks/pack_k_bits_bb.h" +%include "blocks/packed_to_unpacked_bb.h" +%include "blocks/packed_to_unpacked_ss.h" +%include "blocks/packed_to_unpacked_ii.h" +%include "blocks/patterned_interleaver.h" +%include "blocks/pdu_to_tagged_stream.h" +%include "blocks/peak_detector_fb.h" +%include "blocks/peak_detector_ib.h" +%include "blocks/peak_detector_sb.h" +%include "blocks/peak_detector2_fb.h" +%include "blocks/plateau_detector_fb.h" +%include "blocks/probe_rate.h" +%include "blocks/regenerate_bb.h" +%include "blocks/repack_bits_bb.h" +%include "blocks/repeat.h" +%include "blocks/rms_cf.h" +%include "blocks/rms_ff.h" +%include "blocks/sample_and_hold_bb.h" +%include "blocks/sample_and_hold_ss.h" +%include "blocks/sample_and_hold_ii.h" +%include "blocks/sample_and_hold_ff.h" +%include "blocks/short_to_char.h" +%include "blocks/short_to_float.h" +%include "blocks/socket_pdu.h" +%include "blocks/stretch_ff.h" +%include "blocks/sub_ff.h" +%include "blocks/sub_ss.h" +%include "blocks/sub_ii.h" +%include "blocks/sub_cc.h" +%include "blocks/tagged_stream_mux.h" +%include "blocks/tagged_stream_to_pdu.h" +%include "blocks/threshold_ff.h" +%include "blocks/transcendental.h" +%include "blocks/tuntap_pdu.h" +%include "blocks/uchar_to_float.h" +%include "blocks/udp_sink.h" +%include "blocks/udp_source.h" +%include "blocks/unpack_k_bits_bb.h" +%include "blocks/unpacked_to_packed_bb.h" +%include "blocks/unpacked_to_packed_ss.h" +%include "blocks/unpacked_to_packed_ii.h" +%include "blocks/vco_f.h" +%include "blocks/xor_bb.h" +%include "blocks/xor_ss.h" +%include "blocks/xor_ii.h" + +GR_SWIG_BLOCK_MAGIC2(blocks, nlog10_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, not_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, not_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, not_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, patterned_interleaver); +GR_SWIG_BLOCK_MAGIC2(blocks, pack_k_bits_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, packed_to_unpacked_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_fb); +GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_ib); +GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector_sb); +GR_SWIG_BLOCK_MAGIC2(blocks, peak_detector2_fb); +GR_SWIG_BLOCK_MAGIC2(blocks, plateau_detector_fb); +GR_SWIG_BLOCK_MAGIC2(blocks, pdu_to_tagged_stream); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_rate); +GR_SWIG_BLOCK_MAGIC2(blocks, or_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, or_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, or_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_b); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_s); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_i); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_f); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_c); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vb); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vs); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vi); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vf); +GR_SWIG_BLOCK_MAGIC2(blocks, probe_signal_vc); +GR_SWIG_BLOCK_MAGIC2(blocks, regenerate_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, repack_bits_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, repeat); +GR_SWIG_BLOCK_MAGIC2(blocks, rms_cf); +GR_SWIG_BLOCK_MAGIC2(blocks, rms_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, sample_and_hold_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, short_to_char); +GR_SWIG_BLOCK_MAGIC2(blocks, short_to_float); +GR_SWIG_BLOCK_MAGIC2(blocks, socket_pdu); +GR_SWIG_BLOCK_MAGIC2(blocks, stretch_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, sub_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, sub_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, sub_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, sub_cc); +GR_SWIG_BLOCK_MAGIC2(blocks, tagged_stream_mux); +GR_SWIG_BLOCK_MAGIC2(blocks, tagged_stream_to_pdu); +GR_SWIG_BLOCK_MAGIC2(blocks, threshold_ff); +GR_SWIG_BLOCK_MAGIC2(blocks, transcendental); +GR_SWIG_BLOCK_MAGIC2(blocks, tuntap_pdu); +GR_SWIG_BLOCK_MAGIC2(blocks, uchar_to_float); +GR_SWIG_BLOCK_MAGIC2(blocks, udp_sink); +GR_SWIG_BLOCK_MAGIC2(blocks, udp_source); +GR_SWIG_BLOCK_MAGIC2(blocks, unpack_k_bits_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, unpacked_to_packed_ii); +GR_SWIG_BLOCK_MAGIC2(blocks, vco_f); +GR_SWIG_BLOCK_MAGIC2(blocks, xor_bb); +GR_SWIG_BLOCK_MAGIC2(blocks, xor_ss); +GR_SWIG_BLOCK_MAGIC2(blocks, xor_ii); diff --git a/gr-blocks/tests/CMakeLists.txt b/gr-blocks/tests/CMakeLists.txt new file mode 100644 index 0000000000..ec17c017f1 --- /dev/null +++ b/gr-blocks/tests/CMakeLists.txt @@ -0,0 +1,56 @@ +# Copyright 2010-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(GrMiscUtils) #check n def +GR_CHECK_HDR_N_DEF(sys/resource.h HAVE_SYS_RESOURCE_H) + +######################################################################## +# Setup the include and linker paths +######################################################################## +include_directories( + ${GR_BLOCKS_INCLUDE_DIRS} + ${GNURADIO_CORE_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${CPPUNIT_INCLUDE_DIRS} +) + +link_directories( + ${Boost_LIBRARY_DIRS} + ${CPPUNIT_LIBRARY_DIRS} +) + +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + +######################################################################## +# Build benchmarks and non-registered tests +######################################################################## +set(tests_not_run #single source per test + benchmark_nco.cc + benchmark_vco.cc +) + +foreach(test_not_run_src ${tests_not_run}) + get_filename_component(name ${test_not_run_src} NAME_WE) + add_executable(${name} ${test_not_run_src}) + target_link_libraries(${name} test-gnuradio-core gnuradio-blocks ${LOG4CPP_LIBRARIES}) +endforeach(test_not_run_src) + diff --git a/gr-blocks/tests/benchmark_nco.cc b/gr-blocks/tests/benchmark_nco.cc new file mode 100644 index 0000000000..4c2ed120db --- /dev/null +++ b/gr-blocks/tests/benchmark_nco.cc @@ -0,0 +1,225 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <sys/time.h> + +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif + +#include <unistd.h> +#include <blocks/nco.h> +#include <blocks/fxpt_nco.h> +#include <string.h> + +#define ITERATIONS 20000000 +#define BLOCK_SIZE (10 * 1000) // fits in cache + +#define FREQ 5003.123 + +static double +timeval_to_double(const struct timeval *tv) +{ + return (double)tv->tv_sec + (double)tv->tv_usec * 1e-6; +} + + +static void +benchmark(void test (float *x, float *y), const char *implementation_name) +{ +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + float output[2*BLOCK_SIZE]; + float *x = &output[0], *y = &output[BLOCK_SIZE]; + + // touch memory + memset(output, 0, 2*BLOCK_SIZE*sizeof(float)); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if(getrusage(RUSAGE_SELF, &rusage_start) < 0) { + perror("getrusage"); + exit(1); + } +#else + clock_start = (double)clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + test(x, y); + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if(getrusage(RUSAGE_SELF, &rusage_stop) < 0) { + perror("getrusage"); + exit(1); + } + + // compute results + + double user = + timeval_to_double(&rusage_stop.ru_utime) + - timeval_to_double(&rusage_start.ru_utime); + + double sys = + timeval_to_double(&rusage_stop.ru_stime) + - timeval_to_double(&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double)clock() * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + printf("%18s: cpu: %6.3f steps/sec: %10.3e\n", + implementation_name, total, ITERATIONS / total); +} + +// ---------------------------------------------------------------- +// Don't compare the _vec with other functions since memory store's +// are involved. + +void basic_sincos_vec(float *x, float *y) +{ + gr::blocks::nco<float,float> nco; + + nco.set_freq(2 * M_PI / FREQ); + + for(int i = 0; i < ITERATIONS/BLOCK_SIZE; i++) { + for(int j = 0; j < BLOCK_SIZE; j++) { + nco.sincos(&x[2*j+1], &x[2*j]); + nco.step(); + } + } +} + +void native_sincos_vec(float *x, float *y) +{ + gr::blocks::nco<float,float> nco; + + nco.set_freq(2 * M_PI / FREQ); + + for(int i = 0; i < ITERATIONS/BLOCK_SIZE; i++) { + nco.sincos((gr_complex*)x, BLOCK_SIZE); + } +} + +void fxpt_sincos_vec(float *x, float *y) +{ + gr::blocks::fxpt_nco nco; + + nco.set_freq (2 * M_PI / FREQ); + + for(int i = 0; i < ITERATIONS/BLOCK_SIZE; i++) { + nco.sincos((gr_complex*)x, BLOCK_SIZE); + } +} + +// ---------------------------------------------------------------- + +void native_sincos(float *x, float *y) +{ + gr::blocks::nco<float,float> nco; + + nco.set_freq(2 * M_PI / FREQ); + + for(int i = 0; i < ITERATIONS; i++) { + nco.sincos(x, y); + nco.step(); + } +} + +void fxpt_sincos(float *x, float *y) +{ + gr::blocks::fxpt_nco nco; + + nco.set_freq(2 * M_PI / FREQ); + + for(int i = 0; i < ITERATIONS; i++) { + nco.sincos(x, y); + nco.step(); + } +} + +// ---------------------------------------------------------------- + +void native_sin(float *x, float *y) +{ + gr::blocks::nco<float,float> nco; + + nco.set_freq(2 * M_PI / FREQ); + + for(int i = 0; i < ITERATIONS; i++) { + *x = nco.sin(); + nco.step(); + } +} + +void fxpt_sin(float *x, float *y) +{ + gr::blocks::fxpt_nco nco; + + nco.set_freq(2 * M_PI / FREQ); + + for(int i = 0; i < ITERATIONS; i++) { + *x = nco.sin(); + nco.step(); + } +} + +// ---------------------------------------------------------------- + +void nop_fct(float *x, float *y) +{ +} + +void nop_loop(float *x, float *y) +{ + for(int i = 0; i < ITERATIONS; i++) { + nop_fct(x, y); + } +} + +int +main(int argc, char **argv) +{ + benchmark(nop_loop, "nop loop"); + benchmark(native_sin, "native sine"); + benchmark(fxpt_sin, "fxpt sine"); + benchmark(native_sincos, "native sin/cos"); + benchmark(fxpt_sincos, "fxpt sin/cos"); + benchmark(basic_sincos_vec, "basic sin/cos vec"); + benchmark(native_sincos_vec, "native sin/cos vec"); + benchmark(fxpt_sincos_vec, "fxpt sin/cos vec"); +} diff --git a/gr-blocks/tests/benchmark_vco.cc b/gr-blocks/tests/benchmark_vco.cc new file mode 100644 index 0000000000..955dc08051 --- /dev/null +++ b/gr-blocks/tests/benchmark_vco.cc @@ -0,0 +1,172 @@ +/* -*- c++ -*- */ +/* + * Copyright 2002,2004,2005,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <sys/time.h> + +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> +#endif + +#include <unistd.h> +#include <blocks/vco.h> +#include <blocks/fxpt_vco.h> +#include <string.h> + +#define ITERATIONS 5000000 +#define BLOCK_SIZE (10 * 1000) // fits in cache + +#define FREQ 5003.123 +#define K 4.9999999 +#define AMPLITUDE 2.444444444 + + +static double +timeval_to_double(const struct timeval *tv) +{ + return (double) tv->tv_sec + (double) tv->tv_usec * 1e-6; +} + + +static void +benchmark(void test (float *x, const float *y), const char *implementation_name) +{ +#ifdef HAVE_SYS_RESOURCE_H + struct rusage rusage_start; + struct rusage rusage_stop; +#else + double clock_start; + double clock_end; +#endif + float output[BLOCK_SIZE]; + float input[BLOCK_SIZE]; + + // touch memory + memset(output, 0, BLOCK_SIZE*sizeof(float)); + for(int i = 0; i<BLOCK_SIZE; i++) + input[i] = sin(double(i)); + + // get starting CPU usage +#ifdef HAVE_SYS_RESOURCE_H + if(getrusage (RUSAGE_SELF, &rusage_start) < 0) { + perror("getrusage"); + exit(1); + } +#else + clock_start = (double)clock() * (1000000. / CLOCKS_PER_SEC); +#endif + // do the actual work + + test(output, input); + + // get ending CPU usage + +#ifdef HAVE_SYS_RESOURCE_H + if(getrusage (RUSAGE_SELF, &rusage_stop) < 0) { + perror("getrusage"); + exit(1); + } + + // compute results + + double user = + timeval_to_double(&rusage_stop.ru_utime) + - timeval_to_double(&rusage_start.ru_utime); + + double sys = + timeval_to_double(&rusage_stop.ru_stime) + - timeval_to_double(&rusage_start.ru_stime); + + double total = user + sys; +#else + clock_end = (double)clock() * (1000000. / CLOCKS_PER_SEC); + double total = clock_end - clock_start; +#endif + + printf("%18s: cpu: %6.3f steps/sec: %10.3e\n", + implementation_name, total, ITERATIONS / total); +} + +// ---------------------------------------------------------------- + +void basic_vco(float *output, const float *input) +{ + double phase = 0; + + for(int j = 0; j < ITERATIONS/BLOCK_SIZE; j++) { + for(int i = 0; i < BLOCK_SIZE; i++) { + output[i] = cos(phase) * AMPLITUDE; + phase += input[i] * K; + + while(phase > 2 * M_PI) + phase -= 2 * M_PI; + + while(phase < -2 * M_PI) + phase += 2 * M_PI; + } + } +} + +void native_vco(float *output, const float *input) +{ + gr::blocks::vco<float,float> vco; + + for(int j = 0; j < ITERATIONS/BLOCK_SIZE; j++) { + vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE); + } +} + +void fxpt_vco(float *output, const float *input) +{ + gr::blocks::fxpt_vco vco; + + for(int j = 0; j < ITERATIONS/BLOCK_SIZE; j++) { + vco.cos(output, input, BLOCK_SIZE, K, AMPLITUDE); + } +} + +// ---------------------------------------------------------------- + +void nop_fct(float *x, const float *y) +{ +} + +void nop_loop(float *x, const float *y) +{ + for(int i = 0; i < ITERATIONS; i++) { + nop_fct(x, y); + } +} + +int +main(int argc, char **argv) +{ + benchmark(nop_loop, "nop loop"); + benchmark(basic_vco, "basic vco"); + benchmark(native_vco, "native vco"); + benchmark(fxpt_vco, "fxpt vco"); +} diff --git a/gr-blocks/tests/nco_results b/gr-blocks/tests/nco_results new file mode 100644 index 0000000000..5bdf5dd1cb --- /dev/null +++ b/gr-blocks/tests/nco_results @@ -0,0 +1,48 @@ +================================================================ +These are on a 1.4 GHz Pentium M using g++ 3.4.1 +================================================================ + +Default compiler options -O2 + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.900 steps/sec: 1.111e+07 + fxpt sine: cpu: 0.281 steps/sec: 3.559e+07 + native sin/cos: cpu: 1.138 steps/sec: 8.789e+06 + fxpt sin/cos: cpu: 0.550 steps/sec: 1.818e+07 + +-O2 -march=pentium-m -fomit-frame-pointer + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.903 steps/sec: 1.108e+07 + fxpt sine: cpu: 0.271 steps/sec: 3.691e+07 + native sin/cos: cpu: 1.092 steps/sec: 9.159e+06 + fxpt sin/cos: cpu: 0.542 steps/sec: 1.845e+07 + +Inlined fxpt::sin & cos +-O2 -march=pentium-m -fomit-frame-pointer + + nop loop: cpu: 0.015 steps/sec: 6.668e+08 + native sine: cpu: 0.904 steps/sec: 1.106e+07 + fxpt sine: cpu: 0.187 steps/sec: 5.348e+07 + native sin/cos: cpu: 1.091 steps/sec: 9.167e+06 + fxpt sin/cos: cpu: 0.373 steps/sec: 2.681e+07 + +================================================================ +These are on a 1.5 GHz Athon MP 1800+ +================================================================ + +Default compiler options: -O2 + + nop loop: cpu: 0.013 steps/sec: 7.693e+08 + native sine: cpu: 0.733 steps/sec: 1.364e+07 + fxpt sine: cpu: 0.210 steps/sec: 4.763e+07 + native sin/cos: cpu: 1.183 steps/sec: 8.454e+06 + fxpt sin/cos: cpu: 0.420 steps/sec: 2.381e+07 + +-O2 -fomit-frame-pointer -march=athlon-mp + + nop loop: cpu: 0.013 steps/sec: 7.693e+08 + native sine: cpu: 0.679 steps/sec: 1.473e+07 + fxpt sine: cpu: 0.200 steps/sec: 5.001e+07 + native sin/cos: cpu: 1.147 steps/sec: 8.720e+06 + fxpt sin/cos: cpu: 0.444 steps/sec: 2.253e+07 diff --git a/gr-comedi/src/CMakeLists.txt b/gr-comedi/src/CMakeLists.txt index 1d9dac2c48..0dc0960016 100644 --- a/gr-comedi/src/CMakeLists.txt +++ b/gr-comedi/src/CMakeLists.txt @@ -33,6 +33,9 @@ link_directories( ${COMEDI_LIBRARY_DIRS} ) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -46,6 +49,7 @@ list(APPEND comedi_libs gnuradio-core ${Boost_LIBRARIES} ${COMEDI_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-comedi SHARED ${gr_comedi_sources}) diff --git a/gr-digital/CMakeLists.txt b/gr-digital/CMakeLists.txt index 864cd673a9..12918bbfb3 100644 --- a/gr-digital/CMakeLists.txt +++ b/gr-digital/CMakeLists.txt @@ -30,6 +30,8 @@ GR_REGISTER_COMPONENT("gr-digital" ENABLE_GR_DIGITAL Boost_FOUND ENABLE_GR_CORE ENABLE_GR_ANALOG + ENABLE_GR_BLOCKS + ENABLE_GR_FILTER ) GR_SET_GLOBAL(GR_DIGITAL_INCLUDE_DIRS @@ -85,6 +87,7 @@ CPACK_COMPONENT("digital_swig" # Add subdirectories ######################################################################## add_subdirectory(include) +add_subdirectory(include/digital) add_subdirectory(lib) add_subdirectory(doc) if(ENABLE_PYTHON) diff --git a/gr-digital/doc/digital.dox b/gr-digital/doc/digital.dox index 110dcb677e..2809c6a943 100644 --- a/gr-digital/doc/digital.dox +++ b/gr-digital/doc/digital.dox @@ -11,7 +11,7 @@ imported as: \endcode See the Doxygen documentation for details about the blocks available -in this package. The relevant blocks are listed in the \ref digital group. +in this package. A quick listing of the details can be found in Python after importing by using: diff --git a/gr-digital/examples/ofdm/ofdm_loopback.grc b/gr-digital/examples/ofdm/ofdm_loopback.grc new file mode 100644 index 0000000000..45a6ca0869 --- /dev/null +++ b/gr-digital/examples/ofdm/ofdm_loopback.grc @@ -0,0 +1,861 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Tue May 7 15:42:23 2013</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>ofdm_loopback_example</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value>OFDM Loopback Example</value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value>Transmit a pre-defined signal (a complex sine) as OFDM packets.</value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(0, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>len_tag_key</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>"packet_len"</value> + </param> + <param> + <key>_coordinate</key> + <value>(345, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>fft_len</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>64</value> + </param> + <param> + <key>_coordinate</key> + <value>(464, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>freq_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Frequency Offset (Multiples of Sub-carrier spacing)</value> + </param> + <param> + <key>value</key> + <value>0</value> + </param> + <param> + <key>min</key> + <value>-3</value> + </param> + <param> + <key>max</key> + <value>3</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(652, 285)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_slider</key> + <param> + <key>id</key> + <value>noise_voltage</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>Noise Amplitude</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>min</key> + <value>0</value> + </param> + <param> + <key>max</key> + <value>1</value> + </param> + <param> + <key>num_steps</key> + <value>100</value> + </param> + <param> + <key>style</key> + <value>wx.SL_HORIZONTAL</value> + </param> + <param> + <key>converver</key> + <value>float_converter</value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(651, 416)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>import numpy</value> + </param> + <param> + <key>_coordinate</key> + <value>(536, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>from gnuradio.digital.utils import tagged_streams</value> + </param> + <param> + <key>_coordinate</key> + <value>(633, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_tx</key> + <param> + <key>id</key> + <value>digital_ofdm_tx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>fft_len</key> + <value>fft_len</value> + </param> + <param> + <key>cp_len</key> + <value>fft_len/4</value> + </param> + <param> + <key>packet_len_key</key> + <value>len_tag_key</value> + </param> + <param> + <key>occupied_carriers</key> + <value>()</value> + </param> + <param> + <key>pilot_carriers</key> + <value>()</value> + </param> + <param> + <key>pilot_symbols</key> + <value>()</value> + </param> + <param> + <key>sync_word1</key> + <value>()</value> + </param> + <param> + <key>sync_word2</key> + <value>()</value> + </param> + <param> + <key>header_mod</key> + <value>"BPSK"</value> + </param> + <param> + <key>payload_mod</key> + <value>"BPSK"</value> + </param> + <param> + <key>rolloff</key> + <value>0</value> + </param> + <param> + <key>log</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(390, 78)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_float_to_uchar</key> + <param> + <key>id</key> + <value>blocks_float_to_uchar_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(230, 119)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>tx_signal</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>[numpy.sin(2 * numpy.pi * 1.0/8 * x) for x in range(8*2)]</value> + </param> + <param> + <key>_coordinate</key> + <value>(176, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_vector_source_x</key> + <param> + <key>id</key> + <value>blocks_vector_source_x_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>vector</key> + <value>tx_signal</value> + </param> + <param> + <key>tags</key> + <value>tagged_streams.make_lengthtags((8*2*gr.sizeof_float,), (0,), tagname=len_tag_key)</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(-1, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_throttle</key> + <param> + <key>id</key> + <value>blocks_throttle_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>samples_per_second</key> + <value>100e3</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(354, 230)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>blocks_tag_gate</key> + <param> + <key>id</key> + <value>blocks_tag_gate_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>propagate_tags</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(539, 230)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>wxgui_fftsink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Rx Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>100e3</value> + </param> + <param> + <key>baseband_freq</key> + <value>0</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>0</value> + </param> + <param> + <key>ref_scale</key> + <value>2.0</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>15</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>freqvar</key> + <value>None</value> + </param> + <param> + <key>_coordinate</key> + <value>(92, 463)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>channel_model</key> + <param> + <key>id</key> + <value>chan_model</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>noise_voltage</key> + <value>noise_voltage</value> + </param> + <param> + <key>freq_offset</key> + <value>1.0/fft_len * freq_offset</value> + </param> + <param> + <key>epsilon</key> + <value>1.0</value> + </param> + <param> + <key>taps</key> + <value>1.0</value> + </param> + <param> + <key>seed</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(615, 86)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_rx</key> + <param> + <key>id</key> + <value>digital_ofdm_rx_0</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> + <key>fft_len</key> + <value>fft_len</value> + </param> + <param> + <key>cp_len</key> + <value>fft_len/4</value> + </param> + <param> + <key>packet_len_key</key> + <value>"rx_len"</value> + </param> + <param> + <key>occupied_carriers</key> + <value>()</value> + </param> + <param> + <key>pilot_carriers</key> + <value>()</value> + </param> + <param> + <key>pilot_symbols</key> + <value>()</value> + </param> + <param> + <key>sync_word1</key> + <value>()</value> + </param> + <param> + <key>sync_word2</key> + <value>()</value> + </param> + <param> + <key>header_mod</key> + <value>"BPSK"</value> + </param> + <param> + <key>payload_mod</key> + <value>"BPSK"</value> + </param> + <param> + <key>log</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(92, 307)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_uchar_to_float</key> + <param> + <key>id</key> + <value>blocks_uchar_to_float_0</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(332, 340)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_tag_debug</key> + <param> + <key>id</key> + <value>blocks_tag_debug_0</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>name</key> + <value>Rx Packets</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>display</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(336, 412)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>wxgui_scopesink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>title</key> + <value>Scope Plot</value> + </param> + <param> + <key>samp_rate</key> + <value>1.0</value> + </param> + <param> + <key>v_scale</key> + <value>0</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>trig_mode</key> + <value>gr.gr_TRIG_MODE_AUTO</value> + </param> + <param> + <key>y_axis_label</key> + <value>Counts</value> + </param> + <param> + <key>_coordinate</key> + <value>(504, 314)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>blocks_vector_source_x_0</source_block_id> + <sink_block_id>blocks_float_to_uchar_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_tx_0</source_block_id> + <sink_block_id>chan_model</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_float_to_uchar_0</source_block_id> + <sink_block_id>digital_ofdm_tx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_throttle_0</source_block_id> + <sink_block_id>digital_ofdm_rx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_throttle_0</source_block_id> + <sink_block_id>wxgui_fftsink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_rx_0</source_block_id> + <sink_block_id>blocks_uchar_to_float_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_uchar_to_float_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_rx_0</source_block_id> + <sink_block_id>blocks_tag_debug_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>chan_model</source_block_id> + <sink_block_id>blocks_tag_gate_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_tag_gate_0</source_block_id> + <sink_block_id>blocks_throttle_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-digital/examples/ofdm/rx_ofdm.grc b/gr-digital/examples/ofdm/rx_ofdm.grc new file mode 100644 index 0000000000..470f7ba3bf --- /dev/null +++ b/gr-digital/examples/ofdm/rx_ofdm.grc @@ -0,0 +1,1864 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Tue May 7 15:15:56 2013</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>rx_ofdm</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value>OFDM Rx</value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value>Example of an OFDM receiver</value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>prompt</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(0, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>from gnuradio.digital.utils import tagged_streams</value> + </param> + <param> + <key>_coordinate</key> + <value>(163, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>fft_len</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>64</value> + </param> + <param> + <key>_coordinate</key> + <value>(301, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>length_tag_name</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>"frame_len"</value> + </param> + <param> + <key>_coordinate</key> + <value>(367, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>payload_mod</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>digital.constellation_qpsk()</value> + </param> + <param> + <key>_coordinate</key> + <value>(648, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>header_mod</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>digital.constellation_bpsk()</value> + </param> + <param> + <key>_coordinate</key> + <value>(490, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>header_formatter</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>digital.packet_header_ofdm(occupied_carriers, 1, length_tag_name)</value> + </param> + <param> + <key>_coordinate</key> + <value>(811, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>occupied_carriers</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>(range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(598, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>pilot_carriers</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>((-21, -7, 7, 21,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(751, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>pilot_symbols</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>((1, 1, 1, -1,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(875, 65)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sync_word2</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>(0, 0, 0, 0, 0, 1, 1, -1.0, -1, 1.0, 1, 1.0, -1, -1.0, -1, 1.0, 1, -1.0, 1, 1.0, 1, -1.0, -1, -1.0, -1, 1.0, -1, 1.0, -1, 1.0, 1, -1.0, 0, 1.0, 1, -1.0, 1, 1.0, -1, -1.0, 1, -1.0, -1, -1.0, 1, 1.0, 1, -1.0, 1, 1.0, -1, 1.0, -1, -1.0, -1, 1.0, 1, -1.0, 0, 0, 0, 0, 0, 0)</value> + </param> + <param> + <key>_coordinate</key> + <value>(457, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sync_word1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>(0, 0, 0, 0, 0, 0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 0, 0, 0, 0, 0)</value> + </param> + <param> + <key>_coordinate</key> + <value>(313, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>3200000</value> + </param> + <param> + <key>_coordinate</key> + <value>(218, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_tag_debug</key> + <param> + <key>id</key> + <value>blocks_tag_debug_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>name</key> + <value>Rx Packets</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>display</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(1101, 791)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_constellation_decoder_cb</key> + <param> + <key>id</key> + <value>digital_constellation_decoder_cb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>constellation</key> + <value>payload_mod.base()</value> + </param> + <param> + <key>_coordinate</key> + <value>(879, 799)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_serializer_vcc</key> + <param> + <key>id</key> + <value>digital_ofdm_serializer_vcc_1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>fft_len</key> + <value>fft_len</value> + </param> + <param> + <key>occupied_carriers</key> + <value>occupied_carriers</value> + </param> + <param> + <key>len_tag_key</key> + <value>length_tag_key</value> + </param> + <param> + <key>packet_len_tag_key</key> + <value>""</value> + </param> + <param> + <key>symbols_skipped</key> + <value>1</value> + </param> + <param> + <key>input_is_shifted</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(653, 761)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>fft_vxx</key> + <param> + <key>id</key> + <value>fft_vxx_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>fft_size</key> + <value>fft_len</value> + </param> + <param> + <key>forward</key> + <value>True</value> + </param> + <param> + <key>window</key> + <value></value> + </param> + <param> + <key>shift</key> + <value>True</value> + </param> + <param> + <key>nthreads</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(214, 769)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_source</key> + <param> + <key>id</key> + <value>virtual_source_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Payload Stream</value> + </param> + <param> + <key>_coordinate</key> + <value>(0, 799)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_sink</key> + <param> + <key>id</key> + <value>virtual_sink_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Payload Stream</value> + </param> + <param> + <key>_coordinate</key> + <value>(968, 374)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_sink</key> + <param> + <key>id</key> + <value>virtual_sink_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Header Stream</value> + </param> + <param> + <key>_coordinate</key> + <value>(969, 305)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_multiply_xx</key> + <param> + <key>id</key> + <value>blocks_multiply_xx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>num_inputs</key> + <value>2</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(798, 137)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>analog_frequency_modulator_fc</key> + <param> + <key>id</key> + <value>analog_frequency_modulator_fc_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>sensitivity</key> + <value>-2.0/fft_len</value> + </param> + <param> + <key>_coordinate</key> + <value>(579, 134)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_delay</key> + <param> + <key>id</key> + <value>gr_delay_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>delay</key> + <value>fft_len+fft_len/4</value> + </param> + <param> + <key>num_ports</key> + <value>1</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(422, 220)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_sync_sc_cfb</key> + <param> + <key>id</key> + <value>digital_ofdm_sync_sc_cfb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>fft_len</key> + <value>fft_len</value> + </param> + <param> + <key>cp_len</key> + <value>fft_len/4</value> + </param> + <param> + <key>use_even_carriers</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(244, 137)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_throttle</key> + <param> + <key>id</key> + <value>blocks_throttle_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>samples_per_second</key> + <value>samp_rate</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(186, 235)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>analog_noise_source_x</key> + <param> + <key>id</key> + <value>analog_noise_source_x_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>noise_type</key> + <value>analog.GR_GAUSSIAN</value> + </param> + <param> + <key>amp</key> + <value>1</value> + </param> + <param> + <key>seed</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(0, 220)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>uhd_usrp_source</key> + <param> + <key>id</key> + <value>uhd_usrp_source_0</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> + <key>type</key> + <value>fc32</value> + </param> + <param> + <key>otw</key> + <value></value> + </param> + <param> + <key>stream_args</key> + <value></value> + </param> + <param> + <key>dev_addr</key> + <value></value> + </param> + <param> + <key>sync</key> + <value></value> + </param> + <param> + <key>clock_rate</key> + <value>0.0</value> + </param> + <param> + <key>num_mboards</key> + <value>1</value> + </param> + <param> + <key>clock_source0</key> + <value></value> + </param> + <param> + <key>time_source0</key> + <value></value> + </param> + <param> + <key>sd_spec0</key> + <value></value> + </param> + <param> + <key>clock_source1</key> + <value></value> + </param> + <param> + <key>time_source1</key> + <value></value> + </param> + <param> + <key>sd_spec1</key> + <value></value> + </param> + <param> + <key>clock_source2</key> + <value></value> + </param> + <param> + <key>time_source2</key> + <value></value> + </param> + <param> + <key>sd_spec2</key> + <value></value> + </param> + <param> + <key>clock_source3</key> + <value></value> + </param> + <param> + <key>time_source3</key> + <value></value> + </param> + <param> + <key>sd_spec3</key> + <value></value> + </param> + <param> + <key>clock_source4</key> + <value></value> + </param> + <param> + <key>time_source4</key> + <value></value> + </param> + <param> + <key>sd_spec4</key> + <value></value> + </param> + <param> + <key>clock_source5</key> + <value></value> + </param> + <param> + <key>time_source5</key> + <value></value> + </param> + <param> + <key>sd_spec5</key> + <value></value> + </param> + <param> + <key>clock_source6</key> + <value></value> + </param> + <param> + <key>time_source6</key> + <value></value> + </param> + <param> + <key>sd_spec6</key> + <value></value> + </param> + <param> + <key>clock_source7</key> + <value></value> + </param> + <param> + <key>time_source7</key> + <value></value> + </param> + <param> + <key>sd_spec7</key> + <value></value> + </param> + <param> + <key>nchan</key> + <value>1</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>center_freq0</key> + <value>0</value> + </param> + <param> + <key>gain0</key> + <value>0</value> + </param> + <param> + <key>ant0</key> + <value></value> + </param> + <param> + <key>bw0</key> + <value>0</value> + </param> + <param> + <key>center_freq1</key> + <value>0</value> + </param> + <param> + <key>gain1</key> + <value>0</value> + </param> + <param> + <key>ant1</key> + <value></value> + </param> + <param> + <key>bw1</key> + <value>0</value> + </param> + <param> + <key>center_freq2</key> + <value>0</value> + </param> + <param> + <key>gain2</key> + <value>0</value> + </param> + <param> + <key>ant2</key> + <value></value> + </param> + <param> + <key>bw2</key> + <value>0</value> + </param> + <param> + <key>center_freq3</key> + <value>0</value> + </param> + <param> + <key>gain3</key> + <value>0</value> + </param> + <param> + <key>ant3</key> + <value></value> + </param> + <param> + <key>bw3</key> + <value>0</value> + </param> + <param> + <key>center_freq4</key> + <value>0</value> + </param> + <param> + <key>gain4</key> + <value>0</value> + </param> + <param> + <key>ant4</key> + <value></value> + </param> + <param> + <key>bw4</key> + <value>0</value> + </param> + <param> + <key>center_freq5</key> + <value>0</value> + </param> + <param> + <key>gain5</key> + <value>0</value> + </param> + <param> + <key>ant5</key> + <value></value> + </param> + <param> + <key>bw5</key> + <value>0</value> + </param> + <param> + <key>center_freq6</key> + <value>0</value> + </param> + <param> + <key>gain6</key> + <value>0</value> + </param> + <param> + <key>ant6</key> + <value></value> + </param> + <param> + <key>bw6</key> + <value>0</value> + </param> + <param> + <key>center_freq7</key> + <value>0</value> + </param> + <param> + <key>gain7</key> + <value>0</value> + </param> + <param> + <key>ant7</key> + <value></value> + </param> + <param> + <key>bw7</key> + <value>0</value> + </param> + <param> + <key>center_freq8</key> + <value>0</value> + </param> + <param> + <key>gain8</key> + <value>0</value> + </param> + <param> + <key>ant8</key> + <value></value> + </param> + <param> + <key>bw8</key> + <value>0</value> + </param> + <param> + <key>center_freq9</key> + <value>0</value> + </param> + <param> + <key>gain9</key> + <value>0</value> + </param> + <param> + <key>ant9</key> + <value></value> + </param> + <param> + <key>bw9</key> + <value>0</value> + </param> + <param> + <key>center_freq10</key> + <value>0</value> + </param> + <param> + <key>gain10</key> + <value>0</value> + </param> + <param> + <key>ant10</key> + <value></value> + </param> + <param> + <key>bw10</key> + <value>0</value> + </param> + <param> + <key>center_freq11</key> + <value>0</value> + </param> + <param> + <key>gain11</key> + <value>0</value> + </param> + <param> + <key>ant11</key> + <value></value> + </param> + <param> + <key>bw11</key> + <value>0</value> + </param> + <param> + <key>center_freq12</key> + <value>0</value> + </param> + <param> + <key>gain12</key> + <value>0</value> + </param> + <param> + <key>ant12</key> + <value></value> + </param> + <param> + <key>bw12</key> + <value>0</value> + </param> + <param> + <key>center_freq13</key> + <value>0</value> + </param> + <param> + <key>gain13</key> + <value>0</value> + </param> + <param> + <key>ant13</key> + <value></value> + </param> + <param> + <key>bw13</key> + <value>0</value> + </param> + <param> + <key>center_freq14</key> + <value>0</value> + </param> + <param> + <key>gain14</key> + <value>0</value> + </param> + <param> + <key>ant14</key> + <value></value> + </param> + <param> + <key>bw14</key> + <value>0</value> + </param> + <param> + <key>center_freq15</key> + <value>0</value> + </param> + <param> + <key>gain15</key> + <value>0</value> + </param> + <param> + <key>ant15</key> + <value></value> + </param> + <param> + <key>bw15</key> + <value>0</value> + </param> + <param> + <key>center_freq16</key> + <value>0</value> + </param> + <param> + <key>gain16</key> + <value>0</value> + </param> + <param> + <key>ant16</key> + <value></value> + </param> + <param> + <key>bw16</key> + <value>0</value> + </param> + <param> + <key>center_freq17</key> + <value>0</value> + </param> + <param> + <key>gain17</key> + <value>0</value> + </param> + <param> + <key>ant17</key> + <value></value> + </param> + <param> + <key>bw17</key> + <value>0</value> + </param> + <param> + <key>center_freq18</key> + <value>0</value> + </param> + <param> + <key>gain18</key> + <value>0</value> + </param> + <param> + <key>ant18</key> + <value></value> + </param> + <param> + <key>bw18</key> + <value>0</value> + </param> + <param> + <key>center_freq19</key> + <value>0</value> + </param> + <param> + <key>gain19</key> + <value>0</value> + </param> + <param> + <key>ant19</key> + <value></value> + </param> + <param> + <key>bw19</key> + <value>0</value> + </param> + <param> + <key>center_freq20</key> + <value>0</value> + </param> + <param> + <key>gain20</key> + <value>0</value> + </param> + <param> + <key>ant20</key> + <value></value> + </param> + <param> + <key>bw20</key> + <value>0</value> + </param> + <param> + <key>center_freq21</key> + <value>0</value> + </param> + <param> + <key>gain21</key> + <value>0</value> + </param> + <param> + <key>ant21</key> + <value></value> + </param> + <param> + <key>bw21</key> + <value>0</value> + </param> + <param> + <key>center_freq22</key> + <value>0</value> + </param> + <param> + <key>gain22</key> + <value>0</value> + </param> + <param> + <key>ant22</key> + <value></value> + </param> + <param> + <key>bw22</key> + <value>0</value> + </param> + <param> + <key>center_freq23</key> + <value>0</value> + </param> + <param> + <key>gain23</key> + <value>0</value> + </param> + <param> + <key>ant23</key> + <value></value> + </param> + <param> + <key>bw23</key> + <value>0</value> + </param> + <param> + <key>center_freq24</key> + <value>0</value> + </param> + <param> + <key>gain24</key> + <value>0</value> + </param> + <param> + <key>ant24</key> + <value></value> + </param> + <param> + <key>bw24</key> + <value>0</value> + </param> + <param> + <key>center_freq25</key> + <value>0</value> + </param> + <param> + <key>gain25</key> + <value>0</value> + </param> + <param> + <key>ant25</key> + <value></value> + </param> + <param> + <key>bw25</key> + <value>0</value> + </param> + <param> + <key>center_freq26</key> + <value>0</value> + </param> + <param> + <key>gain26</key> + <value>0</value> + </param> + <param> + <key>ant26</key> + <value></value> + </param> + <param> + <key>bw26</key> + <value>0</value> + </param> + <param> + <key>center_freq27</key> + <value>0</value> + </param> + <param> + <key>gain27</key> + <value>0</value> + </param> + <param> + <key>ant27</key> + <value></value> + </param> + <param> + <key>bw27</key> + <value>0</value> + </param> + <param> + <key>center_freq28</key> + <value>0</value> + </param> + <param> + <key>gain28</key> + <value>0</value> + </param> + <param> + <key>ant28</key> + <value></value> + </param> + <param> + <key>bw28</key> + <value>0</value> + </param> + <param> + <key>center_freq29</key> + <value>0</value> + </param> + <param> + <key>gain29</key> + <value>0</value> + </param> + <param> + <key>ant29</key> + <value></value> + </param> + <param> + <key>bw29</key> + <value>0</value> + </param> + <param> + <key>center_freq30</key> + <value>0</value> + </param> + <param> + <key>gain30</key> + <value>0</value> + </param> + <param> + <key>ant30</key> + <value></value> + </param> + <param> + <key>bw30</key> + <value>0</value> + </param> + <param> + <key>center_freq31</key> + <value>0</value> + </param> + <param> + <key>gain31</key> + <value>0</value> + </param> + <param> + <key>ant31</key> + <value></value> + </param> + <param> + <key>bw31</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(0, 135)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_frame_equalizer_vcvc</key> + <param> + <key>id</key> + <value>digital_ofdm_frame_equalizer_vcvc_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>fft_len</key> + <value>fft_len</value> + </param> + <param> + <key>equalizer</key> + <value>digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 2).base()</value> + </param> + <param> + <key>len_tag_key</key> + <value>length_tag_key</value> + </param> + <param> + <key>propagate_channel_state</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(422, 776)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_header_payload_demux</key> + <param> + <key>id</key> + <value>digital_header_payload_demux_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>header_len</key> + <value>3</value> + </param> + <param> + <key>items_per_symbol</key> + <value>fft_len</value> + </param> + <param> + <key>guard_interval</key> + <value>fft_len/4</value> + </param> + <param> + <key>length_tag_key</key> + <value>length_tag_name</value> + </param> + <param> + <key>trigger_tag_key</key> + <value>""</value> + </param> + <param> + <key>output_symbols</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>_coordinate</key> + <value>(678, 298)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_packet_headerparser_b</key> + <param> + <key>id</key> + <value>digital_packet_headerparser_b_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>header_formatter</key> + <value>header_formatter.formatter()</value> + </param> + <param> + <key>_coordinate</key> + <value>(915, 495)</value> + </param> + <param> + <key>_rotation</key> + <value>90</value> + </param> + </block> + <block> + <key>digital_ofdm_serializer_vcc</key> + <param> + <key>id</key> + <value>digital_ofdm_serializer_vcc_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>fft_len</key> + <value>fft_len</value> + </param> + <param> + <key>occupied_carriers</key> + <value>occupied_carriers</value> + </param> + <param> + <key>len_tag_key</key> + <value>length_tag_name</value> + </param> + <param> + <key>packet_len_tag_key</key> + <value>""</value> + </param> + <param> + <key>symbols_skipped</key> + <value>0</value> + </param> + <param> + <key>input_is_shifted</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(245, 643)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_constellation_decoder_cb</key> + <param> + <key>id</key> + <value>digital_constellation_decoder_cb_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>constellation</key> + <value>header_mod.base()</value> + </param> + <param> + <key>_coordinate</key> + <value>(461, 681)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_source</key> + <param> + <key>id</key> + <value>virtual_source_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Header Stream</value> + </param> + <param> + <key>_coordinate</key> + <value>(0, 543)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>fft_vxx</key> + <param> + <key>id</key> + <value>fft_vxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>fft_size</key> + <value>fft_len</value> + </param> + <param> + <key>forward</key> + <value>True</value> + </param> + <param> + <key>window</key> + <value></value> + </param> + <param> + <key>shift</key> + <value>True</value> + </param> + <param> + <key>nthreads</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(213, 513)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_chanest_vcvc</key> + <param> + <key>id</key> + <value>digital_ofdm_chanest_vcvc_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>sync_symbol1</key> + <value>sync_word1</value> + </param> + <param> + <key>sync_symbol2</key> + <value>sync_word2</value> + </param> + <param> + <key>n_data_symbols</key> + <value>2</value> + </param> + <param> + <key>eq_noise_red_len</key> + <value>0</value> + </param> + <param> + <key>max_carr_offset</key> + <value>-1</value> + </param> + <param> + <key>force_one_symbol</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(427, 505)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_frame_equalizer_vcvc</key> + <param> + <key>id</key> + <value>digital_ofdm_frame_equalizer_vcvc_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>fft_len</key> + <value>fft_len</value> + </param> + <param> + <key>equalizer</key> + <value>digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols).base()</value> + </param> + <param> + <key>len_tag_key</key> + <value>length_tag_name</value> + </param> + <param> + <key>propagate_channel_state</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(704, 520)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>digital_ofdm_frame_equalizer_vcvc_0_0</source_block_id> + <sink_block_id>digital_ofdm_serializer_vcc_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>virtual_source_0</source_block_id> + <sink_block_id>fft_vxx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>fft_vxx_0</source_block_id> + <sink_block_id>digital_ofdm_chanest_vcvc_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_chanest_vcvc_0</source_block_id> + <sink_block_id>digital_ofdm_frame_equalizer_vcvc_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_packet_headerparser_b_0</source_block_id> + <sink_block_id>digital_header_payload_demux_0</sink_block_id> + <source_key>header_data</source_key> + <sink_key>header_data</sink_key> + </connection> + <connection> + <source_block_id>digital_constellation_decoder_cb_0_0</source_block_id> + <sink_block_id>digital_packet_headerparser_b_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_serializer_vcc_0</source_block_id> + <sink_block_id>digital_constellation_decoder_cb_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_constellation_decoder_cb_0</source_block_id> + <sink_block_id>blocks_tag_debug_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>fft_vxx_0_0</source_block_id> + <sink_block_id>digital_ofdm_frame_equalizer_vcvc_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_frame_equalizer_vcvc_0</source_block_id> + <sink_block_id>digital_ofdm_serializer_vcc_1</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>virtual_source_0_0</source_block_id> + <sink_block_id>fft_vxx_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_serializer_vcc_1</source_block_id> + <sink_block_id>digital_constellation_decoder_cb_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_header_payload_demux_0</source_block_id> + <sink_block_id>virtual_sink_0_0</sink_block_id> + <source_key>1</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_header_payload_demux_0</source_block_id> + <sink_block_id>virtual_sink_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_throttle_0</source_block_id> + <sink_block_id>digital_ofdm_sync_sc_cfb_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>uhd_usrp_source_0</source_block_id> + <sink_block_id>gr_delay_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>uhd_usrp_source_0</source_block_id> + <sink_block_id>digital_ofdm_sync_sc_cfb_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_throttle_0</source_block_id> + <sink_block_id>gr_delay_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>analog_noise_source_x_0</source_block_id> + <sink_block_id>blocks_throttle_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>analog_frequency_modulator_fc_0</source_block_id> + <sink_block_id>blocks_multiply_xx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_sync_sc_cfb_0</source_block_id> + <sink_block_id>analog_frequency_modulator_fc_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>gr_delay_0</source_block_id> + <sink_block_id>blocks_multiply_xx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>1</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_sync_sc_cfb_0</source_block_id> + <sink_block_id>digital_header_payload_demux_0</sink_block_id> + <source_key>1</source_key> + <sink_key>1</sink_key> + </connection> + <connection> + <source_block_id>blocks_multiply_xx_0</source_block_id> + <sink_block_id>digital_header_payload_demux_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-digital/examples/ofdm/tx_ofdm.grc b/gr-digital/examples/ofdm/tx_ofdm.grc new file mode 100644 index 0000000000..0ac12900f9 --- /dev/null +++ b/gr-digital/examples/ofdm/tx_ofdm.grc @@ -0,0 +1,2008 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Tue May 7 15:13:12 2013</timestamp> + <block> + <key>virtual_source</key> + <param> + <key>id</key> + <value>virtual_source_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Payload Bits</value> + </param> + <param> + <key>_coordinate</key> + <value>(0, 458)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_sink</key> + <param> + <key>id</key> + <value>virtual_sink_0_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Frame Symbols</value> + </param> + <param> + <key>_coordinate</key> + <value>(745, 441)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_tagged_stream_mux</key> + <param> + <key>id</key> + <value>blocks_tagged_stream_mux_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>ninputs</key> + <value>2</value> + </param> + <param> + <key>lengthtagname</key> + <value>length_tag_name</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(510, 428)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_sink</key> + <param> + <key>id</key> + <value>virtual_sink_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Payload Bits</value> + </param> + <param> + <key>_coordinate</key> + <value>(746, 312)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_chunks_to_symbols_xx</key> + <param> + <key>id</key> + <value>digital_chunks_to_symbols_xx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>in_type</key> + <value>byte</value> + </param> + <param> + <key>out_type</key> + <value>complex</value> + </param> + <param> + <key>symbol_table</key> + <value>header_mod.points()</value> + </param> + <param> + <key>dimension</key> + <value>1</value> + </param> + <param> + <key>num_ports</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(195, 375)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_chunks_to_symbols_xx</key> + <param> + <key>id</key> + <value>digital_chunks_to_symbols_xx_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>in_type</key> + <value>byte</value> + </param> + <param> + <key>out_type</key> + <value>complex</value> + </param> + <param> + <key>symbol_table</key> + <value>payload_mod.points()</value> + </param> + <param> + <key>dimension</key> + <value>1</value> + </param> + <param> + <key>num_ports</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(195, 450)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_source</key> + <param> + <key>id</key> + <value>virtual_source_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Header Bits</value> + </param> + <param> + <key>_coordinate</key> + <value>(0, 384)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_packet_headergenerator_bb</key> + <param> + <key>id</key> + <value>digital_packet_headergenerator_bb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>header_formatter</key> + <value>header_formatter.formatter()</value> + </param> + <param> + <key>_coordinate</key> + <value>(514, 231)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_repack_bits_bb</key> + <param> + <key>id</key> + <value>blocks_repack_bits_bb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>k</key> + <value>8</value> + </param> + <param> + <key>l</key> + <value>payload_mod.bits_per_symbol()</value> + </param> + <param> + <key>len_tag_key</key> + <value>length_tag_name</value> + </param> + <param> + <key>align_output</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(522, 289)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_sink</key> + <param> + <key>id</key> + <value>header_bits</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Header Bits</value> + </param> + <param> + <key>_coordinate</key> + <value>(748, 231)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_crc32_bb</key> + <param> + <key>id</key> + <value>digital_crc32_bb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>check</key> + <value>False</value> + </param> + <param> + <key>lengthtagname</key> + <value>length_tag_name</value> + </param> + <param> + <key>_coordinate</key> + <value>(242, 223)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_vector_source_x</key> + <param> + <key>id</key> + <value>blocks_vector_source_x_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>byte</value> + </param> + <param> + <key>vector</key> + <value>range(packet_len)</value> + </param> + <param> + <key>tags</key> + <value>tagged_streams.make_lengthtags((packet_len,), (0,), length_tag_name)</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(0, 216)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>fft_len</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>64</value> + </param> + <param> + <key>_coordinate</key> + <value>(181, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>length_tag_name</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>"packet_len"</value> + </param> + <param> + <key>_coordinate</key> + <value>(352, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>packet_len</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>96</value> + </param> + <param> + <key>_coordinate</key> + <value>(476, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>header_mod</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>digital.constellation_bpsk()</value> + </param> + <param> + <key>_coordinate</key> + <value>(567, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>payload_mod</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>digital.constellation_qpsk()</value> + </param> + <param> + <key>_coordinate</key> + <value>(734, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>rolloff</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(898, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>virtual_source</key> + <param> + <key>id</key> + <value>virtual_source_0_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>stream_id</key> + <value>Frame Symbols</value> + </param> + <param> + <key>_coordinate</key> + <value>(1, 654)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_carrier_allocator_cvc</key> + <param> + <key>id</key> + <value>digital_ofdm_carrier_allocator_cvc_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>fft_len</key> + <value>fft_len</value> + </param> + <param> + <key>occupied_carriers</key> + <value>occupied_carriers</value> + </param> + <param> + <key>pilot_carriers</key> + <value>pilot_carriers</value> + </param> + <param> + <key>pilot_symbols</key> + <value>pilot_symbols</value> + </param> + <param> + <key>len_tag_key</key> + <value>length_tag_name</value> + </param> + <param> + <key>_coordinate</key> + <value>(205, 624)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_tagged_stream_mux</key> + <param> + <key>id</key> + <value>blocks_tagged_stream_mux_1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>ninputs</key> + <value>2</value> + </param> + <param> + <key>lengthtagname</key> + <value>length_tag_name</value> + </param> + <param> + <key>vlen</key> + <value>fft_len</value> + </param> + <param> + <key>_coordinate</key> + <value>(445, 600)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>fft_vxx</key> + <param> + <key>id</key> + <value>fft_vxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>fft_size</key> + <value>fft_len</value> + </param> + <param> + <key>forward</key> + <value>False</value> + </param> + <param> + <key>window</key> + <value></value> + </param> + <param> + <key>shift</key> + <value>False</value> + </param> + <param> + <key>nthreads</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(684, 583)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>samp_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>100000</value> + </param> + <param> + <key>_coordinate</key> + <value>(255, 0)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>uhd_usrp_sink</key> + <param> + <key>id</key> + <value>uhd_usrp_sink_0</value> + </param> + <param> + <key>_enabled</key> + <value>False</value> + </param> + <param> + <key>type</key> + <value>fc32</value> + </param> + <param> + <key>otw</key> + <value></value> + </param> + <param> + <key>stream_args</key> + <value></value> + </param> + <param> + <key>dev_addr</key> + <value></value> + </param> + <param> + <key>sync</key> + <value></value> + </param> + <param> + <key>clock_rate</key> + <value>0.0</value> + </param> + <param> + <key>num_mboards</key> + <value>1</value> + </param> + <param> + <key>clock_source0</key> + <value></value> + </param> + <param> + <key>time_source0</key> + <value></value> + </param> + <param> + <key>sd_spec0</key> + <value></value> + </param> + <param> + <key>clock_source1</key> + <value></value> + </param> + <param> + <key>time_source1</key> + <value></value> + </param> + <param> + <key>sd_spec1</key> + <value></value> + </param> + <param> + <key>clock_source2</key> + <value></value> + </param> + <param> + <key>time_source2</key> + <value></value> + </param> + <param> + <key>sd_spec2</key> + <value></value> + </param> + <param> + <key>clock_source3</key> + <value></value> + </param> + <param> + <key>time_source3</key> + <value></value> + </param> + <param> + <key>sd_spec3</key> + <value></value> + </param> + <param> + <key>clock_source4</key> + <value></value> + </param> + <param> + <key>time_source4</key> + <value></value> + </param> + <param> + <key>sd_spec4</key> + <value></value> + </param> + <param> + <key>clock_source5</key> + <value></value> + </param> + <param> + <key>time_source5</key> + <value></value> + </param> + <param> + <key>sd_spec5</key> + <value></value> + </param> + <param> + <key>clock_source6</key> + <value></value> + </param> + <param> + <key>time_source6</key> + <value></value> + </param> + <param> + <key>sd_spec6</key> + <value></value> + </param> + <param> + <key>clock_source7</key> + <value></value> + </param> + <param> + <key>time_source7</key> + <value></value> + </param> + <param> + <key>sd_spec7</key> + <value></value> + </param> + <param> + <key>nchan</key> + <value>1</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>center_freq0</key> + <value>0</value> + </param> + <param> + <key>gain0</key> + <value>0</value> + </param> + <param> + <key>ant0</key> + <value></value> + </param> + <param> + <key>bw0</key> + <value>0</value> + </param> + <param> + <key>center_freq1</key> + <value>0</value> + </param> + <param> + <key>gain1</key> + <value>0</value> + </param> + <param> + <key>ant1</key> + <value></value> + </param> + <param> + <key>bw1</key> + <value>0</value> + </param> + <param> + <key>center_freq2</key> + <value>0</value> + </param> + <param> + <key>gain2</key> + <value>0</value> + </param> + <param> + <key>ant2</key> + <value></value> + </param> + <param> + <key>bw2</key> + <value>0</value> + </param> + <param> + <key>center_freq3</key> + <value>0</value> + </param> + <param> + <key>gain3</key> + <value>0</value> + </param> + <param> + <key>ant3</key> + <value></value> + </param> + <param> + <key>bw3</key> + <value>0</value> + </param> + <param> + <key>center_freq4</key> + <value>0</value> + </param> + <param> + <key>gain4</key> + <value>0</value> + </param> + <param> + <key>ant4</key> + <value></value> + </param> + <param> + <key>bw4</key> + <value>0</value> + </param> + <param> + <key>center_freq5</key> + <value>0</value> + </param> + <param> + <key>gain5</key> + <value>0</value> + </param> + <param> + <key>ant5</key> + <value></value> + </param> + <param> + <key>bw5</key> + <value>0</value> + </param> + <param> + <key>center_freq6</key> + <value>0</value> + </param> + <param> + <key>gain6</key> + <value>0</value> + </param> + <param> + <key>ant6</key> + <value></value> + </param> + <param> + <key>bw6</key> + <value>0</value> + </param> + <param> + <key>center_freq7</key> + <value>0</value> + </param> + <param> + <key>gain7</key> + <value>0</value> + </param> + <param> + <key>ant7</key> + <value></value> + </param> + <param> + <key>bw7</key> + <value>0</value> + </param> + <param> + <key>center_freq8</key> + <value>0</value> + </param> + <param> + <key>gain8</key> + <value>0</value> + </param> + <param> + <key>ant8</key> + <value></value> + </param> + <param> + <key>bw8</key> + <value>0</value> + </param> + <param> + <key>center_freq9</key> + <value>0</value> + </param> + <param> + <key>gain9</key> + <value>0</value> + </param> + <param> + <key>ant9</key> + <value></value> + </param> + <param> + <key>bw9</key> + <value>0</value> + </param> + <param> + <key>center_freq10</key> + <value>0</value> + </param> + <param> + <key>gain10</key> + <value>0</value> + </param> + <param> + <key>ant10</key> + <value></value> + </param> + <param> + <key>bw10</key> + <value>0</value> + </param> + <param> + <key>center_freq11</key> + <value>0</value> + </param> + <param> + <key>gain11</key> + <value>0</value> + </param> + <param> + <key>ant11</key> + <value></value> + </param> + <param> + <key>bw11</key> + <value>0</value> + </param> + <param> + <key>center_freq12</key> + <value>0</value> + </param> + <param> + <key>gain12</key> + <value>0</value> + </param> + <param> + <key>ant12</key> + <value></value> + </param> + <param> + <key>bw12</key> + <value>0</value> + </param> + <param> + <key>center_freq13</key> + <value>0</value> + </param> + <param> + <key>gain13</key> + <value>0</value> + </param> + <param> + <key>ant13</key> + <value></value> + </param> + <param> + <key>bw13</key> + <value>0</value> + </param> + <param> + <key>center_freq14</key> + <value>0</value> + </param> + <param> + <key>gain14</key> + <value>0</value> + </param> + <param> + <key>ant14</key> + <value></value> + </param> + <param> + <key>bw14</key> + <value>0</value> + </param> + <param> + <key>center_freq15</key> + <value>0</value> + </param> + <param> + <key>gain15</key> + <value>0</value> + </param> + <param> + <key>ant15</key> + <value></value> + </param> + <param> + <key>bw15</key> + <value>0</value> + </param> + <param> + <key>center_freq16</key> + <value>0</value> + </param> + <param> + <key>gain16</key> + <value>0</value> + </param> + <param> + <key>ant16</key> + <value></value> + </param> + <param> + <key>bw16</key> + <value>0</value> + </param> + <param> + <key>center_freq17</key> + <value>0</value> + </param> + <param> + <key>gain17</key> + <value>0</value> + </param> + <param> + <key>ant17</key> + <value></value> + </param> + <param> + <key>bw17</key> + <value>0</value> + </param> + <param> + <key>center_freq18</key> + <value>0</value> + </param> + <param> + <key>gain18</key> + <value>0</value> + </param> + <param> + <key>ant18</key> + <value></value> + </param> + <param> + <key>bw18</key> + <value>0</value> + </param> + <param> + <key>center_freq19</key> + <value>0</value> + </param> + <param> + <key>gain19</key> + <value>0</value> + </param> + <param> + <key>ant19</key> + <value></value> + </param> + <param> + <key>bw19</key> + <value>0</value> + </param> + <param> + <key>center_freq20</key> + <value>0</value> + </param> + <param> + <key>gain20</key> + <value>0</value> + </param> + <param> + <key>ant20</key> + <value></value> + </param> + <param> + <key>bw20</key> + <value>0</value> + </param> + <param> + <key>center_freq21</key> + <value>0</value> + </param> + <param> + <key>gain21</key> + <value>0</value> + </param> + <param> + <key>ant21</key> + <value></value> + </param> + <param> + <key>bw21</key> + <value>0</value> + </param> + <param> + <key>center_freq22</key> + <value>0</value> + </param> + <param> + <key>gain22</key> + <value>0</value> + </param> + <param> + <key>ant22</key> + <value></value> + </param> + <param> + <key>bw22</key> + <value>0</value> + </param> + <param> + <key>center_freq23</key> + <value>0</value> + </param> + <param> + <key>gain23</key> + <value>0</value> + </param> + <param> + <key>ant23</key> + <value></value> + </param> + <param> + <key>bw23</key> + <value>0</value> + </param> + <param> + <key>center_freq24</key> + <value>0</value> + </param> + <param> + <key>gain24</key> + <value>0</value> + </param> + <param> + <key>ant24</key> + <value></value> + </param> + <param> + <key>bw24</key> + <value>0</value> + </param> + <param> + <key>center_freq25</key> + <value>0</value> + </param> + <param> + <key>gain25</key> + <value>0</value> + </param> + <param> + <key>ant25</key> + <value></value> + </param> + <param> + <key>bw25</key> + <value>0</value> + </param> + <param> + <key>center_freq26</key> + <value>0</value> + </param> + <param> + <key>gain26</key> + <value>0</value> + </param> + <param> + <key>ant26</key> + <value></value> + </param> + <param> + <key>bw26</key> + <value>0</value> + </param> + <param> + <key>center_freq27</key> + <value>0</value> + </param> + <param> + <key>gain27</key> + <value>0</value> + </param> + <param> + <key>ant27</key> + <value></value> + </param> + <param> + <key>bw27</key> + <value>0</value> + </param> + <param> + <key>center_freq28</key> + <value>0</value> + </param> + <param> + <key>gain28</key> + <value>0</value> + </param> + <param> + <key>ant28</key> + <value></value> + </param> + <param> + <key>bw28</key> + <value>0</value> + </param> + <param> + <key>center_freq29</key> + <value>0</value> + </param> + <param> + <key>gain29</key> + <value>0</value> + </param> + <param> + <key>ant29</key> + <value></value> + </param> + <param> + <key>bw29</key> + <value>0</value> + </param> + <param> + <key>center_freq30</key> + <value>0</value> + </param> + <param> + <key>gain30</key> + <value>0</value> + </param> + <param> + <key>ant30</key> + <value></value> + </param> + <param> + <key>bw30</key> + <value>0</value> + </param> + <param> + <key>center_freq31</key> + <value>0</value> + </param> + <param> + <key>gain31</key> + <value>0</value> + </param> + <param> + <key>ant31</key> + <value></value> + </param> + <param> + <key>bw31</key> + <value>0</value> + </param> + <param> + <key>_coordinate</key> + <value>(578, 746)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_throttle</key> + <param> + <key>id</key> + <value>blocks_throttle_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>samples_per_second</key> + <value>samp_rate</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(579, 823)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_scopesink2</key> + <param> + <key>id</key> + <value>wxgui_scopesink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>Scope Plot</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>v_scale</key> + <value>0</value> + </param> + <param> + <key>v_offset</key> + <value>0</value> + </param> + <param> + <key>t_scale</key> + <value>0</value> + </param> + <param> + <key>ac_couple</key> + <value>False</value> + </param> + <param> + <key>xy_mode</key> + <value>False</value> + </param> + <param> + <key>num_inputs</key> + <value>1</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>trig_mode</key> + <value>gr.gr_TRIG_MODE_AUTO</value> + </param> + <param> + <key>y_axis_label</key> + <value>Counts</value> + </param> + <param> + <key>_coordinate</key> + <value>(761, 800)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>wxgui_fftsink2_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>title</key> + <value>FFT Plot</value> + </param> + <param> + <key>samp_rate</key> + <value>samp_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>0</value> + </param> + <param> + <key>y_per_div</key> + <value>10</value> + </param> + <param> + <key>y_divs</key> + <value>10</value> + </param> + <param> + <key>ref_level</key> + <value>0</value> + </param> + <param> + <key>ref_scale</key> + <value>2.0</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>15</value> + </param> + <param> + <key>peak_hold</key> + <value>False</value> + </param> + <param> + <key>average</key> + <value>False</value> + </param> + <param> + <key>avg_alpha</key> + <value>0</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value></value> + </param> + <param> + <key>grid_pos</key> + <value></value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>freqvar</key> + <value>None</value> + </param> + <param> + <key>_coordinate</key> + <value>(579, 867)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_multiply_const_vxx</key> + <param> + <key>id</key> + <value>blocks_multiply_const_vxx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>const</key> + <value>0.05</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(386, 823)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>blocks_vector_source_x</key> + <param> + <key>id</key> + <value>blocks_vector_source_x_1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>vector</key> + <value>tuple(numpy.array(sync_word1) * numpy.sqrt(2)) + sync_word2</value> + </param> + <param> + <key>tags</key> + <value>tagged_streams.make_lengthtags((2,), (0,), length_tag_name)</value> + </param> + <param> + <key>repeat</key> + <value>True</value> + </param> + <param> + <key>vlen</key> + <value>fft_len</value> + </param> + <param> + <key>_coordinate</key> + <value>(1, 532)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>options</key> + <param> + <key>id</key> + <value>tx_ofdm</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value>OFDM Tx</value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value>Example of an OFDM Transmitter</value> + </param> + <param> + <key>window_size</key> + <value>1280, 1024</value> + </param> + <param> + <key>generate_options</key> + <value>wx_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>run</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>max_nouts</key> + <value>0</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(0, -1)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>digital_ofdm_cyclic_prefixer</key> + <param> + <key>id</key> + <value>digital_ofdm_cyclic_prefixer_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>input_size</key> + <value>fft_len</value> + </param> + <param> + <key>output_size</key> + <value>fft_len+fft_len/4</value> + </param> + <param> + <key>rolloff</key> + <value>rolloff</value> + </param> + <param> + <key>tagname</key> + <value>length_tag_name</value> + </param> + <param> + <key>_coordinate</key> + <value>(86, 800)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sync_word2</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>(0, 0, 0, 0, 0, 1, 1, -1.0, -1, 1.0, 1, 1.0, -1, -1.0, -1, 1.0, 1, -1.0, 1, 1.0, 1, -1.0, -1, -1.0, -1, 1.0, -1, 1.0, -1, 1.0, 1, -1.0, 0, 1.0, 1, -1.0, 1, 1.0, -1, -1.0, 1, -1.0, -1, -1.0, 1, 1.0, 1, -1.0, 1, 1.0, -1, 1.0, -1, -1.0, -1, 1.0, 1, -1.0, 0, 0, 0, 0, 0, 0)</value> + </param> + <param> + <key>_coordinate</key> + <value>(496, 128)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sync_word1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>(0, 0, 0, 0, 0, 0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 0, 0, 0, 0, 0)</value> + </param> + <param> + <key>_coordinate</key> + <value>(352, 128)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>occupied_carriers</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>(range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(329, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>pilot_carriers</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>((-21, -7, 7, 21,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(480, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>header_formatter</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>digital.packet_header_ofdm(occupied_carriers, 1, length_tag_name)</value> + </param> + <param> + <key>_coordinate</key> + <value>(708, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>pilot_symbols</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>((1, 1, 1, -1,),)</value> + </param> + <param> + <key>_coordinate</key> + <value>(601, 64)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>import numpy</value> + </param> + <param> + <key>_coordinate</key> + <value>(237, 93)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_1</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>from gnuradio.digital.utils import tagged_streams</value> + </param> + <param> + <key>_coordinate</key> + <value>(99, 93)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>import random</value> + </param> + <param> + <key>_coordinate</key> + <value>(3, 94)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>blocks_tagged_stream_mux_0</source_block_id> + <sink_block_id>virtual_sink_0_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>virtual_source_0_0</source_block_id> + <sink_block_id>digital_chunks_to_symbols_xx_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>virtual_source_0</source_block_id> + <sink_block_id>digital_chunks_to_symbols_xx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_crc32_bb_0</source_block_id> + <sink_block_id>digital_packet_headergenerator_bb_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_crc32_bb_0</source_block_id> + <sink_block_id>blocks_repack_bits_bb_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_packet_headergenerator_bb_0</source_block_id> + <sink_block_id>header_bits</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_repack_bits_bb_0</source_block_id> + <sink_block_id>virtual_sink_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_vector_source_x_0</source_block_id> + <sink_block_id>digital_crc32_bb_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_chunks_to_symbols_xx_0_0</source_block_id> + <sink_block_id>blocks_tagged_stream_mux_0</sink_block_id> + <source_key>0</source_key> + <sink_key>1</sink_key> + </connection> + <connection> + <source_block_id>digital_chunks_to_symbols_xx_0</source_block_id> + <sink_block_id>blocks_tagged_stream_mux_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> + <sink_block_id>uhd_usrp_sink_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_cyclic_prefixer_0</source_block_id> + <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>digital_ofdm_carrier_allocator_cvc_0</source_block_id> + <sink_block_id>blocks_tagged_stream_mux_1</sink_block_id> + <source_key>0</source_key> + <sink_key>1</sink_key> + </connection> + <connection> + <source_block_id>blocks_tagged_stream_mux_1</source_block_id> + <sink_block_id>fft_vxx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>fft_vxx_0</source_block_id> + <sink_block_id>digital_ofdm_cyclic_prefixer_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>virtual_source_0_0_0</source_block_id> + <sink_block_id>digital_ofdm_carrier_allocator_cvc_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_vector_source_x_1</source_block_id> + <sink_block_id>blocks_tagged_stream_mux_1</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> + <sink_block_id>wxgui_fftsink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_multiply_const_vxx_0</source_block_id> + <sink_block_id>blocks_throttle_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>blocks_throttle_0</source_block_id> + <sink_block_id>wxgui_scopesink2_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-digital/grc/CMakeLists.txt b/gr-digital/grc/CMakeLists.txt index bace20847f..9888247ca2 100644 --- a/gr-digital/grc/CMakeLists.txt +++ b/gr-digital/grc/CMakeLists.txt @@ -18,4 +18,6 @@ # Boston, MA 02110-1301, USA. file(GLOB xml_files "*.xml") -install(FILES ${xml_files} DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "digital_python") +install(FILES ${xml_files} + DESTINATION ${GRC_BLOCKS_DIR} COMPONENT "digital_python" +) diff --git a/gr-digital/grc/digital_block_tree.xml b/gr-digital/grc/digital_block_tree.xml index 36827028e9..32b1fa9427 100644 --- a/gr-digital/grc/digital_block_tree.xml +++ b/gr-digital/grc/digital_block_tree.xml @@ -1,7 +1,6 @@ <?xml version="1.0"?> - <!-- - Copyright 2011 Free Software Foundation, Inc. + Copyright 2011-2013 Free Software Foundation, Inc. This file is part of GNU Radio @@ -27,61 +26,102 @@ ################################################### --> <cat> - <name></name> <!-- Blank for Root Name --> - <cat> - <name>Digital</name> - <block>digital_additive_scrambler_bb</block> - <block>digital_binary_slicer_fb</block> - <block>digital_bytes_to_syms</block> - <block>digital_chunks_to_symbols_xx</block> - <block>digital_clock_recovery_mm_xx</block> - <block>digital_cma_equalizer_cc</block> - <block>digital_constellation_decoder_cb</block> - <block>digital_constellation_receiver_cb</block> - <block>digital_correlate_access_code_bb</block> - <block>digital_costas_loop_cc</block> - <block>digital_descrambler_bb</block> - <block>digital_fll_band_edge_cc</block> - <block>digital_glfsr_source_x</block> - <block>digital_kurtotic_equalizer_cc</block> - <block>digital_lms_dd_equalizer_cc</block> - <block>digital_map_bb</block> - <block>digital_mpsk_receiver_cc</block> - <block>digital_mpsk_snr_est_cc</block> - <block>digital_pfb_clock_sync_xxx</block> - <block>digital_pn_correlator_cc</block> - <block>digital_probe_density_b</block> - <block>digital_probe_mpsk_snr_est_c</block> - <block>digital_scrambler_bb</block> - <block>digital_diff_decoder_bb</block> - <block>digital_diff_encoder_bb</block> - <block>digital_diff_phasor_cc</block> - <block>digital_framer_sink_1</block> - <block>digital_packet_sink</block> - <block>digital_simple_framer</block> - <block>digital_simple_correlator</block> - </cat> - <cat> - <name>Digital Modulators</name> - <block>digital_dxpsk_mod</block> - <block>digital_dxpsk_demod</block> - <block>digital_psk_mod</block> - <block>digital_psk_demod</block> - <block>digital_qam_mod</block> - <block>digital_qam_demod</block> - <block>digital_gmskmod_bc</block> - <block>digital_cpmmod_bc</block> - <block>digital_gmsk_mod</block> - <block>digital_gmsk_demod</block> - </cat> - <cat> - <name>OFDM</name> - <block>digital_ofdm_mod</block> - <block>digital_ofdm_demod</block> - <block>digital_ofdm_cyclic_prefixer</block> - <block>digital_ofdm_frame_acquisition</block> - <block>digital_ofdm_insert_preamble</block> - <block>digital_ofdm_sampler</block> - <block>digital_ofdm_sync_pn</block> - </cat> + <name></name> <!-- Blank for Root Name --> + <cat> + <name>Coding</name> + <block>digital_additive_scrambler_bb</block> + <block>digital_descrambler_bb</block> + <block>digital_scrambler_bb</block> + </cat> + <cat> + <name>Equalizers</name> + <block>digital_cma_equalizer_cc</block> + <block>digital_lms_dd_equalizer_cc</block> + <block>digital_kurtotic_equalizer_cc</block> + </cat> + <cat> + <name>Measurement Tools</name> + <block>digital_mpsk_snr_est_cc</block> + <block>digital_probe_density_b</block> + <block>digital_probe_mpsk_snr_est_c</block> + </cat> + <cat> + <name>Modulators</name> + <block>digital_cpmmod_bc</block> + <block>digital_dxpsk_mod</block> + <block>digital_dxpsk_demod</block> + <block>digital_gfsk_mod</block> + <block>digital_gfsk_demod</block> + <block>digital_gmskmod_bc</block> + <block>digital_gmsk_mod</block> + <block>digital_gmsk_demod</block> + <block>digital_psk_mod</block> + <block>digital_psk_demod</block> + <block>digital_qam_mod</block> + <block>digital_qam_demod</block> + <block>digital_constellation_receiver_cb</block> + </cat> + <cat> + <name>Packet Operators</name> + <block>digital_correlate_access_code_bb</block> + <block>digital_crc32_bb</block> + <block>digital_framer_sink_1</block> + <block>digital_header_payload_demux</block> + <block>digital_packet_headergenerator_bb</block> + <block>digital_packet_headergenerator_bb_default</block> + <block>digital_packet_headerparser_b</block> + <block>digital_packet_headerparser_b_default</block> + <block>digital_packet_sink</block> + <block>digital_simple_framer</block> + <block>digital_simple_correlator</block> + </cat> + <cat> + <name>OFDM</name> + <block>digital_ofdm_mod</block> + <block>digital_ofdm_mod2</block> + <block>digital_ofdm_demod</block> + <block>digital_ofdm_carrier_allocator_cvc</block> + <block>digital_ofdm_chanest_vcvc</block> + <block>digital_ofdm_cyclic_prefixer</block> + <block>digital_ofdm_frame_acquisition</block> + <block>digital_ofdm_frame_equalizer_vcvc</block> + <block>digital_ofdm_insert_preamble</block> + <block>digital_ofdm_rx</block> + <block>digital_ofdm_sampler</block> + <block>digital_ofdm_serializer_vcc</block> + <block>digital_ofdm_sync_pn</block> + <block>digital_ofdm_sync_sc_cfb</block> + <block>digital_ofdm_tx</block> + </cat> + <cat> + <name>Symbol Coding</name> + <block>digital_binary_slicer_fb</block> + <block>digital_bytes_to_syms</block> + <block>digital_chunks_to_symbols_xx</block> + <block>digital_constellation_decoder_cb</block> + <block>digital_constellation_receiver_cb</block> + <block>digital_diff_decoder_bb</block> + <block>digital_diff_encoder_bb</block> + <block>digital_diff_phasor_cc</block> + <block>digital_map_bb</block> + </cat> + <cat> + <name>Synchronizers</name> + <block>digital_clock_recovery_mm_xx</block> + <block>digital_costas_loop_cc</block> + <block>digital_fll_band_edge_cc</block> + <block>digital_mpsk_receiver_cc</block> + <block>digital_pfb_clock_sync_xxx</block> + <block>digital_pn_correlator_cc</block> + </cat> + <cat> + <name>Waveform Generators</name> + <block>digital_glfsr_source_x</block> + </cat> + <cat> + <name>Deprecated</name> + <block>digital_correlate_access_code_bb</block> + <block>digital_simple_framer</block> + <block>digital_simple_correlator</block> + </cat> </cat> diff --git a/gr-digital/grc/digital_crc32_bb.xml b/gr-digital/grc/digital_crc32_bb.xml new file mode 100644 index 0000000000..d60f08f814 --- /dev/null +++ b/gr-digital/grc/digital_crc32_bb.xml @@ -0,0 +1,33 @@ +<block> + <name>Stream CRC32</name> + <key>digital_crc32_bb</key> + <import>from gnuradio import digital</import> + <make>digital.crc32_bb($check, $lengthtagname)</make> + <param> + <name>Mode</name> + <key>check</key> + <type>enum</type> + <option> + <name>Generate CRC</name> + <key>False</key> + </option> + <option> + <name>Check CRC</name> + <key>True</key> + </option> + </param> + <param> + <name>Length tag name</name> + <key>lengthtagname</key> + <value>"packet_len"</value> + <type>string</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-digital/grc/digital_header_payload_demux.xml b/gr-digital/grc/digital_header_payload_demux.xml new file mode 100644 index 0000000000..f5be5dc6e2 --- /dev/null +++ b/gr-digital/grc/digital_header_payload_demux.xml @@ -0,0 +1,94 @@ +<block> + <name>Header/Payload Demux</name> + <key>digital_header_payload_demux</key> + <import>from gnuradio import digital</import> + <make>digital.header_payload_demux($header_len, $items_per_symbol, $guard_interval, $length_tag_key, $trigger_tag_key, $output_symbols, $(type.itemsize))</make> + <param> + <name>Header Length (Symbols)</name> + <key>header_len</key> + <type>int</type> + </param> + <param> + <name>Items per symbol</name> + <key>items_per_symbol</key> + <type>int</type> + </param> + <param> + <name>Guard Interval (items)</name> + <key>guard_interval</key> + <value>0</value> + <type>int</type> + </param> + <param> + <name>Length tag key</name> + <key>length_tag_key</key> + <value>"frame_len"</value> + <type>string</type> + </param> + <param> + <name>Trigger tag key</name> + <key>trigger_tag_key</key> + <value>""</value> + <type>string</type> + </param> + <param> + <name>Output Format</name> + <key>output_symbols</key> + <type>enum</type> + <option> + <name>Items</name> + <key>False</key> + </option> + <option> + <name>Symbols</name> + <key>True</key> + </option> + </param> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>itemsize:gr.sizeof_gr_complex</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>itemsize:gr.sizeof_float</opt> + </option> + <option> + <name>Int</name> + <key>int</key> + <opt>itemsize:gr.sizeof_int</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>itemsize:gr.sizeof_short</opt> + </option> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <sink> + <name>trigger</name> + <type>byte</type> + </sink> + <sink> + <name>header_data</name> + <type>message</type> + </sink> + <source> + <name>out_hdr</name> + <type>$type</type> + <vlen>{True: $items_per_symbol, False: 1}[$output_symbols]</vlen> + </source> + <source> + <name>out_payload</name> + <type>$type</type> + <vlen>{True: $items_per_symbol, False: 1}[$output_symbols]</vlen> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_carrier_allocator_cvc.xml b/gr-digital/grc/digital_ofdm_carrier_allocator_cvc.xml new file mode 100644 index 0000000000..826778ff37 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_carrier_allocator_cvc.xml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<block> + <name>OFDM Carrier Allocator</name> + <key>digital_ofdm_carrier_allocator_cvc</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_carrier_allocator_cvc($fft_len, $occupied_carriers, $pilot_carriers, $pilot_symbols, $len_tag_key)</make> + <param> + <name>FFT length</name> + <key>fft_len</key> + <value>fft_len</value> + <type>int</type> + </param> + <param> + <name>Occupied Carriers</name> + <key>occupied_carriers</key> + <type>raw</type> + </param> + <param> + <name>Pilot Carriers</name> + <key>pilot_carriers</key> + <value>()</value> + <type>raw</type> + </param> + <param> + <name>Pilot Symbols</name> + <key>pilot_symbols</key> + <value>()</value> + <type>raw</type> + </param> + <param> + <name>Length tag key</name> + <key>len_tag_key</key> + <value>"packet_len"</value> + <type>string</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + <vlen>$fft_len</vlen> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_chanest_vcvc.xml b/gr-digital/grc/digital_ofdm_chanest_vcvc.xml new file mode 100644 index 0000000000..ea9855fdb6 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_chanest_vcvc.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> +<block> + <name>OFDM Channel Estimation</name> + <key>digital_ofdm_chanest_vcvc</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_chanest_vcvc($sync_symbol1, $sync_symbol2, $n_data_symbols, $eq_noise_red_len, $max_carr_offset, $force_one_symbol)</make> + <param> + <name>Synchronisation preamble symbol 1</name> + <key>sync_symbol1</key> + <type>complex_vector</type> + </param> + <param> + <name>Synchronisation preamble symbol 2</name> + <key>sync_symbol2</key> + <value>()</value> + <type>complex_vector</type> + </param> + <param> + <name>Number of data symbols</name> + <key>n_data_symbols</key> + <value>1</value> + <type>int</type> + </param> + <param> + <name>Channel taps noise reduction length</name> + <key>eq_noise_red_len</key> + <value>0</value> + <type>int</type> + </param> + <param> + <name>Maximum carrier offset</name> + <key>max_carr_offset</key> + <value>-1</value> + <type>int</type> + </param> + <param> + <name>Force One Synchronisation Symbol</name> + <key>force_one_symbol</key> + <type>enum</type> + <option> + <name>No</name> + <key>False</key> + </option> + <option> + <name>Yes</name> + <key>True</key> + </option> + </param> + <check>len($sync_symbol1)</check> + <check>len($sync_symbol2) == 0 or len($sync_symbol2) == len($sync_symbol1)</check> + <sink> + <name>in</name> + <type>complex</type> + <vlen>len($sync_symbol1)</vlen> + </sink> + <source> + <name>out</name> + <type>complex</type> + <vlen>len($sync_symbol1)</vlen> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml b/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml index d5e5d38940..80bf339cbe 100644 --- a/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml +++ b/gr-digital/grc/digital_ofdm_cyclic_prefixer.xml @@ -29,17 +29,31 @@ <name>OFDM Cyclic Prefixer</name> <key>digital_ofdm_cyclic_prefixer</key> <import>from gnuradio import digital</import> - <make>digital.ofdm_cyclic_prefixer($input_size, $output_size)</make> + <make>digital.ofdm_cyclic_prefixer($input_size, $output_size, $rolloff, $tagname)</make> <param> - <name>Input Size</name> + <name>FFT Length</name> <key>input_size</key> + <value>fft_len</value> <type>int</type> </param> <param> - <name>Output Size</name> + <name>Output Size (FFT length + CP length)</name> <key>output_size</key> + <value>fft_len+fft_len/4</value> <type>int</type> </param> + <param> + <name>Rolloff</name> + <key>rolloff</key> + <value>0</value> + <type>int</type> + </param> + <param> + <name>Length Tag Key</name> + <key>tagname</key> + <value>"frame_len"</value> + <type>string</type> + </param> <sink> <name>in</name> <type>complex</type> diff --git a/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml b/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml new file mode 100644 index 0000000000..330b29a2fb --- /dev/null +++ b/gr-digital/grc/digital_ofdm_frame_equalizer_vcvc.xml @@ -0,0 +1,45 @@ +<block> + <name>OFDM Frame Equalizer</name> + <key>digital_ofdm_frame_equalizer_vcvc</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_frame_equalizer_vcvc($equalizer, $len_tag_key, $propagate_channel_state)</make> + <param> + <name>FFT length</name> + <key>fft_len</key> + <value>fft_len</value> + <type>int</type> + </param> + <param> + <name>Equalizer</name> + <key>equalizer</key> + <type>raw</type> + </param> + <param> + <name>Length Tag Key</name> + <key>len_tag_key</key> + <type>string</type> + </param> + <param> + <name>Propagate Channel State</name> + <key>propagate_channel_state</key> + <type>enum</type> + <option> + <name>Yes</name> + <key>True</key> + </option> + <option> + <name>No</name> + <key>False</key> + </option> + </param> + <sink> + <name>in</name> + <type>complex</type> + <vlen>$fft_len</vlen> + </sink> + <source> + <name>out</name> + <type>complex</type> + <vlen>$fft_len</vlen> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_mod2.xml b/gr-digital/grc/digital_ofdm_mod2.xml new file mode 100644 index 0000000000..f2f69cd5d6 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_mod2.xml @@ -0,0 +1,64 @@ +<block> + <name>OFDM Mod 2</name> + <key>digital_ofdm_mod2</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_mod2(fft_len=$fft_len, + cp_len=$cp_len, + length_tag_name=$length_tag_name, + occupied_carriers=$occupied_carriers, + pilot_carriers=$pilot_carriers, + pilot_symbols=$pilot_symbols, + sync_sequence=$sync_sequence, + ) + </make> + <param> + <name>Cyclic Prefix Length</name> + <key>cp_len</key> + <value>16</value> + <type>int</type> + </param> + <param> + <name>FFT Length</name> + <key>fft_len</key> + <value>64</value> + <type>int</type> + </param> + <param> + <name>Length Tag Name</name> + <key>length_tag_name</key> + <value>length</value> + <type>string</type> + </param> + <param> + <name>Occupied Carriers</name> + <key>occupied_carriers</key> + <value>(range(1, 27) + range(38, 64),)</value> + <type>raw</type> + </param> + <param> + <name>Pilot Carriers</name> + <key>pilot_carriers</key> + <value>((0,),)</value> + <type>raw</type> + </param> + <param> + <name>Pilot Symbols</name> + <key>pilot_symbols</key> + <value>((100,),)</value> + <type>raw</type> + </param> + <param> + <name>Synchronization Sequence</name> + <key>sync_sequence</key> + <value>None</value> + <type>raw</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_rx.xml b/gr-digital/grc/digital_ofdm_rx.xml new file mode 100644 index 0000000000..38222265a7 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_rx.xml @@ -0,0 +1,174 @@ +<?xml version="1.0"?> +<block> + <name>OFDM Receiver</name> + <key>digital_ofdm_rx</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_rx( + fft_len=$fft_len, cp_len=$cp_len, + frame_length_tag_key='frame_'+$packet_len_key, + packet_length_tag_key=$packet_len_key, + #if $occupied_carriers() + occupied_carriers=$occupied_carriers, + #end if + #if $occupied_carriers() + pilot_carriers=$pilot_carriers, + #end if + #if $occupied_carriers() + pilot_symbols=$pilot_symbols, + #end if + #if $sync_word1() + sync_word1=$sync_word1, + #end if + #if $sync_word2() + sync_word2=$sync_word2, + #end if + bps_header=$header_mod.bps, + bps_payload=$payload_mod.bps, + debug_log=$log + )</make> + <param> + <name>FFT Length</name> + <key>fft_len</key> + <value>64</value> + <type>int</type> + </param> + <param> + <name>Cyclic Prefix Length</name> + <key>cp_len</key> + <value>16</value> + <type>int</type> + </param> + <param> + <name>Packet Length Tag Key</name> + <key>packet_len_key</key> + <value>"length"</value> + <type>string</type> + </param> + <param> + <name>Occupied Carriers</name> + <key>occupied_carriers</key> + <value>()</value> + <type>raw</type> + <hide> + #if $occupied_carriers() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Pilot Carriers</name> + <key>pilot_carriers</key> + <value>()</value> + <type>raw</type> + <hide> + #if $pilot_carriers() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Pilot Symbols</name> + <key>pilot_symbols</key> + <value>()</value> + <type>raw</type> + <hide> + #if $pilot_symbols() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Sync Word 1</name> + <key>sync_word1</key> + <value>()</value> + <type>raw</type> + <hide> + #if $sync_word1() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Sync Word 2</name> + <key>sync_word2</key> + <value>()</value> + <type>raw</type> + <hide> + #if $sync_word2() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Header Modulation</name> + <key>header_mod</key> + <type>enum</type> + <option> + <name>BPSK</name> + <key>"BPSK"</key> + <opt>bps:1</opt> + </option> + <option> + <name>QPSK</name> + <key>"QPSK"</key> + <opt>bps:2</opt> + </option> + </param> + <param> + <name>Payload Modulation</name> + <key>payload_mod</key> + <type>enum</type> + <option> + <name>BPSK</name> + <key>"BPSK"</key> + <opt>bps:1</opt> + </option> + <option> + <name>QPSK</name> + <key>"QPSK"</key> + <opt>bps:2</opt> + </option> + <option> + <name>8-PSK</name> + <key>"8-PSK"</key> + <opt>bps:3</opt> + </option> + </param> + <param> + <name>Log Debug Info</name> + <key>log</key> + <value>False</value> + <type>enum</type> + <hide> #if $log then 'none' else 'part'#</hide> + <option> + <name>No</name> + <key>False</key> + </option> + <option> + <name>Yes</name> + <key>True</key> + </option> + </param> + <check>$fft_len > 0</check> + <check>$cp_len > 0</check> + <check>$cp_len < $fft_len</check> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> + diff --git a/gr-digital/grc/digital_ofdm_serializer_vcc.xml b/gr-digital/grc/digital_ofdm_serializer_vcc.xml new file mode 100644 index 0000000000..c7596bbb0d --- /dev/null +++ b/gr-digital/grc/digital_ofdm_serializer_vcc.xml @@ -0,0 +1,50 @@ +<?xml version="1.0"?> +<block> + <name>OFDM Serializer</name> + <key>digital_ofdm_serializer_vcc</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_serializer_vcc($fft_len, $occupied_carriers, $len_tag_key, $packet_len_tag_key, $symbols_skipped, $input_is_shifted)</make> + <param> + <name>FFT length</name> + <key>fft_len</key> + <value>fft_len</value> + <type>int</type> + </param> + <param> + <name>Occupied Carriers</name> + <key>occupied_carriers</key> + <type>raw</type> + </param> + <param> + <name>Length Tag Key</name> + <key>len_tag_key</key> + <type>string</type> + </param> + <param> + <name>Packet Length Tag Key</name> + <key>packet_len_tag_key</key> + <value>""</value> + <type>string</type> + </param> + <param> + <name>Symbols skipped</name> + <key>symbols_skipped</key> + <value>0</value> + <type>int</type> + </param> + <param> + <name>Input is shifted</name> + <key>input_is_shifted</key> + <value>True</value> + <type>bool</type> + </param> + <sink> + <name>in</name> + <type>complex</type> + <vlen>$fft_len</vlen> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_sync_sc_cfb.xml b/gr-digital/grc/digital_ofdm_sync_sc_cfb.xml new file mode 100644 index 0000000000..4705c1027a --- /dev/null +++ b/gr-digital/grc/digital_ofdm_sync_sc_cfb.xml @@ -0,0 +1,44 @@ +<?xml version="1.0"?> +<block> + <name>Schmidl & Cox OFDM synchronisation</name> + <key>digital_ofdm_sync_sc_cfb</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_sync_sc_cfb($fft_len, $cp_len, $use_even_carriers)</make> + <param> + <name>FFT length</name> + <key>fft_len</key> + <type>int</type> + </param> + <param> + <name>Cyclic Prefix length</name> + <key>cp_len</key> + <type>int</type> + </param> + <param> + <name>Preamble Carriers</name> + <key>use_even_carriers</key> + <value>False</value> + <type>enum</type> + <hide>part</hide> + <option> + <name>Odd</name> + <key>False</key> + </option> + <option> + <name>Even</name> + <key>True</key> + </option> + </param> + <sink> + <name>in</name> + <type>complex</type> + </sink> + <source> + <name>freq_offset</name> + <type>float</type> + </source> + <source> + <name>detect</name> + <type>byte</type> + </source> +</block> diff --git a/gr-digital/grc/digital_ofdm_tx.xml b/gr-digital/grc/digital_ofdm_tx.xml new file mode 100644 index 0000000000..034d34a2a5 --- /dev/null +++ b/gr-digital/grc/digital_ofdm_tx.xml @@ -0,0 +1,180 @@ +<?xml version="1.0"?> +<block> + <name>OFDM Transmitter</name> + <key>digital_ofdm_tx</key> + <import>from gnuradio import digital</import> + <make>digital.ofdm_tx( + fft_len=$fft_len, cp_len=$cp_len, + packet_length_tag_key=$packet_len_key, + #if $occupied_carriers() + occupied_carriers=$occupied_carriers, + #end if + #if $occupied_carriers() + pilot_carriers=$pilot_carriers, + #end if + #if $occupied_carriers() + pilot_symbols=$pilot_symbols, + #end if + #if $sync_word1() + sync_word1=$sync_word1, + #end if + #if $sync_word2() + sync_word2=$sync_word2, + #end if + bps_header=$header_mod.bps, + bps_payload=$payload_mod.bps, + rolloff=$rolloff, + debug_log=$log + )</make> + <param> + <name>FFT Length</name> + <key>fft_len</key> + <value>64</value> + <type>int</type> + </param> + <param> + <name>Cyclic Prefix Length</name> + <key>cp_len</key> + <value>16</value> + <type>int</type> + </param> + <param> + <name>Length Tag Name</name> + <key>packet_len_key</key> + <value>length</value> + <type>string</type> + </param> + <param> + <name>Occupied Carriers</name> + <key>occupied_carriers</key> + <value>()</value> + <type>raw</type> + <hide> + #if $occupied_carriers() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Pilot Carriers</name> + <key>pilot_carriers</key> + <value>()</value> + <type>raw</type> + <hide> + #if $pilot_carriers() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Pilot Symbols</name> + <key>pilot_symbols</key> + <value>()</value> + <type>raw</type> + <hide> + #if $pilot_symbols() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Sync Word 1</name> + <key>sync_word1</key> + <value>()</value> + <type>raw</type> + <hide> + #if $sync_word1() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Sync Word 2</name> + <key>sync_word2</key> + <value>()</value> + <type>raw</type> + <hide> + #if $sync_word2() + none + #else + part + #end if + </hide> + </param> + <param> + <name>Header Modulation</name> + <key>header_mod</key> + <type>enum</type> + <option> + <name>BPSK</name> + <key>"BPSK"</key> + <opt>bps:1</opt> + </option> + <option> + <name>QPSK</name> + <key>"QPSK"</key> + <opt>bps:2</opt> + </option> + </param> + <param> + <name>Payload Modulation</name> + <key>payload_mod</key> + <type>enum</type> + <option> + <name>BPSK</name> + <key>"BPSK"</key> + <opt>bps:1</opt> + </option> + <option> + <name>QPSK</name> + <key>"QPSK"</key> + <opt>bps:2</opt> + </option> + <option> + <name>8-PSK</name> + <key>"8-PSK"</key> + <opt>bps:3</opt> + </option> + </param> + <param> + <name>Rolloff length (samples)</name> + <key>rolloff</key> + <value>0</value> + <type>int</type> + </param> + <param> + <name>Log Debug Info</name> + <key>log</key> + <value>False</value> + <type>enum</type> + <hide> #if $log then 'none' else 'part'#</hide> + <option> + <name>No</name> + <key>False</key> + </option> + <option> + <name>Yes</name> + <key>True</key> + </option> + </param> + <check>$fft_len > 0</check> + <check>$cp_len > 0</check> + <check>$cp_len < $fft_len</check> + <check>$rolloff >= 0</check> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>complex</type> + </source> +</block> diff --git a/gr-digital/grc/digital_packet_headergenerator_bb.xml b/gr-digital/grc/digital_packet_headergenerator_bb.xml new file mode 100644 index 0000000000..a0ec14ae80 --- /dev/null +++ b/gr-digital/grc/digital_packet_headergenerator_bb.xml @@ -0,0 +1,19 @@ +<block> + <name>Packet Header Generator</name> + <key>digital_packet_headergenerator_bb</key> + <import>from gnuradio import digital</import> + <make>digital.packet_headergenerator_bb($header_formatter)</make> + <param> + <name>Formatter Object</name> + <key>header_formatter</key> + <type>raw</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> diff --git a/gr-digital/grc/digital_packet_headergenerator_bb_default.xml b/gr-digital/grc/digital_packet_headergenerator_bb_default.xml new file mode 100644 index 0000000000..e89c340bf1 --- /dev/null +++ b/gr-digital/grc/digital_packet_headergenerator_bb_default.xml @@ -0,0 +1,26 @@ +<block> + <name>Packet Header Generator (Default)</name> + <key>digital_packet_headergenerator_bb_default</key> + <import>from gnuradio import digital</import> + <make>digital.packet_headergenerator_bb($header_len, $len_tag_key)</make> + <param> + <name>Header Length</name> + <key>header_len</key> + <type>int</type> + </param> + <param> + <name>Length Tag Name</name> + <key>len_tag_key</key> + <value>"packet_len"</value> + <type>string</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>byte</type> + </source> +</block> + diff --git a/gr-digital/grc/digital_packet_headerparser_b.xml b/gr-digital/grc/digital_packet_headerparser_b.xml new file mode 100644 index 0000000000..bab6bd22ed --- /dev/null +++ b/gr-digital/grc/digital_packet_headerparser_b.xml @@ -0,0 +1,19 @@ +<block> + <name>Packet Header Parser</name> + <key>digital_packet_headerparser_b</key> + <import>from gnuradio import digital</import> + <make>digital.packet_headerparser_b($header_formatter)</make> + <param> + <name>Formatter Object</name> + <key>header_formatter</key> + <type>raw</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>header_data</name> + <type>message</type> + </source> +</block> diff --git a/gr-digital/grc/digital_packet_headerparser_b_default.xml b/gr-digital/grc/digital_packet_headerparser_b_default.xml new file mode 100644 index 0000000000..415f4839f4 --- /dev/null +++ b/gr-digital/grc/digital_packet_headerparser_b_default.xml @@ -0,0 +1,26 @@ +<block> + <name>Packet Header Parser (Default)</name> + <key>digital_packet_headerparser_b_default</key> + <import>from gnuradio import digital</import> + <make>digital.packet_headerparser_b($header_len, $len_tag_key)</make> + <param> + <name>Header Length</name> + <key>header_len</key> + <type>int</type> + </param> + <param> + <name>Length Tag Name</name> + <key>len_tag_key</key> + <value>"packet_len"</value> + <type>string</type> + </param> + <sink> + <name>in</name> + <type>byte</type> + </sink> + <source> + <name>out</name> + <type>message</type> + </source> +</block> + diff --git a/gr-digital/include/CMakeLists.txt b/gr-digital/include/CMakeLists.txt index ad5baec87e..06300cc27b 100644 --- a/gr-digital/include/CMakeLists.txt +++ b/gr-digital/include/CMakeLists.txt @@ -123,6 +123,13 @@ install(FILES digital_scrambler_bb.h digital_simple_framer.h digital_simple_framer_sync.h + digital_ofdm_sync_sc_cfb.h + digital_ofdm_chanest_vcvc.h + digital_crc32_bb.h + digital_ofdm_carrier_allocator_cvc.h + digital_ofdm_equalizer_base.h + digital_ofdm_equalizer_static.h + digital_ofdm_equalizer_simpledfe.h digital_simple_correlator.h DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "digital_devel" diff --git a/gr-digital/include/digital/CMakeLists.txt b/gr-digital/include/digital/CMakeLists.txt new file mode 100644 index 0000000000..1042517294 --- /dev/null +++ b/gr-digital/include/digital/CMakeLists.txt @@ -0,0 +1,40 @@ +# Copyright 2012 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. + +######################################################################## +# generate helper scripts to expand templated files +######################################################################## +include(GrPython) + +######################################################################## +# Install header files +######################################################################## +install(FILES + api.h + ofdm_frame_equalizer_vcvc.h + ofdm_serializer_vcc.h + packet_header_default.h + packet_header_ofdm.h + packet_headergenerator_bb.h + packet_headerparser_b.h + header_payload_demux.h + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/digital + COMPONENT "digital_devel" +) + diff --git a/gr-digital/include/digital/api.h b/gr-digital/include/digital/api.h new file mode 100644 index 0000000000..0912f7e0d4 --- /dev/null +++ b/gr-digital/include/digital/api.h @@ -0,0 +1,33 @@ +/* + * Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_API_H +#define INCLUDED_DIGITAL_API_H + +#include <gruel/attributes.h> + +#ifdef gnuradio_digital_EXPORTS +# define DIGITAL_API __GR_ATTR_EXPORT +#else +# define DIGITAL_API __GR_ATTR_IMPORT +#endif + +#endif /* INCLUDED_DIGITAL_API_H */ diff --git a/gr-digital/include/digital/header_payload_demux.h b/gr-digital/include/digital/header_payload_demux.h new file mode 100644 index 0000000000..1427062d77 --- /dev/null +++ b/gr-digital/include/digital/header_payload_demux.h @@ -0,0 +1,91 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H +#define INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H + +#include <digital/api.h> +#include <gr_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief Header/Payload demuxer. + * \ingroup packet_operators_blk + * + * \details + * This block is designed to handle packets from a bursty transmission. + * Input 0 takes a continuous transmission of samples. + * If used, input 1 is a trigger signal. In this case, a 1 on input 1 + * is a trigger. Otherwise, a tag with the key specified in \p trigger_tag_key + * is used as a trigger (its value is irrelevant). + * + * Until a trigger signal is detected, all samples are dropped onto the floor. + * Once a trigger is detected, a total of \p header_len items are copied to output 0. + * The block then stalls until it receives a message on the message port + * \p header_data. The message must be a PMT dictionary; all key/value pairs are + * copied as tags to the first item of the payload (which is assumed to be the + * first item after the header). + * The value corresponding to the key specified in \p length_tag_key is read + * and taken as the payload length. The payload, together with the header data + * as tags, is then copied to output 1. + * + * If specified, \p guard_interval items are discarded before every symbol. + * This is useful for demuxing bursts of OFDM signals. + * + * Any tags on the input stream are copied to the corresponding output *if* they're + * on an item that is propagated. Note that a tag on the header items is copied to the + * header stream; that means the header-parsing block must handle these tags if they + * should go on the payload. + * A special case are tags on items that make up the guard interval. These are copied + * to the first item of the following symbol. + */ + class DIGITAL_API header_payload_demux : virtual public gr_block + { + public: + typedef boost::shared_ptr<header_payload_demux> sptr; + + /*! + * \param header_len Number of symbols per header + * \param items_per_symbol Number of items per symbol + * \param guard_interval Number of items between two consecutive symbols + * \param length_tag_key Key of the frame length tag + * \param trigger_tag_key Key of the trigger tag + * \param output_symbols Output symbols (true) or items (false)? + * \param itemsize Item size (bytes per item) + */ + static sptr make( + int header_len, + int items_per_symbol, + int guard_interval=0, + const std::string &length_tag_key="frame_len", + const std::string &trigger_tag_key="", + bool output_symbols=false, + size_t itemsize=sizeof(gr_complex) + ); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_H */ + diff --git a/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h b/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h new file mode 100644 index 0000000000..cd1b943f47 --- /dev/null +++ b/gr-digital/include/digital/ofdm_frame_equalizer_vcvc.h @@ -0,0 +1,78 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + + +#ifndef INCLUDED_OFDM_FRAME_EQUALIZER_VCVC_H +#define INCLUDED_OFDM_FRAME_EQUALIZER_VCVC_H + +#include <digital_ofdm_equalizer_base.h> +#include <digital/api.h> +#include <gr_tagged_stream_block.h> + +namespace gr { + namespace digital { + + /*! + * \brief OFDM frame equalizer + * \ingroup ofdm_blk + * + * This does two things: + * First, it removes the coarse carrier offset. If a tag is found on the first + * item with the key 'ofdm_sync_carr_offset', this is interpreted as the coarse + * frequency offset in number of carriers. + * Next, it performs equalization in one or two dimensions on a tagged OFDM frame. + * The actual equalization is done by a ofdm_frame_equalizer object, outside of + * the block. + * + * Note that the tag with the coarse carrier offset is not removed. Blocks + * downstream from this block must not attempt to also correct this offset. + * + * Input: a tagged series of OFDM symbols. + * Output: The same as the input, but equalized and frequency-corrected. + */ + class DIGITAL_API ofdm_frame_equalizer_vcvc : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<ofdm_frame_equalizer_vcvc> sptr; + + /*! + * \param equalizer The equalizer object that will do the actual work + * \param cp_len Length of the cyclic prefix in samples (required to correct the frequency offset) + * \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( + digital_ofdm_equalizer_base_sptr equalizer, + int cp_len, + const std::string &len_tag_key="frame_len", + bool propagate_channel_state=false, + int fixed_frame_len=0 + ); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_OFDM_FRAME_EQUALIZER_VCVC_H */ + diff --git a/gr-digital/include/digital/ofdm_serializer_vcc.h b/gr-digital/include/digital/ofdm_serializer_vcc.h new file mode 100644 index 0000000000..fde2458b6b --- /dev/null +++ b/gr-digital/include/digital/ofdm_serializer_vcc.h @@ -0,0 +1,98 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_H +#define INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_H + +#include <digital/api.h> +#include <gr_tagged_stream_block.h> +#include <digital_ofdm_carrier_allocator_cvc.h> + +namespace gr { + namespace digital { + + /*! + * \brief Serializes complex modulations symbols from OFDM sub-carriers + * \ingroup ofdm_blk + * + * This is the inverse block to the carrier_allocator_cvc. It outputs the + * complex data symbols as a tagged stream, discarding the pilot symbols. + * + * If given, two different tags are parsed: The first key (\p len_tag_key) + * specifies the number of OFDM symbols in the frame at the input. The + * second key (\p packet_len_tag_key) specifies the number of complex symbols + * that are coded into this frame. If given, this second key is then used + * at the output, otherwise, \p len_tag_key is used. + * If both are given, the packet length specifies the maximum number of + * output items, and the frame length specifies the exact number of + * consumed input items. + * + * It is possible to correct a carrier offset in this function by passing + * another tag with said offset. + * + * Input: Complex vectors of length \p fft_len + * Output: Complex scalars, in the same order as specified in occupied_carriers. + */ + class DIGITAL_API ofdm_serializer_vcc : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<ofdm_serializer_vcc> sptr; + + /*! + * \param fft_len FFT length + * \param occupied_carriers See ofdm_carrier_allocator_cvc. + * \param len_tag_key The key of the tag identifying the length of the input frame in OFDM symbols. + * \param packet_len_tag_key The key of the tag identifying the number of complex symbols in this packet. + * \param symbols_skipped If the first symbol is not allocated as in \p occupied_carriers[0], set this + * \param carr_offset_key When this block should correct a carrier offset, specify the tag key of the offset here (not necessary if following an ofdm_frame_equalizer_vcvc) + * \param input_is_shifted If the input has the DC carrier on index 0 (i.e. it is not FFT shifted), set this to false + */ + static sptr make( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::string &len_tag_key="frame_len", + const std::string &packet_len_tag_key="", + int symbols_skipped=0, + const std::string &carr_offset_key="", + bool input_is_shifted=true + ); + + /*! + * \param allocator The carrier allocator block of which this shall be the inverse + * \param packet_len_tag_key The key of the tag identifying the number of complex symbols in this packet. + * \param symbols_skipped If the first symbol is not allocated as in \p occupied_carriers[0], set this + * \param carr_offset_key When this block should correct a carrier offset, specify the tag key of the offset here (not necessary if following an ofdm_frame_equalizer_vcvc) + * \param input_is_shifted If the input has the DC carrier on index 0 (i.e. it is not FFT shifted), set this to false + */ + static sptr make( + const digital_ofdm_carrier_allocator_cvc_sptr &allocator, + const std::string &packet_len_tag_key="", + int symbols_skipped=0, + const std::string &carr_offset_key="", + bool input_is_shifted=true + ); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_H */ + diff --git a/gr-digital/include/digital/packet_header_default.h b/gr-digital/include/digital/packet_header_default.h new file mode 100644 index 0000000000..e4c994593f --- /dev/null +++ b/gr-digital/include/digital/packet_header_default.h @@ -0,0 +1,113 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_PACKET_HEADER_DEFAULT_H +#define INCLUDED_DIGITAL_PACKET_HEADER_DEFAULT_H + +#include <gr_tags.h> +#include <digital/api.h> +#include <boost/enable_shared_from_this.hpp> + +namespace gr { + namespace digital { + + /*! + * \brief Default header formatter for digital packet transmission. + * \ingroup packet_operators_blk + * + * \details + * For bursty/packetized digital transmission, packets are usually prepended + * with a packet header, containing the number of bytes etc. + * This class is not a block, but a tool to create these packet header. + * + * This is a default packet header (see header_formatter()) for a description + * on the header format). To create other header, derive packet header creator + * classes from this function. + * + * gr::digital::packet_headergenerator_bb uses header generators derived from + * this class to create packet headers from data streams. + */ + class DIGITAL_API packet_header_default : public boost::enable_shared_from_this<gr::digital::packet_header_default> + { + public: + typedef boost::shared_ptr<packet_header_default> sptr; + + packet_header_default( + long header_len, + const std::string &len_tag_key="packet_len", + const std::string &num_tag_key="packet_num", + int bits_per_byte=1); + ~packet_header_default(); + + sptr base() { return shared_from_this(); }; + sptr formatter() { return shared_from_this(); }; + + void set_header_num(unsigned header_num) { d_header_number = header_num; }; + long header_len() { return d_header_len; }; + pmt::pmt_t len_tag_key() { return d_len_tag_key; }; + + /*! + * \brief Encodes the header information in the given tags into bits and places them into \p out + * + * Uses the following header format: + * Bits 0-11: The packet length (what was stored in the tag with key \p len_tag_key) + * Bits 12-27: The header number (counts up everytime this function is called) + * Bit 28: Even parity bit + * All other bits: Are set to zero + * + * If the header length is smaller than 29, bits are simply left out. For this + * reason, they always start with the LSB. + */ + virtual bool header_formatter( + long packet_len, + unsigned char *out, + const std::vector<gr_tag_t> &tags=std::vector<gr_tag_t>() + ); + + /*! + * \brief Inverse function to header_formatter(). + * + * Reads the bit stream in \p header and writes a corresponding tag into \p tags. + */ + virtual bool header_parser( + const unsigned char *header, + std::vector<gr_tag_t> &tags); + + static sptr make( + long header_len, + const std::string &len_tag_key="packet_len", + const std::string &num_tag_key="packet_num", + int bits_per_byte=1); + + protected: + long d_header_len; + pmt::pmt_t d_len_tag_key; + pmt::pmt_t d_num_tag_key; + int d_bits_per_byte; + unsigned d_header_number; + unsigned d_mask; + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_PACKET_HEADER_DEFAULT_H */ + diff --git a/gr-digital/include/digital/packet_header_ofdm.h b/gr-digital/include/digital/packet_header_ofdm.h new file mode 100644 index 0000000000..ea55a4510a --- /dev/null +++ b/gr-digital/include/digital/packet_header_ofdm.h @@ -0,0 +1,104 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H +#define INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H + +#include <vector> +#include <digital/api.h> +#include <digital/packet_header_default.h> + +namespace gr { + namespace digital { + + /*! + * \brief Header utility for OFDM signals. + * \ingroup ofdm_blk + * + */ + class DIGITAL_API packet_header_ofdm : public packet_header_default + { + public: + typedef boost::shared_ptr<packet_header_ofdm> sptr; + + packet_header_ofdm( + const std::vector<std::vector<int> > &occupied_carriers, + int n_syms, + const std::string &len_tag_key, + const std::string &frame_len_tag_key, + const std::string &num_tag_key, + int bits_per_header_sym, + int bits_per_payload_sym); + ~packet_header_ofdm(); + + /*! + * \brief Inverse function to header_formatter(). + * + * Does the same as packet_header_default::header_parser(), but + * adds another tag that stores the number of OFDM symbols in the + * packet. + * Note that there is usually no linear connection between the number + * of OFDM symbols and the packet length, because, a packet might + * finish mid-OFDM-symbol. + */ + bool header_parser( + const unsigned char *header, + std::vector<gr_tag_t> &tags); + + /*! + * \param occupied_carriers See carrier allocator + * \param n_syms The number of OFDM symbols the header should be (usually 1) + * \param len_tag_key The tag key used for the packet length (number of bytes) + * \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. + * \param bits_per_payload_sym Bits per complex symbol in the payload. This is + * required to figure out how many OFDM symbols + * are necessary to encode the given number of + * bytes. + */ + static sptr make( + const std::vector<std::vector<int> > &occupied_carriers, + int n_syms, + const std::string &len_tag_key="packet_len", + const std::string &frame_len_tag_key="frame_len", + const std::string &num_tag_key="packet_num", + int bits_per_header_sym=1, + int bits_per_payload_sym=1 + ); + + + protected: + pmt::pmt_t d_frame_len_tag_key; + const std::vector<std::vector<int> > d_occupied_carriers; //!< Which carriers/symbols carry data + int d_syms_per_set; //!< Helper variable: Total number of elements in d_occupied_carriers + int d_bits_per_payload_sym; + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_PACKET_HEADER_OFDM_H */ + diff --git a/gr-digital/include/digital/packet_headergenerator_bb.h b/gr-digital/include/digital/packet_headergenerator_bb.h new file mode 100644 index 0000000000..426f49dee5 --- /dev/null +++ b/gr-digital/include/digital/packet_headergenerator_bb.h @@ -0,0 +1,73 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_PACKET_HEADERGENERATOR_BB_H +#define INCLUDED_PACKET_HEADERGENERATOR_BB_H + +#include <digital/api.h> +#include <gr_tagged_stream_block.h> +#include <digital/packet_header_default.h> + +namespace gr { + namespace digital { + + /*! + * \brief Generates a header for a tagged, streamed packet. + * \ingroup packet_operators_blk + * + * \details + * Input: A tagged stream. This is consumed entirely, it is not appended + * to the output stream. + * Output: An tagged stream containing the header. The details on the header + * are set in a header formatter object (of type packet_header_default + * or a subclass thereof). If only a number of bits is specified, a + * default header is generated (see packet_header_default). + */ + class DIGITAL_API packet_headergenerator_bb : virtual public gr_tagged_stream_block + { + public: + typedef boost::shared_ptr<packet_headergenerator_bb> sptr; + + /* \param header_formatter A header formatter object. + * \param len_tag_key Length tag key. Note that for header generation, + * it is irrelevant which tag names are set in the + * formatter object, only this value is relevant! + */ + static sptr make( + const packet_header_default::sptr &header_formatter, + const std::string &len_tag_key="packet_len" + ); + + /* \param header_len If this value is given, a packet_header_default + * object is used to generate the header. This is + * the number of bits per header. + * \param len_tag_key Length tag key. + */ + static sptr make( + long header_len, + const std::string &len_tag_key = "packet_len"); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_PACKET_HEADERGENERATOR_BB_H */ + diff --git a/gr-digital/include/digital/packet_headerparser_b.h b/gr-digital/include/digital/packet_headerparser_b.h new file mode 100644 index 0000000000..cdf76f1209 --- /dev/null +++ b/gr-digital/include/digital/packet_headerparser_b.h @@ -0,0 +1,71 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_H +#define INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_H + +#include <digital/api.h> +#include <gr_sync_block.h> +#include <digital/packet_header_default.h> + +namespace gr { + namespace digital { + + /*! + * \brief Post header metadata as a PMT + * \ingroup packet_operators_blk + * + * \details + * In a sense, this is the inverse block to packet_headergenerator_bb. + * The difference is, the parsed header is not output as a stream, + * but as a PMT dictionary, which is published to message port with + * the id "header_data". + * + * The dictionary consists of the tags created by the header formatter + * object. You should be able to use the exact same formatter object + * as used on the Tx side in the packet_headergenerator_bb. + * + * If only a header length is given, this block uses the default header + * format. + */ + class DIGITAL_API packet_headerparser_b : virtual public gr_sync_block + { + public: + typedef boost::shared_ptr<packet_headerparser_b> sptr; + + /*! + * \param header_formatter Header object. This should be the same as used for + * packet_headergenerator_bb. + */ + static sptr make(const gr::digital::packet_header_default::sptr &header_formatter); + + /*! + * \param header_len Number of bytes per header + * \param len_tag_key Length Tag Key + */ + static sptr make(long header_len, const std::string &len_tag_key); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_H */ + diff --git a/gr-digital/include/digital_additive_scrambler_bb.h b/gr-digital/include/digital_additive_scrambler_bb.h index f1d0113e96..cb87e059b9 100644 --- a/gr-digital/include/digital_additive_scrambler_bb.h +++ b/gr-digital/include/digital_additive_scrambler_bb.h @@ -34,23 +34,16 @@ digital_make_additive_scrambler_bb(int mask, int seed, int len, int count=0); /*! + * \ingroup coding_blk * Scramble an input stream using an LFSR. This block works on the LSB only * of the input data stream, i.e., on an "unpacked binary" stream, and * produces the same format on its output. * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * \param count Number of bits after which shift register is reset, 0=never - * * The scrambler works by XORing the incoming bit stream by the output of * the LFSR. Optionally, after 'count' bits have been processed, the shift * register is reset to the seed value. This allows processing fixed length * vectors of samples. - * - * \ingroup coding_blk */ - class DIGITAL_API digital_additive_scrambler_bb : public gr_sync_block { friend DIGITAL_API digital_additive_scrambler_bb_sptr @@ -61,6 +54,14 @@ class DIGITAL_API digital_additive_scrambler_bb : public gr_sync_block int d_count; int d_bits; + /*! + * Build an additive scrambler block. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + * \param count Number of bits after which shift register is reset, 0=never + */ digital_additive_scrambler_bb(int mask, int seed, int len, int count); diff --git a/gr-digital/include/digital_binary_slicer_fb.h b/gr-digital/include/digital_binary_slicer_fb.h index 35a7380fb9..914c7a195d 100644 --- a/gr-digital/include/digital_binary_slicer_fb.h +++ b/gr-digital/include/digital_binary_slicer_fb.h @@ -33,9 +33,9 @@ DIGITAL_API digital_binary_slicer_fb_sptr digital_make_binary_slicer_fb (); /*! * \brief slice float binary symbol outputting 1 bit output - * \ingroup converter_blk - * \ingroup digital + * \ingroup symbol_coding_blk * + * \details * x < 0 --> 0 * x >= 0 --> 1 */ diff --git a/gr-digital/include/digital_bytes_to_syms.h b/gr-digital/include/digital_bytes_to_syms.h index 3062366b95..7b4b4412d0 100644 --- a/gr-digital/include/digital_bytes_to_syms.h +++ b/gr-digital/include/digital_bytes_to_syms.h @@ -32,8 +32,9 @@ DIGITAL_API digital_bytes_to_syms_sptr digital_make_bytes_to_syms(); /*! * \brief Convert stream of bytes to stream of +/- 1 symbols - * \ingroup converter_blk + * \ingroup symbol_coding_blk * + * \details * input: stream of bytes; output: stream of float * * This block is deprecated. diff --git a/gr-digital/include/digital_chunks_to_symbols_XX.h.t b/gr-digital/include/digital_chunks_to_symbols_XX.h.t index 92b7c94d58..dbcd05967a 100644 --- a/gr-digital/include/digital_chunks_to_symbols_XX.h.t +++ b/gr-digital/include/digital_chunks_to_symbols_XX.h.t @@ -36,8 +36,9 @@ digital_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D /*! * \brief Map a stream of symbol indexes (unpacked bytes or shorts) to stream of float or complex constellation points in D dimensions (D = 1 by default) - * \ingroup converter_blk + * \ingroup symbol_coding_blk * + * \details * input: stream of @I_TYPE@; output: stream of @O_TYPE@ * * out[n D + k] = symbol_table[in[n] D + k], k=0,1,...,D-1 diff --git a/gr-digital/include/digital_clock_recovery_mm_cc.h b/gr-digital/include/digital_clock_recovery_mm_cc.h index a2577d5378..b5c125d24e 100644 --- a/gr-digital/include/digital_clock_recovery_mm_cc.h +++ b/gr-digital/include/digital_clock_recovery_mm_cc.h @@ -41,9 +41,9 @@ digital_make_clock_recovery_mm_cc (float omega, float gain_omega, /*! * \brief Mueller and Müller (M&M) based clock recovery block with complex input, complex output. - * \ingroup sync_blk - * \ingroup digital + * \ingroup synchronizers_blk * + * \details * This implements the Mueller and Müller (M&M) discrete-time * error-tracking synchronizer. * diff --git a/gr-digital/include/digital_clock_recovery_mm_ff.h b/gr-digital/include/digital_clock_recovery_mm_ff.h index 36749553fb..bec570be85 100644 --- a/gr-digital/include/digital_clock_recovery_mm_ff.h +++ b/gr-digital/include/digital_clock_recovery_mm_ff.h @@ -41,9 +41,9 @@ digital_make_clock_recovery_mm_ff (float omega, float gain_omega, /*! * \brief Mueller and Müller (M&M) based clock recovery block with float input, float output. - * \ingroup sync_blk - * \ingroup digital + * \ingroup synchronizers_blk * + * \details * This implements the Mueller and Müller (M&M) discrete-time error-tracking synchronizer. * * See "Digital Communication Receivers: Synchronization, Channel diff --git a/gr-digital/include/digital_cma_equalizer_cc.h b/gr-digital/include/digital_cma_equalizer_cc.h index 79e84ca4b3..606f13f9a0 100644 --- a/gr-digital/include/digital_cma_equalizer_cc.h +++ b/gr-digital/include/digital_cma_equalizer_cc.h @@ -36,9 +36,9 @@ digital_make_cma_equalizer_cc(int num_taps, float modulus, float mu, int sps); /*! * \brief Implements constant modulus adaptive filter on complex stream - * \ingroup eq_blk - * \ingroup digital + * \ingroup equalizers_blk * + * \details * The error value and tap update equations (for p=2) can be found in: * * "D. Godard, "Self-Recovering Equalization and Carrier Tracking in diff --git a/gr-digital/include/digital_constellation.h b/gr-digital/include/digital_constellation.h index 9d34d951ff..5503fb46f1 100644 --- a/gr-digital/include/digital_constellation.h +++ b/gr-digital/include/digital_constellation.h @@ -278,6 +278,80 @@ class DIGITAL_API digital_constellation_rect : public digital_constellation_sect }; +/************************************************************/ +/* digital_constellation_expl_rect */ +/************************************************************/ + +/*! + * \brief Rectangular digital constellation + * \ingroup digital + * + * Only implemented for 1-(complex)dimensional constellation. + * + * Constellation space is divided into rectangular sectors. Each + * sector is associated with the nearest constellation point. + * + * This class is different from constellation_rect in that the mapping + * from sector to constellation point is explicitly passed into the + * constructor as sector_values. Usually we do not need this, since + * we want each sector to be automatically mapped to the closest + * constellation point, however sometimes it's nice to have the + * flexibility. + */ + +class digital_constellation_expl_rect; +typedef boost::shared_ptr<digital_constellation_expl_rect> digital_constellation_expl_rect_sptr; + +// public constructor +DIGITAL_API digital_constellation_expl_rect_sptr +digital_make_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values +); + +class DIGITAL_API digital_constellation_expl_rect : public digital_constellation_rect +{ + public: + + digital_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values + ); + + protected: + unsigned int calc_sector_value (unsigned int sector) { + return d_sector_values[sector]; + } + + private: + std::vector<unsigned int> d_sector_values; + + friend DIGITAL_API digital_constellation_expl_rect_sptr + digital_make_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values + ); + +}; + /************************************************************/ /* digital_constellation_psk */ diff --git a/gr-digital/include/digital_constellation_decoder_cb.h b/gr-digital/include/digital_constellation_decoder_cb.h index cce3a564f3..2f85cc5a0e 100644 --- a/gr-digital/include/digital_constellation_decoder_cb.h +++ b/gr-digital/include/digital_constellation_decoder_cb.h @@ -36,9 +36,7 @@ digital_make_constellation_decoder_cb (digital_constellation_sptr constellation) /*! * \brief Constellation Decoder - * \ingroup coding_blk - * \ingroup digital - * + * \ingroup symbol_coding_blk */ class DIGITAL_API digital_constellation_decoder_cb : public gr_block { diff --git a/gr-digital/include/digital_constellation_receiver_cb.h b/gr-digital/include/digital_constellation_receiver_cb.h index 92c31311f7..264e009515 100644 --- a/gr-digital/include/digital_constellation_receiver_cb.h +++ b/gr-digital/include/digital_constellation_receiver_cb.h @@ -42,10 +42,10 @@ digital_make_constellation_receiver_cb (digital_constellation_sptr constellation /*! * \brief This block does fine-phase and frequency locking and decision making. - * \ingroup sync_blk - * \ingroup demod_blk - * \ingroup digital + * \ingroup symbol_coding_blk + * \ingroup modulators_blk * + * \details * The phase and frequency synchronization are based on a Costas loop * that finds the error of the incoming signal point compared to its * nearest constellation point. The frequency and phase of the NCO are diff --git a/gr-digital/include/digital_correlate_access_code_bb.h b/gr-digital/include/digital_correlate_access_code_bb.h index 8095dd4090..0a7ca50a17 100644 --- a/gr-digital/include/digital_correlate_access_code_bb.h +++ b/gr-digital/include/digital_correlate_access_code_bb.h @@ -39,9 +39,10 @@ digital_make_correlate_access_code_bb (const std::string &access_code, int thres /*! * \brief Examine input for specified access code, one bit at a time. - * \ingroup sync_blk - * \ingroup digital + * \ingroup packet_operators_blk + * \ingroup deprecated_blk * + * \details * input: stream of bits, 1 bit per input byte (data in LSB) * output: stream of bits, 2 bits per output byte (data in LSB, flag in next higher bit) * diff --git a/gr-digital/include/digital_costas_loop_cc.h b/gr-digital/include/digital_costas_loop_cc.h index 4aab22fb45..67cfd6d5a5 100644 --- a/gr-digital/include/digital_costas_loop_cc.h +++ b/gr-digital/include/digital_costas_loop_cc.h @@ -28,13 +28,21 @@ #include <gri_control_loop.h> #include <stdexcept> #include <fstream> +#include <digital_api.h> + +class digital_costas_loop_cc; +typedef boost::shared_ptr<digital_costas_loop_cc> digital_costas_loop_cc_sptr; + +DIGITAL_API digital_costas_loop_cc_sptr +digital_make_costas_loop_cc (float loop_bw, int order + ) throw (std::invalid_argument); /*! * \brief A Costas loop carrier recovery module. - * \ingroup sync_blk - * \ingroup digital + * \ingroup synchronizers_blk * + * \details * The Costas loop locks to the center frequency of a signal and * downconverts it to baseband. The second (order=2) order loop is * used for BPSK where the real part of the output signal is the @@ -49,31 +57,6 @@ * processing, pp. 20-36, 2002. * * http://rfdesign.com/images/archive/0102Feigin20.pdf - * - * \param loop_bw internal 2nd order loop bandwidth (~ 2pi/100) - * \param order the loop order, either 2, 4, or 8 - */ - -#include <digital_api.h> - -class digital_costas_loop_cc; -typedef boost::shared_ptr<digital_costas_loop_cc> digital_costas_loop_cc_sptr; - - -DIGITAL_API digital_costas_loop_cc_sptr -digital_make_costas_loop_cc (float loop_bw, int order - ) throw (std::invalid_argument); - - -/*! - * \brief Carrier tracking PLL for QPSK - * \ingroup sync_blk - * input: complex; output: complex - * <br>The Costas loop can have two output streams: - * stream 1 is the baseband I and Q; - * stream 2 is the normalized frequency of the loop - * - * \p order must be 2, 4, or 8. */ class DIGITAL_API digital_costas_loop_cc : public gr_sync_block, public gri_control_loop { @@ -83,6 +66,16 @@ class DIGITAL_API digital_costas_loop_cc : public gr_sync_block, public gri_cont int d_order; + /*! + * \brief Carrier tracking PLL for QPSK + * input: complex; output: complex + * <br>The Costas loop can have two output streams: + * stream 1 is the baseband I and Q; + * stream 2 is the normalized frequency of the loop + * + * \param loop_bw internal 2nd order loop bandwidth (~ 2pi/100) + * \param order the loop order, either 2, 4, or 8 + */ digital_costas_loop_cc (float loop_bw, int order ) throw (std::invalid_argument); diff --git a/gr-digital/include/digital_cpmmod_bc.h b/gr-digital/include/digital_cpmmod_bc.h index f0f11ee30e..acc304b9c9 100644 --- a/gr-digital/include/digital_cpmmod_bc.h +++ b/gr-digital/include/digital_cpmmod_bc.h @@ -42,25 +42,9 @@ digital_make_cpmmod_bc(int type, float h, /*! * \brief Generic CPM modulator + * \ingroup modulators_blk * - * \ingroup modulation_blk - * \ingroup digital - * - * \param type The modulation type. Can be one of LREC, LRC, LSRC, TFM - * or GAUSSIAN. See gr_cpm::phase_response() for a - * detailed description. - * \param h The modulation index. \f$ h \cdot \pi\f$ is the maximum - * phase change that can occur between two symbols, i.e., if - * you only send ones, the phase will increase by \f$ h \cdot - * \pi\f$ every \p samples_per_sym samples. Set this to 0.5 - * for Minimum Shift Keying variants. - * \param samples_per_sym Samples per symbol. - * \param L The length of the phase duration in symbols. For L=1, this - * yields full- response CPM symbols, for L > 1, - * partial-response. - * \param beta For LSRC, this is the rolloff factor. For Gaussian - * pulses, this is the 3 dB time-bandwidth product. - * + * \details * Examples: * - Setting h = 0.5, L = 1, type = LREC yields MSK. * - Setting h = 0.5, type = GAUSSIAN and beta = 0.3 yields GMSK @@ -85,6 +69,24 @@ class DIGITAL_API digital_cpmmod_bc : public gr_hier_block2 gr_frequency_modulator_fc_sptr d_fm; protected: + /*! + * Build a generic CPM modulator block. + * + * \param type The modulation type. Can be one of LREC, LRC, LSRC, TFM + * or GAUSSIAN. See gr_cpm::phase_response() for a + * detailed description. + * \param h The modulation index. \f$ h \cdot \pi\f$ is the maximum + * phase change that can occur between two symbols, i.e., if + * you only send ones, the phase will increase by \f$ h \cdot + * \pi\f$ every \p samples_per_sym samples. Set this to 0.5 + * for Minimum Shift Keying variants. + * \param samples_per_sym Samples per symbol. + * \param L The length of the phase duration in symbols. For L=1, this + * yields full- response CPM symbols, for L > 1, + * partial-response. + * \param beta For LSRC, this is the rolloff factor. For Gaussian + * pulses, this is the 3 dB time-bandwidth product. + */ digital_cpmmod_bc(gr_cpm::cpm_type type, float h, unsigned samples_per_sym, unsigned L, double beta); diff --git a/gr-digital/include/digital_crc32_bb.h b/gr-digital/include/digital_crc32_bb.h new file mode 100644 index 0000000000..0aae26fad6 --- /dev/null +++ b/gr-digital/include/digital_crc32_bb.h @@ -0,0 +1,68 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + + +#ifndef INCLUDED_DIGITAL_CRC32_BB_H +#define INCLUDED_DIGITAL_CRC32_BB_H + +#include <digital_api.h> +#include <gr_tagged_stream_block.h> + +class digital_crc32_bb; + +typedef boost::shared_ptr<digital_crc32_bb> digital_crc32_bb_sptr; + +DIGITAL_API digital_crc32_bb_sptr digital_make_crc32_bb (bool check=false, const std::string& lengthtagname="packet_len"); + +/*! + * \brief Byte-stream CRC block + * \ingroup packet_operators_blk + * + * \details + * Input: stream of bytes, which form a packet. The first byte of the packet + * has a tag with key "length" and the value being the number of bytes in the + * packet. + * + * Output: The same bytes as incoming, but trailing a CRC32 of the packet. + * The tag is re-set to the new length. + */ +class DIGITAL_API digital_crc32_bb : public gr_tagged_stream_block +{ + private: + friend DIGITAL_API digital_crc32_bb_sptr digital_make_crc32_bb (bool check, const std::string& lengthtagname); + + bool d_check; + + digital_crc32_bb(bool check, const std::string& lengthtagname); + + public: + ~digital_crc32_bb(); + + int calculate_output_stream_length(const std::vector<int> &ninput_items); + + int work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_DIGITAL_CRC32_BB_H */ + diff --git a/gr-digital/include/digital_descrambler_bb.h b/gr-digital/include/digital_descrambler_bb.h index d503102a9e..112d9afb32 100644 --- a/gr-digital/include/digital_descrambler_bb.h +++ b/gr-digital/include/digital_descrambler_bb.h @@ -33,17 +33,11 @@ DIGITAL_API digital_descrambler_bb_sptr digital_make_descrambler_bb(int mask, int seed, int len); /*! + * \ingroup coding_blk * Descramble an input stream using an LFSR. This block works on the LSB only * of the input data stream, i.e., on an "unpacked binary" stream, and * produces the same format on its output. - * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * - * \ingroup coding_blk */ - class DIGITAL_API digital_descrambler_bb : public gr_sync_block { friend DIGITAL_API digital_descrambler_bb_sptr @@ -51,6 +45,13 @@ class DIGITAL_API digital_descrambler_bb : public gr_sync_block gr::analog::lfsr d_lfsr; + /*! + * Build a descrambler block. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + */ digital_descrambler_bb(int mask, int seed, int len); public: diff --git a/gr-digital/include/digital_diff_decoder_bb.h b/gr-digital/include/digital_diff_decoder_bb.h index 928035d0e7..25e5a3fec4 100644 --- a/gr-digital/include/digital_diff_decoder_bb.h +++ b/gr-digital/include/digital_diff_decoder_bb.h @@ -34,8 +34,9 @@ digital_make_diff_decoder_bb(unsigned int modulus); /*! * \brief y[0] = (x[0] - x[-1]) % M - * \ingroup coding_blk + * \ingroup symbol_coding_blk * + * \details * Uses current and previous symbols and the alphabet modulus to * perform differential decoding. */ diff --git a/gr-digital/include/digital_diff_encoder_bb.h b/gr-digital/include/digital_diff_encoder_bb.h index d4be69cadd..4f7d6f0bed 100644 --- a/gr-digital/include/digital_diff_encoder_bb.h +++ b/gr-digital/include/digital_diff_encoder_bb.h @@ -34,8 +34,9 @@ digital_make_diff_encoder_bb(unsigned int modulus); /*! * \brief y[0] = (x[0] + y[-1]) % M - * \ingroup coding_blk + * \ingroup symbol_coding_blk * + * \details * Uses current and previous symbols and the alphabet modulus to * perform differential encoding. */ diff --git a/gr-digital/include/digital_diff_phasor_cc.h b/gr-digital/include/digital_diff_phasor_cc.h index 32a2464b28..f35867fa14 100644 --- a/gr-digital/include/digital_diff_phasor_cc.h +++ b/gr-digital/include/digital_diff_phasor_cc.h @@ -26,21 +26,21 @@ #include <digital_api.h> #include <gr_sync_block.h> +class digital_diff_phasor_cc; +typedef boost::shared_ptr<digital_diff_phasor_cc> digital_diff_phasor_cc_sptr; + +DIGITAL_API digital_diff_phasor_cc_sptr digital_make_diff_phasor_cc(); + /*! * \brief Differential decoding based on phase change. - * \ingroup coding_blk + * \ingroup symbol_coding_blk * + * \details * Uses the phase difference between two symbols to determine the * output symbol: * * out[i] = in[i] * conj(in[i-1]); */ -class digital_diff_phasor_cc; -typedef boost::shared_ptr<digital_diff_phasor_cc> digital_diff_phasor_cc_sptr; - -DIGITAL_API digital_diff_phasor_cc_sptr digital_make_diff_phasor_cc(); - - class DIGITAL_API digital_diff_phasor_cc : public gr_sync_block { friend DIGITAL_API digital_diff_phasor_cc_sptr diff --git a/gr-digital/include/digital_fll_band_edge_cc.h b/gr-digital/include/digital_fll_band_edge_cc.h index 68083bbaeb..906c004813 100644 --- a/gr-digital/include/digital_fll_band_edge_cc.h +++ b/gr-digital/include/digital_fll_band_edge_cc.h @@ -44,10 +44,9 @@ digital_make_fll_band_edge_cc(float samps_per_sym, /*! * \class digital_fll_band_edge_cc * \brief Frequency Lock Loop using band-edge filters + * \ingroup synchronizers_blk * - * \ingroup general - * \ingroup digital - * + * \details * The frequency lock loop derives a band-edge filter that covers the * upper and lower bandwidths of a digitally-modulated signal. The * bandwidth range is determined by the excess bandwidth (e.g., diff --git a/gr-digital/include/digital_framer_sink_1.h b/gr-digital/include/digital_framer_sink_1.h index bb82bf5a73..6edf1a66a5 100644 --- a/gr-digital/include/digital_framer_sink_1.h +++ b/gr-digital/include/digital_framer_sink_1.h @@ -35,8 +35,9 @@ digital_make_framer_sink_1(gr_msg_queue_sptr target_queue); /*! * \brief Given a stream of bits and access_code flags, assemble packets. - * \ingroup sink_blk + * \ingroup packet_operators_blk * + * \details * input: stream of bytes from gr_correlate_access_code_bb * output: none. Pushes assembled packet into target queue * diff --git a/gr-digital/include/digital_glfsr_source_b.h b/gr-digital/include/digital_glfsr_source_b.h index 92e5e81f5c..29d6040d14 100644 --- a/gr-digital/include/digital_glfsr_source_b.h +++ b/gr-digital/include/digital_glfsr_source_b.h @@ -38,14 +38,6 @@ digital_make_glfsr_source_b(int degree, bool repeat=true, /*! * \brief Galois LFSR pseudo-random source * \ingroup source_blk - * - * \param degree Degree of shift register must be in [1, 32]. If mask - * is 0, the degree determines a default mask (see - * digital_impl_glfsr.cc for the mapping). - * \param repeat Set to repeat sequence. - * \param mask Allows a user-defined bit mask for indexes of the shift - * register to feed back. - * \param seed Initial setting for values in shift register. */ class DIGITAL_API digital_glfsr_source_b : public gr_sync_block { @@ -60,6 +52,17 @@ class DIGITAL_API digital_glfsr_source_b : public gr_sync_block unsigned int d_index; unsigned int d_length; + /*! + * Build a Galois LFSR pseudo-random source generating block. + * + * \param degree Degree of shift register must be in [1, 32]. If mask + * is 0, the degree determines a default mask (see + * digital_impl_glfsr.cc for the mapping). + * \param repeat Set to repeat sequence. + * \param mask Allows a user-defined bit mask for indexes of the shift + * register to feed back. + * \param seed Initial setting for values in shift register. + */ digital_glfsr_source_b(int degree, bool repeat, int mask, int seed); diff --git a/gr-digital/include/digital_glfsr_source_f.h b/gr-digital/include/digital_glfsr_source_f.h index 77d7b0f741..eb5e9554b3 100644 --- a/gr-digital/include/digital_glfsr_source_f.h +++ b/gr-digital/include/digital_glfsr_source_f.h @@ -37,15 +37,7 @@ digital_make_glfsr_source_f(int degree, bool repeat=true, /*! * \brief Galois LFSR pseudo-random source generating float outputs -1.0 - 1.0. - * \ingroup source_blk - * - * \param degree Degree of shift register must be in [1, 32]. If mask - * is 0, the degree determines a default mask (see - * digital_impl_glfsr.cc for the mapping). - * \param repeat Set to repeat sequence. - * \param mask Allows a user-defined bit mask for indexes of the shift - * register to feed back. - * \param seed Initial setting for values in shift register. + * \ingroup waveform_generators_blk */ class DIGITAL_API digital_glfsr_source_f : public gr_sync_block { @@ -60,6 +52,17 @@ class DIGITAL_API digital_glfsr_source_f : public gr_sync_block unsigned int d_index; unsigned int d_length; + /*! + * Build a Galois LFSR pseudo-random source generating block. + * + * \param degree Degree of shift register must be in [1, 32]. If mask + * is 0, the degree determines a default mask (see + * digital_impl_glfsr.cc for the mapping). + * \param repeat Set to repeat sequence. + * \param mask Allows a user-defined bit mask for indexes of the shift + * register to feed back. + * \param seed Initial setting for values in shift register. + */ digital_glfsr_source_f(int degree, bool repeat, int mask, int seed); diff --git a/gr-digital/include/digital_gmskmod_bc.h b/gr-digital/include/digital_gmskmod_bc.h index 9f378c8a70..a13cb19aa7 100644 --- a/gr-digital/include/digital_gmskmod_bc.h +++ b/gr-digital/include/digital_gmskmod_bc.h @@ -36,15 +36,9 @@ digital_make_gmskmod_bc(unsigned samples_per_sym=2, /*! * \brief GMSK modulator + * \ingroup modulators_blk * - * \ingroup modulation_blk - * \ingroup digital - * - * \param samples_per_sym Samples per symbol. - * \param bt The 3 dB time-bandwidth product. - * \param L The length of the phase duration in symbols. The Gaussian - * pulse is truncated after L symbols. - * + * \details * The input of this block are symbols from an M-ary alphabet * +/-1, +/-3, ..., +/-(M-1). Usually, M = 2 and therefore, the * valid inputs are +/-1. @@ -55,6 +49,14 @@ class DIGITAL_API digital_gmskmod_bc : public digital_cpmmod_bc { friend DIGITAL_API digital_gmskmod_bc_sptr digital_make_gmskmod_bc(unsigned samples_per_sym, double bt, unsigned L); + /*! + * Build a GMSK modulator block. + * + * \param samples_per_sym Samples per symbol. + * \param bt The 3 dB time-bandwidth product. + * \param L The length of the phase duration in symbols. The Gaussian + * pulse is truncated after L symbols. + */ digital_gmskmod_bc(unsigned samples_per_sym, double bt, unsigned L); }; diff --git a/gr-digital/include/digital_kurtotic_equalizer_cc.h b/gr-digital/include/digital_kurtotic_equalizer_cc.h index fed88c3741..254f92db63 100644 --- a/gr-digital/include/digital_kurtotic_equalizer_cc.h +++ b/gr-digital/include/digital_kurtotic_equalizer_cc.h @@ -36,9 +36,9 @@ digital_make_kurtotic_equalizer_cc(int num_taps, float mu); /*! * \brief Implements a kurtosis-based adaptive equalizer on complex stream - * \ingroup eq_blk - * \ingroup digital + * \ingroup equalizers_blk * + * \details * "Y. Guo, J. Zhao, Y. Sun, "Sign kurtosis maximization based blind * equalization algorithm," IEEE Conf. on Control, Automation, * Robotics and Vision, Vol. 3, Dec. 2004, pp. 2052 - 2057." diff --git a/gr-digital/include/digital_lms_dd_equalizer_cc.h b/gr-digital/include/digital_lms_dd_equalizer_cc.h index 56871fa678..25918ffe19 100644 --- a/gr-digital/include/digital_lms_dd_equalizer_cc.h +++ b/gr-digital/include/digital_lms_dd_equalizer_cc.h @@ -36,9 +36,9 @@ DIGITAL_API digital_lms_dd_equalizer_cc_sptr digital_make_lms_dd_equalizer_cc (i /*! * \brief Least-Mean-Square Decision Directed Equalizer (complex in/out) - * \ingroup eq_blk - * \ingroup digital + * \ingroup equalizers_blk * + * \details * This block implements an LMS-based decision-directed equalizer. * It uses a set of weights, w, to correlate against the inputs, u, * and a decisions is then made from this output. The error diff --git a/gr-digital/include/digital_map_bb.h b/gr-digital/include/digital_map_bb.h index 4aca66fbe1..047cbceb8d 100644 --- a/gr-digital/include/digital_map_bb.h +++ b/gr-digital/include/digital_map_bb.h @@ -33,8 +33,9 @@ digital_make_map_bb(const std::vector<int> &map); /*! * \brief output[i] = map[input[i]] - * \ingroup coding_blk + * \ingroup symbol_coding_blk * + * \details * This block maps an incoming signal to the value in the map. * The block expects that the incoming signal has a maximum * value of len(map)-1. diff --git a/gr-digital/include/digital_mpsk_receiver_cc.h b/gr-digital/include/digital_mpsk_receiver_cc.h index 1f11a26b64..e883f3757a 100644 --- a/gr-digital/include/digital_mpsk_receiver_cc.h +++ b/gr-digital/include/digital_mpsk_receiver_cc.h @@ -46,10 +46,9 @@ digital_make_mpsk_receiver_cc (unsigned int M, float theta, /*! * \brief This block takes care of receiving M-PSK modulated signals * through phase, frequency, and symbol synchronization. - * \ingroup sync_blk - * \ingroup demod_blk - * \ingroup digital + * \ingroup synchronizers_blk * + * \details * This block takes care of receiving M-PSK modulated signals through * phase, frequency, and symbol synchronization. It performs carrier * frequency and phase locking as well as symbol timing recovery. It @@ -77,9 +76,7 @@ digital_make_mpsk_receiver_cc (unsigned int M, float theta, * optimized decision algorithms for BPSK and QPKS, but 8PSK uses * another brute force computation against all possible symbols. The * modifications to the M&M used here reduce self-noise. - * */ - class DIGITAL_API digital_mpsk_receiver_cc : public gr_block, public gri_control_loop { public: diff --git a/gr-digital/include/digital_mpsk_snr_est_cc.h b/gr-digital/include/digital_mpsk_snr_est_cc.h index 2cbd98bab8..5edba5c418 100644 --- a/gr-digital/include/digital_mpsk_snr_est_cc.h +++ b/gr-digital/include/digital_mpsk_snr_est_cc.h @@ -34,9 +34,10 @@ digital_make_mpsk_snr_est_cc(snr_est_type_t type, int tag_nsamples=10000, double alpha=0.001); -//! \brief A block for computing SNR of a signal. -/*! \ingroup snr_blk +/*! \brief A block for computing SNR of a signal. + * \ingroup measurement_tools_blk * + * \details * This block can be used to monitor and retrieve estimations of the * signal SNR. It is designed to work in a flowgraph and passes all * incoming data along to its output. diff --git a/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h b/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h new file mode 100644 index 0000000000..c1efcead22 --- /dev/null +++ b/gr-digital/include/digital_ofdm_carrier_allocator_cvc.h @@ -0,0 +1,116 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + + +#ifndef INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H +#define INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H + +#include <digital_api.h> +#include <gr_tagged_stream_block.h> + +class digital_ofdm_carrier_allocator_cvc; +typedef boost::shared_ptr<digital_ofdm_carrier_allocator_cvc> digital_ofdm_carrier_allocator_cvc_sptr; + +/* + * \param occupied_carriers A vector of vectors of indexes. Example: if + * occupied_carriers = ((1, 2, 3), (1, 2, 4)), the first + * three input symbols will be mapped to carriers 1, 2 + * and 3. After that, a new OFDM symbol is started. The next + * three input symbols will be placed onto carriers 1, 2 + * and 4 of the second OFDM symbol. The allocation then + * starts from the beginning. + * Order matters! The first input symbol is always mapped + * onto occupied_carriers[0][0]. + * \param pilot_carriers The position of the pilot symbols. Same as occupied_carriers, + * but the actual symbols are taken from pilot_symbols instead + * of the input stream. + * \param pilot_symbols The pilot symbols which are placed onto the pilot carriers. + * pilot_symbols[0][0] is placed onto the first OFDM symbol, on + * carrier index pilot_carriers[0][0] etc. + * \param len_tag_key The key of the tag identifying the length of the input packet. + */ +DIGITAL_API digital_ofdm_carrier_allocator_cvc_sptr +digital_make_ofdm_carrier_allocator_cvc ( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + const std::string &len_tag_key = "packet_len"); + +/*! + * \brief Create frequency domain OFDM symbols from complex values, add pilots. + * \ingroup ofdm_blk + * + * This block turns a stream of complex, scalar modulation symbols into vectors + * which are the input for an IFFT in an OFDM transmitter. It also supports the + * possibility of placing pilot symbols onto the carriers. + * + * The carriers can be allocated freely, if a carrier is not allocated, it is set + * to zero. This allows doing OFDMA-style carrier allocations. + * + * Input: A tagged stream of complex scalars. The first item must have a tag + * containing the number of complex symbols in this frame. + * Output: A tagged stream of complex vectors of length fft_len. This can directly + * be connected to an FFT block. Make sure to set this block to 'reverse' + * for the IFFT and to deactivate FFT shifting. + * + * Carrier indexes are always such that index 0 is the DC carrier (note: you should + * not allocate this carrier). The carriers below the DC carrier are either indexed + * with negative numbers, or with indexes larger than fft_len/2. Index -1 and index + * fft_len-1 both identify the carrier below the DC carrier. + * + */ +class DIGITAL_API digital_ofdm_carrier_allocator_cvc : public gr_tagged_stream_block +{ + private: + friend DIGITAL_API digital_ofdm_carrier_allocator_cvc_sptr digital_make_ofdm_carrier_allocator_cvc (int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key); + + digital_ofdm_carrier_allocator_cvc(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key); + + //! FFT length + const int d_fft_len; + //! Which carriers/symbols carry data + std::vector<std::vector<int> > d_occupied_carriers; + //! Which carriers/symbols carry pilots symbols + std::vector<std::vector<int> > d_pilot_carriers; + //! Value of said pilot symbols + const std::vector<std::vector<gr_complex> > d_pilot_symbols; + int d_symbols_per_set; + + protected: + int calculate_output_stream_length(const gr_vector_int &ninput_items); + + public: + ~digital_ofdm_carrier_allocator_cvc(); + + std::string len_tag_key() { return d_length_tag_key_str; }; + + const int fft_len() { return d_fft_len; }; + std::vector<std::vector<int> > occupied_carriers() { return d_occupied_carriers; }; + + int work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_DIGITAL_OFDM_CARRIER_ALLOCATOR_CVC_H */ + diff --git a/gr-digital/include/digital_ofdm_chanest_vcvc.h b/gr-digital/include/digital_ofdm_chanest_vcvc.h new file mode 100644 index 0000000000..afea16994c --- /dev/null +++ b/gr-digital/include/digital_ofdm_chanest_vcvc.h @@ -0,0 +1,135 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H +#define INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H + +#include <digital_api.h> +#include <gr_block.h> + +class digital_ofdm_chanest_vcvc; + +typedef boost::shared_ptr<digital_ofdm_chanest_vcvc> digital_ofdm_chanest_vcvc_sptr; + +/* + * \param sync_symbol1 First synchronisation symbol in the frequency domain. Its length must be + * the FFT length. For Schmidl & Cox synchronisation, every second sub-carrier + * has to be zero. + * \param sync_symbol2 Second synchronisation symbol in the frequency domain. Must be equal to + * the FFT length, or zero length if only one synchronisation symbol is used. + * Using this symbol is how synchronisation is described in [1]. Leaving this + * empty forces us to interpolate the equalizer taps. + * If you are using an unusual sub-carrier configuration (e.g. because of OFDMA), + * this sync symbol is used to identify the active sub-carriers. If you only + * have one synchronisation symbol, set the active sub-carriers to a non-zero + * value in here, and also set \p force_one_sync_symbol parameter to true. + * \param n_data_symbols The number of data symbols following each set of synchronisation symbols. + * Must be at least 1. + * \param eq_noise_red_len If non-zero, noise reduction for the equalizer taps is done according + * to [2]. In this case, it is the channel influence time in number of + * samples. A good value is usually the length of the cyclic prefix. + * \param max_carr_offset Limit the number of sub-carriers the frequency offset can maximally be. + * Leave this zero to try all possibilities. + * \param force_one_sync_symbol See \p sync_symbol2. + */ +DIGITAL_API digital_ofdm_chanest_vcvc_sptr +digital_make_ofdm_chanest_vcvc ( + const std::vector<gr_complex> &sync_symbol1, + const std::vector<gr_complex> &sync_symbol2, + int n_data_symbols, + int eq_noise_red_len=0, + int max_carr_offset=-1, + bool force_one_sync_symbol=false); + +/*! + * \brief Estimate channel and coarse frequency offset for OFDM from preambles + * \ingroup ofdm_blk + * \ingroup syncronizers_blk + * + * Input: OFDM symbols (in frequency domain). The first one (or two) symbols are expected + * to be synchronisation symbols, which are used to estimate the coarse freq offset + * and the initial equalizer taps (these symbols are removed from the stream). + * The following \p n_data_symbols are passed through unmodified (the actual equalisation + * must be done elsewhere). + * Output: The data symbols, without the synchronisation symbols. + * The first data symbol passed through has two tags: + * 'ofdm_sync_carr_offset' (integer), the coarse frequency offset as number of carriers, + * and 'ofdm_sync_eq_taps' (complex vector). + * Any tags attached to the synchronisation symbols are attached to the first data + * symbol. All other tags are propagated as expected. + * + * Note: The vector on ofdm_sync_eq_taps is already frequency-corrected, whereas the rest is not. + * + * This block assumes the frequency offset is even (i.e. an integer multiple of 2). + * + * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM", + * Communications, IEEE Transactions on, 1997. + * [2] K.D. Kammeyer, "Nachrichtenuebertragung," Chapter. 16.3.2. + */ +class DIGITAL_API digital_ofdm_chanest_vcvc : public gr_block +{ + private: + friend DIGITAL_API digital_ofdm_chanest_vcvc_sptr digital_make_ofdm_chanest_vcvc (const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol); + + int d_fft_len; //! FFT length + int d_n_data_syms; //! Number of data symbols following the sync symbol(s) + int d_n_sync_syms; //! Number of sync symbols (1 or 2) + //! 0 if no noise reduction is done for the initial channel state estimation. Otherwise, the maximum length of the channel delay in samples. + int d_eq_noise_red_len; + //! Is sync_symbol1 if d_n_sync_syms == 1, otherwise sync_symbol2. Used as a reference symbol to estimate the channel. + std::vector<gr_complex> d_ref_sym; + //! If d_n_sync_syms == 2 this is used as a differential correlation vector (called 'v' in [1]). + std::vector<gr_complex> d_corr_v; + //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset + std::vector<float> d_known_symbol_diffs; + //! If d_n_sync_syms == 1 we use this instead of d_corr_v to estimate the coarse freq. offset (temp. variable) + std::vector<float> d_new_symbol_diffs; + //! The index of the first carrier with data (index 0 is not DC here, but the lowest frequency) + int d_first_active_carrier; + //! The index of the last carrier with data + int d_last_active_carrier; + //! If true, the channel estimation must be interpolated + bool d_interpolate; + //! Maximum carrier offset (negative value!) + int d_max_neg_carr_offset; + //! Maximum carrier offset (positive value!) + int d_max_pos_carr_offset; + + + digital_ofdm_chanest_vcvc(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol); + + //! Calculate the coarse frequency offset in number of carriers + int get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2); + //! Estimate the channel (phase and amplitude offset per carrier) + void get_chan_taps(const gr_complex *sync_sym1, const gr_complex *sync_sym2, int carr_offset, std::vector<gr_complex> &taps); + + public: + ~digital_ofdm_chanest_vcvc(); + + void forecast (int noutput_items, gr_vector_int &ninput_items_required); + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_DIGITAL_OFDM_CHANEST_VCVC_H */ + diff --git a/gr-digital/include/digital_ofdm_cyclic_prefixer.h b/gr-digital/include/digital_ofdm_cyclic_prefixer.h index 1b9682bb35..e6c36b4c14 100644 --- a/gr-digital/include/digital_ofdm_cyclic_prefixer.h +++ b/gr-digital/include/digital_ofdm_cyclic_prefixer.h @@ -24,36 +24,72 @@ #define INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H #include <digital_api.h> -#include <gr_sync_interpolator.h> -#include <stdio.h> +#include <gr_tagged_stream_block.h> class digital_ofdm_cyclic_prefixer; typedef boost::shared_ptr<digital_ofdm_cyclic_prefixer> digital_ofdm_cyclic_prefixer_sptr; -DIGITAL_API digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); +/*! + * \param input_size FFT length (i.e. length of the OFDM symbols) + * \param output_size FFT length + cyclic prefix length (in samples) + * \param rolloff_len Length of the rolloff flank in samples + * \param len_tag_key For framed processing the key of the length tag + */ +DIGITAL_API digital_ofdm_cyclic_prefixer_sptr +digital_make_ofdm_cyclic_prefixer (size_t input_size, + size_t output_size, + int rolloff_len=0, + const std::string &len_tag_key=""); /*! - * \brief adds a cyclic prefix vector to an input size long ofdm - * symbol(vector) and converts vector to a stream output_size long. + * \brief Adds a cyclic prefix and performs pulse shaping on OFDM symbols. * \ingroup ofdm_blk + * + * Input: OFDM symbols (in the time domain, i.e. after the IFFT). Optionally, + * entire frames can be processed. In this case, \p len_tag_key must be + * specified which holds the key of the tag that denotes how + * many OFDM symbols are in a frame. + * Output: A stream of (scalar) complex symbols, which include the cyclic prefix + * and the pulse shaping. + * Note: If complete frames are processed, and \p rolloff_len is greater + * than zero, the final OFDM symbol is followed by the delay line of + * the pulse shaping. + * + * The pulse shape is a raised cosine in the time domain. */ -class DIGITAL_API digital_ofdm_cyclic_prefixer : public gr_sync_interpolator +class DIGITAL_API digital_ofdm_cyclic_prefixer : public gr_tagged_stream_block { friend DIGITAL_API digital_ofdm_cyclic_prefixer_sptr - digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); + digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key); + protected: - digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); + digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size, int rolloff_len, const std::string &len_tag_key); + + //! Return the number of complex samples from the number of OFDM symbols (includes rolloff) + int calculate_output_stream_length(const gr_vector_int &ninput_items); public: - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + private: - size_t d_input_size; + size_t d_fft_len; + //! FFT length + CP length in samples size_t d_output_size; + //! Length of the cyclic prefix in samples + int d_cp_size; + //! Length of pulse rolloff in samples + int d_rolloff_len; + //! Buffers the up-flank (at the beginning of the cyclic prefix) + std::vector<float> d_up_flank; + //! Buffers the down-flank (which trails the symbol) + std::vector<float> d_down_flank; + std::vector<gr_complex> d_delay_line; // We do this explicitly to avoid outputting zeroes (i.e. no history!) }; #endif /* INCLUDED_DIGITAL_OFDM_CYCLIC_PREFIXER_H */ + diff --git a/gr-digital/include/digital_ofdm_equalizer_base.h b/gr-digital/include/digital_ofdm_equalizer_base.h new file mode 100644 index 0000000000..2fc5cf52c3 --- /dev/null +++ b/gr-digital/include/digital_ofdm_equalizer_base.h @@ -0,0 +1,100 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H +#define INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H + +#include <digital_api.h> +#include <gr_tags.h> +#include <gr_complex.h> +#include <boost/enable_shared_from_this.hpp> + +class digital_ofdm_equalizer_base; +typedef boost::shared_ptr<digital_ofdm_equalizer_base> digital_ofdm_equalizer_base_sptr; + +class digital_ofdm_equalizer_1d_pilots; +typedef boost::shared_ptr<digital_ofdm_equalizer_1d_pilots> digital_ofdm_equalizer_1d_pilots_sptr; + +/* \brief Base class for implementation details of frequency-domain OFDM equalizers. + * \ingroup ofdm_blk + * \ingroup equalizers_blk + * + */ +class DIGITAL_API digital_ofdm_equalizer_base : public boost::enable_shared_from_this<digital_ofdm_equalizer_base> +{ + protected: + int d_fft_len; + + public: + digital_ofdm_equalizer_base(int fft_len); + ~digital_ofdm_equalizer_base(); + + virtual void reset() = 0; + virtual void equalize( + gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()) = 0; + virtual void get_channel_state(std::vector<gr_complex> &taps) = 0; + int fft_len() { return d_fft_len; }; + digital_ofdm_equalizer_base_sptr base() { return shared_from_this(); }; +}; + + +/* \brief Base class for implementation details of 1-dimensional OFDM FDEs which use pilot tones. + * \ingroup digital + * + */ +class DIGITAL_API digital_ofdm_equalizer_1d_pilots : public digital_ofdm_equalizer_base +{ + protected: + //! If \p d_occupied_carriers[k][l] is true, symbol k, carrier l is carrying data. + // (this is a different format than occupied_carriers!) + std::vector<bool> d_occupied_carriers; + //! If \p d_pilot_carriers[k][l] is true, symbol k, carrier l is carrying a pilot symbol. + // (this is a different format than pilot_carriers!) + std::vector<std::vector<bool> > d_pilot_carriers; + //! If \p d_pilot_carriers[k][l] is true, d_pilot_symbols[k][l] is its tx'd value. + // (this is a different format than pilot_symbols!) + std::vector<std::vector<gr_complex> > d_pilot_symbols; + //! In case the frame doesn't begin with OFDM symbol 0, this is the index of the first symbol + int d_symbols_skipped; + //! The current position in the set of pilot symbols + int d_pilot_carr_set; + //! Vector of length d_fft_len saving the current channel state (on the occupied carriers) + std::vector<gr_complex> d_channel_state; + + public: + digital_ofdm_equalizer_1d_pilots( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted); + ~digital_ofdm_equalizer_1d_pilots(); + + void reset(); + void get_channel_state(std::vector<gr_complex> &taps); +}; + +#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_BASE_H */ + diff --git a/gr-digital/include/digital_ofdm_equalizer_simpledfe.h b/gr-digital/include/digital_ofdm_equalizer_simpledfe.h new file mode 100644 index 0000000000..b8dec4833e --- /dev/null +++ b/gr-digital/include/digital_ofdm_equalizer_simpledfe.h @@ -0,0 +1,126 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H +#define INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H + +#include <digital_api.h> +#include <digital_constellation.h> +#include <digital_ofdm_equalizer_base.h> + +class digital_ofdm_equalizer_simpledfe; +typedef boost::shared_ptr<digital_ofdm_equalizer_simpledfe> digital_ofdm_equalizer_simpledfe_sptr; + +/* + * \param fft_len FFT length + * \param constellation The constellation object describing the modulation used + * on the subcarriers (e.g. QPSK). This is used to decode + * the individual symbols. + * \param occupied_carriers List of occupied carriers, see ofdm_carrier_allocator + * for a description. + * \param pilot_carriers Position of pilot symbols, see ofdm_carrier_allocator + * for a description. + * \param pilot_symbols Value of pilot symbols, see ofdm_carrier_allocator + * for a description. + * \param alpha Averaging coefficient (in a nutshell, if \f$H_{i,k}\f$ is the channel + * state for carrier i and symbol k, + * \f$H_{i,k+1} = \alpha H_{i,k} + (1 - \alpha) H_{i,k+1}\f$. Make this + * larger if there's more noise, but keep in mind that larger values + * of alpha mean slower response to channel changes). + * \param symbols_skipped Starting position within occupied_carriers and pilot_carriers. + * If the first symbol of the frame was removed (e.g. to decode the + * header), set this make sure the pilot symbols are correctly + * identified. + * \param input_is_shifted Set this to false if the input signal is not shifted, i.e. + * the first input items is on the DC carrier. + * Note that a lot of the OFDM receiver blocks operate on shifted + * signals! + */ +DIGITAL_API digital_ofdm_equalizer_simpledfe_sptr +digital_make_ofdm_equalizer_simpledfe( + int fft_len, + const digital_constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + float alpha = 0.1, + bool input_is_shifted = true); + +/* \brief Simple decision feedback equalizer for OFDM. + * \ingroup ofdm_blk + * \ingroup equalizers_blk + * + * Equalizes an OFDM signal symbol by symbol using knowledge of the + * complex modulations symbols. + * For every symbol, the following steps are performed: + * - On every sub-carrier, decode the modulation symbol + * - Use the difference between the decoded symbol and the received symbol + * to update the channel state on this carrier + * - Whenever a pilot symbol is found, it uses the known pilot symbol to + * update the channel state. + * + * This equalizer makes a lot of assumptions: + * - The initial channel state is good enough to decode the first + * symbol without error (unless the first symbol only consists of pilot + * tones) + * - The channel changes only very slowly, such that the channel state + * from one symbol is enough to decode the next + * - SNR low enough that equalization will always suffice to correctly + * decode a symbol + * If these assumptions are not met, the most common error is that the + * channel state is estimated incorrectly during equalization; after that, + * all subsequent symbols will be completely wrong. + * + * Note that the equalized symbols are *exact points* on the constellation. + * This means soft information of the modulation symbols is lost after the + * equalization, which is suboptimal for channel codes that use soft decision. + * + */ +class DIGITAL_API digital_ofdm_equalizer_simpledfe : public digital_ofdm_equalizer_1d_pilots +{ + public: + digital_ofdm_equalizer_simpledfe( + int fft_len, + const digital_constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + float alpha = 0.1, + bool input_is_shifted = true); + + ~digital_ofdm_equalizer_simpledfe(); + + void equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); + + private: + digital_constellation_sptr d_constellation; + //! Averaging coefficient + float d_alpha; + +}; + +#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_SIMPLEDFE_H */ + diff --git a/gr-digital/include/digital_ofdm_equalizer_static.h b/gr-digital/include/digital_ofdm_equalizer_static.h new file mode 100644 index 0000000000..dd8d48aadb --- /dev/null +++ b/gr-digital/include/digital_ofdm_equalizer_static.h @@ -0,0 +1,97 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H +#define INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H + +#include <digital_api.h> +#include <digital_constellation.h> +#include <digital_ofdm_equalizer_base.h> + +class digital_ofdm_equalizer_static; +typedef boost::shared_ptr<digital_ofdm_equalizer_static> digital_ofdm_equalizer_static_sptr; + +/* + * \param fft_len FFT length + * \param occupied_carriers List of occupied carriers, see ofdm_carrier_allocator + * for a description. + * \param pilot_carriers Position of pilot symbols, see ofdm_carrier_allocator + * for a description. + * \param pilot_symbols Value of pilot symbols, see ofdm_carrier_allocator + * for a description. + * \param symbols_skipped Starting position within occupied_carriers and pilot_carriers. + * If the first symbol of the frame was removed (e.g. to decode the + * header), set this make sure the pilot symbols are correctly + * identified. + * \param input_is_shifted Set this to false if the input signal is not shifted, i.e. + * the first input items is on the DC carrier. + * Note that a lot of the OFDM receiver blocks operate on shifted + * signals! + */ +DIGITAL_API digital_ofdm_equalizer_static_sptr +digital_make_ofdm_equalizer_static( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + bool input_is_shifted = true); + +/* \brief Very simple static equalizer for OFDM. + * \ingroup ofdm_blk + * \ingroup equalizers_blk + * + * This is an extremely simple equalizer. It will only work for high-SNR, very, very + * slowly changing channels. + * It simply divides the signal with the currently known channel state. Whenever + * a pilot symbol comes around, it updates the channel state on that particular + * carrier by dividing the received symbol with the known pilot symbol. + */ +class DIGITAL_API digital_ofdm_equalizer_static : public digital_ofdm_equalizer_1d_pilots +{ + public: + digital_ofdm_equalizer_static( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted); + ~digital_ofdm_equalizer_static(); + + /*! \brief Divide the input signal with the current channel state. + * + * Does the following (and nothing else): + * - Divide every OFDM symbol with the current channel state + * - If a pilot symbol is found, re-set the channel state by dividing the received + * symbol with the known pilot symbol + */ + void equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); + + private: + +}; + +#endif /* INCLUDED_DIGITAL_OFDM_EQUALIZER_STATIC_H */ + diff --git a/gr-digital/include/digital_ofdm_frame_acquisition.h b/gr-digital/include/digital_ofdm_frame_acquisition.h index 9c2f602334..27920d36e3 100644 --- a/gr-digital/include/digital_ofdm_frame_acquisition.h +++ b/gr-digital/include/digital_ofdm_frame_acquisition.h @@ -39,7 +39,6 @@ DIGITAL_API digital_make_ofdm_frame_acquisition (unsigned int occupied_carriers, /*! * \brief take a vector of complex constellation points in from an FFT * and performs a correlation and equalization. - * \ingroup demodulation_blk * \ingroup ofdm_blk * * This block takes the output of an FFT of a received OFDM symbol and finds the diff --git a/gr-digital/include/digital_ofdm_frame_sink.h b/gr-digital/include/digital_ofdm_frame_sink.h index 5785d4be7b..eb2acb398f 100644 --- a/gr-digital/include/digital_ofdm_frame_sink.h +++ b/gr-digital/include/digital_ofdm_frame_sink.h @@ -39,7 +39,6 @@ digital_make_ofdm_frame_sink (const std::vector<gr_complex> &sym_position, /*! * \brief Takes an OFDM symbol in, demaps it into bits of 0's and 1's, packs * them into packets, and sends to to a message queue sink. - * \ingroup sink_blk * \ingroup ofdm_blk * * NOTE: The mod input parameter simply chooses a pre-defined demapper/slicer. Eventually, diff --git a/gr-digital/include/digital_ofdm_insert_preamble.h b/gr-digital/include/digital_ofdm_insert_preamble.h index fa44558add..5fac6d6023 100644 --- a/gr-digital/include/digital_ofdm_insert_preamble.h +++ b/gr-digital/include/digital_ofdm_insert_preamble.h @@ -35,7 +35,6 @@ digital_make_ofdm_insert_preamble(int fft_length, /*! * \brief insert "pre-modulated" preamble symbols before each payload. - * \ingroup sync_blk * \ingroup ofdm_blk * * <pre> diff --git a/gr-digital/include/digital_ofdm_mapper_bcv.h b/gr-digital/include/digital_ofdm_mapper_bcv.h index daed1eab29..a3b9c3b60f 100644 --- a/gr-digital/include/digital_ofdm_mapper_bcv.h +++ b/gr-digital/include/digital_ofdm_mapper_bcv.h @@ -39,7 +39,6 @@ digital_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsi * \brief take a stream of bytes in and map to a vector of complex * constellation points suitable for IFFT input to be used in an ofdm * modulator. Abstract class must be subclassed with specific mapping. - * \ingroup modulation_blk * \ingroup ofdm_blk */ diff --git a/gr-digital/include/digital_ofdm_sync_sc_cfb.h b/gr-digital/include/digital_ofdm_sync_sc_cfb.h new file mode 100644 index 0000000000..26cf5b3de5 --- /dev/null +++ b/gr-digital/include/digital_ofdm_sync_sc_cfb.h @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H +#define INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H + +#include <digital_api.h> +#include <gr_hier_block2.h> + +class digital_ofdm_sync_sc_cfb; +typedef boost::shared_ptr<digital_ofdm_sync_sc_cfb> digital_ofdm_sync_sc_cfb_sptr; + +/*! \param fft_len FFT length + * \param cp_len Length of the guard interval (cyclic prefix) in samples + * \param use_even_carriers If true, the carriers in the sync preamble are occupied such + * that the even carriers are used (0, 2, 4, ...). If you use all + * carriers, that would include the DC carrier, so be careful. + */ +DIGITAL_API digital_ofdm_sync_sc_cfb_sptr +digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len, bool use_even_carriers=false); + +/*! + * \brief Schmidl & Cox synchronisation for OFDM + * \ingroup ofdm_blk + * \ingroup synchronizers_blk + * + * \details + * Input: complex samples. + * Output 0: Fine frequency offset, scaled by the OFDM symbol duration. + * This is \f$\hat{\varphi}\f$ in [1]. The normalized frequency + * offset is then 2.0*output0/fft_len. + * Output 1: Beginning of the first OFDM symbol after the first (doubled) OFDM + * symbol. The beginning is marked with a 1 (it's 0 everywhere else). + * + * The evaluation of the coarse frequency offset is *not* done in this block. + * Also, the initial equalizer taps are not calculated here. + * + * Note that we use a different normalization factor in the timing metric than + * the authors do in their original work[1]. If the timing metric (8) is + * \f[ + * M(d) = \frac{|P(d)|^2}{(R(d))^2}, + * \f] + * we calculate the normalization as + * \f[ + * R(d) = \frac{1}{2} \sum_{k=0}^{N-1} |r_{k+d}|^2, + * \f] + * i.e., we estimate the energy from *both* half-symbols. This avoids spurious detects + * at the end of a burst, when the energy level suddenly drops. + * + * [1] Schmidl, T.M. and Cox, D.C., "Robust frequency and timing synchronization for OFDM", + * Communications, IEEE Transactions on, 1997. + */ +class DIGITAL_API digital_ofdm_sync_sc_cfb : public gr_hier_block2 +{ + private: + friend DIGITAL_API digital_ofdm_sync_sc_cfb_sptr digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len, bool use_even_carriers); + digital_ofdm_sync_sc_cfb(int fft_len, int cp_len, bool use_even_carriers); + + public: + ~digital_ofdm_sync_sc_cfb(); + +}; + +#endif /* INCLUDED_DIGITAL_OFDM_SYNC_SC_CFB_H */ + diff --git a/gr-digital/include/digital_packet_sink.h b/gr-digital/include/digital_packet_sink.h index 7ab41c0ef7..d9efa8f565 100644 --- a/gr-digital/include/digital_packet_sink.h +++ b/gr-digital/include/digital_packet_sink.h @@ -37,8 +37,9 @@ digital_make_packet_sink(const std::vector<unsigned char>& sync_vector, /*! * \brief process received bits looking for packet sync, header, and process bits into packet - * \ingroup sink_blk + * \ingroup packet_operators_blk * + * \details * input: stream of symbols to be sliced. * * output: none. Pushes assembled packet into target queue @@ -53,10 +54,6 @@ digital_make_packet_sink(const std::vector<unsigned char>& sync_vector, * This block is not very useful anymore as it only works with 2-level * modulations such as BPSK or GMSK. The block can generally be * replaced with a correlate access code and frame sink blocks. - * - * \param sync_vector The synchronization vector as a vector of 1's and 0's. - * \param target_queue The message queue that packets are sent to. - * \param threshold Number of bits that can be incorrect in the \p sync_vector. */ class DIGITAL_API digital_packet_sink : public gr_sync_block { @@ -89,6 +86,13 @@ class DIGITAL_API digital_packet_sink : public gr_sync_block int d_packetlen_cnt; // how many so far protected: + /*! + * Build a packet sink block. + * + * \param sync_vector The synchronization vector as a vector of 1's and 0's. + * \param target_queue The message queue that packets are sent to. + * \param threshold Number of bits that can be incorrect in the \p sync_vector. + */ digital_packet_sink(const std::vector<unsigned char>& sync_vector, gr_msg_queue_sptr target_queue, int threshold); diff --git a/gr-digital/include/digital_pfb_clock_sync_ccf.h b/gr-digital/include/digital_pfb_clock_sync_ccf.h index 1b403ab253..4a7cfc0019 100644 --- a/gr-digital/include/digital_pfb_clock_sync_ccf.h +++ b/gr-digital/include/digital_pfb_clock_sync_ccf.h @@ -40,13 +40,10 @@ digital_make_pfb_clock_sync_ccf(double sps, float loop_bw, class gr_fir_ccf; /*! - * \class digital_pfb_clock_sync_ccf - * * \brief Timing synchronizer using polyphase filterbanks + * \ingroup synchronizers_blk * - * \ingroup filter_blk - * \ingroup pfb_blk - * + * \details * This block performs timing synchronization for PAM signals by * minimizing the derivative of the filtered signal, which in turn * maximizes the SNR and minimizes ISI. diff --git a/gr-digital/include/digital_pfb_clock_sync_fff.h b/gr-digital/include/digital_pfb_clock_sync_fff.h index c7e8babd69..c19ebab0aa 100644 --- a/gr-digital/include/digital_pfb_clock_sync_fff.h +++ b/gr-digital/include/digital_pfb_clock_sync_fff.h @@ -40,13 +40,10 @@ digital_make_pfb_clock_sync_fff(double sps, float gain, class gr_fir_fff; /*! - * \class digital_pfb_clock_sync_fff - * * \brief Timing synchronizer using polyphase filterbanks + * \ingroup synchronizers_blk * - * \ingroup filter_blk - * \ingroup pfb_blk - * + * \details * This block performs timing synchronization for PAM signals by * minimizing the derivative of the filtered signal, which in turn * maximizes the SNR and minimizes ISI. diff --git a/gr-digital/include/digital_pn_correlator_cc.h b/gr-digital/include/digital_pn_correlator_cc.h index 87cc2ff93c..17fa795988 100644 --- a/gr-digital/include/digital_pn_correlator_cc.h +++ b/gr-digital/include/digital_pn_correlator_cc.h @@ -32,10 +32,10 @@ typedef boost::shared_ptr<digital_pn_correlator_cc> digital_pn_correlator_cc_spt DIGITAL_API digital_pn_correlator_cc_sptr digital_make_pn_correlator_cc(int degree, int mask=0, int seed=1); + /*! * \brief PN code sequential search correlator - * - * \ingroup sync_blk + * \ingroup synchronizers_blk * * Receives complex baseband signal, outputs complex correlation * against reference PN code, one sample per PN code period. The PN diff --git a/gr-digital/include/digital_probe_density_b.h b/gr-digital/include/digital_probe_density_b.h index 271ad2a072..65d33afcfa 100644 --- a/gr-digital/include/digital_probe_density_b.h +++ b/gr-digital/include/digital_probe_density_b.h @@ -31,6 +31,8 @@ DIGITAL_API digital_probe_density_b_sptr digital_make_probe_density_b(double alpha); /*! + * \ingroup measurement_tools_blk + * * This block maintains a running average of the input stream and * makes it available as an accessor function. The input stream * is type unsigned char. diff --git a/gr-digital/include/digital_probe_mpsk_snr_est_c.h b/gr-digital/include/digital_probe_mpsk_snr_est_c.h index a78e904124..70e0df6a8f 100644 --- a/gr-digital/include/digital_probe_mpsk_snr_est_c.h +++ b/gr-digital/include/digital_probe_mpsk_snr_est_c.h @@ -34,9 +34,10 @@ digital_make_probe_mpsk_snr_est_c(snr_est_type_t type, int msg_nsamples=10000, double alpha=0.001); -//! \brief A probe for computing SNR of a signal. -/*! \ingroup snr_blk +/*! \brief A probe for computing SNR of a signal. + * \ingroup measurement_tools_blk * + * \details * This is a probe block (a sink) that can be used to monitor and * retrieve estimations of the signal SNR. This probe is designed for * use with M-PSK signals especially. The type of estimator is @@ -61,8 +62,6 @@ class DIGITAL_API digital_probe_mpsk_snr_est_c : public gr_sync_block /*! Factory function returning shared pointer of this class * - * Parameters: - * * \param type: the type of estimator to use \ref ref_snr_est_types * "snr_est_type_t" for details about the available types. * \param msg_nsamples: [not implemented yet] after this many diff --git a/gr-digital/include/digital_scrambler_bb.h b/gr-digital/include/digital_scrambler_bb.h index cafb0e5f2c..c7ae7fa539 100644 --- a/gr-digital/include/digital_scrambler_bb.h +++ b/gr-digital/include/digital_scrambler_bb.h @@ -33,17 +33,11 @@ DIGITAL_API digital_scrambler_bb_sptr digital_make_scrambler_bb(int mask, int seed, int len); /*! + * \ingroup coding_blk * Scramble an input stream using an LFSR. This block works on the LSB only * of the input data stream, i.e., on an "unpacked binary" stream, and * produces the same format on its output. - * - * \param mask Polynomial mask for LFSR - * \param seed Initial shift register contents - * \param len Shift register length - * - * \ingroup coding_blk */ - class DIGITAL_API digital_scrambler_bb : public gr_sync_block { friend DIGITAL_API digital_scrambler_bb_sptr @@ -51,6 +45,13 @@ class DIGITAL_API digital_scrambler_bb : public gr_sync_block gr::analog::lfsr d_lfsr; + /*! + * Build a scrambler block. + * + * \param mask Polynomial mask for LFSR + * \param seed Initial shift register contents + * \param len Shift register length + */ digital_scrambler_bb(int mask, int seed, int len); public: diff --git a/gr-digital/include/digital_simple_correlator.h b/gr-digital/include/digital_simple_correlator.h index 716c6995ca..a8364810c6 100644 --- a/gr-digital/include/digital_simple_correlator.h +++ b/gr-digital/include/digital_simple_correlator.h @@ -33,7 +33,8 @@ DIGITAL_API digital_simple_correlator_sptr digital_make_simple_correlator(int pa /*! * \brief inverse of simple_framer (more or less) - * \ingroup sync_blk + * \ingroup packet_operators_blk + * \ingroup deprecated_blk */ class DIGITAL_API digital_simple_correlator : public gr_block { diff --git a/gr-digital/include/digital_simple_framer.h b/gr-digital/include/digital_simple_framer.h index b622ae5dd4..fcfdad1077 100644 --- a/gr-digital/include/digital_simple_framer.h +++ b/gr-digital/include/digital_simple_framer.h @@ -33,8 +33,10 @@ DIGITAL_API digital_simple_framer_sptr digital_make_simple_framer(int payload_by /*! * \brief add sync field, seq number and command field to payload - * \ingroup sync_blk + * \ingroup packet_operators_blk + * \ingroup deprecated_blk * + * \details * Takes in enough samples to create a full output frame. The frame is * prepended with the GRSF_SYNC (defind in * digital_simple_framer_sync.h) and an 8-bit sequence number. diff --git a/gr-digital/lib/CMakeLists.txt b/gr-digital/lib/CMakeLists.txt index 7ac16602c7..42340b6c2a 100644 --- a/gr-digital/lib/CMakeLists.txt +++ b/gr-digital/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011,2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,12 +24,16 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/../include ${GR_DIGITAL_INCLUDE_DIRS} ${GR_ANALOG_INCLUDE_DIRS} + ${GR_FILTER_INCLUDE_DIRS} + ${GR_BLOCKS_INCLUDE_DIRS} ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories(${Boost_LIBRARY_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) ######################################################################## # generate helper scripts to expand templated files @@ -90,6 +94,7 @@ expand_cc(digital_chunks_to_symbols_XX bf bc sf sc if ic) ######################################################################## # Setup library ######################################################################## + list(APPEND gr_digital_sources ${generated_sources} digital_impl_glfsr.cc @@ -136,16 +141,54 @@ list(APPEND gr_digital_sources digital_probe_mpsk_snr_est_c.cc digital_scrambler_bb.cc digital_simple_framer.cc + digital_ofdm_sync_sc_cfb.cc + digital_ofdm_chanest_vcvc.cc + digital_crc32_bb.cc + digital_ofdm_carrier_allocator_cvc.cc + digital_ofdm_equalizer_base.cc + digital_ofdm_equalizer_static.cc + digital_ofdm_equalizer_simpledfe.cc + ofdm_frame_equalizer_vcvc_impl.cc + ofdm_serializer_vcc_impl.cc + packet_header_default.cc + packet_header_ofdm.cc + packet_headergenerator_bb_impl.cc + packet_headerparser_b_impl.cc + header_payload_demux_impl.cc digital_simple_correlator.cc ) +#Add Windows DLL resource file if using MSVC +IF(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-digital.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-digital.rc + @ONLY) + + list(APPEND gr_digital_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-digital.rc + ) +ENDIF(MSVC) + list(APPEND digital_libs gnuradio-core + gnuradio-blocks + gnuradio-analog + gnuradio-filter ${Boost_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-digital SHARED ${gr_digital_sources}) target_link_libraries(gnuradio-digital ${digital_libs}) GR_LIBRARY_FOO(gnuradio-digital RUNTIME_COMPONENT "digital_runtime" DEVEL_COMPONENT "digital_devel") +add_dependencies(gnuradio-digital + digital_generated_includes + digital_generated_swigs + gnuradio-analog + gnuradio-blocks + gnuradio-filter +) -add_dependencies(gnuradio-digital digital_generated_includes digital_generated_swigs gnuradio-analog) diff --git a/gr-digital/lib/digital_constellation.cc b/gr-digital/lib/digital_constellation.cc index 8b34d9e6b2..fdd970afe3 100644 --- a/gr-digital/lib/digital_constellation.cc +++ b/gr-digital/lib/digital_constellation.cc @@ -349,6 +349,37 @@ digital_constellation_rect::calc_sector_value (unsigned int sector) return closest_point; } +digital_constellation_expl_rect_sptr +digital_make_constellation_expl_rect( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values +) +{ + return digital_constellation_expl_rect_sptr( + new digital_constellation_expl_rect( + constellation, pre_diff_code, rotational_symmetry, real_sectors, imag_sectors, + width_real_sectors, width_imag_sectors, sector_values)); +} + +digital_constellation_expl_rect::digital_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, + unsigned int imag_sectors, + float width_real_sectors, + float width_imag_sectors, + std::vector<unsigned int> sector_values + ) : digital_constellation_rect( + constellation, pre_diff_code, rotational_symmetry, real_sectors, imag_sectors, + width_real_sectors, width_imag_sectors), + d_sector_values(sector_values) {}; digital_constellation_psk_sptr digital_make_constellation_psk(std::vector<gr_complex> constellation, diff --git a/gr-digital/lib/digital_crc32_bb.cc b/gr-digital/lib/digital_crc32_bb.cc new file mode 100644 index 0000000000..89d9e42151 --- /dev/null +++ b/gr-digital/lib/digital_crc32_bb.cc @@ -0,0 +1,102 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include <digital_crc32.h> +#include "digital_crc32_bb.h" + +digital_crc32_bb_sptr +digital_make_crc32_bb (bool check, const std::string& lengthtagname) +{ + return gnuradio::get_initial_sptr (new digital_crc32_bb(check, lengthtagname)); +} + + +digital_crc32_bb::digital_crc32_bb (bool check, const std::string& lengthtagname) + : gr_tagged_stream_block ("crc32_bb", + gr_make_io_signature(1, 1, sizeof (char)), + gr_make_io_signature(1, 1, sizeof (char)), + lengthtagname), + d_check(check) +{ + set_tag_propagation_policy(TPP_DONT); +} + + +digital_crc32_bb::~digital_crc32_bb() +{ +} + + +int +digital_crc32_bb::calculate_output_stream_length(const std::vector<int> &ninput_items) +{ + if (d_check) { + return ninput_items[0] - 4; + } else { + return ninput_items[0] + 4; + } +} + + +int +digital_crc32_bb::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const unsigned char *in = (const unsigned char *) input_items[0]; + unsigned char *out = (unsigned char *) output_items[0]; + long packet_length = ninput_items[0]; + int packet_size_diff = d_check ? -4 : 4; + unsigned int crc; + + if (d_check) { + crc = digital_crc32(in, packet_length-4); + if (crc != *(unsigned int *)(in+packet_length-4)) { // Drop package + return 0; + } + memcpy((void *) out, (const void *) in, packet_length-4); + } else { + crc = digital_crc32(in, packet_length); + memcpy((void *) out, (const void *) in, packet_length); + memcpy((void *) (out + packet_length), &crc, 4); // FIXME big-endian/little-endian, this might be wrong + } + + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+packet_length); + for (unsigned i = 0; i < tags.size(); i++) { + tags[i].offset -= nitems_read(0); + if (d_check && tags[i].offset > packet_length+packet_size_diff) { + tags[i].offset = packet_length-5; + } + add_item_tag(0, nitems_written(0) + tags[i].offset, + tags[i].key, + tags[i].value); + } + + return packet_length + packet_size_diff; +} + diff --git a/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc b/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc new file mode 100644 index 0000000000..e5b3013302 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_carrier_allocator_cvc.cc @@ -0,0 +1,156 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "digital_ofdm_carrier_allocator_cvc.h" + +digital_ofdm_carrier_allocator_cvc_sptr +digital_make_ofdm_carrier_allocator_cvc ( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + const std::string &len_tag_key) +{ + return gnuradio::get_initial_sptr (new digital_ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, len_tag_key)); +} + + +digital_ofdm_carrier_allocator_cvc::digital_ofdm_carrier_allocator_cvc ( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + const std::string &len_tag_key) + : gr_tagged_stream_block ("ofdm_carrier_allocator_cvc", + gr_make_io_signature(1, 1, sizeof (gr_complex)), + gr_make_io_signature(1, 1, sizeof (gr_complex) * fft_len), len_tag_key), + d_fft_len(fft_len), + d_occupied_carriers(occupied_carriers), + d_pilot_carriers(pilot_carriers), + d_pilot_symbols(pilot_symbols), + d_symbols_per_set(0) +{ + for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { + for (unsigned j = 0; j < d_occupied_carriers[i].size(); j++) { + if (occupied_carriers[i][j] < 0) { + d_occupied_carriers[i][j] += d_fft_len; + } + if (d_occupied_carriers[i][j] > d_fft_len || d_occupied_carriers[i][j] < 0) { + throw std::invalid_argument("data carrier index out of bounds"); + } + } + } + for (unsigned i = 0; i < d_pilot_carriers.size(); i++) { + if (d_pilot_carriers[i].size() != pilot_symbols[i].size()) { + throw std::invalid_argument("pilot_carriers do not match pilot_symbols"); + } + for (unsigned j = 0; j < d_pilot_carriers[i].size(); j++) { + if (d_pilot_carriers[i][j] < 0) { + d_pilot_carriers[i][j] += d_fft_len; + } + if (d_pilot_carriers[i][j] > d_fft_len || d_pilot_carriers[i][j] < 0) { + throw std::invalid_argument("pilot carrier index out of bounds"); + } + } + } + + for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { + d_symbols_per_set += d_occupied_carriers[i].size(); + } + set_tag_propagation_policy(TPP_DONT); + set_relative_rate((double) d_symbols_per_set / d_occupied_carriers.size()); +} + + +digital_ofdm_carrier_allocator_cvc::~digital_ofdm_carrier_allocator_cvc() +{ +} + + +int +digital_ofdm_carrier_allocator_cvc::calculate_output_stream_length(const gr_vector_int &ninput_items) +{ + int nin = ninput_items[0]; + int nout = (nin / d_symbols_per_set) * d_occupied_carriers.size(); + int k = 0; + for (int i = 0; i < nin % d_symbols_per_set; k++) { + nout++; + i += d_occupied_carriers[k % d_occupied_carriers.size()].size(); + } + return nout; +} + + +int +digital_ofdm_carrier_allocator_cvc::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + + std::vector<gr_tag_t> tags; + + memset((void *) out, 0x00, sizeof(gr_complex) * d_fft_len * noutput_items); + long n_ofdm_symbols = 0; + int curr_set = 0; + int symbols_to_allocate = d_occupied_carriers[0].size(); + int symbols_allocated = 0; + for (int i = 0; i < ninput_items[0]; i++) { + if (symbols_allocated == 0) { + // Copy all tags associated with these input symbols onto this OFDM symbol + get_tags_in_range(tags, 0, + nitems_read(0)+i, + nitems_read(0)+std::min(i+symbols_to_allocate, (int) ninput_items[0]) + ); + for (unsigned t = 0; t < tags.size(); t++) { + add_item_tag(0, nitems_written(0)+n_ofdm_symbols, + tags[t].key, + tags[t].value); + } + n_ofdm_symbols++; + } + out[(n_ofdm_symbols-1) * d_fft_len + d_occupied_carriers[curr_set][symbols_allocated]] = in[i]; + symbols_allocated++; + if (symbols_allocated == symbols_to_allocate) { + curr_set = (curr_set + 1) % d_occupied_carriers.size(); + symbols_to_allocate = d_occupied_carriers[curr_set].size(); + symbols_allocated = 0; + } + } + // 2) Copy pilot symbols + curr_set = 0; + for (int i = 0; i < n_ofdm_symbols; i++) { + for (unsigned k = 0; k < d_pilot_carriers[curr_set].size(); k++) { + out[i * d_fft_len + d_pilot_carriers[curr_set][k]] = d_pilot_symbols[curr_set][k]; + } + curr_set = (curr_set + 1) % d_pilot_carriers.size(); + } + + return n_ofdm_symbols; +} + diff --git a/gr-digital/lib/digital_ofdm_chanest_vcvc.cc b/gr-digital/lib/digital_ofdm_chanest_vcvc.cc new file mode 100644 index 0000000000..1e3adbb67f --- /dev/null +++ b/gr-digital/lib/digital_ofdm_chanest_vcvc.cc @@ -0,0 +1,296 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "digital_ofdm_chanest_vcvc.h" + +digital_ofdm_chanest_vcvc_sptr +digital_make_ofdm_chanest_vcvc ( + const std::vector<gr_complex> &sync_symbol1, + const std::vector<gr_complex> &sync_symbol2, + int n_data_symbols, + int eq_noise_red_len, + int max_carr_offset, + bool force_one_sync_symbol) +{ + return gnuradio::get_initial_sptr ( + new digital_ofdm_chanest_vcvc( + sync_symbol1, + sync_symbol2, + n_data_symbols, + eq_noise_red_len, + max_carr_offset, + force_one_sync_symbol + ) + ); +} + + +digital_ofdm_chanest_vcvc::digital_ofdm_chanest_vcvc ( + const std::vector<gr_complex> &sync_symbol1, + const std::vector<gr_complex> &sync_symbol2, + int n_data_symbols, + int eq_noise_red_len, + int max_carr_offset, + bool force_one_sync_symbol) + : gr_block ("ofdm_chanest_vcvc", + gr_make_io_signature(1, 1, sizeof (gr_complex) * sync_symbol1.size()), + gr_make_io_signature(1, 2, sizeof (gr_complex) * sync_symbol1.size())), + d_fft_len(sync_symbol1.size()), + d_n_data_syms(n_data_symbols), + d_n_sync_syms(1), + d_eq_noise_red_len(eq_noise_red_len), + d_ref_sym((sync_symbol2.size() && !force_one_sync_symbol) ? sync_symbol2 : sync_symbol1), + d_corr_v(sync_symbol2), + d_known_symbol_diffs(0, 0), + d_new_symbol_diffs(0, 0), + d_interpolate(false) +{ + // Set index of first and last active carrier + for (int i = 0; i < d_fft_len; i++) { + if (d_ref_sym[i] != gr_complex(0, 0)) { + d_first_active_carrier = i; + break; + } + } + for (int i = d_fft_len-1; i >= 0; i--) { + if (d_ref_sym[i] != gr_complex(0, 0)) { + d_last_active_carrier = i; + break; + } + } + + // Sanity checks + if (sync_symbol2.size()) { + if (sync_symbol1.size() != sync_symbol2.size()) { + throw std::invalid_argument("sync symbols must have equal length."); + } + if (!force_one_sync_symbol) { + d_n_sync_syms = 2; + } + } else { + if (sync_symbol1[d_first_active_carrier+1] == gr_complex(0, 0)) { + d_last_active_carrier++; + d_interpolate = true; + } + } + + // Set up coarse freq estimation info + // Allow all possible values: + d_max_neg_carr_offset = -d_first_active_carrier; + d_max_pos_carr_offset = d_fft_len - d_last_active_carrier - 1; + if (max_carr_offset != -1) { + d_max_neg_carr_offset = std::max(-max_carr_offset, d_max_neg_carr_offset); + d_max_pos_carr_offset = std::min(max_carr_offset, d_max_pos_carr_offset); + } + // Carrier offsets must be even + if (d_max_neg_carr_offset % 2) + d_max_neg_carr_offset++; + if (d_max_pos_carr_offset % 2) + d_max_pos_carr_offset--; + + if (d_n_sync_syms == 2) { + for (int i = 0; i < d_fft_len; i++) { + if (sync_symbol1[i] == gr_complex(0, 0)) { + d_corr_v[i] = gr_complex(0, 0); + } else { + d_corr_v[i] /= sync_symbol1[i]; + } + } + } else { + d_corr_v.resize(0, 0); + d_known_symbol_diffs.resize(d_fft_len, 0); + d_new_symbol_diffs.resize(d_fft_len, 0); + for (int i = d_first_active_carrier; i < d_last_active_carrier-2 && i < d_fft_len-2; i += 2) { + d_known_symbol_diffs[i] = std::norm(sync_symbol1[i] - sync_symbol1[i+2]); + } + } + + set_relative_rate((double) n_data_symbols / (n_data_symbols + d_n_sync_syms)); + set_tag_propagation_policy(TPP_DONT); +} + + +digital_ofdm_chanest_vcvc::~digital_ofdm_chanest_vcvc() +{ +} + +void +digital_ofdm_chanest_vcvc::forecast (int noutput_items, gr_vector_int &ninput_items_required) +{ + ninput_items_required[0] = (noutput_items/d_n_data_syms) * (d_n_data_syms + d_n_sync_syms); +} + + +int +digital_ofdm_chanest_vcvc::get_carr_offset(const gr_complex *sync_sym1, const gr_complex *sync_sym2) +{ + int carr_offset = 0; + if (d_corr_v.size()) { + // Use Schmidl & Cox method + float Bg_max = 0; + // g here is 2g in the paper + for (int g = d_max_neg_carr_offset; g <= d_max_pos_carr_offset; g += 2) { + gr_complex tmp = gr_complex(0, 0); + for (int k = 0; k < d_fft_len; k++) { + if (d_corr_v[k] != gr_complex(0, 0)) { + tmp += std::conj(sync_sym1[k+g]) * std::conj(d_corr_v[k]) * sync_sym2[k+g]; + } + } + if (std::abs(tmp) > Bg_max) { + Bg_max = std::abs(tmp); + carr_offset = g; + } + } + } else { + // Correlate + std::fill(d_new_symbol_diffs.begin(), d_new_symbol_diffs.end(), 0); + for(int i = 0; i < d_fft_len-2; i++) { + d_new_symbol_diffs[i] = std::norm(sync_sym1[i] - sync_sym1[i+2]); + } + + float sum; + float max = 0; + for (int g = d_max_neg_carr_offset; g <= d_max_pos_carr_offset; g += 2) { + sum = 0; + for (int j = 0; j < d_fft_len; j++) { + if (d_known_symbol_diffs[j]) { + sum += (d_known_symbol_diffs[j] * d_new_symbol_diffs[j + g]); + } + if(sum > max) { + max = sum; + carr_offset = g; + } + } + } + } + return carr_offset; +} + + +void +digital_ofdm_chanest_vcvc::get_chan_taps( + const gr_complex *sync_sym1, + const gr_complex *sync_sym2, + int carr_offset, + std::vector<gr_complex> &taps) +{ + const gr_complex *sym = ((d_n_sync_syms == 2) ? sync_sym2 : sync_sym1); + std::fill(taps.begin(), taps.end(), gr_complex(0, 0)); + int loop_start = 0; + int loop_end = d_fft_len; + if (carr_offset > 0) { + loop_start = carr_offset; + } else if (carr_offset < 0) { + loop_end = d_fft_len + carr_offset; + } + for (int i = loop_start; i < loop_end; i++) { + if ((d_ref_sym[i-carr_offset] != gr_complex(0, 0))) { + taps[i-carr_offset] = sym[i] / d_ref_sym[i-carr_offset]; + } + } + + if (d_interpolate) { + // FIXME check this out re offset + update docs + for (int i = d_first_active_carrier + 1; i < d_last_active_carrier; i += 2) { + taps[i] = taps[i-1]; + } + taps[d_last_active_carrier] = taps[d_last_active_carrier-1]; + } + + if (d_eq_noise_red_len) { + // TODO + // 1) IFFT + // 2) Set all elements > d_eq_noise_red_len to zero + // 3) FFT + } +} + + +// 1) Go through all the frames available on the input buffer +// 2) Estimate the coarse freq. offset and the eq. taps from the +// input symbol(s) +// 3) Copy the data symbols to the output +// 4) Copy all other tags onto the output. A tag that was on +// a sync symbol is copied onto the first data symbol. +// 5) Add the new tags for carrier offset and eq. taps +int +digital_ofdm_chanest_vcvc::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + int n_frames = noutput_items/d_n_data_syms; + const int framesize = d_n_sync_syms + d_n_data_syms; + + for (int i = 0; i < n_frames; i++) { + int carr_offset = 0; + if (d_max_neg_carr_offset || d_max_pos_carr_offset) + carr_offset = get_carr_offset(in, in+d_fft_len); + std::vector<gr_complex> chan_taps(d_fft_len, 0); + get_chan_taps(in, in+d_fft_len, carr_offset, chan_taps); + + if (output_items.size() == 2) { + gr_complex *out_chantaps = ((gr_complex *) output_items[1]) + i * d_fft_len; + memcpy((void *) out_chantaps, (void *) &chan_taps[0], sizeof(gr_complex) * d_fft_len); + produce(1, 1); + } + + memcpy((void *) out, + (void *) &in[d_n_sync_syms * d_fft_len], + sizeof(gr_complex) * d_fft_len * d_n_data_syms); + in += framesize * d_fft_len; + out += d_n_data_syms * d_fft_len; + + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, 0, + nitems_read(0)+i*framesize, + nitems_read(0)+(i+1)*framesize); + for (unsigned t = 0; t < tags.size(); t++) { + int offset = tags[t].offset - (nitems_read(0) + i*framesize); + if (offset < d_n_sync_syms) { + offset = 0; + } else { + offset -= d_n_sync_syms; + } + tags[t].offset = offset + nitems_written(0) + i*d_n_data_syms; + add_item_tag(0, tags[t]); + } + + add_item_tag(0, nitems_written(0) + i*d_n_data_syms, + pmt::pmt_string_to_symbol("ofdm_sync_carr_offset"), + pmt::pmt_from_long(carr_offset)); + add_item_tag(0, nitems_written(0) + i*d_n_data_syms, + pmt::pmt_string_to_symbol("ofdm_sync_chan_taps"), + pmt::pmt_init_c32vector(d_fft_len, chan_taps)); + } + produce(0, n_frames * d_n_data_syms); + consume_each(n_frames * framesize); + + return WORK_CALLED_PRODUCE; +} + diff --git a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc index 192af2591d..ada5742a51 100644 --- a/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc +++ b/gr-digital/lib/digital_ofdm_cyclic_prefixer.cc @@ -24,47 +24,139 @@ #include "config.h" #endif +#include <cmath> #include <digital_ofdm_cyclic_prefixer.h> #include <gr_io_signature.h> digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) +digital_make_ofdm_cyclic_prefixer (size_t input_size, + size_t output_size, + int rolloff_len, + const std::string &len_tag_key) { return gnuradio::get_initial_sptr(new digital_ofdm_cyclic_prefixer (input_size, - output_size)); + output_size, + rolloff_len, + len_tag_key)); } digital_ofdm_cyclic_prefixer::digital_ofdm_cyclic_prefixer (size_t input_size, - size_t output_size) - : gr_sync_interpolator ("ofdm_cyclic_prefixer", - gr_make_io_signature (1, 1, input_size*sizeof(gr_complex)), - gr_make_io_signature (1, 1, sizeof(gr_complex)), - output_size), - d_input_size(input_size), - d_output_size(output_size) + size_t output_size, + int rolloff_len, + const std::string &len_tag_key) + : gr_tagged_stream_block ("ofdm_cyclic_prefixer", + gr_make_io_signature (1, 1, input_size*sizeof(gr_complex)), + gr_make_io_signature (1, 1, sizeof(gr_complex)), + len_tag_key), + d_fft_len(input_size), + d_output_size(output_size), + d_cp_size(output_size - input_size), + d_rolloff_len(rolloff_len), + d_up_flank((rolloff_len ? rolloff_len-1 : 0), 0), + d_down_flank((rolloff_len ? rolloff_len-1 : 0), 0), + d_delay_line(0, 0) +{ + set_relative_rate(d_output_size); + + // Flank of length 1 would just be rectangular + if (d_rolloff_len == 1) { + d_rolloff_len = 0; + } + if (d_rolloff_len) { + d_delay_line.resize(d_rolloff_len-1, 0); + if (rolloff_len > d_cp_size) { + throw std::invalid_argument("cyclic prefixer: rolloff len must smaller than the cyclic prefix."); + } + // The actual flanks are one sample shorter than d_rolloff_len, because the + // first sample of the up- and down flank is always zero and one, respectively + for (int i = 1; i < d_rolloff_len; i++) { + d_up_flank[i-1] = 0.5 * (1 + cos(M_PI * i/rolloff_len - M_PI)); + d_down_flank[i-1] = 0.5 * (1 + cos(M_PI * (rolloff_len-i)/rolloff_len - M_PI)); + } + } + if (len_tag_key.empty()) { + set_output_multiple(d_output_size); + } else { + set_tag_propagation_policy(TPP_DONT); + } +} + +int +digital_ofdm_cyclic_prefixer::calculate_output_stream_length(const gr_vector_int &ninput_items) { + int nout = ninput_items[0] * d_output_size + d_delay_line.size(); + return nout; } +// Operates in two ways: +// - When there's a length tag name specified, operates in packet mode. +// Here, an entire OFDM frame is processed at once. The final OFDM symbol +// is postfixed with the delay line of the pulse shape. +// We manually propagate tags. +// - Otherwise, we're in freewheeling mode. Process as many OFDM symbols as +// are space for in the output buffer. The delay line is never flushed. +// Tags are propagated by the scheduler. int digital_ofdm_cyclic_prefixer::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { gr_complex *in = (gr_complex *) input_items[0]; gr_complex *out = (gr_complex *) output_items[0]; - size_t cp_size = d_output_size - d_input_size; - unsigned int i=0, j=0; + int symbols_to_read = 0; - j = cp_size; - for(i=0; i < d_input_size; i++,j++) { - out[j] = in[i]; + // 1) Figure out if we're in freewheeling or packet mode + if (!d_length_tag_key_str.empty()) { + symbols_to_read = ninput_items[0]; + noutput_items = symbols_to_read * d_output_size + d_delay_line.size(); + } else { + symbols_to_read = std::min(noutput_items / (int) d_output_size, ninput_items[0]); + noutput_items = symbols_to_read * d_output_size; } - j = d_input_size - cp_size; - for(i=0; i < cp_size; i++, j++) { - out[i] = in[j]; + // 2) Do the cyclic prefixing and, optionally, the pulse shaping + for (int sym_idx = 0; sym_idx < symbols_to_read; sym_idx++) { + memcpy((void *)(out + d_cp_size), (void *) in, d_fft_len * sizeof(gr_complex)); + memcpy((void *) out, (void *) (in + d_fft_len - d_cp_size), d_cp_size * sizeof(gr_complex)); + if (d_rolloff_len) { + for (int i = 0; i < d_rolloff_len-1; i++) { + out[i] = out[i] * d_up_flank[i] + d_delay_line[i]; + d_delay_line[i] = in[i] * d_down_flank[i]; + } + } + in += d_fft_len; + out += d_output_size; } - return d_output_size; + // 3) If we're in packet mode: + // - flush the delay line, if applicable + // - Propagate tags + if (!d_length_tag_key_str.empty()) { + if (d_rolloff_len) { + for (unsigned i = 0; i < d_delay_line.size(); i++) { + *out++ = d_delay_line[i]; + } + d_delay_line.assign(d_delay_line.size(), 0); + } + std::vector<gr_tag_t> tags; + get_tags_in_range( + tags, 0, + nitems_read(0), nitems_read(0)+symbols_to_read + ); + for (unsigned i = 0; i < tags.size(); i++) { + tags[i].offset = ((tags[i].offset - nitems_read(0)) * d_output_size) + nitems_written(0); + add_item_tag(0, + tags[i].offset, + tags[i].key, + tags[i].value + ); + } + } else { + consume_each(symbols_to_read); + } + + return noutput_items; } + diff --git a/gr-digital/lib/digital_ofdm_equalizer_base.cc b/gr-digital/lib/digital_ofdm_equalizer_base.cc new file mode 100644 index 0000000000..29f23910b9 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_equalizer_base.cc @@ -0,0 +1,114 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "digital_ofdm_equalizer_base.h" + +// *** Base class **************************************************** +digital_ofdm_equalizer_base::digital_ofdm_equalizer_base(int fft_len) : + d_fft_len(fft_len) +{ +} + + +digital_ofdm_equalizer_base::~digital_ofdm_equalizer_base() +{ +} + + +// *** Sub-Base class for 1D equalizers using pilot tones ************* +digital_ofdm_equalizer_1d_pilots::digital_ofdm_equalizer_1d_pilots( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted) + : digital_ofdm_equalizer_base(fft_len), + d_occupied_carriers(fft_len, false), + d_pilot_carriers(pilot_carriers.size(), std::vector<bool>(fft_len, false)), + d_pilot_symbols(pilot_symbols.size(), std::vector<gr_complex>(fft_len, gr_complex(0, 0))), + d_symbols_skipped(symbols_skipped), + d_pilot_carr_set(pilot_carriers.empty() ? 0 : symbols_skipped % pilot_carriers.size()), + d_channel_state(fft_len, gr_complex(1, 0)) +{ + int fft_shift_width = 0; + if (input_is_shifted) { + fft_shift_width = fft_len/2; + } + if (!occupied_carriers.size()) { + std::fill(d_occupied_carriers.begin(), d_occupied_carriers.end(), true); + } else { + for (unsigned i = 0; i < occupied_carriers.size(); i++) { + for (unsigned k = 0; k < occupied_carriers[i].size(); k++) { + int carr_index = occupied_carriers[i][k]; + if (occupied_carriers[i][k] < 0) { + carr_index += fft_len; + } + if (carr_index >= fft_len || carr_index < 0) { + throw std::invalid_argument("data carrier index out of bounds."); + } + d_occupied_carriers[(carr_index + fft_shift_width) % fft_len] = true; + } + } + } + if (pilot_carriers.size()) { + for (unsigned i = 0; i < pilot_carriers.size(); i++) { + if (pilot_carriers[i].size() != pilot_symbols[i].size()) { + throw std::invalid_argument("pilot carriers and -symbols do not match."); + } + for (unsigned k = 0; k < pilot_carriers[i].size(); k++) { + int carr_index = pilot_carriers[i][k]; + if (pilot_carriers[i][k] < 0) { + carr_index += fft_len; + } + if (carr_index >= fft_len || carr_index < 0) { + throw std::invalid_argument("pilot carrier index out of bounds."); + } + d_pilot_carriers[i][(carr_index + fft_shift_width) % fft_len] = true; + d_pilot_symbols[i][(carr_index + fft_shift_width) % fft_len] = pilot_symbols[i][k]; + } + } + } +} + + +digital_ofdm_equalizer_1d_pilots::~digital_ofdm_equalizer_1d_pilots() +{ +} + + +void +digital_ofdm_equalizer_1d_pilots::reset() +{ + std::fill(d_channel_state.begin(), d_channel_state.end(), gr_complex(1, 0)); + d_pilot_carr_set = d_pilot_carriers.empty() ? 0 : d_symbols_skipped % d_pilot_carriers.size(); +} + + +void digital_ofdm_equalizer_1d_pilots::get_channel_state(std::vector<gr_complex> &taps) +{ + taps = d_channel_state; +} + diff --git a/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc b/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc new file mode 100644 index 0000000000..6e771446b0 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_equalizer_simpledfe.cc @@ -0,0 +1,103 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "digital_ofdm_equalizer_simpledfe.h" + +digital_ofdm_equalizer_simpledfe_sptr +digital_make_ofdm_equalizer_simpledfe( + int fft_len, + const digital_constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + float alpha, + bool input_is_shifted) +{ + return digital_ofdm_equalizer_simpledfe_sptr(new digital_ofdm_equalizer_simpledfe( + fft_len, + constellation, + occupied_carriers, + pilot_carriers, + pilot_symbols, + symbols_skipped, + alpha, + input_is_shifted)); +} + +digital_ofdm_equalizer_simpledfe::digital_ofdm_equalizer_simpledfe( + int fft_len, + const digital_constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + float alpha, + bool input_is_shifted) + : digital_ofdm_equalizer_1d_pilots(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, symbols_skipped, input_is_shifted), + d_constellation(constellation), + d_alpha(alpha) +{ +} + + +digital_ofdm_equalizer_simpledfe::~digital_ofdm_equalizer_simpledfe() +{ +} + + +void +digital_ofdm_equalizer_simpledfe::equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps, + const std::vector<gr_tag_t> &tags) +{ + if (!initial_taps.empty()) { + d_channel_state = initial_taps; + } + gr_complex sym_eq, sym_est; + + for (int i = 0; i < n_sym; i++) { + for (int k = 0; k < d_fft_len; k++) { + if (!d_occupied_carriers[k]) { + continue; + } + if (!d_pilot_carriers.empty() && d_pilot_carriers[d_pilot_carr_set][k]) { + d_channel_state[k] = d_alpha * d_channel_state[k] + + (1-d_alpha) * frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k]; + frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k]; + } else { + sym_eq = frame[i*d_fft_len+k] / d_channel_state[k]; + d_constellation->map_to_points(d_constellation->decision_maker(&sym_eq), &sym_est); + d_channel_state[k] = d_alpha * d_channel_state[k] + frame[i*d_fft_len+k] / sym_est; + frame[i*d_fft_len+k] = sym_est; + } + } + if (!d_pilot_carriers.empty()) { + d_pilot_carr_set = (d_pilot_carr_set + 1) % d_pilot_carriers.size(); + } + } +} + diff --git a/gr-digital/lib/digital_ofdm_equalizer_static.cc b/gr-digital/lib/digital_ofdm_equalizer_static.cc new file mode 100644 index 0000000000..e4ae325dd8 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_equalizer_static.cc @@ -0,0 +1,88 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "digital_ofdm_equalizer_static.h" + +digital_ofdm_equalizer_static_sptr +digital_make_ofdm_equalizer_static( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted) +{ + return digital_ofdm_equalizer_static_sptr(new digital_ofdm_equalizer_static( + fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + symbols_skipped, + input_is_shifted)); +} + +digital_ofdm_equalizer_static::digital_ofdm_equalizer_static( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted) + : digital_ofdm_equalizer_1d_pilots(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, symbols_skipped, input_is_shifted) +{ +} + + +digital_ofdm_equalizer_static::~digital_ofdm_equalizer_static() +{ +} + + +void +digital_ofdm_equalizer_static::equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps, + const std::vector<gr_tag_t> &tags) +{ + d_channel_state = initial_taps; + + for (int i = 0; i < n_sym; i++) { + for (int k = 0; k < d_fft_len; k++) { + if (!d_occupied_carriers[k]) { + continue; + } + if (!d_pilot_carriers.empty() && d_pilot_carriers[d_pilot_carr_set][k]) { + d_channel_state[k] = frame[i*d_fft_len + k] / d_pilot_symbols[d_pilot_carr_set][k]; + frame[i*d_fft_len+k] = d_pilot_symbols[d_pilot_carr_set][k]; + } else { + frame[i*d_fft_len+k] /= d_channel_state[k]; + } + } + if (!d_pilot_carriers.empty()) { + d_pilot_carr_set = (d_pilot_carr_set + 1) % d_pilot_carriers.size(); + } + } +} + diff --git a/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc b/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc new file mode 100644 index 0000000000..23c3712707 --- /dev/null +++ b/gr-digital/lib/digital_ofdm_sync_sc_cfb.cc @@ -0,0 +1,109 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "digital_ofdm_sync_sc_cfb.h" + +#include <gr_delay.h> +#include <blocks/conjugate_cc.h> +#include <blocks/multiply_cc.h> +#include <filter/fir_filter_ccf.h> +#include <blocks/complex_to_mag_squared.h> +#include <filter/fir_filter_fff.h> +#include <blocks/multiply_ff.h> +#include <blocks/divide_ff.h> +#include <blocks/complex_to_arg.h> +#include <blocks/plateau_detector_fb.h> +#include <gr_sample_and_hold_ff.h> + +// Define this to add a third output for debugging +//#define SYNC_ADD_DEBUG_OUTPUT + +digital_ofdm_sync_sc_cfb_sptr +digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len, bool use_even_carriers) +{ + return gnuradio::get_initial_sptr (new digital_ofdm_sync_sc_cfb(fft_len, cp_len, use_even_carriers)); +} + + +digital_ofdm_sync_sc_cfb::digital_ofdm_sync_sc_cfb (int fft_len, int cp_len, bool use_even_carriers) + : gr_hier_block2 ("ofdm_sync_sc_cfb", + gr_make_io_signature(1, 1, sizeof (gr_complex)), +#ifndef SYNC_ADD_DEBUG_OUTPUT + gr_make_io_signature2(2, 2, sizeof (float), sizeof (unsigned char))) +#else + gr_make_io_signature3(3, 3, sizeof (float), sizeof (unsigned char), sizeof (float))) +#endif +{ + std::vector<float> ma_taps(fft_len/2, 1.0); + gr_delay_sptr delay(gr_make_delay(sizeof(gr_complex), fft_len/2)); + gr::blocks::conjugate_cc::sptr delay_conjugate(gr::blocks::conjugate_cc::make()); + gr::blocks::multiply_cc::sptr delay_corr(gr::blocks::multiply_cc::make()); + gr::filter::fir_filter_ccf::sptr delay_ma(gr::filter::fir_filter_ccf::make(1, std::vector<float>(fft_len/2, use_even_carriers ? 1.0 : -1.0))); + gr::blocks::complex_to_mag_squared::sptr delay_magsquare(gr::blocks::complex_to_mag_squared::make()); + gr::blocks::divide_ff::sptr delay_normalize(gr::blocks::divide_ff::make()); + + gr::blocks::complex_to_mag_squared::sptr normalizer_magsquare(gr::blocks::complex_to_mag_squared::make()); + gr::filter::fir_filter_fff::sptr normalizer_ma(gr::filter::fir_filter_fff::make(1, std::vector<float>(fft_len, 0.5))); + gr::blocks::multiply_ff::sptr normalizer_square(gr::blocks::multiply_ff::make()); + + gr::blocks::complex_to_arg::sptr peak_to_angle(gr::blocks::complex_to_arg::make()); + gr_sample_and_hold_ff_sptr sample_and_hold(gr_make_sample_and_hold_ff()); + + gr::blocks::plateau_detector_fb::sptr plateau_detector(gr::blocks::plateau_detector_fb::make(cp_len)); + + // Delay Path + connect(self(), 0, delay, 0); + connect(delay, 0, delay_conjugate, 0); + connect(delay_conjugate, 0, delay_corr, 1); + connect(self(), 0, delay_corr, 0); + connect(delay_corr, 0, delay_ma, 0); + connect(delay_ma, 0, delay_magsquare, 0); + connect(delay_magsquare, 0, delay_normalize, 0); + // Energy Path + connect(self(), 0, normalizer_magsquare, 0); + connect(normalizer_magsquare, 0, normalizer_ma, 0); + connect(normalizer_ma, 0, normalizer_square, 0); + connect(normalizer_ma, 0, normalizer_square, 1); + connect(normalizer_square, 0, delay_normalize, 1); + // Fine frequency estimate (output 0) + connect(delay_ma, 0, peak_to_angle, 0); + connect(peak_to_angle, 0, sample_and_hold, 0); + connect(sample_and_hold, 0, self(), 0); + // Peak detect (output 1) + connect(delay_normalize, 0, plateau_detector, 0); + connect(plateau_detector, 0, sample_and_hold, 1); + connect(plateau_detector, 0, self(), 1); +#ifdef SYNC_ADD_DEBUG_OUTPUT + // Debugging: timing metric (output 2) + connect(delay_normalize, 0, self(), 2); +#endif +} + + +digital_ofdm_sync_sc_cfb::~digital_ofdm_sync_sc_cfb() +{ +} + diff --git a/gr-digital/lib/gnuradio-digital.rc.in b/gr-digital/lib/gnuradio-digital.rc.in new file mode 100644 index 0000000000..3b287f9d62 --- /dev/null +++ b/gr-digital/lib/gnuradio-digital.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-digital" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-digital.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-digital.dll" + VALUE "ProductName", "gnuradio-digital" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-digital/lib/header_payload_demux_impl.cc b/gr-digital/lib/header_payload_demux_impl.cc new file mode 100644 index 0000000000..0c3adf701e --- /dev/null +++ b/gr-digital/lib/header_payload_demux_impl.cc @@ -0,0 +1,296 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <climits> +#include <gr_io_signature.h> +#include "header_payload_demux_impl.h" + +namespace gr { + namespace digital { + + enum demux_states_t { + STATE_IDLE, + STATE_HEADER, + STATE_WAIT_FOR_MSG, + STATE_PAYLOAD + }; + +#define msg_port_id pmt::mp("header_data") + + header_payload_demux::sptr + header_payload_demux::make( + int header_len, + int items_per_symbol, + int guard_interval, + const std::string &length_tag_key, + const std::string &trigger_tag_key, + bool output_symbols, + size_t itemsize) + { + return gnuradio::get_initial_sptr ( + new header_payload_demux_impl( + header_len, + items_per_symbol, + guard_interval, + length_tag_key, + trigger_tag_key, + output_symbols, + itemsize + ) + ); + } + + header_payload_demux_impl::header_payload_demux_impl( + int header_len, + int items_per_symbol, + int guard_interval, + const std::string &length_tag_key, + const std::string &trigger_tag_key, + bool output_symbols, + size_t itemsize + ) : gr_block("header_payload_demux", + gr_make_io_signature2(1, 2, itemsize, sizeof(char)), + gr_make_io_signature(2, 2, (output_symbols ? itemsize * items_per_symbol : itemsize))), + d_header_len(header_len), + d_items_per_symbol(items_per_symbol), + d_gi(guard_interval), + d_len_tag_key(pmt::pmt_string_to_symbol(length_tag_key)), + d_trigger_tag_key(pmt::pmt_string_to_symbol(trigger_tag_key)), + d_output_symbols(output_symbols), + d_itemsize(itemsize), + d_uses_trigger_tag(!trigger_tag_key.empty()), + d_state(STATE_IDLE) + { + if (d_header_len < 1) { + throw std::invalid_argument("Header length must be at least 1 symbol."); + } + if (d_items_per_symbol < 1 || d_gi < 0 || d_itemsize < 1) { + throw std::invalid_argument("Items and symbol sizes must be at least 1."); + } + set_output_multiple(d_items_per_symbol); + message_port_register_in(msg_port_id); + } + + header_payload_demux_impl::~header_payload_demux_impl() + { + } + + void + header_payload_demux_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) + { + // noutput_items is an integer multiple of d_items_per_symbol! + for (unsigned i = 0; i < ninput_items_required.size(); i++) { + ninput_items_required[i] = + noutput_items / d_items_per_symbol * (d_items_per_symbol + d_gi); + } + } + + int + header_payload_demux_impl::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *) input_items[0]; + unsigned char *out_header = (unsigned char *) output_items[0]; + unsigned char *out_payload = (unsigned char *) output_items[1]; + + int nread = 0; + bool exit_loop = false; + + int produced_hdr = 0; + int produced_payload = 0; + + // FIXME ninput_items[1] does not have to be defined O_o + while (nread < noutput_items && nread < ninput_items[0] && nread < ninput_items[1] && !exit_loop) { + switch (d_state) { + case STATE_IDLE: + // 1) Search for a trigger signal on input 1 (if present) + // 2) Search for a trigger tag, make sure it's the first one + // The first trigger to be found is used! + // 3) Make sure the right number of items is skipped + // 4) If trigger found, switch to STATE_HEADER + if (find_trigger_signal(nread, noutput_items, input_items)) { + d_remaining_symbols = d_header_len; + d_state = STATE_HEADER; + in += nread * d_itemsize; + } + break; + + case STATE_HEADER: + copy_symbol(in, out_header, 0, nread, produced_hdr); + if (d_remaining_symbols == 0) { + d_state = STATE_WAIT_FOR_MSG; + exit_loop = true; + } + break; + + case STATE_WAIT_FOR_MSG: + // If we're in this state, nread is zero (because previous state exits loop) + // 1) Wait for msg (blocking call) + // 2) set d_remaining_symbols + // 3) Write tags + // 4) fall through to next state + d_remaining_symbols = -1; + if (!parse_header_data_msg()) { + d_state = STATE_IDLE; + exit_loop = true; + break; + } + d_state = STATE_PAYLOAD; + + case STATE_PAYLOAD: + copy_symbol(in, out_payload, 1, nread, produced_payload); + if (d_remaining_symbols == 0) { + d_state = STATE_IDLE; + exit_loop = true; + } + break; + + default: + throw std::runtime_error("invalid state"); + } /* switch */ + } /* while(nread < noutput_items) */ + + if (!d_output_symbols) { + produced_hdr *= d_items_per_symbol; + produced_payload *= d_items_per_symbol; + } + produce(0, produced_hdr); + produce(1, produced_payload); + consume_each (nread); + return WORK_CALLED_PRODUCE; + } /* general_work() */ + + + bool + header_payload_demux_impl::find_trigger_signal( + int &pos, + int noutput_items, + gr_vector_const_void_star &input_items) + { + if (input_items.size() == 2) { + unsigned char *in_trigger = (unsigned char *) input_items[1]; + for (int i = 0; i < noutput_items; i++) { + if (in_trigger[i]) { + pos = i; + return true; + } + } + } + if (d_uses_trigger_tag) { + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+noutput_items); + uint64_t min_offset = ULLONG_MAX; + int tag_index = -1; + for (unsigned i = 0; i < tags.size(); i++) { + if (tags[i].key == d_trigger_tag_key && tags[i].offset < min_offset) { + tag_index = (int) i; + min_offset = tags[i].offset; + } + } + if (tag_index != -1) { + pos = min_offset - nitems_read(0); + return true; + } + } + pos += noutput_items; + return false; + } + + + bool + header_payload_demux_impl::parse_header_data_msg() + { + pmt::pmt_t msg(delete_head_blocking(msg_port_id)); + if (pmt::pmt_is_integer(msg)) { + d_remaining_symbols = pmt::pmt_to_long(msg); + add_item_tag(1, nitems_written(1), d_len_tag_key, msg); + } else if (pmt::pmt_is_dict(msg)) { + pmt::pmt_t dict_items(pmt::pmt_dict_items(msg)); + while (!pmt::pmt_is_null(dict_items)) { + pmt::pmt_t this_item(pmt::pmt_car(dict_items)); + add_item_tag(1, nitems_written(1), pmt::pmt_car(this_item), pmt::pmt_cdr(this_item)); + if (pmt::pmt_equal(pmt::pmt_car(this_item), d_len_tag_key)) { + d_remaining_symbols = pmt::pmt_to_long(pmt::pmt_cdr(this_item)); + } + dict_items = pmt::pmt_cdr(dict_items); + } + if (d_remaining_symbols == -1) { + throw std::runtime_error("no length tag passed from header data"); + } + } else if (pmt::pmt_is_null(msg)) { // Blocking call was interrupted + return false; + } else if (msg == pmt::PMT_F) { // Header was invalid + return false; + } else { + throw std::runtime_error("Received illegal header data"); + } + return true; + } + + void + header_payload_demux_impl::copy_symbol(const unsigned char *&in, unsigned char *&out, int port, int &nread, int &nproduced) + { + std::vector<gr_tag_t> tags; + memcpy((void *) out, + (void *) (in + d_gi * d_itemsize), + d_itemsize * d_items_per_symbol + ); + // Tags on GI + get_tags_in_range(tags, 0, + nitems_read(0) + nread, + nitems_read(0) + nread + d_gi + ); + for (unsigned t = 0; t < tags.size(); t++) { + add_item_tag(port, + nitems_written(port)+nproduced, + tags[t].key, + tags[t].value + ); + } + // Tags on symbol + get_tags_in_range( + tags, 0, + nitems_read(port) + nread + d_gi, + nitems_read(port) + nread + d_gi + d_items_per_symbol + ); + for (unsigned t = 0; t < tags.size(); t++) { + add_item_tag(0, + tags[t].offset - nitems_read(0)-nread + nitems_written(port)+nproduced, + tags[t].key, + tags[t].value + ); + } + in += d_itemsize * (d_items_per_symbol + d_gi); + out += d_items_per_symbol * d_itemsize; + nread += d_items_per_symbol + d_gi; + nproduced++; + d_remaining_symbols--; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/header_payload_demux_impl.h b/gr-digital/lib/header_payload_demux_impl.h new file mode 100644 index 0000000000..dc8cc7883a --- /dev/null +++ b/gr-digital/lib/header_payload_demux_impl.h @@ -0,0 +1,85 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H +#define INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H + +#include <digital/header_payload_demux.h> + +namespace gr { + namespace digital { + + class header_payload_demux_impl : public header_payload_demux + { + private: + int d_header_len; //!< Number of bytes per header + int d_items_per_symbol; //!< Bytes per symbol + int d_gi; //!< Bytes per guard interval + pmt::pmt_t d_len_tag_key; //!< Key of length tag + pmt::pmt_t d_trigger_tag_key; //!< Key of trigger tag (if used) + bool d_output_symbols; //!< If true, output is symbols, not items + size_t d_itemsize; //!< Bytes per item + bool d_uses_trigger_tag; //!< If a trigger tag is used + int d_ninput_items_reqd; //!< Helper for forecast() + int d_state; //!< Current read state + int d_remaining_symbols; //!< When in payload or header state, the number of symbols still to transmit + + // Helpers to make the state machine more readable + + //! Helper function that does the reading from the msg port + bool parse_header_data_msg(); + + //! Helper function that returns true if a trigger signal is detected. + // Searches input 1 (if active), then the tags. Sets \p pos to the position + // of the first tag. + bool find_trigger_signal( + int &pos, + int noutput_items, + gr_vector_const_void_star &input_items); + + //! Helper function, copies one symbol from in to out and updates all pointers and counters + void copy_symbol(const unsigned char *&in, unsigned char *&out, int port, int &nread, int &nproduced); + + public: + + header_payload_demux_impl( + int header_len, + int items_per_symbol, + int guard_interval, + const std::string &length_tag_key, + const std::string &trigger_tag_key, + bool output_symbols, + size_t itemsize); + ~header_payload_demux_impl(); + + void forecast (int noutput_items, gr_vector_int &ninput_items_required); + + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_HEADER_PAYLOAD_DEMUX_IMPL_H */ + diff --git a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc new file mode 100644 index 0000000000..f881a6e6dd --- /dev/null +++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.cc @@ -0,0 +1,178 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_expj.h> +#include <gr_io_signature.h> +#include "ofdm_frame_equalizer_vcvc_impl.h" + +#define M_TWOPI (2*M_PI) + +namespace gr { + namespace digital { + + ofdm_frame_equalizer_vcvc::sptr + ofdm_frame_equalizer_vcvc::make( + digital_ofdm_equalizer_base_sptr equalizer, + int cp_len, + const std::string &len_tag_key, + bool propagate_channel_state, + int fixed_frame_len + ) + { + return gnuradio::get_initial_sptr ( + new ofdm_frame_equalizer_vcvc_impl( + equalizer, cp_len, len_tag_key, propagate_channel_state, fixed_frame_len + ) + ); + } + + ofdm_frame_equalizer_vcvc_impl::ofdm_frame_equalizer_vcvc_impl( + digital_ofdm_equalizer_base_sptr equalizer, + int cp_len, + const std::string &len_tag_key, + bool propagate_channel_state, + int fixed_frame_len + ) : gr_tagged_stream_block("ofdm_frame_equalizer_vcvc", + gr_make_io_signature(1, 1, sizeof (gr_complex) * equalizer->fft_len()), + gr_make_io_signature(1, 1, sizeof (gr_complex) * equalizer->fft_len()), + len_tag_key), + d_fft_len(equalizer->fft_len()), + d_cp_len(cp_len), + d_eq(equalizer), + d_propagate_channel_state(propagate_channel_state), + d_fixed_frame_len(fixed_frame_len), + d_channel_state(equalizer->fft_len(), gr_complex(1, 0)) + { + if (len_tag_key.empty() && fixed_frame_len == 0) { + throw std::invalid_argument("Either specify a length tag or a frame length!"); + } + if (d_fixed_frame_len < 0) { + throw std::invalid_argument("Invalid frame length!"); + } + if (d_fixed_frame_len) { + set_output_multiple(d_fixed_frame_len); + } + set_relative_rate(1.0); + } + + ofdm_frame_equalizer_vcvc_impl::~ofdm_frame_equalizer_vcvc_impl() + { + } + + void + ofdm_frame_equalizer_vcvc_impl::parse_length_tags( + const std::vector<std::vector<gr_tag_t> > &tags, + gr_vector_int &n_input_items_reqd + ){ + if (d_fixed_frame_len) { + n_input_items_reqd[0] = d_fixed_frame_len; + } else { + for (unsigned k = 0; k < tags[0].size(); k++) { + if (tags[0][k].key == pmt::pmt_string_to_symbol(d_length_tag_key_str)) { + n_input_items_reqd[0] = pmt::pmt_to_long(tags[0][k].value); + remove_item_tag(0, tags[0][k]); + } + } + } + } + + +#include <iostream> + int + ofdm_frame_equalizer_vcvc_impl::work(int noutput_items, + gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + int carrier_offset = 0; + int frame_len = 0; + if (d_fixed_frame_len) { + frame_len = d_fixed_frame_len; + } else { + frame_len = ninput_items[0]; + } + + std::vector<gr_tag_t> tags; + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+1); + for (unsigned i = 0; i < tags.size(); i++) { + if (pmt::pmt_symbol_to_string(tags[i].key) == "ofdm_sync_chan_taps") { + d_channel_state = pmt::pmt_c32vector_elements(tags[i].value); + remove_item_tag(0, tags[i]); + } + if (pmt::pmt_symbol_to_string(tags[i].key) == "ofdm_sync_carr_offset") { + carrier_offset = pmt::pmt_to_long(tags[i].value); + } + } + + // Copy the frame and the channel state vector such that the symbols are shifted to the correct position + if (carrier_offset < 0) { + memset((void *) out, 0x00, sizeof(gr_complex) * (-carrier_offset)); + memcpy( + (void *) &out[-carrier_offset], (void *) in, + sizeof(gr_complex) * (d_fft_len * frame_len + carrier_offset) + ); + } else { + memset((void *) (out + d_fft_len * frame_len - carrier_offset), 0x00, sizeof(gr_complex) * carrier_offset); + memcpy( + (void *) out, (void *) (in+carrier_offset), + sizeof(gr_complex) * (d_fft_len * frame_len - carrier_offset) + ); + } + + // Correct the frequency shift on the symbols + gr_complex phase_correction; + for (int i = 0; i < frame_len; i++) { + phase_correction = gr_expj(-M_TWOPI * carrier_offset * d_cp_len / d_fft_len * (i+1)); + for (int k = 0; k < d_fft_len; k++) { + out[i*d_fft_len+k] *= phase_correction; + } + } + + // Do the equalizing + d_eq->reset(); + d_eq->equalize(out, frame_len, d_channel_state); + d_eq->get_channel_state(d_channel_state); + + // Update the channel state regarding the frequency offset + phase_correction = gr_expj(M_TWOPI * carrier_offset * d_cp_len / d_fft_len * frame_len); + for (int k = 0; k < d_fft_len; k++) { + d_channel_state[k] *= phase_correction; + } + + // Housekeeping + if (d_propagate_channel_state) { + add_item_tag(0, nitems_written(0), + pmt::pmt_string_to_symbol("ofdm_sync_chan_taps"), + pmt::pmt_init_c32vector(d_fft_len, d_channel_state)); + } + if (d_fixed_frame_len && d_length_tag_key_str.empty()) { + consume_each(frame_len); + } + return frame_len; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h new file mode 100644 index 0000000000..c855b46f7d --- /dev/null +++ b/gr-digital/lib/ofdm_frame_equalizer_vcvc_impl.h @@ -0,0 +1,66 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_FRAME_EQUALIZER_VCVC_IMPL_H +#define INCLUDED_DIGITAL_OFDM_FRAME_EQUALIZER_VCVC_IMPL_H + +#include <digital/ofdm_frame_equalizer_vcvc.h> + +namespace gr { + namespace digital { + + class ofdm_frame_equalizer_vcvc_impl : public ofdm_frame_equalizer_vcvc + { + private: + const int d_fft_len; + const int d_cp_len; + digital_ofdm_equalizer_base_sptr d_eq; + bool d_propagate_channel_state; + const int d_fixed_frame_len; + std::vector<gr_complex> d_channel_state; + + protected: + void parse_length_tags( + const std::vector<std::vector<gr_tag_t> > &tags, + gr_vector_int &n_input_items_reqd + ); + + public: + ofdm_frame_equalizer_vcvc_impl( + digital_ofdm_equalizer_base_sptr equalizer, + int cp_len, + const std::string &len_tag_key, + bool propagate_channel_state, + int fixed_frame_len + ); + ~ofdm_frame_equalizer_vcvc_impl(); + + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_FRAME_EQUALIZER_VCVC_IMPL_H */ + diff --git a/gr-digital/lib/ofdm_serializer_vcc_impl.cc b/gr-digital/lib/ofdm_serializer_vcc_impl.cc new file mode 100644 index 0000000000..2d6d68f758 --- /dev/null +++ b/gr-digital/lib/ofdm_serializer_vcc_impl.cc @@ -0,0 +1,212 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "ofdm_serializer_vcc_impl.h" + +namespace gr { + namespace digital { + + ofdm_serializer_vcc::sptr + ofdm_serializer_vcc::make( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::string &len_tag_key, + const std::string &packet_len_tag_key, + int symbols_skipped, + const std::string &carr_offset_key, + bool input_is_shifted + ) + { + return gnuradio::get_initial_sptr ( + new ofdm_serializer_vcc_impl( + fft_len, occupied_carriers, + len_tag_key, packet_len_tag_key, + symbols_skipped, + carr_offset_key, + input_is_shifted + ) + ); + } + + ofdm_serializer_vcc::sptr + ofdm_serializer_vcc::make( + const digital_ofdm_carrier_allocator_cvc_sptr &allocator, + const std::string &packet_len_tag_key, + int symbols_skipped, + const std::string &carr_offset_key, + bool input_is_shifted + ) + { + return gnuradio::get_initial_sptr( + new ofdm_serializer_vcc_impl( + allocator->fft_len(), + allocator->occupied_carriers(), + allocator->len_tag_key(), + packet_len_tag_key, + symbols_skipped, + carr_offset_key, + input_is_shifted + ) + ); + } + + ofdm_serializer_vcc_impl::ofdm_serializer_vcc_impl ( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::string &len_tag_key, + const std::string &packet_len_tag_key, + int symbols_skipped, + const std::string &carr_offset_key, + bool input_is_shifted) + : gr_tagged_stream_block ("ofdm_serializer_vcc", + gr_make_io_signature(1, 1, sizeof (gr_complex) * fft_len), + gr_make_io_signature(1, 1, sizeof (gr_complex)), + len_tag_key), + d_fft_len(fft_len), + d_occupied_carriers(occupied_carriers), + d_packet_len_tag_key(pmt::pmt_string_to_symbol(packet_len_tag_key)), + d_out_len_tag_key(pmt::pmt_string_to_symbol((packet_len_tag_key.empty() ? len_tag_key : packet_len_tag_key))), + d_symbols_skipped(symbols_skipped % occupied_carriers.size()), + d_carr_offset_key(pmt::pmt_string_to_symbol(carr_offset_key)), + d_curr_set(symbols_skipped % occupied_carriers.size()), + d_symbols_per_set(0) + { + for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { + for (unsigned k = 0; k < d_occupied_carriers[i].size(); k++) { + if (d_occupied_carriers[i][k] < 0) { + d_occupied_carriers[i][k] += fft_len; + } + if (d_occupied_carriers[i][k] >= fft_len || d_occupied_carriers[i][k] < 0) { + throw std::invalid_argument("ofdm_serializer_vcc: trying to occupy a carrier outside the fft length."); + } + if (input_is_shifted) { + d_occupied_carriers[i][k] = (d_occupied_carriers[i][k] + fft_len/2) % fft_len; + } + } + } + + for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { + d_symbols_per_set += d_occupied_carriers[i].size(); + } + set_relative_rate((double) d_symbols_per_set / d_occupied_carriers.size()); + set_tag_propagation_policy(TPP_DONT); + } + + ofdm_serializer_vcc_impl::~ofdm_serializer_vcc_impl() + { + } + + int + ofdm_serializer_vcc_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + int nout = (ninput_items[0] / d_occupied_carriers.size()) * d_symbols_per_set; + for (unsigned i = 0; i < ninput_items[0] % d_occupied_carriers.size(); i++) { + nout += d_occupied_carriers[(i + d_curr_set) % d_occupied_carriers.size()].size(); + } + return nout; + } + + void + ofdm_serializer_vcc_impl::update_length_tags(int n_produced, int n_ports) + { + add_item_tag(0, nitems_written(0), + d_out_len_tag_key, + pmt::pmt_from_long(n_produced) + ); + } + + int + ofdm_serializer_vcc_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex *) input_items[0]; + gr_complex *out = (gr_complex *) output_items[0]; + long frame_length = ninput_items[0]; // Input frame + long packet_length = 0; // Output frame + int carr_offset = 0; + + std::vector<gr_tag_t> tags; + // Packet mode + if (!d_length_tag_key_str.empty()) { + get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+1); + for (unsigned i = 0; i < tags.size(); i++) { + if (tags[i].key == d_carr_offset_key) { + carr_offset = pmt::pmt_to_long(tags[i].value); + } + if (tags[i].key == d_packet_len_tag_key) { + packet_length = pmt::pmt_to_long(tags[i].value); + remove_item_tag(0, tags[i]); + } + } + } else { + // recalc frame length from noutput_items + frame_length = 0; + int sym_per_frame = 0; + while ((sym_per_frame + d_occupied_carriers[(frame_length + 1) % d_occupied_carriers.size()].size()) < noutput_items) { + frame_length++; + sym_per_frame += d_occupied_carriers[(frame_length + 1) % d_occupied_carriers.size()].size(); + } + } + + // Copy symbols + int n_out_symbols = 0; + for (int i = 0; i < frame_length; i++) { + // Copy all tags associated with this input OFDM symbol onto the first output symbol + get_tags_in_range(tags, 0, + nitems_read(0)+i, + nitems_read(0)+i+1 + ); + for (unsigned t = 0; t < tags.size(); t++) { + add_item_tag(0, nitems_written(0)+n_out_symbols, + tags[t].key, + tags[t].value + ); + } + for (unsigned k = 0; k < d_occupied_carriers[d_curr_set].size(); k++) { + out[n_out_symbols++] = in[i * d_fft_len + d_occupied_carriers[d_curr_set][k] + carr_offset]; + } + if (packet_length && n_out_symbols > packet_length) { + n_out_symbols = packet_length; + break; + } + d_curr_set = (d_curr_set + 1) % d_occupied_carriers.size(); + } + + // Housekeeping + if (d_length_tag_key_str.empty()) { + consume_each(frame_length); + } else { + d_curr_set = d_symbols_skipped; + } + + return n_out_symbols; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/ofdm_serializer_vcc_impl.h b/gr-digital/lib/ofdm_serializer_vcc_impl.h new file mode 100644 index 0000000000..b6fbfdb146 --- /dev/null +++ b/gr-digital/lib/ofdm_serializer_vcc_impl.h @@ -0,0 +1,72 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_IMPL_H +#define INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_IMPL_H + +#include <digital/ofdm_serializer_vcc.h> + +namespace gr { + namespace digital { + + class ofdm_serializer_vcc_impl : public ofdm_serializer_vcc + { + private: + int d_fft_len; //!< FFT length + std::vector<std::vector<int> > d_occupied_carriers; //!< Which carriers/symbols carry data + pmt::pmt_t d_packet_len_tag_key; //!< Key of the length tag + pmt::pmt_t d_out_len_tag_key; //!< Key of the length tag + const int d_symbols_skipped; //!< Start position in d_occupied_carriers + pmt::pmt_t d_carr_offset_key; //!< Key of the carrier offset tag + int d_curr_set; //!< Current position in d_occupied_carriers + int d_symbols_per_set; + + protected: + /*! + * Calculate the number of scalar complex symbols given a number of + * OFDM symbols. + */ + int calculate_output_stream_length(const gr_vector_int &ninput_items); + void update_length_tags(int n_produced, int n_ports); + + public: + ofdm_serializer_vcc_impl( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::string &len_tag_key, + const std::string &packet_len_tag_key, + int symbols_skipped, + const std::string &carr_offset_key, + bool input_is_shifted + ); + ~ofdm_serializer_vcc_impl(); + + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_OFDM_SERIALIZER_VCC_IMPL_H */ + diff --git a/gr-digital/lib/packet_header_default.cc b/gr-digital/lib/packet_header_default.cc new file mode 100644 index 0000000000..573114bc51 --- /dev/null +++ b/gr-digital/lib/packet_header_default.cc @@ -0,0 +1,133 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <string.h> +#include <digital/packet_header_default.h> + +namespace gr { + namespace digital { + + packet_header_default::sptr + packet_header_default::make( + long header_len, + const std::string &len_tag_key, + const std::string &num_tag_key, + int bits_per_byte) + { + return packet_header_default::sptr(new packet_header_default(header_len, len_tag_key, num_tag_key, bits_per_byte)); + } + + const unsigned MASK_LUT[9] = {0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x2F, 0x7F, 0xFF}; + packet_header_default::packet_header_default( + long header_len, + const std::string &len_tag_key, + const std::string &num_tag_key, + int bits_per_byte) + : d_header_len(header_len), + d_len_tag_key(pmt::pmt_string_to_symbol(len_tag_key)), + d_num_tag_key(num_tag_key.empty() ? pmt::PMT_NIL : pmt::pmt_string_to_symbol(num_tag_key)), + d_bits_per_byte(bits_per_byte), + d_header_number(0) + { + if (d_bits_per_byte < 1 || d_bits_per_byte > 8) { + throw std::invalid_argument("bits_per_byte must be in [1, 8]"); + } + d_mask = MASK_LUT[d_bits_per_byte]; + } + + packet_header_default::~packet_header_default() + { + } + + bool packet_header_default::header_formatter( + long packet_len, + unsigned char *out, + const std::vector<gr_tag_t> &tags + ) + { + packet_len &= 0x0FFF; + + memset(out, 0x00, d_header_len); + int parity = 0; + int k = 0; // Position in out + for (int i = 0; i < 12 && k < d_header_len; i += d_bits_per_byte, k++) { + out[k] = (unsigned char) ((packet_len >> i) & d_mask); + parity += out[k]; + } + for (int i = 0; i < 16 && k < d_header_len; i += d_bits_per_byte, k++) { + out[k] = (unsigned char) ((d_header_number >> i) & d_mask); + parity += out[k]; + } + if (k < d_header_len) { + out[k] = (unsigned char) (parity % 2); + } + d_header_number++; + + return true; + } + + + bool packet_header_default::header_parser( + const unsigned char *in, + std::vector<gr_tag_t> &tags) + { + unsigned header_len = 0; + unsigned header_num = 0; + gr_tag_t tag; + + int k = 0; // Position in "in" + for (int i = 0; i < 12 && k < d_header_len; i += d_bits_per_byte, k++) { + header_len |= (((int) in[k]) & d_mask) << i; + } + tag.key = d_len_tag_key; + tag.value = pmt::pmt_from_long(header_len); + tags.push_back(tag); + if (k >= d_header_len) { + return true; + } + if (d_num_tag_key == pmt::PMT_NIL) { + k += 16; + } else { + for (int i = 0; i < 16 && k < d_header_len; i += d_bits_per_byte, k++) { + header_num |= (((int) in[k]) & d_mask) << i; + } + tag.key = d_num_tag_key; + tag.value = pmt::pmt_from_long(header_num); + tags.push_back(tag); + } + if (k >= d_header_len) { + return true; + } + + int parity = in[k]; + for (int i = 0; i < 28; i++) { + parity += in[i]; + } + return !(parity % 2); + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/packet_header_ofdm.cc b/gr-digital/lib/packet_header_ofdm.cc new file mode 100644 index 0000000000..9758ee696a --- /dev/null +++ b/gr-digital/lib/packet_header_ofdm.cc @@ -0,0 +1,124 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <digital/packet_header_ofdm.h> + +namespace gr { + namespace digital { + + int _get_header_len_from_occupied_carriers(const std::vector<std::vector<int> > &occupied_carriers, int n_syms) + { + int header_len = 0; + for (int i = 0; i < n_syms; i++) { + header_len += occupied_carriers[i].size(); + } + + return header_len; + } + + packet_header_ofdm::sptr + packet_header_ofdm::make( + const std::vector<std::vector<int> > &occupied_carriers, + int n_syms, + const std::string &len_tag_key, + const std::string &frame_len_tag_key, + const std::string &num_tag_key, + int bits_per_header_sym, + int bits_per_payload_sym) + { + return packet_header_ofdm::sptr( + new packet_header_ofdm( + occupied_carriers, n_syms, len_tag_key, frame_len_tag_key, num_tag_key, bits_per_header_sym, bits_per_payload_sym + ) + ); + } + + packet_header_ofdm::packet_header_ofdm( + const std::vector<std::vector<int> > &occupied_carriers, + int n_syms, + const std::string &len_tag_key, + const std::string &frame_len_tag_key, + const std::string &num_tag_key, + int bits_per_header_sym, + int bits_per_payload_sym) + : packet_header_default( + _get_header_len_from_occupied_carriers(occupied_carriers, n_syms), + len_tag_key, + num_tag_key, + bits_per_header_sym), + d_frame_len_tag_key(pmt::pmt_string_to_symbol(frame_len_tag_key)), + d_occupied_carriers(occupied_carriers), + d_syms_per_set(0), + d_bits_per_payload_sym(bits_per_payload_sym) + { + for (unsigned i = 0; i < d_occupied_carriers.size(); i++) { + d_syms_per_set += d_occupied_carriers[i].size(); + } + } + + packet_header_ofdm::~packet_header_ofdm() + { + } + + + bool packet_header_ofdm::header_parser( + const unsigned char *in, + std::vector<gr_tag_t> &tags) + { + if (!packet_header_default::header_parser(in, tags)) { + return false; + } + int packet_len = 0; // # of symbols in this frame + for (unsigned i = 0; i < tags.size(); i++) { + if (pmt::pmt_equal(tags[i].key, d_len_tag_key)) { + // Convert bytes to complex symbols: + packet_len = pmt::pmt_to_long(tags[i].value) * 8 / d_bits_per_payload_sym; + if (pmt::pmt_to_long(tags[i].value) * 8 % d_bits_per_payload_sym) { + packet_len++; + } + tags[i].value = pmt::pmt_from_long(packet_len); + break; + } + } + + // frame_len == # of OFDM symbols in this frame + int frame_len = packet_len / d_syms_per_set; + int k = 0; + int i = frame_len * d_syms_per_set; + while (i < packet_len) { + frame_len++; + i += d_occupied_carriers[k].size(); + } + gr_tag_t tag; + tag.key = d_frame_len_tag_key; + tag.value = pmt::pmt_from_long(frame_len); + tags.push_back(tag); + + return true; + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/packet_headergenerator_bb_impl.cc b/gr-digital/lib/packet_headergenerator_bb_impl.cc new file mode 100644 index 0000000000..3232858148 --- /dev/null +++ b/gr-digital/lib/packet_headergenerator_bb_impl.cc @@ -0,0 +1,93 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <boost/format.hpp> +#include <gr_io_signature.h> +#include "packet_headergenerator_bb_impl.h" + +namespace gr { + namespace digital { + + packet_headergenerator_bb::sptr + packet_headergenerator_bb::make( + const packet_header_default::sptr &header_formatter, + const std::string &len_tag_key + ) + { + return gnuradio::get_initial_sptr (new packet_headergenerator_bb_impl(header_formatter, len_tag_key)); + } + + + packet_headergenerator_bb::sptr + packet_headergenerator_bb::make( + long header_len, + const std::string &len_tag_key + ) + { + const packet_header_default::sptr header_formatter( + new packet_header_default(header_len, len_tag_key) + ); + return gnuradio::get_initial_sptr (new packet_headergenerator_bb_impl(header_formatter, len_tag_key)); + } + + + packet_headergenerator_bb_impl::packet_headergenerator_bb_impl( + const gr::digital::packet_header_default::sptr &header_formatter, + const std::string &len_tag_key + ) + : gr_tagged_stream_block("packet_headergenerator_bb_impl", + gr_make_io_signature(1, 1, sizeof (char)), + gr_make_io_signature(1, 1, sizeof (char)), + len_tag_key), + d_formatter(header_formatter) + { + set_output_multiple(d_formatter->header_len()); + // This is the worst case rate, because we don't know the true value, of course + set_relative_rate(d_formatter->header_len()); + set_tag_propagation_policy(TPP_DONT); + } + + packet_headergenerator_bb_impl::~packet_headergenerator_bb_impl() + { + } + + int + packet_headergenerator_bb_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + unsigned char *out = (unsigned char *) output_items[0]; + if (!d_formatter->header_formatter(ninput_items[0], out)) { + GR_LOG_FATAL(d_logger, boost::format("header_formatter() returned false (this shouldn't happen). Offending header started at %1%") % nitems_read(0)); + throw std::runtime_error("header formatter returned false."); + } + + return d_formatter->header_len(); + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/packet_headergenerator_bb_impl.h b/gr-digital/lib/packet_headergenerator_bb_impl.h new file mode 100644 index 0000000000..ce60fdf76c --- /dev/null +++ b/gr-digital/lib/packet_headergenerator_bb_impl.h @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_PACKET_HEADERGENERATOR_BB_IMPL_H +#define INCLUDED_DIGITAL_PACKET_HEADERGENERATOR_BB_IMPL_H + +#include <digital/packet_headergenerator_bb.h> + +namespace gr { + namespace digital { + + class packet_headergenerator_bb_impl : public packet_headergenerator_bb + { + private: + gr::digital::packet_header_default::sptr d_formatter; + + public: + packet_headergenerator_bb_impl( + const packet_header_default::sptr &header_formatter, + const std::string &len_tag_key + ); + ~packet_headergenerator_bb_impl(); + + void remove_length_tags(const std::vector<std::vector<gr_tag_t> > &tags) {}; + int calculate_output_stream_length(const gr_vector_int &ninput_items) { return d_formatter->header_len(); }; + + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_PACKET_HEADERGENERATOR_BB_IMPL_H */ + diff --git a/gr-digital/lib/packet_headerparser_b_impl.cc b/gr-digital/lib/packet_headerparser_b_impl.cc new file mode 100644 index 0000000000..fa24564d48 --- /dev/null +++ b/gr-digital/lib/packet_headerparser_b_impl.cc @@ -0,0 +1,97 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <boost/format.hpp> +#include <gr_io_signature.h> +#include "packet_headerparser_b_impl.h" + +#define msg_port_id pmt::mp("header_data") + +namespace gr { + namespace digital { + + packet_headerparser_b::sptr + packet_headerparser_b::make(long header_len, const std::string &len_tag_key) + { + const packet_header_default::sptr header_formatter( + new packet_header_default(header_len, len_tag_key) + ); + return gnuradio::get_initial_sptr (new packet_headerparser_b_impl(header_formatter)); + } + + packet_headerparser_b::sptr + packet_headerparser_b::make(const gr::digital::packet_header_default::sptr &header_formatter) + { + return gnuradio::get_initial_sptr (new packet_headerparser_b_impl(header_formatter)); + } + + packet_headerparser_b_impl::packet_headerparser_b_impl(const gr::digital::packet_header_default::sptr &header_formatter) + : gr_sync_block("packet_headerparser_b", + gr_make_io_signature(1, 1, sizeof (unsigned char)), + gr_make_io_signature(0, 0, 0)), + d_header_formatter(header_formatter) + { + message_port_register_out(msg_port_id); + set_output_multiple(header_formatter->header_len()); + } + + packet_headerparser_b_impl::~packet_headerparser_b_impl() + { + } + + int + packet_headerparser_b_impl::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const unsigned char *in = (const unsigned char *) input_items[0]; + + if (noutput_items < d_header_formatter->header_len()) { + return 0; + } + + std::vector<gr_tag_t> tags; + get_tags_in_range( + tags, 0, + nitems_read(0), + nitems_read(0)+d_header_formatter->header_len() + ); + if (!d_header_formatter->header_parser(in, tags)) { + GR_LOG_INFO(d_logger, boost::format("Detected an invalid packet at item %1%") % nitems_read(0)); + message_port_pub(msg_port_id, pmt::PMT_F); + } else { + pmt::pmt_t dict(pmt::pmt_make_dict()); + for (unsigned i = 0; i < tags.size(); i++) { + dict = pmt::pmt_dict_add(dict, tags[i].key, tags[i].value); + } + message_port_pub(msg_port_id, dict); + } + + return d_header_formatter->header_len(); + } + + } /* namespace digital */ +} /* namespace gr */ + diff --git a/gr-digital/lib/packet_headerparser_b_impl.h b/gr-digital/lib/packet_headerparser_b_impl.h new file mode 100644 index 0000000000..a7ded1143f --- /dev/null +++ b/gr-digital/lib/packet_headerparser_b_impl.h @@ -0,0 +1,48 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +#ifndef INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_IMPL_H +#define INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_IMPL_H + +#include <digital/packet_headerparser_b.h> + +namespace gr { + namespace digital { + + class packet_headerparser_b_impl : public packet_headerparser_b + { + private: + packet_header_default::sptr d_header_formatter; + + public: + packet_headerparser_b_impl(const gr::digital::packet_header_default::sptr &header_formatter); + ~packet_headerparser_b_impl(); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + }; + + } // namespace digital +} // namespace gr + +#endif /* INCLUDED_DIGITAL_PACKET_HEADERPARSER_B_IMPL_H */ + diff --git a/gr-digital/python/CMakeLists.txt b/gr-digital/python/CMakeLists.txt index 8f2af0664d..f820736c2f 100644 --- a/gr-digital/python/CMakeLists.txt +++ b/gr-digital/python/CMakeLists.txt @@ -39,10 +39,12 @@ GR_PYTHON_INSTALL( ofdm_sync_ml.py ofdm_sync_pnac.py ofdm_sync_pn.py + ofdm_txrx.py packet_utils.py pkt.py psk.py qam.py + qamlike.py qpsk.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/digital COMPONENT "digital_python" @@ -54,6 +56,7 @@ GR_PYTHON_INSTALL( utils/gray_code.py utils/mod_codes.py utils/alignment.py + utils/tagged_streams.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/digital/utils COMPONENT "digital_python" ) @@ -66,6 +69,12 @@ if(ENABLE_TESTING) list(APPEND GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gr-digital/python ${CMAKE_BINARY_DIR}/gr-digital/swig + ${CMAKE_BINARY_DIR}/gr-fft/python + ${CMAKE_BINARY_DIR}/gr-fft/swig + ${CMAKE_BINARY_DIR}/gr-blocks/python + ${CMAKE_BINARY_DIR}/gr-blocks/swig + ${CMAKE_BINARY_DIR}/gr-analog/python + ${CMAKE_BINARY_DIR}/gr-analog/swig ) list(APPEND GR_TEST_TARGET_DEPS gnuradio-digital gnuradio-filter gnuradio-fft) diff --git a/gr-digital/python/__init__.py b/gr-digital/python/__init__.py index 3fdbca769a..1c7958f178 100644 --- a/gr-digital/python/__init__.py +++ b/gr-digital/python/__init__.py @@ -42,6 +42,7 @@ from ofdm_sync_fixed import * from ofdm_sync_ml import * from ofdm_sync_pnac import * from ofdm_sync_pn import * +from ofdm_txrx import ofdm_tx, ofdm_rx import packet_utils import ofdm_packet_utils diff --git a/gr-digital/python/ofdm_txrx.py b/gr-digital/python/ofdm_txrx.py new file mode 100644 index 0000000000..ea5f682edd --- /dev/null +++ b/gr-digital/python/ofdm_txrx.py @@ -0,0 +1,393 @@ +# +# 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. +# +""" +OFDM Transmitter / Receiver hier blocks. + +For simple configurations, no need to connect all the relevant OFDM blocks +to form an OFDM Tx/Rx--simply use these. +""" + +import numpy +from gnuradio import gr +import digital_swig as digital +from utils import tagged_streams + +try: + # This will work when feature #505 is added. + from gnuradio import fft + from gnuradio import blocks + from gnuradio import analog +except ImportError: + # Until then this will work. + import fft_swig as fft + import blocks_swig as blocks + import analog_swig as analog + +_def_fft_len = 64 +_def_cp_len = 16 +_def_frame_length_tag_key = "frame_length" +_def_packet_length_tag_key = "packet_length" +_def_packet_num_tag_key = "packet_num" +# Data and pilot carriers are same as in 802.11a +_def_occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) +_def_pilot_carriers=((-21, -7, 7, 21,),) +_pilot_sym_scramble_seq = ( + 1,1,1,1, -1,-1,-1,1, -1,-1,-1,-1, 1,1,-1,1, -1,-1,1,1, -1,1,1,-1, 1,1,1,1, 1,1,-1,1, + 1,1,-1,1, 1,-1,-1,1, 1,1,-1,1, -1,-1,-1,1, -1,1,-1,-1, 1,-1,-1,1, 1,1,1,1, -1,-1,1,1, + -1,-1,1,-1, 1,-1,1,1, -1,-1,-1,1, 1,-1,-1,-1, -1,1,-1,-1, 1,-1,1,1, 1,1,-1,1, -1,1,-1,1, + -1,-1,-1,-1, -1,1,-1,1, 1,-1,1,-1, 1,1,1,-1, -1,1,-1,-1, -1,1,1,1, -1,-1,-1,-1, -1,-1,-1 +) +_def_pilot_symbols= tuple([(x, x, x, -x) for x in _pilot_sym_scramble_seq]) +_seq_seed = 42 + + +def _get_active_carriers(fft_len, occupied_carriers, pilot_carriers): + active_carriers = list() + for carrier in list(occupied_carriers[0]) + list(pilot_carriers[0]): + if carrier < 0: + carrier += fft_len + active_carriers.append(carrier) + return active_carriers + +def _make_sync_word1(fft_len, occupied_carriers, pilot_carriers): + """ Creates a random sync sequence for fine frequency offset and timing + estimation. This is the first of typically two sync preamble symbols + for the Schmidl & Cox sync algorithm. + The relevant feature of this symbols is that every second sub-carrier + is zero. In the time domain, this results in two identical halves of + the OFDM symbols. + Symbols are always BPSK symbols. Carriers are scaled by sqrt(2) to keep + total energy constant. + Carrier 0 (DC carrier) is always zero. If used, carrier 1 is non-zero. + This means the sync algorithm has to check on odd carriers! + """ + active_carriers = _get_active_carriers(fft_len, occupied_carriers, pilot_carriers) + numpy.random.seed(_seq_seed) + bpsk = {0: numpy.sqrt(2), 1: -numpy.sqrt(2)} + return [bpsk[numpy.random.randint(2)] if x in active_carriers and x % 2 else 0 for x in range(fft_len)] + +def _make_sync_word2(fft_len, occupied_carriers, pilot_carriers): + """ Creates a random sync sequence for coarse frequency offset and channel + estimation. This is the second of typically two sync preamble symbols + for the Schmidl & Cox sync algorithm. + Symbols are always BPSK symbols. + """ + active_carriers = _get_active_carriers(fft_len, occupied_carriers, pilot_carriers) + numpy.random.seed(_seq_seed) + bpsk = {0: 1, 1: -1} + sw2 = [bpsk[numpy.random.randint(2)] if x in active_carriers else 0 for x in range(fft_len)] + sw2[0] = 0j + return sw2 + +SW2 = ( + 0+0j, 1, -1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -1, 1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1 +) + +def _get_constellation(bps): + """ Returns a modulator block for a given number of bits per symbol """ + constellation = { + 1: digital.constellation_bpsk(), + 2: digital.constellation_qpsk(), + 3: digital.constellation_8psk() + } + try: + return constellation[bps] + except KeyError: + print 'Modulation not supported.' + exit(1) + +class ofdm_tx(gr.hier_block2): + """ Hierarchical block for OFDM modulation. + + The input is a byte stream (unsigned char) and the + output is the complex modulated signal at baseband. + + Args: + fft_len: The length of FFT (integer). + cp_len: The length of cyclic prefix in total samples (integer). + packet_length_tag_key: The name of the tag giving packet length at the input. + occupied_carriers: A vector of vectors describing which OFDM carriers are occupied. + pilot_carriers: A vector of vectors describing which OFDM carriers are occupied with pilot symbols. + pilot_symbols: The pilot symbols. + bps_header: Bits per symbol (header). + bps_payload: Bits per symbol (payload). + sync_word1: The first sync preamble symbol. This has to be with zeros on alternating carriers. + Used for fine and coarse frequency offset and timing estimation. + sync_word2: The second sync preamble symbol. This has to be filled entirely. Also used for + coarse frequency offset and channel estimation. + rolloff: The rolloff length in samples. Must be smaller than the CP. + """ + def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len, + packet_length_tag_key=_def_packet_length_tag_key, + occupied_carriers=_def_occupied_carriers, + pilot_carriers=_def_pilot_carriers, + pilot_symbols=_def_pilot_symbols, + bps_header=1, + bps_payload=1, + sync_word1=None, + sync_word2=None, + rolloff=0, + debug_log=False + ): + gr.hier_block2.__init__(self, "ofdm_tx", + gr.io_signature(1, 1, gr.sizeof_char), + gr.io_signature(1, 1, gr.sizeof_gr_complex)) + ### Param init / sanity check ######################################## + self.fft_len = fft_len + self.cp_len = cp_len + self.packet_length_tag_key = packet_length_tag_key + self.occupied_carriers = occupied_carriers + self.pilot_carriers = pilot_carriers + self.pilot_symbols = pilot_symbols + self.bps_header = bps_header + self.bps_payload = bps_payload + n_sync_words = 1 + self.sync_word1 = sync_word1 + if sync_word1 is None: + self.sync_word1 = _make_sync_word1(fft_len, occupied_carriers, pilot_carriers) + else: + if len(sync_word1) != self.fft_len: + raise ValueError("Length of sync sequence(s) must be FFT length.") + total_sync_word = self.sync_word1 + self.sync_words = [self.sync_word1,] + self.sync_word2 = () + if sync_word2 is None: + self.sync_word2 = _make_sync_word2(fft_len, occupied_carriers, pilot_carriers) + if len(self.sync_word2): + if len(self.sync_word2) != fft_len: + raise ValueError("Length of sync sequence(s) must be FFT length.") + self.sync_word2 = list(self.sync_word2) + total_sync_word = self.sync_word1 + self.sync_word2 + n_sync_words = 2 + ### Header modulation ################################################ + crc = digital.crc32_bb(False, self.packet_length_tag_key) + header_constellation = _get_constellation(bps_header) + header_mod = digital.chunks_to_symbols_bc(header_constellation.points()) + formatter_object = digital.packet_header_ofdm( + occupied_carriers=occupied_carriers, n_syms=1, + bits_per_header_sym=self.bps_header, + bits_per_payload_sym=self.bps_payload + ) + header_gen = digital.packet_headergenerator_bb(formatter_object.base(), self.packet_length_tag_key) + header_payload_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, self.packet_length_tag_key) + self.connect(self, crc, header_gen, header_mod, (header_payload_mux, 0)) + ### Payload modulation ############################################### + payload_constellation = _get_constellation(bps_payload) + payload_mod = digital.chunks_to_symbols_bc(payload_constellation.points()) + self.connect( + crc, + blocks.repack_bits_bb( + 8, # Unpack 8 bits per byte + bps_payload, + self.packet_length_tag_key + ), + payload_mod, + (header_payload_mux, 1) + ) + ### Sync word prepending ############################################# + sync_word_gen = gr.vector_source_c( + total_sync_word, True, self.fft_len, + tagged_streams.make_lengthtags((n_sync_words,), (0,), self.packet_length_tag_key) + ) + syncword_data_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*self.fft_len, self.packet_length_tag_key) + self.connect(sync_word_gen, (syncword_data_mux, 0)) + ### Create OFDM frame ################################################ + allocator = digital.ofdm_carrier_allocator_cvc( + self.fft_len, + self.occupied_carriers, + self.pilot_carriers, + self.pilot_symbols, + #self.sync_words, + self.packet_length_tag_key + ) + ffter = fft.fft_vcc( + self.fft_len, + False, # Inverse FFT + (), # No window + False # No shifting + ) + cyclic_prefixer = digital.ofdm_cyclic_prefixer( + self.fft_len, + self.fft_len+self.cp_len, + rolloff, + self.packet_length_tag_key + ) + self.connect(header_payload_mux, allocator, (syncword_data_mux, 1)) + self.connect(syncword_data_mux, ffter, cyclic_prefixer, self) + if debug_log: + self.connect(allocator, blocks.file_sink(8*64, 'tx-post-allocator.dat')) + self.connect(syncword_data_mux, blocks.file_sink(8*64, 'post-sync-mux.dat')) + self.connect(cyclic_prefixer, blocks.file_sink(8, 'tx-signal.dat')) + + +class ofdm_rx(gr.hier_block2): + """ Hierarchical block for OFDM demodulation. + + The input is a complex baseband signal (e.g. from a UHD source). + The detected packets are output as a stream of packed bits on the output. + + Args: + fft_len: The length of FFT (integer). + cp_len: The length of cyclic prefix in total samples (integer). + frame_length_tag_key: Used internally to tag the length of the OFDM frame. + packet_length_tag_key: The name of the tag giving packet length at the input. + occupied_carriers: A vector of vectors describing which OFDM carriers are occupied. + pilot_carriers: A vector of vectors describing which OFDM carriers are occupied with pilot symbols. + pilot_symbols: The pilot symbols. + bps_header: Bits per symbol (header). + bps_payload: Bits per symbol (payload). + sync_word1: The first sync preamble symbol. This has to be with zeros on alternating carriers. + Used for fine and coarse frequency offset and timing estimation. + sync_word2: The second sync preamble symbol. This has to be filled entirely. Also used for + coarse frequency offset and channel estimation. + """ + def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len, + frame_length_tag_key=_def_frame_length_tag_key, + packet_length_tag_key=_def_packet_length_tag_key, + packet_num_tag_key=_def_packet_num_tag_key, + occupied_carriers=_def_occupied_carriers, + pilot_carriers=_def_pilot_carriers, + pilot_symbols=_def_pilot_symbols, + bps_header=1, + bps_payload=1, + sync_word1=None, + sync_word2=None, + debug_log=False + ): + gr.hier_block2.__init__(self, "ofdm_rx", + gr.io_signature(1, 1, gr.sizeof_gr_complex), + gr.io_signature(1, 1, gr.sizeof_char)) + ### Param init / sanity check ######################################## + self.fft_len = fft_len + self.cp_len = cp_len + self.frame_length_tag_key = frame_length_tag_key + self.packet_length_tag_key = packet_length_tag_key + self.occupied_carriers = occupied_carriers + self.bps_header = bps_header + self.bps_payload = bps_payload + n_sync_words = 1 + if sync_word1 is None: + self.sync_word1 = _make_sync_word1(fft_len, occupied_carriers, pilot_carriers) + else: + if len(sync_word1) != self.fft_len: + raise ValueError("Length of sync sequence(s) must be FFT length.") + self.sync_word1 = sync_word1 + self.sync_word2 = () + if sync_word2 is None: + self.sync_word2 = _make_sync_word2(fft_len, occupied_carriers, pilot_carriers) + n_sync_words = 2 + elif len(sync_word2): + if len(sync_word2) != fft_len: + raise ValueError("Length of sync sequence(s) must be FFT length.") + self.sync_word2 = sync_word2 + n_sync_words = 2 + ### Sync ############################################################ + sync_detect = digital.ofdm_sync_sc_cfb(fft_len, cp_len) + delay = blocks.delay(gr.sizeof_gr_complex, fft_len+cp_len) + oscillator = analog.frequency_modulator_fc(-2.0 / fft_len) + mixer = gr.multiply_cc() + hpd = digital.header_payload_demux( + n_sync_words+1, # Number of OFDM symbols before payload (sync + 1 sym header) + fft_len, cp_len, # FFT length, guard interval + frame_length_tag_key, # Frame length tag key + "", # We're not using trigger tags + True # One output item is one OFDM symbol (False would output complex scalars) + ) + self.connect(self, sync_detect) + self.connect(self, delay, (mixer, 0), (hpd, 0)) + self.connect((sync_detect, 0), oscillator, (mixer, 1)) + self.connect((sync_detect, 1), (hpd, 1)) + if debug_log: + self.connect((sync_detect, 0), blocks.file_sink(gr.sizeof_float, 'freq-offset.dat')) + self.connect((sync_detect, 1), blocks.file_sink(gr.sizeof_char, 'sync-detect.dat')) + ### Header demodulation ############################################## + header_fft = fft.fft_vcc(self.fft_len, True, (), True) + chanest = digital.ofdm_chanest_vcvc(self.sync_word1, numpy.fft.fftshift(self.sync_word2), 1) + header_constellation = _get_constellation(bps_header) + header_equalizer = digital.ofdm_equalizer_simpledfe( + fft_len, header_constellation.base(), + occupied_carriers, pilot_carriers, pilot_symbols, 0, 0 + ) + header_eq = digital.ofdm_frame_equalizer_vcvc( + header_equalizer.base(), + cp_len, + self.frame_length_tag_key, + True, + 1 # Header is 1 symbol long + ) + header_serializer = digital.ofdm_serializer_vcc( + fft_len, occupied_carriers, + self.frame_length_tag_key + ) + header_demod = digital.constellation_decoder_cb(header_constellation.base()) + header_formatter = digital.packet_header_ofdm( + occupied_carriers, 1, + packet_length_tag_key, + frame_length_tag_key, + packet_num_tag_key, + bps_header + ) + header_parser = digital.packet_headerparser_b(header_formatter.formatter()) + self.connect((hpd, 0), header_fft, chanest, header_eq, header_serializer, header_demod, header_parser) + self.msg_connect(header_parser, "header_data", hpd, "header_data") + if debug_log: + self.connect((chanest, 1), blocks.file_sink(512, 'channel-estimate.dat')) + self.connect((chanest, 0), blocks.file_sink(512, 'post-hdr-chanest.dat')) + self.connect(header_eq, blocks.file_sink(512, 'post-hdr-eq.dat')) + self.connect(header_serializer, blocks.file_sink(8, 'post-hdr-serializer.dat')) + self.connect(header_demod, blocks.file_sink(1, 'post-hdr-demod.dat')) + ### Payload demod #################################################### + payload_fft = fft.fft_vcc(self.fft_len, True, (), True) + payload_constellation = _get_constellation(bps_payload) + payload_equalizer = digital.ofdm_equalizer_simpledfe( + fft_len, payload_constellation.base(), + occupied_carriers, + pilot_carriers, + pilot_symbols, + 1 # Skip 1 symbol (that was already in the header) + ) + payload_eq = digital.ofdm_frame_equalizer_vcvc( + payload_equalizer.base(), + cp_len, + self.frame_length_tag_key + ) + payload_serializer = digital.ofdm_serializer_vcc( + fft_len, occupied_carriers, + self.frame_length_tag_key, + self.packet_length_tag_key, + 1 # Skip 1 symbol (that was already in the header) + ) + payload_demod = digital.constellation_decoder_cb(payload_constellation.base()) + repack = blocks.repack_bits_bb(bps_payload, 8, self.packet_length_tag_key, True) + crc = digital.crc32_bb(True, self.packet_length_tag_key) + self.connect((hpd, 1), payload_fft, payload_eq, payload_serializer, payload_demod, repack, crc, self) + if debug_log: + self.connect((hpd, 1), blocks.tag_debug(8*64, 'post-hpd')); + self.connect(payload_fft, blocks.file_sink(8*64, 'post-payload-fft.dat')) + self.connect(payload_eq, blocks.file_sink(8*64, 'post-payload-eq.dat')) + self.connect(payload_serializer, blocks.file_sink(8, 'post-payload-serializer.dat')) + self.connect(payload_demod, blocks.file_sink(1, 'post-payload-demod.dat')) + self.connect(repack, blocks.file_sink(1, 'post-payload-repack.dat')) + self.connect(crc, blocks.file_sink(1, 'post-payload-crc.dat')) + self.connect(crc, blocks.tag_debug(1, 'post-payload-crc')) + + diff --git a/gr-digital/python/qa_constellation.py b/gr-digital/python/qa_constellation.py index 6962ec6338..ddd8c71e64 100755 --- a/gr-digital/python/qa_constellation.py +++ b/gr-digital/python/qa_constellation.py @@ -30,6 +30,7 @@ import digital_swig # import from local folder import psk import qam +import qamlike tested_mod_codes = (mod_codes.NO_CODE, mod_codes.GRAY_CODE) @@ -64,14 +65,19 @@ def threed_constell(): dim = 3 return digital_swig.constellation_calcdist(points, [], rot_sym, dim) -tested_constellation_info = ( +# A list of tuples for constellation testing. The contents of the +# tuples are (constructor, poss_args, differential, diff_argname). + +# These constellations should lock on well. +easy_constellation_info = ( (psk.psk_constellation, - {'m': (2, 4, 8, 16, 32, 64), + {'m': (2, 4, 8, 16, ), 'mod_code': tested_mod_codes, }, True, None), (qam.qam_constellation, - {'constellation_points': (4, 16, 64), - 'mod_code': tested_mod_codes, }, + {'constellation_points': (4,), + 'mod_code': tested_mod_codes, + 'large_ampls_to_corners': [False],}, True, None), (digital_swig.constellation_bpsk, {}, True, None), (digital_swig.constellation_qpsk, {}, False, None), @@ -81,11 +87,44 @@ tested_constellation_info = ( (threed_constell, {}, True, None), ) -def tested_constellations(): +# These constellations don't work nicely. +# We have a lower required error rate. +medium_constellation_info = ( + (psk.psk_constellation, + {'m': (32, 64), + 'mod_code': tested_mod_codes, }, + True, None), + (qam.qam_constellation, + {'constellation_points': (16 ,), + 'mod_code': tested_mod_codes, + 'large_ampls_to_corners': [False, True],}, + True, None), + (qamlike.qam32_holeinside_constellation, + {'large_ampls_to_corners': [True]}, + True, None), +) + +# These constellation are basically broken in our test +difficult_constellation_info = ( + (qam.qam_constellation, + {'constellation_points': (64,), + 'mod_code': tested_mod_codes, + 'large_ampls_to_corners': [False, True],}, + True, None), +) + +def tested_constellations(easy=True, medium=True, difficult=True): """ Generator to produce (constellation, differential) tuples for testing purposes. """ - for constructor, poss_args, differential, diff_argname in tested_constellation_info: + constellation_info = [] + if easy: + constellation_info += easy_constellation_info + if medium: + constellation_info += medium_constellation_info + if difficult: + constellation_info += difficult_constellation_info + for constructor, poss_args, differential, diff_argname in constellation_info: if differential: diff_poss = (True, False) else: diff --git a/gr-digital/python/qa_constellation_receiver.py b/gr-digital/python/qa_constellation_receiver.py index 2d25433b92..37e56b4cf7 100755 --- a/gr-digital/python/qa_constellation_receiver.py +++ b/gr-digital/python/qa_constellation_receiver.py @@ -39,7 +39,9 @@ SEED = 1239 # We need this many to let the frequency recovery block converge. DATA_LENGTH = 2000 # Test fails if fraction of output that is correct is less than this. -REQ_CORRECT = 0.7 +EASY_REQ_CORRECT = 0.9 +# For constellations that aren't expected to work so well. +MEDIUM_REQ_CORRECT = 0.8 # CHANNEL PARAMETERS NOISE_VOLTAGE = 0.01 @@ -78,25 +80,33 @@ class test_constellation_receiver (gr_unittest.TestCase): self.indices = alignment.random_sample( self.max_data_length, self.max_num_samples, SEED) - for constellation, differential in tested_constellations(): - # The constellation_receiver doesn't work for constellations - # of multple dimensions (i.e. multiple complex numbers to a - # single symbol). - # That is not implemented since the receiver has no way of - # knowing where the beginning of a symbol is. - # It also doesn't work for non-differential modulation. - if constellation.dimensionality() != 1 or not differential: - continue - data_length = DATA_LENGTH * constellation.bits_per_symbol() - tb = rec_test_tb(constellation, differential, - src_data=self.src_data[:data_length]) - tb.run() - data = tb.dst.data() - d1 = tb.src_data[:int(len(tb.src_data)*self.ignore_fraction)] - d2 = data[:int(len(data)*self.ignore_fraction)] - correct, overlap, offset, indices = alignment.align_sequences( - d1, d2, indices=self.indices) - self.assertTrue(correct > REQ_CORRECT) + requirements = ( + (EASY_REQ_CORRECT, tested_constellations(easy=True, medium=False, difficult=False)), + (MEDIUM_REQ_CORRECT, tested_constellations(easy=False, medium=True, difficult=False)), + ) + for req_correct, tcs in requirements: + for constellation, differential in tcs: + # The constellation_receiver doesn't work for constellations + # of multple dimensions (i.e. multiple complex numbers to a + # single symbol). + # That is not implemented since the receiver has no way of + # knowing where the beginning of a symbol is. + # It also doesn't work for non-differential modulation. + if constellation.dimensionality() != 1 or not differential: + continue + data_length = DATA_LENGTH * constellation.bits_per_symbol() + tb = rec_test_tb(constellation, differential, + src_data=self.src_data[:data_length]) + tb.run() + data = tb.dst.data() + d1 = tb.src_data[:int(len(tb.src_data)*self.ignore_fraction)] + d2 = data[:int(len(data)*self.ignore_fraction)] + correct, overlap, offset, indices = alignment.align_sequences( + d1, d2, indices=self.indices) + if correct <= req_correct: + print("Constellation is {0}. Differential is {1}. Required correct is {2}. Correct is {3}. FAIL.". + format(constellation, differential, req_correct, correct)) + self.assertTrue(correct > req_correct) class rec_test_tb (gr.top_block): diff --git a/gr-digital/python/qa_crc32_bb.py b/gr-digital/python/qa_crc32_bb.py new file mode 100755 index 0000000000..d63b5e1222 --- /dev/null +++ b/gr-digital/python/qa_crc32_bb.py @@ -0,0 +1,149 @@ +#!/usr/bin/env python +# Copyright 2012 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. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital +try: import pmt +except: from gruel import pmt + +class qa_crc32_bb (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_crc_len (self): + """ Make sure the output of a CRC set is 4 bytes longer than the input. """ + data = range(16) + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(data)) + src = gr.vector_source_b(data, False, 1, (tag,)) + crc = digital.crc32_bb(False, tag_name) + sink = gr.vector_sink_b() + self.tb.connect(src, crc, sink) + self.tb.run() + # Check that the packets before crc_check are 4 bytes longer that the input. + self.assertEqual(len(data)+4, len(sink.data())) + + def test_002_crc_equal (self): + """ Go through CRC set / CRC check and make sure the output + is the same as the input. """ + data = (0, 1, 2, 3, 4, 5, 6, 7, 8) + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(data)) + src = gr.vector_source_b(data, False, 1, (tag,)) + crc = digital.crc32_bb(False, tag_name) + crc_check = digital.crc32_bb(True, tag_name) + sink = gr.vector_sink_b() + self.tb.connect(src, crc, crc_check, sink) + self.tb.run() + # Check that the packets after crc_check are the same as input. + self.assertEqual(data, sink.data()) + + def test_003_crc_correct_lentag (self): + tag_name = "length" + pack_len = 8 + packets = range(pack_len*2) + tag1 = gr.gr_tag_t() + tag1.offset = 0 + tag1.key = pmt.pmt_string_to_symbol(tag_name) + tag1.value = pmt.pmt_from_long(pack_len) + tag2 = gr.gr_tag_t() + tag2.offset = pack_len + tag2.key = pmt.pmt_string_to_symbol(tag_name) + tag2.value = pmt.pmt_from_long(pack_len) + testtag1 = gr.gr_tag_t() + testtag1.offset = 1 + testtag1.key = pmt.pmt_string_to_symbol("tag1") + testtag1.value = pmt.pmt_from_long(0) + testtag2 = gr.gr_tag_t() + testtag2.offset = pack_len + testtag2.key = pmt.pmt_string_to_symbol("tag2") + testtag2.value = pmt.pmt_from_long(0) + testtag3 = gr.gr_tag_t() + testtag3.offset = len(packets)-1 + testtag3.key = pmt.pmt_string_to_symbol("tag3") + testtag3.value = pmt.pmt_from_long(0) + src = gr.vector_source_b(packets, False, 1, (tag1, tag2, testtag1, testtag2, testtag3)) + crc = digital.crc32_bb(False, tag_name) + sink = gr.vector_sink_b() + self.tb.connect(src, crc, sink) + self.tb.run() + self.assertEqual(len(sink.data()), 2*(pack_len+4)) + correct_offsets = {'tag1': 1, 'tag2': 12, 'tag3': 19} + tags_found = {'tag1': False, 'tag2': False, 'tag3': False} + for tag in sink.tags(): + key = pmt.pmt_symbol_to_string(tag.key) + if key in correct_offsets.keys(): + tags_found[key] = True + self.assertEqual(correct_offsets[key], tag.offset) + if key == tag_name: + self.assertTrue(tag.offset == 0 or tag.offset == pack_len+4) + self.assertTrue(all(tags_found.values())) + + + def test_004_fail (self): + """ Corrupt the data and make sure it fails CRC test. """ + data = (0, 1, 2, 3, 4, 5, 6, 7) + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(data)) + src = gr.vector_source_b(data, False, 1, (tag,)) + crc = digital.crc32_bb(False, tag_name) + crc_check = digital.crc32_bb(True, tag_name) + corruptor = gr.add_const_bb(1) + sink = gr.vector_sink_b() + self.tb.connect(src, crc, corruptor, crc_check, sink) + self.tb.run() + # crc_check will drop invalid packets + self.assertEqual(len(sink.data()), 0) + + def test_005_tag_propagation (self): + """ Make sure tags on the CRC aren't lost. """ + data = (0, 1, 2, 3, 4, 5, 6, 7, 8, 230, 166, 39, 8) + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(data)) + testtag = gr.gr_tag_t() + testtag.offset = len(data)-1 + testtag.key = pmt.pmt_string_to_symbol('tag1') + testtag.value = pmt.pmt_from_long(0) + src = gr.vector_source_b(data, False, 1, (tag, testtag)) + crc_check = digital.crc32_bb(True, tag_name) + sink = gr.vector_sink_b() + self.tb.connect(src, crc_check, sink) + self.tb.run() + self.assertEqual([len(data)-5,], [tag.offset for tag in sink.tags() if pmt.pmt_symbol_to_string(tag.key) == 'tag1']) + +if __name__ == '__main__': + gr_unittest.run(qa_crc32_bb, "qa_crc32_bb.xml") diff --git a/gr-digital/python/qa_header_payload_demux.py b/gr-digital/python/qa_header_payload_demux.py new file mode 100755 index 0000000000..15b3eadcf8 --- /dev/null +++ b/gr-digital/python/qa_header_payload_demux.py @@ -0,0 +1,78 @@ +#!/usr/bin/env python +# Copyright 2012 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. +# + +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import digital_swig as digital +import time + +class qa_header_payload_demux (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_t (self): + """ Simplest possible test: put in zeros, then header, + then payload, trigger signal, try to demux. + The return signal from the header parser is faked via _post() + """ + n_zeros = 100 + header = (1, 2, 3) + payload = tuple(range(17)) + data_signal = (0,) * n_zeros + header + payload + trigger_signal = [0,] * len(data_signal) + trigger_signal[n_zeros] = 1 + + data_src = gr.vector_source_f(data_signal, False) + trigger_src = gr.vector_source_b(trigger_signal, False) + hpd = digital.header_payload_demux( + len(header), 1, 0, "frame_len", "detect", False, gr.sizeof_float + ) + self.assertEqual(pmt.pmt_length(hpd.message_ports_in()), 1) + header_sink = gr.vector_sink_f() + payload_sink = gr.vector_sink_f() + + self.tb.connect(data_src, (hpd, 0)) + self.tb.connect(trigger_src, (hpd, 1)) + self.tb.connect((hpd, 0), header_sink) + self.tb.connect((hpd, 1), payload_sink) + self.tb.start() + time.sleep(.2) # Need this, otherwise, the next message is ignored + hpd.to_basic_block()._post( + pmt.pmt_intern('header_data'), + pmt.pmt_from_long(len(payload)) + ) + while len(payload_sink.data()) < len(payload): + time.sleep(.2) + self.tb.stop() + self.tb.wait() + + self.assertEqual(header_sink.data(), header) + self.assertEqual(payload_sink.data(), payload) + + +if __name__ == '__main__': + gr_unittest.run(qa_header_payload_demux, "qa_header_payload_demux.xml") + diff --git a/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py b/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py new file mode 100755 index 0000000000..1b013865f4 --- /dev/null +++ b/gr-digital/python/qa_ofdm_carrier_allocator_cvc.py @@ -0,0 +1,154 @@ +#!/usr/bin/env python +# Copyright 2012 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. +# + +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import digital_swig as digital + +class qa_digital_carrier_allocator_cvc (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_t (self): + """ + pretty simple + """ + fft_len = 6 + tx_symbols = (1, 2, 3) + pilot_symbols = ((1j,),) + occupied_carriers = ((0, 1, 2),) + pilot_carriers = ((3,),) + expected_result = (1, 2, 3, 1j, 0, 0) + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(tx_symbols)) + src = gr.vector_source_c(tx_symbols, False, 1, (tag,)) + alloc = digital.ofdm_carrier_allocator_cvc(fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + tag_name) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, alloc, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_result) + + def test_002_t (self): + """ + same, but using negative carrier indices + """ + fft_len = 6 + tx_symbols = (1, 2, 3) + pilot_symbols = ((1j,),) + occupied_carriers = ((-1, 1, 2),) + pilot_carriers = ((3,),) + expected_result = (0, 2, 3, 1j, 0, 1) + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(tx_symbols)) + src = gr.vector_source_c(tx_symbols, False, 1, (tag,)) + alloc = digital.ofdm_carrier_allocator_cvc(fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + tag_name) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, alloc, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_result) + + def test_003_t (self): + """ + more advanced: + - 6 symbols per carrier + - 2 pilots per carrier + - have enough data for nearly 3 OFDM symbols + - send that twice + - add some random tags + """ + tx_symbols = range(1, 16); # 15 symbols + pilot_symbols = ((1j, 2j), (3j, 4j)) + occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),) + pilot_carriers = ((2, 13), (3, 12)) + expected_result = (0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, 0, + 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, 0, + 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0, 0) + fft_len = 16 + tag_name = "len" + tag1 = gr.gr_tag_t() + tag1.offset = 0 + tag1.key = pmt.pmt_string_to_symbol(tag_name) + tag1.value = pmt.pmt_from_long(len(tx_symbols)) + tag2 = gr.gr_tag_t() + tag2.offset = len(tx_symbols) + tag2.key = pmt.pmt_string_to_symbol(tag_name) + tag2.value = pmt.pmt_from_long(len(tx_symbols)) + testtag1 = gr.gr_tag_t() + testtag1.offset = 0 + testtag1.key = pmt.pmt_string_to_symbol('tag1') + testtag1.value = pmt.pmt_from_long(0) + testtag2 = gr.gr_tag_t() + testtag2.offset = 7 # On the 2nd OFDM symbol + testtag2.key = pmt.pmt_string_to_symbol('tag2') + testtag2.value = pmt.pmt_from_long(0) + testtag3 = gr.gr_tag_t() + testtag3.offset = len(tx_symbols)+1 # First OFDM symbol of packet 2 + testtag3.key = pmt.pmt_string_to_symbol('tag3') + testtag3.value = pmt.pmt_from_long(0) + testtag4 = gr.gr_tag_t() + testtag4.offset = 2*len(tx_symbols)-1 # Last OFDM symbol of packet 2 + testtag4.key = pmt.pmt_string_to_symbol('tag4') + testtag4.value = pmt.pmt_from_long(0) + src = gr.vector_source_c(tx_symbols * 2, False, 1, (tag1, tag2, testtag1, testtag2, testtag3, testtag4)) + alloc = digital.ofdm_carrier_allocator_cvc(fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + tag_name) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, alloc, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_result * 2) + tags_found = {'tag1': False, 'tag2': False, 'tag3': False, 'tag4': False} + correct_offsets = {'tag1': 0, 'tag2': 1, 'tag3': 3, 'tag4': 5} + for tag in sink.tags(): + key = pmt.pmt_symbol_to_string(tag.key) + if key in tags_found.keys(): + tags_found[key] = True + self.assertEqual(correct_offsets[key], tag.offset) + if key == tag_name: + self.assertTrue(tag.offset == 0 or tag.offset == 3) + self.assertTrue(pmt.pmt_to_long(tag.value) == 3) + self.assertTrue(all(tags_found.values())) + + +if __name__ == '__main__': + gr_unittest.run(qa_digital_carrier_allocator_cvc, "qa_digital_carrier_allocator_cvc.xml") + diff --git a/gr-digital/python/qa_ofdm_chanest_vcvc.py b/gr-digital/python/qa_ofdm_chanest_vcvc.py new file mode 100755 index 0000000000..3b1ca15a05 --- /dev/null +++ b/gr-digital/python/qa_ofdm_chanest_vcvc.py @@ -0,0 +1,290 @@ +#!/usr/bin/env python +# Copyright 2012 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. +# + +import sys +import numpy +import random +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import digital_swig as digital +import blocks_swig as blocks +from ofdm_txrx import ofdm_tx + +def shift_tuple(vec, N): + """ Shifts a vector by N elements. Fills up with zeros. """ + if N > 0: + return (0,) * N + tuple(vec[0:-N]) + else: + N = -N + return tuple(vec[N:]) + (0,) * N + +def rand_range(min_val, max_val): + """ Returns a random value (uniform) from the interval min_val, max_val """ + return random.random() * (max_val - min_val) + min_val + + +class qa_ofdm_sync_eqinit_vcvc (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_offset_2sym (self): + """ Add a frequency offset, check if it's correctly detected. + Also add some random tags and see if they come out at the correct + position. """ + fft_len = 16 + carr_offset = -2 + sync_symbol1 = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) + sync_symbol2 = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) + data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) + tx_data = shift_tuple(sync_symbol1, carr_offset) + \ + shift_tuple(sync_symbol2, carr_offset) + \ + shift_tuple(data_symbol, carr_offset) + tag1 = gr.gr_tag_t() + tag1.offset = 0 + tag1.key = pmt.pmt_string_to_symbol("test_tag_1") + tag1.value = pmt.pmt_from_long(23) + tag2 = gr.gr_tag_t() + tag2.offset = 2 + tag2.key = pmt.pmt_string_to_symbol("test_tag_2") + tag2.value = pmt.pmt_from_long(42) + src = gr.vector_source_c(tx_data, False, fft_len, (tag1, tag2)) + chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, chanest, sink) + self.tb.run() + self.assertEqual(shift_tuple(sink.data(), -carr_offset), data_symbol) + tags = sink.tags() + detected_tags = { + 'ofdm_sync_carr_offset': False, + 'test_tag_1': False, + 'test_tag_2': False + } + for tag in tags: + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + carr_offset_hat = pmt.pmt_to_long(tag.value) + self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset) + if pmt.pmt_symbol_to_string(tag.key) == 'test_tag_1': + self.assertEqual(tag.offset, 0) + if pmt.pmt_symbol_to_string(tag.key) == 'test_tag_2': + self.assertEqual(tag.offset, 0) + detected_tags[pmt.pmt_symbol_to_string(tag.key)] = True + self.assertTrue(all(detected_tags.values())) + + def test_002_offset_1sym (self): + """ Add a frequency offset, check if it's correctly detected. + Difference to previous test is, it only uses one synchronisation symbol. """ + fft_len = 16 + carr_offset = -2 + # This will not correct for +2 because it thinks carrier 14 is used + # (because of interpolation) + sync_symbol = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) + data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) + tx_data = shift_tuple(sync_symbol, carr_offset) + \ + shift_tuple(data_symbol, carr_offset) + src = gr.vector_source_c(tx_data, False, fft_len) + # 17 is out of bounds! + chanest = digital.ofdm_chanest_vcvc(sync_symbol, (), 1, 0, 17) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, chanest, sink) + self.tb.run() + self.assertEqual(shift_tuple(sink.data(), -carr_offset), data_symbol) + tags = sink.tags() + for tag in tags: + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + carr_offset_hat = pmt.pmt_to_long(tag.value) + self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset) + + def test_003_channel_no_carroffset (self): + """ Add a channel, check if it's correctly estimated """ + fft_len = 16 + carr_offset = 0 + sync_symbol1 = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) + sync_symbol2 = (0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1, 0, 0) + data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) + tx_data = sync_symbol1 + sync_symbol2 + data_symbol + channel = (0, 0, 0, 2, -2, 2, 3j, 2, 0, 2, 2, 2, 2, 3, 0, 0) + src = gr.vector_source_c(tx_data, False, fft_len) + chan = gr.multiply_const_vcc(channel) + chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1) + sink = gr.vector_sink_c(fft_len) + sink_chanest = gr.vector_sink_c(fft_len) + self.tb.connect(src, chan, chanest, sink) + self.tb.connect((chanest, 1), sink_chanest) + self.tb.run() + tags = sink.tags() + self.assertEqual(shift_tuple(sink.data(), -carr_offset), tuple(numpy.multiply(data_symbol, channel))) + for tag in tags: + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset) + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + self.assertEqual(pmt.pmt_c32vector_elements(tag.value), channel) + self.assertEqual(sink_chanest.data(), channel) + + def test_004_channel_no_carroffset_1sym (self): + """ Add a channel, check if it's correctly estimated. + Only uses 1 synchronisation symbol. """ + fft_len = 16 + carr_offset = 0 + sync_symbol = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) + data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) + tx_data = sync_symbol + data_symbol + channel = (0, 0, 0, 2, 2, 2, 2, 3, 3, 2.5, 2.5, -3, -3, 1j, 1j, 0) + #channel = (0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0) + src = blocks.vector_source_c(tx_data, False, fft_len) + chan = blocks.multiply_const_vcc(channel) + chanest = digital.ofdm_chanest_vcvc(sync_symbol, (), 1) + sink = blocks.vector_sink_c(fft_len) + sink_chanest = blocks.vector_sink_c(fft_len) + self.tb.connect(src, chan, chanest, sink) + self.tb.connect((chanest, 1), sink_chanest) + self.tb.run() + self.assertEqual(sink_chanest.data(), channel) + tags = sink.tags() + for tag in tags: + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset) + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + self.assertEqual(pmt.pmt_c32vector_elements(tag.value), channel) + + def test_005_both_1sym_force (self): + """ Add a channel, check if it's correctly estimated. + Only uses 1 synchronisation symbol. """ + fft_len = 16 + carr_offset = 0 + sync_symbol = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) + ref_symbol = (0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0) + data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) + tx_data = sync_symbol + data_symbol + channel = (0, 0, 0, 2, 2, 2, 2.5, 3, 2.5, 2, 2.5, 3, 2, 1, 1, 0) + src = gr.vector_source_c(tx_data, False, fft_len) + chan = gr.multiply_const_vcc(channel) + chanest = digital.ofdm_chanest_vcvc(sync_symbol, ref_symbol, 1) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, chan, chanest, sink) + self.tb.run() + tags = sink.tags() + for tag in tags: + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset) + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + self.assertEqual(pmt.pmt_c32vector_elements(tag.value), channel) + + def test_006_channel_and_carroffset (self): + """ Add a channel, check if it's correctly estimated """ + fft_len = 16 + carr_offset = 2 + # Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + sync_symbol1 = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) + sync_symbol2 = (0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1, 0, 0) + data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) + # Channel 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + # Shifted (0, 0, 0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1) + chanest_exp = (0, 0, 0, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15, 0, 0) + tx_data = shift_tuple(sync_symbol1, carr_offset) + \ + shift_tuple(sync_symbol2, carr_offset) + \ + shift_tuple(data_symbol, carr_offset) + channel = range(fft_len) + src = gr.vector_source_c(tx_data, False, fft_len) + chan = gr.multiply_const_vcc(channel) + chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, chan, chanest, sink) + self.tb.run() + tags = sink.tags() + chan_est = None + for tag in tags: + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + self.assertEqual(pmt.pmt_to_long(tag.value), carr_offset) + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + chan_est = pmt.pmt_c32vector_elements(tag.value) + self.assertEqual(chan_est, chanest_exp) + self.assertEqual(sink.data(), tuple(numpy.multiply(shift_tuple(data_symbol, carr_offset), channel))) + + + def test_999_all_at_once(self): + """docstring for test_999_all_at_once""" + fft_len = 32 + # 6 carriers empty, 10 carriers full, 1 DC carrier, 10 carriers full, 5 carriers empty + syncsym_mask = (0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0) + carrier_mask = (0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0) + max_offset = 4 + wgn_amplitude = 0.05 + min_chan_ampl = 0.1 + max_chan_ampl = 5 + n_iter = 20 # The more the accurater + def run_flow_graph(sync_sym1, sync_sym2, data_sym): + top_block = gr.top_block() + carr_offset = random.randint(-max_offset/2, max_offset/2) * 2 + tx_data = shift_tuple(sync_sym1, carr_offset) + \ + shift_tuple(sync_sym2, carr_offset) + \ + shift_tuple(data_sym, carr_offset) + channel = [rand_range(min_chan_ampl, max_chan_ampl) * numpy.exp(1j * rand_range(0, 2 * numpy.pi)) for x in range(fft_len)] + src = gr.vector_source_c(tx_data, False, fft_len) + chan= gr.multiply_const_vcc(channel) + noise = gr.noise_source_c(gr.GR_GAUSSIAN, wgn_amplitude) + add = gr.add_cc(fft_len) + chanest = digital.ofdm_chanest_vcvc(sync_sym1, sync_sym2, 1) + sink = gr.vector_sink_c(fft_len) + top_block.connect(src, chan, (add, 0), chanest, sink) + top_block.connect(noise, gr.stream_to_vector(gr.sizeof_gr_complex, fft_len), (add, 1)) + top_block.run() + channel_est = None + carr_offset_hat = 0 + rx_sym_est = [0,] * fft_len + tags = sink.tags() + for tag in tags: + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': + carr_offset_hat = pmt.pmt_to_long(tag.value) + self.assertEqual(carr_offset, carr_offset_hat) + if pmt.pmt_symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': + channel_est = shift_tuple(pmt.pmt_c32vector_elements(tag.value), carr_offset) + shifted_carrier_mask = shift_tuple(carrier_mask, carr_offset) + for i in range(fft_len): + if shifted_carrier_mask[i] and channel_est[i]: + self.assertAlmostEqual(channel[i], channel_est[i], places=0) + rx_sym_est[i] = (sink.data()[i] / channel_est[i]).real + return (carr_offset, list(shift_tuple(rx_sym_est, -carr_offset_hat))) + bit_errors = 0 + for k in xrange(n_iter): + sync_sym = [(random.randint(0, 1) * 2 - 1) * syncsym_mask[i] for i in range(fft_len)] + ref_sym = [(random.randint(0, 1) * 2 - 1) * carrier_mask[i] for i in range(fft_len)] + data_sym = [(random.randint(0, 1) * 2 - 1) * carrier_mask[i] for i in range(fft_len)] + data_sym[26] = 1 + (carr_offset, rx_sym) = run_flow_graph(sync_sym, ref_sym, data_sym) + rx_sym_est = [0,] * fft_len + for i in xrange(fft_len): + if carrier_mask[i] == 0: + continue + rx_sym_est[i] = {True: 1, False: -1}[rx_sym[i] > 0] + if rx_sym_est[i] != data_sym[i]: + bit_errors += 1 + # This is much more than we could allow + self.assertTrue(bit_errors < n_iter) + + +if __name__ == '__main__': + gr_unittest.run(qa_ofdm_sync_eqinit_vcvc, "qa_ofdm_sync_eqinit_vcvc.xml") + diff --git a/gr-digital/python/qa_ofdm_cyclic_prefixer.py b/gr-digital/python/qa_ofdm_cyclic_prefixer.py new file mode 100755 index 0000000000..838e992d02 --- /dev/null +++ b/gr-digital/python/qa_ofdm_cyclic_prefixer.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,2011 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. +# + +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import digital_swig as digital + +class test_ofdm_cyclic_prefixer (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_wo_tags_no_rolloff(self): + " The easiest test: make sure the CP is added correctly. " + fft_len = 8 + cp_len = 2 + expected_result = (6, 7, 0, 1, 2, 3, 4, 5, 6, 7, + 6, 7, 0, 1, 2, 3, 4, 5, 6, 7) + src = gr.vector_source_c(range(fft_len) * 2, False, fft_len) + cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len) + sink = gr.vector_sink_c() + self.tb.connect(src, cp, sink) + self.tb.run() + self.assertEqual(sink.data(), expected_result) + + def test_wo_tags_2s_rolloff(self): + " No tags, but have a 2-sample rolloff " + fft_len = 8 + cp_len = 2 + rolloff = 2 + expected_result = (7.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 + 7.0/2+1.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8) + src = gr.vector_source_c(range(1, fft_len+1) * 2, False, fft_len) + cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, rolloff) + sink = gr.vector_sink_c() + self.tb.connect(src, cp, sink) + self.tb.run() + self.assertEqual(sink.data(), expected_result) + + def test_with_tags_2s_rolloff(self): + " With tags and a 2-sample rolloff " + fft_len = 8 + cp_len = 2 + tag_name = "length" + expected_result = (7.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 + 7.0/2+1.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1.0/2) + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(2) + tag2 = gr.gr_tag_t() + tag2.offset = 1 + tag2.key = pmt.pmt_string_to_symbol("random_tag") + tag2.value = pmt.pmt_from_long(42) + src = gr.vector_source_c(range(1, fft_len+1) * 2, False, fft_len, (tag, tag2)) + cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, 2, tag_name) + sink = gr.vector_sink_c() + self.tb.connect(src, cp, sink) + self.tb.run() + self.assertEqual(sink.data(), expected_result) + tags = [gr.tag_to_python(x) for x in sink.tags()] + tags = sorted([(x.offset, x.key, x.value) for x in tags]) + expected_tags = [ + (0, tag_name, len(expected_result)), + (fft_len+cp_len, "random_tag", 42) + ] + self.assertEqual(tags, expected_tags) + + +if __name__ == '__main__': + gr_unittest.run(test_ofdm_cyclic_prefixer, "test_ofdm_cyclic_prefixer.xml") + diff --git a/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py b/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py new file mode 100755 index 0000000000..36ae9af29e --- /dev/null +++ b/gr-digital/python/qa_ofdm_frame_equalizer_vcvc.py @@ -0,0 +1,349 @@ +#!/usr/bin/env python +# Copyright 2012 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. +# + +import numpy +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import digital_swig as digital +import blocks_swig as blocks + +class qa_ofdm_frame_equalizer_vcvc (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_simple (self): + """ Very simple functionality testing: + - static equalizer + - init channel state with all ones + - transmit all ones + - make sure we rx all ones + - Tag check: put in frame length tag and one other random tag, + make sure they're propagated + """ + fft_len = 8 + equalizer = digital.ofdm_equalizer_static(fft_len) + n_syms = 3 + len_tag_key = "frame_len" + tx_data = (1,) * fft_len * n_syms + len_tag = gr.gr_tag_t() + len_tag.offset = 0 + len_tag.key = pmt.pmt_string_to_symbol(len_tag_key) + len_tag.value = pmt.pmt_from_long(n_syms) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps") + chan_tag.value = pmt.pmt_init_c32vector(fft_len, (1,) * fft_len) + random_tag = gr.gr_tag_t() + random_tag.offset = 1 + random_tag.key = pmt.pmt_string_to_symbol("foo") + random_tag.value = pmt.pmt_from_long(42) + src = gr.vector_source_c(tx_data, False, fft_len, (len_tag, chan_tag, random_tag)) + eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), 0, len_tag_key) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, eq, sink) + self.tb.run () + # Check data + self.assertEqual(tx_data, sink.data()) + # Check tags + tag_dict = dict() + for tag in sink.tags(): + ptag = gr.tag_to_python(tag) + tag_dict[ptag.key] = ptag.value + expected_dict = { + 'frame_len': n_syms, + 'foo': 42 + } + self.assertEqual(tag_dict, expected_dict) + + def test_001b_simple_skip_nothing (self): + """ + Same as before, but put a skip-header in there + """ + fft_len = 8 + equalizer = digital.ofdm_equalizer_static(fft_len, symbols_skipped=1) + n_syms = 3 + len_tag_key = "frame_len" + tx_data = (1,) * fft_len * n_syms + len_tag = gr.gr_tag_t() + len_tag.offset = 0 + len_tag.key = pmt.pmt_string_to_symbol(len_tag_key) + len_tag.value = pmt.pmt_from_long(n_syms) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps") + chan_tag.value = pmt.pmt_init_c32vector(fft_len, (1,) * fft_len) + src = gr.vector_source_c(tx_data, False, fft_len, (len_tag, chan_tag)) + eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), 0, len_tag_key) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, eq, sink) + self.tb.run () + # Check data + self.assertEqual(tx_data, sink.data()) + + def test_001c_carrier_offset_no_cp (self): + """ + Same as before, but put a carrier offset in there + """ + fft_len = 8 + cp_len = 0 + n_syms = 1 + carr_offset = 1 + occupied_carriers = ((-2, -1, 1, 2),) + tx_data = ( + 0, 0, 0, -1j, -1j, 0, -1j, -1j, + ) + # The rx'd signal is shifted + rx_expected = (0, 0, 1, 1, 0, 1, 1, 0) * n_syms + equalizer = digital.ofdm_equalizer_static(fft_len, occupied_carriers) + len_tag_key = "frame_len" + len_tag = gr.gr_tag_t() + len_tag.offset = 0 + len_tag.key = pmt.pmt_string_to_symbol(len_tag_key) + len_tag.value = pmt.pmt_from_long(n_syms) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps") + # Note: this is shifted to the correct position! + chan_tag.value = pmt.pmt_init_c32vector(fft_len, (0, 0, -1j, -1j, 0, -1j, -1j, 0)) + offset_tag = gr.gr_tag_t() + offset_tag.offset = 0 + offset_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_carr_offset") + offset_tag.value = pmt.pmt_from_long(carr_offset) + src = gr.vector_source_c(tx_data, False, fft_len, (len_tag, chan_tag, offset_tag)) + eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), cp_len, len_tag_key) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, eq, sink) + self.tb.run () + # Check data + self.assertComplexTuplesAlmostEqual(rx_expected, sink.data(), places=4) + + def test_001c_carrier_offset_cp (self): + """ + Same as before, but put a carrier offset in there and a CP + """ + fft_len = 8 + cp_len = 2 + n_syms = 3 + # cp_len/fft_len == 1/4, therefore, the phase is rotated by + # carr_offset * \pi/2 in every symbol + occupied_carriers = ((-2, -1, 1, 2),) + carr_offset = -1 + tx_data = ( + 0,-1j,-1j, 0,-1j,-1j, 0, 0, + 0, -1, -1, 0, -1, -1, 0, 0, + 0, 1j, 1j, 0, 1j, 1j, 0, 0, + ) + # Rx'd signal is corrected + rx_expected = (0, 0, 1, 1, 0, 1, 1, 0) * n_syms + equalizer = digital.ofdm_equalizer_static(fft_len, occupied_carriers) + len_tag_key = "frame_len" + len_tag = gr.gr_tag_t() + len_tag.offset = 0 + len_tag.key = pmt.pmt_string_to_symbol(len_tag_key) + len_tag.value = pmt.pmt_from_long(n_syms) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps") + chan_tag.value = pmt.pmt_init_c32vector(fft_len, (0, 0, 1, 1, 0, 1, 1, 0)) + offset_tag = gr.gr_tag_t() + offset_tag.offset = 0 + offset_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_carr_offset") + offset_tag.value = pmt.pmt_from_long(carr_offset) + src = gr.vector_source_c(tx_data, False, fft_len, (len_tag, chan_tag, offset_tag)) + eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), cp_len, len_tag_key) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, eq, sink) + self.tb.run () + # Check data + self.assertComplexTuplesAlmostEqual(rx_expected, sink.data(), places=4) + + def test_002_static (self): + """ + - Add a simple channel + - Make symbols QPSK + """ + fft_len = 8 + # 4 5 6 7 0 1 2 3 + tx_data = [-1, -1, 1, 2, -1, 3, 0, -1, # 0 + -1, -1, 0, 2, -1, 2, 0, -1, # 8 + -1, -1, 3, 0, -1, 1, 0, -1, # 16 (Pilot symbols) + -1, -1, 1, 1, -1, 0, 2, -1] # 24 + cnst = digital.constellation_qpsk() + tx_signal = [cnst.map_to_points_v(x)[0] if x != -1 else 0 for x in tx_data] + occupied_carriers = ((1, 2, 6, 7),) + pilot_carriers = ((), (), (1, 2, 6, 7), ()) + pilot_symbols = ( + [], [], [cnst.map_to_points_v(x)[0] for x in (1, 0, 3, 0)], [] + ) + equalizer = digital.ofdm_equalizer_static(fft_len, occupied_carriers, pilot_carriers, pilot_symbols) + channel = [ + 0, 0, 1, 1, 0, 1, 1, 0, + 0, 0, 1, 1, 0, 1, 1, 0, # These coefficients will be rotated slightly (but less than \pi/2) + 0, 0, 1j, 1j, 0, 1j, 1j, 0, # Go crazy here! + 0, 0, 1j, 1j, 0, 1j, 1j, 0 + ] + channel = [ + 0, 0, 1, 1, 0, 1, 1, 0, + 0, 0, 1, 1, 0, 1, 1, 0, # These coefficients will be rotated slightly (but less than \pi/2) + 0, 0, 1j, 1j, 0, 1j, 1j, 0, # Go crazy here! + 0, 0, 1j, 1j, 0, 1j, 1j, 0 + ] + for idx in range(fft_len, 2*fft_len): + channel[idx] = channel[idx-fft_len] * numpy.exp(1j * .1 * numpy.pi * (numpy.random.rand()-.5)) + len_tag_key = "frame_len" + len_tag = gr.gr_tag_t() + len_tag.offset = 0 + len_tag.key = pmt.pmt_string_to_symbol(len_tag_key) + len_tag.value = pmt.pmt_from_long(4) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps") + chan_tag.value = pmt.pmt_init_c32vector(fft_len, channel[:fft_len]) + src = gr.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len, (len_tag, chan_tag)) + eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), 0, len_tag_key, True) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, eq, sink) + self.tb.run () + rx_data = [cnst.decision_maker_v((x,)) if x != 0 else -1 for x in sink.data()] + # Check data + self.assertEqual(tx_data, rx_data) + # Check tags + tag_dict = dict() + for tag in sink.tags(): + ptag = gr.tag_to_python(tag) + tag_dict[ptag.key] = ptag.value + if ptag.key == 'ofdm_sync_chan_taps': + tag_dict[ptag.key] = list(pmt.pmt_c32vector_elements(tag.value)) + else: + tag_dict[ptag.key] = pmt.to_python(tag.value) + expected_dict = { + 'frame_len': 4, + 'ofdm_sync_chan_taps': channel[-fft_len:] + } + self.assertEqual(tag_dict, expected_dict) + + def test_002_static_wo_tags (self): + """ Same as before, but the input stream has no tag. + We specify the frame size in the constructor. + We also specify a tag key, so the output stream *should* have + a length tag. + """ + fft_len = 8 + n_syms = 4 + # 4 5 6 7 0 1 2 3 + tx_data = [-1, -1, 1, 2, -1, 3, 0, -1, # 0 + -1, -1, 0, 2, -1, 2, 0, -1, # 8 + -1, -1, 3, 0, -1, 1, 0, -1, # 16 (Pilot symbols) + -1, -1, 1, 1, -1, 0, 2, -1] # 24 + cnst = digital.constellation_qpsk() + tx_signal = [cnst.map_to_points_v(x)[0] if x != -1 else 0 for x in tx_data] + occupied_carriers = ((1, 2, 6, 7),) + pilot_carriers = ((), (), (1, 2, 6, 7), ()) + pilot_symbols = ( + [], [], [cnst.map_to_points_v(x)[0] for x in (1, 0, 3, 0)], [] + ) + equalizer = digital.ofdm_equalizer_static(fft_len, occupied_carriers, pilot_carriers, pilot_symbols) + channel = [ + 0, 0, 1, 1, 0, 1, 1, 0, + 0, 0, 1, 1, 0, 1, 1, 0, # These coefficients will be rotated slightly (below)... + 0, 0, 1j, 1j, 0, 1j, 1j, 0, # Go crazy here! + 0, 0, 1j, 1j, 0, 1j, 1j, 0 # ...and again here. + ] + for idx in range(fft_len, 2*fft_len): + channel[idx] = channel[idx-fft_len] * numpy.exp(1j * .1 * numpy.pi * (numpy.random.rand()-.5)) + idx2 = idx+2*fft_len + channel[idx2] = channel[idx2] * numpy.exp(1j * 0 * numpy.pi * (numpy.random.rand()-.5)) + src = gr.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len) + # We do specify a length tag, it should then appear at the output + eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), 0, "frame_len", False, n_syms) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, eq, sink) + self.tb.run () + rx_data = [cnst.decision_maker_v((x,)) if x != 0 else -1 for x in sink.data()] + self.assertEqual(tx_data, rx_data) + # Check len tag + tags = sink.tags() + len_tag = dict() + for tag in tags: + ptag = gr.tag_to_python(tag) + if ptag.key == 'frame_len': + len_tag[ptag.key] = ptag.value + self.assertEqual(len_tag, {'frame_len': 4}) + + def test_002_simpledfe (self): + """ Use the simple DFE equalizer. """ + fft_len = 8 + # 4 5 6 7 0 1 2 3 + tx_data = [-1, -1, 1, 2, -1, 3, 0, -1, # 0 + -1, -1, 0, 2, -1, 2, 0, -1, # 8 + -1, -1, 3, 0, -1, 1, 0, -1, # 16 (Pilot symbols) + -1, -1, 1, 1, -1, 0, 2, -1] # 24 + cnst = digital.constellation_qpsk() + tx_signal = [cnst.map_to_points_v(x)[0] if x != -1 else 0 for x in tx_data] + occupied_carriers = ((1, 2, 6, 7),) + pilot_carriers = ((), (), (1, 2, 6, 7), ()) + pilot_symbols = ( + [], [], [cnst.map_to_points_v(x)[0] for x in (1, 0, 3, 0)], [] + ) + equalizer = digital.ofdm_equalizer_simpledfe( + fft_len, cnst.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 0.01 + ) + channel = [ + 0, 0, 1, 1, 0, 1, 1, 0, + 0, 0, 1, 1, 0, 1, 1, 0, # These coefficients will be rotated slightly... + 0, 0, 1j, 1j, 0, 1j, 1j, 0, # Go crazy here! + 0, 0, 1j, 1j, 0, 1j, 1j, 0 # ...and again here. + ] + for idx in range(fft_len, 2*fft_len): + channel[idx] = channel[idx-fft_len] * numpy.exp(1j * .1 * numpy.pi * (numpy.random.rand()-.5)) + idx2 = idx+2*fft_len + channel[idx2] = channel[idx2] * numpy.exp(1j * 0 * numpy.pi * (numpy.random.rand()-.5)) + len_tag_key = "frame_len" + len_tag = gr.gr_tag_t() + len_tag.offset = 0 + len_tag.key = pmt.pmt_string_to_symbol(len_tag_key) + len_tag.value = pmt.pmt_from_long(4) + chan_tag = gr.gr_tag_t() + chan_tag.offset = 0 + chan_tag.key = pmt.pmt_string_to_symbol("ofdm_sync_chan_taps") + chan_tag.value = pmt.pmt_init_c32vector(fft_len, channel[:fft_len]) + src = gr.vector_source_c(numpy.multiply(tx_signal, channel), False, fft_len, (len_tag, chan_tag)) + eq = digital.ofdm_frame_equalizer_vcvc(equalizer.base(), 0, len_tag_key, True) + sink = gr.vector_sink_c(fft_len) + self.tb.connect(src, eq, sink) + self.tb.run () + rx_data = [cnst.decision_maker_v((x,)) if x != 0 else -1 for x in sink.data()] + self.assertEqual(tx_data, rx_data) + for tag in sink.tags(): + if pmt.pmt_symbol_to_string(tag.key) == len_tag_key: + self.assertEqual(pmt.pmt_to_long(tag.value), 4) + if pmt.pmt_symbol_to_string(tag.key) == "ofdm_sync_chan_taps": + self.assertComplexTuplesAlmostEqual(list(pmt.pmt_c32vector_elements(tag.value)), channel[-fft_len:], places=1) + + +if __name__ == '__main__': + gr_unittest.run(qa_ofdm_frame_equalizer_vcvc, "qa_ofdm_frame_equalizer_vcvc.xml") + diff --git a/gr-digital/python/qa_ofdm_serializer_vcc.py b/gr-digital/python/qa_ofdm_serializer_vcc.py new file mode 100755 index 0000000000..1c7b4c23b1 --- /dev/null +++ b/gr-digital/python/qa_ofdm_serializer_vcc.py @@ -0,0 +1,245 @@ +#!/usr/bin/env python +# +# Copyright 2012 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. +# + +from gnuradio import gr, gr_unittest +import fft_swig as fft +import digital_swig as digital +import blocks_swig as blocks +try: import pmt +except: from gruel import pmt +import numpy + +class qa_ofdm_serializer_vcc (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_simple (self): + """ Standard test """ + fft_len = 16 + tx_symbols = (0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, 0, + 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, 0, + 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0, 0) + expected_result = tuple(range(1, 16)) + (0, 0, 0) + occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),) + n_syms = len(tx_symbols)/fft_len + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(n_syms) + src = gr.vector_source_c(tx_symbols, False, fft_len, (tag,)) + serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name, "", 0, "", False) + sink = gr.vector_sink_c() + self.tb.connect(src, serializer, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_result) + self.assertEqual(len(sink.tags()), 1) + result_tag = sink.tags()[0] + self.assertEqual(pmt.pmt_symbol_to_string(result_tag.key), tag_name) + self.assertEqual(pmt.pmt_to_long(result_tag.value), n_syms * len(occupied_carriers[0])) + + def test_001b_shifted (self): + """ Same as before, but shifted, because that's the normal mode in OFDM Rx """ + fft_len = 16 + tx_symbols = ( + 0, 0, 0, 0, 0, 0, 1, 2, 0, 3, 4, 5, 0, 0, 0, 0, + 0, 0, 0, 0, 6, 1j, 7, 8, 0, 9, 10, 1j, 11, 0, 0, 0, + 0, 0, 0, 0, 0, 12, 13, 14, 0, 15, 16, 17, 0, 0, 0, 0, + ) + expected_result = tuple(range(18)) + occupied_carriers = ((13, 14, 15, 1, 2, 3), (-4, -2, -1, 1, 2, 4),) + n_syms = len(tx_symbols)/fft_len + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(n_syms) + src = gr.vector_source_c(tx_symbols, False, fft_len, (tag,)) + serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name) + sink = gr.vector_sink_c() + self.tb.connect(src, serializer, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_result) + self.assertEqual(len(sink.tags()), 1) + result_tag = sink.tags()[0] + self.assertEqual(pmt.pmt_symbol_to_string(result_tag.key), tag_name) + self.assertEqual(pmt.pmt_to_long(result_tag.value), n_syms * len(occupied_carriers[0])) + + def test_002_with_offset (self): + """ Standard test, carrier offset """ + fft_len = 16 + tx_symbols = range(1, 16); + tx_symbols = (0, 0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, + 0, 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, + 0, 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0) + carr_offset = 1 # Compare this with tx_symbols from the previous test + expected_result = tuple(range(1, 16)) + (0, 0, 0) + occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),) + n_syms = len(tx_symbols)/fft_len + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(n_syms) + offsettag = gr.gr_tag_t() + offsettag.offset = 0 + offsettag.key = pmt.pmt_string_to_symbol("ofdm_sync_carr_offset") + offsettag.value = pmt.pmt_from_long(carr_offset) + src = gr.vector_source_c(tx_symbols, False, fft_len, (tag, offsettag)) + serializer = digital.ofdm_serializer_vcc( + fft_len, + occupied_carriers, + tag_name, + "", 0, + "ofdm_sync_carr_offset", + False + ) + sink = gr.vector_sink_c() + self.tb.connect(src, serializer, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_result) + self.assertEqual(len(sink.tags()), 2) + for tag in sink.tags(): + if pmt.pmt_symbol_to_string(tag.key) == tag_name: + self.assertEqual(pmt.pmt_to_long(tag.value), n_syms * len(occupied_carriers[0])) + + def test_003_connect (self): + """ Connect carrier_allocator to ofdm_serializer, + make sure output==input """ + fft_len = 8 + n_syms = 10 + occupied_carriers = ((1, 2, 6, 7),) + pilot_carriers = ((3,),(5,)) + pilot_symbols = ((1j,),(-1j,)) + tx_data = tuple([numpy.random.randint(0, 10) for x in range(4 * n_syms)]) + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(tx_data)) + src = gr.vector_source_c(tx_data, False, 1, (tag,)) + alloc = digital.ofdm_carrier_allocator_cvc(fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + tag_name) + serializer = digital.ofdm_serializer_vcc(alloc, "", 0, "", False) + sink = gr.vector_sink_c() + self.tb.connect(src, alloc, serializer, sink) + self.tb.run () + self.assertEqual(sink.data(), tx_data) + + def test_004_connect (self): + """ + Advanced test: + - Allocator -> IFFT -> Frequency offset -> FFT -> Serializer + - FFT does shift (moves DC to middle) + - Make sure input == output + - Frequency offset is -2 carriers + """ + fft_len = 8 + n_syms = 1 + carr_offset = -2 + freq_offset = 1.0 / fft_len * carr_offset # Normalized frequency + occupied_carriers = ((-2, -1, 1, 2),) + pilot_carriers = ((3,),(5,)) + pilot_symbols = ((1j,),(-1j,)) + tx_data = (1, 1, 1, 1) + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(len(tx_data)) + offsettag = gr.gr_tag_t() + offsettag.offset = 0 + offsettag.key = pmt.pmt_string_to_symbol("ofdm_sync_carr_offset") + offsettag.value = pmt.pmt_from_long(carr_offset) + src = gr.vector_source_c(tx_data, False, 1, (tag, offsettag)) + alloc = digital.ofdm_carrier_allocator_cvc(fft_len, + occupied_carriers, + pilot_carriers, + pilot_symbols, + tag_name) + tx_ifft = fft.fft_vcc(fft_len, False, (1.0/fft_len,)*fft_len) + oscillator = gr.sig_source_c(1.0, gr.GR_COS_WAVE, freq_offset, 1.0/fft_len) + mixer = gr.multiply_cc() + rx_fft = fft.fft_vcc(fft_len, True, (), True) + serializer = digital.ofdm_serializer_vcc( + alloc, "", 0, "ofdm_sync_carr_offset" + ) + sink = gr.vector_sink_c() + self.tb.connect( + src, alloc, tx_ifft, + gr.vector_to_stream(gr.sizeof_gr_complex, fft_len), + (mixer, 0), + gr.stream_to_vector(gr.sizeof_gr_complex, fft_len), + rx_fft, serializer, sink + ) + self.tb.connect(oscillator, (mixer, 1)) + self.tb.run () + self.assertComplexTuplesAlmostEqual(sink.data(), tx_data, places=5) + + def test_005_packet_len_tag (self): + """ Standard test """ + fft_len = 16 + tx_symbols = range(1, 16); + tx_symbols = (0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, 0, + 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, 0, + 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0, 0) + expected_result = tuple(range(1, 16)) + occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),) + n_syms = len(tx_symbols)/fft_len + tag_name = "len" + tag = gr.gr_tag_t() + tag.offset = 0 + tag.key = pmt.pmt_string_to_symbol(tag_name) + tag.value = pmt.pmt_from_long(n_syms) + tag2 = gr.gr_tag_t() + tag2.offset = 0 + tag2.key = pmt.pmt_string_to_symbol("packet_len") + tag2.value = pmt.pmt_from_long(len(expected_result)) + src = gr.vector_source_c(tx_symbols, False, fft_len, (tag, tag2)) + serializer = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, tag_name, "packet_len", 0, "", False) + sink = gr.vector_sink_c() + self.tb.connect(src, serializer, sink) + self.tb.run () + self.assertEqual(sink.data(), expected_result) + self.assertEqual(len(sink.tags()), 1) + result_tag = sink.tags()[0] + self.assertEqual(pmt.pmt_symbol_to_string(result_tag.key), "packet_len") + self.assertEqual(pmt.pmt_to_long(result_tag.value), len(expected_result)) + + def test_099 (self): + """ Make sure it fails if it should """ + fft_len = 16 + occupied_carriers = ((1, 3, 4, 11, 12, 17),) + tag_name = "len" + self.assertRaises(RuntimeError, digital.ofdm_serializer_vcc, fft_len, occupied_carriers, tag_name) + + +if __name__ == '__main__': + gr_unittest.run(qa_ofdm_serializer_vcc, "qa_ofdm_serializer_vcc.xml") + diff --git a/gr-digital/python/qa_ofdm_sync_sc_cfb.py b/gr-digital/python/qa_ofdm_sync_sc_cfb.py new file mode 100755 index 0000000000..b6feee79cd --- /dev/null +++ b/gr-digital/python/qa_ofdm_sync_sc_cfb.py @@ -0,0 +1,174 @@ +#!/usr/bin/env python +# +# Copyright 2012 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. +# + +import numpy +import random + +from gnuradio import gr, gr_unittest +try: + # This will work when feature #505 is added. + from gnuradio import digital + from gnuradio.digital.utils import tagged_streams + from gnuradio.digital.ofdm_txrx import ofdm_tx +except ImportError: + # Until then this will work. + import digital_swig as digital + from utils import tagged_streams + from ofdm_txrx import ofdm_tx + +class qa_ofdm_sync_sc_cfb (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_detect (self): + """ Send two bursts, with zeros in between, and check + they are both detected at the correct position and no + false alarms occur """ + n_zeros = 15 + fft_len = 32 + cp_len = 4 + sig_len = (fft_len + cp_len) * 10 + sync_symbol = [(random.randint(0, 1)*2)-1 for x in range(fft_len/2)] * 2 + tx_signal = [0,] * n_zeros + \ + sync_symbol[-cp_len:] + \ + sync_symbol + \ + [(random.randint(0, 1)*2)-1 for x in range(sig_len)] + tx_signal = tx_signal * 2 + add = gr.add_cc() + sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len) + sink_freq = gr.vector_sink_f() + sink_detect = gr.vector_sink_b() + self.tb.connect(gr.vector_source_c(tx_signal), (add, 0)) + self.tb.connect(gr.noise_source_c(gr.GR_GAUSSIAN, .005), (add, 1)) + self.tb.connect(add, sync) + self.tb.connect((sync, 0), sink_freq) + self.tb.connect((sync, 1), sink_detect) + self.tb.run() + sig1_detect = sink_detect.data()[0:len(tx_signal)/2] + sig2_detect = sink_detect.data()[len(tx_signal)/2:] + self.assertTrue(abs(sig1_detect.index(1) - (n_zeros + fft_len + cp_len)) < cp_len) + self.assertTrue(abs(sig2_detect.index(1) - (n_zeros + fft_len + cp_len)) < cp_len) + self.assertEqual(numpy.sum(sig1_detect), 1) + self.assertEqual(numpy.sum(sig2_detect), 1) + + def test_002_freq (self): + """ Add a fine frequency offset and see if that get's detected properly """ + fft_len = 32 + cp_len = 4 + # This frequency offset is normalized to rads, i.e. \pi == f_s/2 + max_freq_offset = 2*numpy.pi/fft_len # Otherwise, it's coarse + freq_offset = ((2 * random.random()) - 1) * max_freq_offset + sig_len = (fft_len + cp_len) * 10 + sync_symbol = [(random.randint(0, 1)*2)-1 for x in range(fft_len/2)] * 2 + tx_signal = sync_symbol[-cp_len:] + \ + sync_symbol + \ + [(random.randint(0, 1)*2)-1 for x in range(sig_len)] + mult = gr.multiply_cc() + add = gr.add_cc() + sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len, True) + channel = gr.channel_model(0.005, freq_offset / 2.0 / numpy.pi) + sink_freq = gr.vector_sink_f() + sink_detect = gr.vector_sink_b() + self.tb.connect(gr.vector_source_c(tx_signal), channel, sync) + self.tb.connect((sync, 0), sink_freq) + self.tb.connect((sync, 1), sink_detect) + self.tb.run() + phi_hat = sink_freq.data()[sink_detect.data().index(1)] + est_freq_offset = 2 * phi_hat / fft_len + self.assertAlmostEqual(est_freq_offset, freq_offset, places=2) + + def test_003_multiburst (self): + """ Send several bursts, see if the number of detects is correct. + Burst lengths and content are random. + """ + n_bursts = 42 + fft_len = 32 + cp_len = 4 + tx_signal = [] + for i in xrange(n_bursts): + sync_symbol = [(random.randint(0, 1)*2)-1 for x in range(fft_len/2)] * 2 + tx_signal += [0,] * random.randint(0, 2*fft_len) + \ + sync_symbol[-cp_len:] + \ + sync_symbol + \ + [(random.randint(0, 1)*2)-1 for x in range(fft_len * random.randint(5,23))] + add = gr.add_cc() + sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len) + sink_freq = gr.vector_sink_f() + sink_detect = gr.vector_sink_b() + channel = gr.channel_model(0.005) + self.tb.connect(gr.vector_source_c(tx_signal), channel, sync) + self.tb.connect((sync, 0), sink_freq) + self.tb.connect((sync, 1), sink_detect) + self.tb.run() + n_bursts_detected = numpy.sum(sink_detect.data()) + # We allow for one false alarm or missed burst + self.assertTrue(abs(n_bursts_detected - n_bursts) <= 1, + msg="""Because of statistics, it is possible (though unlikely) +that the number of detected bursts differs slightly. If the number of detects is +off by one or two, run the test again and see what happen. +Detection error was: %d """ % (numpy.sum(sink_detect.data()) - n_bursts) + ) + + def test_004_ofdm_packets (self): + """ + Send several bursts using ofdm_tx, see if the number of detects is correct. + Burst lengths and content are random. + """ + n_bursts = 42 + fft_len = 64 + cp_len = 16 + # Here, coarse freq offset is allowed + max_freq_offset = 2*numpy.pi/fft_len * 4 + freq_offset = ((2 * random.random()) - 1) * max_freq_offset + tx_signal = [] + packets = [] + tagname = "packet_length" + min_packet_length = 10 + max_packet_length = 50 + sync_sequence = [random.randint(0, 1)*2-1 for x in range(fft_len/2)] + for i in xrange(n_bursts): + packet_length = random.randint(min_packet_length, + max_packet_length+1) + packet = [random.randint(0, 255) for i in range(packet_length)] + packets.append(packet) + data, tags = tagged_streams.packets_to_vectors(packets, tagname, vlen=1) + total_length = len(data) + src = gr.vector_source_b(data, False, 1, tags) + mod = ofdm_tx(packet_length_tag_key=tagname) + sync = digital.ofdm_sync_sc_cfb(fft_len, cp_len) + sink_freq = gr.vector_sink_f() + sink_detect = gr.vector_sink_b() + noise_level = 0.005 + channel = gr.channel_model(noise_level, freq_offset / 2 / numpy.pi) + self.tb.connect(src, mod, channel, sync, sink_freq) + self.tb.connect((sync, 1), sink_detect) + self.tb.run() + self.assertEqual(numpy.sum(sink_detect.data()), n_bursts) + + +if __name__ == '__main__': + gr_unittest.run(qa_ofdm_sync_sc_cfb, "qa_ofdm_sync_sc_cfb.xml") + diff --git a/gr-digital/python/qa_ofdm_txrx.py b/gr-digital/python/qa_ofdm_txrx.py new file mode 100755 index 0000000000..ca85c776d4 --- /dev/null +++ b/gr-digital/python/qa_ofdm_txrx.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python +# +# 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. +# + +import numpy +import scipy +import random +from gnuradio import gr, gr_unittest +import blocks_swig as blocks +import digital_swig as digital +from ofdm_txrx import ofdm_tx, ofdm_rx +from utils import tagged_streams + +# Set this to true if you need to write out data +LOG_DEBUG_INFO=False + +class ofdm_tx_fg (gr.top_block): + def __init__(self, data, len_tag_key): + gr.top_block.__init__(self, "ofdm_tx") + tx_data, tags = tagged_streams.packets_to_vectors((data,), len_tag_key) + src = blocks.vector_source_b(data, False, 1, tags) + self.tx = ofdm_tx(packet_length_tag_key=len_tag_key, debug_log=LOG_DEBUG_INFO) + self.sink = blocks.vector_sink_c() + self.connect(src, self.tx, self.sink) + + def get_tx_samples(self): + return self.sink.data() + +class ofdm_rx_fg (gr.top_block): + def __init__(self, samples, len_tag_key, channel=None, prepend_zeros=100): + gr.top_block.__init__(self, "ofdm_rx") + if prepend_zeros: + samples = (0,) * prepend_zeros + tuple(samples) + src = blocks.vector_source_c(tuple(samples) + (0,) * 1000) + self.rx = ofdm_rx(frame_length_tag_key=len_tag_key, debug_log=LOG_DEBUG_INFO) + if channel is not None: + self.connect(src, channel, self.rx) + else: + self.connect(src, self.rx) + self.sink = blocks.vector_sink_b() + self.connect(self.rx, self.sink) + + def get_rx_bytes(self): + return self.sink.data() + +class test_ofdm_txrx (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_tx (self): + """ Just make sure the Tx works in general """ + len_tag_key = 'frame_len' + n_bytes = 52 + n_samples_expected = (numpy.ceil(1.0 * (n_bytes + 4) / 6) + 3) * 80 + test_data = [random.randint(0, 255) for x in range(n_bytes)] + tx_data, tags = tagged_streams.packets_to_vectors((test_data,), len_tag_key) + src = gr.vector_source_b(test_data, False, 1, tags) + tx = ofdm_tx(packet_length_tag_key=len_tag_key) + tx_fg = ofdm_tx_fg(test_data, len_tag_key) + tx_fg.run() + self.assertEqual(len(tx_fg.get_tx_samples()), n_samples_expected) + + def test_002_rx_only_noise(self): + """ Run the RX with only noise, check it doesn't crash + or return a burst. """ + len_tag_key = 'frame_len' + samples = (0,) * 1000 + channel = gr.channel_model(0.1) + rx_fg = ofdm_rx_fg(samples, len_tag_key, channel) + rx_fg.run() + self.assertEqual(len(rx_fg.get_rx_bytes()), 0) + + def test_003_tx1packet(self): + """ Transmit one packet, with slight AWGN and slight frequency + timing offset. + Check packet is received and no bit errors have occurred. """ + len_tag_key = 'frame_len' + n_bytes = 21 + fft_len = 64 + test_data = tuple([random.randint(0, 255) for x in range(n_bytes)]) + # 1.0/fft_len is one sub-carrier, a fine freq offset stays below that + freq_offset = 1.0 / fft_len * 0.7 + channel = gr.channel_model(0.01, freq_offset) + # Tx + tx_fg = ofdm_tx_fg(test_data, len_tag_key) + tx_fg.run() + tx_samples = tx_fg.get_tx_samples() + # Rx + rx_fg = ofdm_rx_fg(tx_samples, len_tag_key, channel, prepend_zeros=100) + rx_fg.run() + rx_data = rx_fg.get_rx_bytes() + self.assertEqual(tx_fg.tx.sync_word1, rx_fg.rx.sync_word1) + self.assertEqual(tuple(tx_fg.tx.sync_word2), tuple(rx_fg.rx.sync_word2)) + self.assertEqual(test_data, rx_data) + + def test_004_tx1packet_large_fO(self): + """ Transmit one packet, with slight AWGN and large frequency offset. + Check packet is received and no bit errors have occurred. """ + fft_len = 64 + len_tag_key = 'frame_len' + n_bytes = 21 + #test_data = tuple([random.randint(0, 255) for x in range(n_bytes)]) + test_data = tuple([255 for x in range(n_bytes)]) + # 1.0/fft_len is one sub-carrier + frequency_offset = 1.0 / fft_len * 2.5 + channel = gr.channel_model(0.00001, frequency_offset) + # Tx + tx_fg = ofdm_tx_fg(test_data, len_tag_key) + tx_fg.run() + tx_samples = tx_fg.get_tx_samples() + # Rx + rx_fg = ofdm_rx_fg(tx_samples, len_tag_key, channel, prepend_zeros=100) + rx_fg.run() + rx_data = rx_fg.get_rx_bytes() + self.assertEqual(tx_fg.tx.sync_word1, rx_fg.rx.sync_word1) + self.assertEqual(tuple(tx_fg.tx.sync_word2), tuple(rx_fg.rx.sync_word2)) + self.assertEqual(test_data, rx_data) + +if __name__ == '__main__': + gr_unittest.run(test_ofdm_txrx, "test_ofdm_txrx.xml") + diff --git a/gr-digital/python/qa_packet_headergenerator_bb.py b/gr-digital/python/qa_packet_headergenerator_bb.py new file mode 100755 index 0000000000..2dbe5604fa --- /dev/null +++ b/gr-digital/python/qa_packet_headergenerator_bb.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python +# Copyright 2012 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. +# + +from gnuradio import gr, gr_unittest +import digital_swig as digital +try: import pmt +except: from gruel import pmt + +class qa_packet_headergenerator_bb (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_12bits (self): + # 3 PDUs: | | | + data = (1, 2, 3, 4, 1, 2) + tuple(range(25)) + tagname = "packet_len" + tag1 = gr.gr_tag_t() + tag1.offset = 0 + tag1.key = pmt.pmt_string_to_symbol(tagname) + tag1.value = pmt.pmt_from_long(4) + tag2 = gr.gr_tag_t() + tag2.offset = 4 + tag2.key = pmt.pmt_string_to_symbol(tagname) + tag2.value = pmt.pmt_from_long(2) + tag3 = gr.gr_tag_t() + tag3.offset = 6 + tag3.key = pmt.pmt_string_to_symbol(tagname) + tag3.value = pmt.pmt_from_long(25) + src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3)) + header = digital.packet_headergenerator_bb(12, tagname) + sink = gr.vector_sink_b() + self.tb.connect(src, header, sink) + self.tb.run() + expected_data = ( + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0 + ) + self.assertEqual(sink.data(), expected_data) + + + def test_002_32bits (self): + # 3 PDUs: | | | | + data = (1, 2, 3, 4, 1, 2, 1, 2, 3, 4) + tagname = "packet_len" + tag1 = gr.gr_tag_t() + tag1.offset = 0 + tag1.key = pmt.pmt_string_to_symbol(tagname) + tag1.value = pmt.pmt_from_long(4) + tag2 = gr.gr_tag_t() + tag2.offset = 4 + tag2.key = pmt.pmt_string_to_symbol(tagname) + tag2.value = pmt.pmt_from_long(2) + tag3 = gr.gr_tag_t() + tag3.offset = 6 + tag3.key = pmt.pmt_string_to_symbol(tagname) + tag3.value = pmt.pmt_from_long(4) + src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3)) + header = digital.packet_headergenerator_bb(32, tagname) + sink = gr.vector_sink_b() + self.tb.connect(src, header, sink) + self.tb.run() + expected_data = ( + # | Number of symbols | Packet number | Parity + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ) + self.assertEqual(sink.data(), expected_data) + + + def test_003_12bits_formatter_object (self): + # 3 PDUs: | | | | + data = (1, 2, 3, 4, 1, 2, 1, 2, 3, 4) + tagname = "packet_len" + tag1 = gr.gr_tag_t() + tag1.offset = 0 + tag1.key = pmt.pmt_string_to_symbol(tagname) + tag1.value = pmt.pmt_from_long(4) + tag2 = gr.gr_tag_t() + tag2.offset = 4 + tag2.key = pmt.pmt_string_to_symbol(tagname) + tag2.value = pmt.pmt_from_long(2) + tag3 = gr.gr_tag_t() + tag3.offset = 6 + tag3.key = pmt.pmt_string_to_symbol(tagname) + tag3.value = pmt.pmt_from_long(4) + src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3)) + formatter_object = digital.packet_header_default(12, tagname) + header = digital.packet_headergenerator_bb(formatter_object.formatter(), tagname) + sink = gr.vector_sink_b() + self.tb.connect(src, header, sink) + self.tb.run() + expected_data = ( + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 + ) + self.assertEqual(sink.data(), expected_data) + + def test_004_8bits_formatter_ofdm (self): + occupied_carriers = ((1, 2, 3, 5, 6, 7),) + # 3 PDUs: | | | | + data = (1, 2, 3, 4, 1, 2, 1, 2, 3, 4) + tagname = "packet_len" + tag1 = gr.gr_tag_t() + tag1.offset = 0 + tag1.key = pmt.pmt_string_to_symbol(tagname) + tag1.value = pmt.pmt_from_long(4) + tag2 = gr.gr_tag_t() + tag2.offset = 4 + tag2.key = pmt.pmt_string_to_symbol(tagname) + tag2.value = pmt.pmt_from_long(2) + tag3 = gr.gr_tag_t() + tag3.offset = 6 + tag3.key = pmt.pmt_string_to_symbol(tagname) + tag3.value = pmt.pmt_from_long(4) + src = gr.vector_source_b(data, False, 1, (tag1, tag2, tag3)) + formatter_object = digital.packet_header_ofdm(occupied_carriers, 1, tagname) + self.assertEqual(formatter_object.header_len(), 6) + self.assertEqual(pmt.pmt_symbol_to_string(formatter_object.len_tag_key()), tagname) + header = digital.packet_headergenerator_bb(formatter_object.formatter(), tagname) + sink = gr.vector_sink_b() + self.tb.connect(src, header, sink) + self.tb.run() + expected_data = ( + 0, 0, 1, 0, 0, 0, + 0, 1, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0 + ) + self.assertEqual(sink.data(), expected_data) + +if __name__ == '__main__': + gr_unittest.run(qa_packet_headergenerator_bb, "qa_packet_headergenerator_bb.xml") + diff --git a/gr-digital/python/qa_packet_headerparser_b.py b/gr-digital/python/qa_packet_headerparser_b.py new file mode 100755 index 0000000000..3b8b8b3ee9 --- /dev/null +++ b/gr-digital/python/qa_packet_headerparser_b.py @@ -0,0 +1,137 @@ +#!/usr/bin/env python +# Copyright 2012 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. +# + +import time +import random +from gnuradio import gr, gr_unittest +try: import pmt +except: from gruel import pmt +import digital_swig as digital +from utils import tagged_streams + +class qa_packet_headerparser_b (gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + + def test_001_t (self): + """ + First header: Packet length 4, packet num 0 + Second header: Packet 2, packet num 1 + Third header: Invalid (parity bit does not check) (would be len 4, num 2) + """ + encoded_headers = ( + # | Number of bytes | Packet number | Parity + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0 + ) + packet_len_tagname = "packet_len" + + random_tag = gr.gr_tag_t() + random_tag.offset = 5 + random_tag.key = pmt.pmt_string_to_symbol("foo") + random_tag.value = pmt.pmt_from_long(42) + src = gr.vector_source_b(encoded_headers, tags=(random_tag,)) + parser = digital.packet_headerparser_b(32, packet_len_tagname) + sink = gr.message_debug() + self.tb.connect(src, parser) + self.tb.msg_connect(parser, "header_data", sink, "store") + self.tb.start() + time.sleep(1) + self.tb.stop() + self.tb.wait() + self.assertEqual(sink.num_messages(), 3) + msg1 = pmt.to_python(sink.get_message(0)) + msg2 = pmt.to_python(sink.get_message(1)) + msg3 = pmt.to_python(sink.get_message(2)) + self.assertEqual(msg1, {'packet_len': 4, 'packet_num': 0, 'foo': 42}) + self.assertEqual(msg2, {'packet_len': 2, 'packet_num': 1}) + self.assertEqual(msg3, False) + + def test_002_pipe(self): + """ + Create N packets of random length, pipe them through header generator, + back to header parser, make sure output is the same. + """ + N = 20 + header_len = 32 + packet_len_tagname = "packet_len" + packet_lengths = [random.randint(1, 100) for x in range(N)] + data, tags = tagged_streams.packets_to_vectors([range(packet_lengths[i]) for i in range(N)], packet_len_tagname) + src = gr.vector_source_b(data, False, 1, tags) + header_gen = digital.packet_headergenerator_bb(header_len, packet_len_tagname) + header_parser = digital.packet_headerparser_b(header_len, packet_len_tagname) + sink = gr.message_debug() + self.tb.connect(src, header_gen, header_parser) + self.tb.msg_connect(header_parser, "header_data", sink, "store") + self.tb.start() + time.sleep(1) + self.tb.stop() + self.tb.wait() + self.assertEqual(sink.num_messages(), N) + for i in xrange(N): + msg = pmt.to_python(sink.get_message(i)) + self.assertEqual(msg, {'packet_len': packet_lengths[i], 'packet_num': i}) + + def test_003_ofdm (self): + """ Header 1: 193 bytes + Header 2: 8 bytes + 2 bits per complex symbol, 32 carriers => 64 bits = 8 bytes per OFDM symbol + """ + encoded_headers = ( + # | Number of bytes | Packet number | Parity + 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ) + packet_len_tagname = "packet_len" + frame_len_tagname = "frame_len" + src = gr.vector_source_b(encoded_headers) + header_formatter = digital.packet_header_ofdm( + (range(32),), # 32 carriers are occupied (which doesn't matter here) + 1, # 1 OFDM symbol per header (= 32 bits) + packet_len_tagname, + frame_len_tagname, + "packet_num", + 1, # 1 bit per header symbols (BPSK) + 2 # 2 bits per payload symbol (QPSK) + ) + parser = digital.packet_headerparser_b(header_formatter.base()) + sink = gr.message_debug() + self.tb.connect(src, parser) + self.tb.msg_connect(parser, "header_data", sink, "store") + self.tb.start() + time.sleep(1) + self.tb.stop() + self.tb.wait() + self.assertEqual(sink.num_messages(), 2) + msg1 = pmt.to_python(sink.get_message(0)) + msg2 = pmt.to_python(sink.get_message(1)) + self.assertEqual(msg1, {'packet_len': 193*4, 'frame_len': 25, 'packet_num': 0}) + self.assertEqual(msg2, {'packet_len': 8*4, 'frame_len': 1, 'packet_num': 1}) + +if __name__ == '__main__': + gr_unittest.run(qa_packet_headerparser_b, "qa_packet_headerparser_b.xml") + + diff --git a/gr-digital/python/qam.py b/gr-digital/python/qam.py index 5b1f7683b8..6834e1945a 100644 --- a/gr-digital/python/qam.py +++ b/gr-digital/python/qam.py @@ -146,9 +146,17 @@ def make_non_differential_constellation(m, gray_coded): def qam_constellation(constellation_points=_def_constellation_points, differential=_def_differential, - mod_code=_def_mod_code): + mod_code=_def_mod_code, + large_ampls_to_corners=False): """ Creates a QAM constellation object. + + If large_ampls_to_corners=True then sectors that are probably + occupied due to a phase offset, are not mapped to the closest + constellation point. Rather we take into account the fact that a + phase offset is probably the problem and map them to the closest + corner point. It's a bit hackish but it seems to improve + frequency locking. """ if mod_code == mod_codes.GRAY_CODE: gray_coded = True @@ -165,10 +173,85 @@ def qam_constellation(constellation_points=_def_constellation_points, # No pre-diff code # Should add one so that we can gray-code the quadrant bits too. pre_diff_code = [] - constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, - side, side, width, width) + if not large_ampls_to_corners: + constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, + side, side, width, width) + else: + sector_values = large_ampls_to_corners_mapping(side, points, width) + constellation = digital_swig.constellation_expl_rect( + points, pre_diff_code, 4, side, side, width, width, sector_values) return constellation +def find_closest_point(p, qs): + """ + Return in index of the closest point in 'qs' to 'p'. + """ + min_dist = None + min_i = None + for i, q in enumerate(qs): + dist = abs(q-p) + if min_dist is None or dist < min_dist: + min_dist = dist + min_i = i + return min_i + +def large_ampls_to_corners_mapping(side, points, width): + """ + We have a grid that we use for decision making. One additional row/column + is placed on each side of the grid. Points in these additional rows/columns + are mapped to the corners rather than the closest constellation points. + + Args: + side: The number of rows/columns in the grid that we use to do + decision making. + points: The list of constellation points. + width: The width of the rows/columns. + + Returns: + sector_values maps the sector index to the constellation + point index. + """ + # First find the indices of the corner points. + # Assume the corner points are the 4 points with the largest magnitudes. + corner_indices = [] + corner_points = [] + max_mag = 0 + for i, p in enumerate(points): + if abs(p) > max_mag: + corner_indices = [i] + corner_points = [p] + max_mag = abs(p) + elif abs(p) == max_mag: + corner_indices.append(i) + corner_points.append(p) + if len(corner_indices) != 4: + raise ValueError("Found {0} corner indices. Expected 4." + .format(len(corner_indices))) + # We want an additional layer around the constellation + # Value in this extra layer will be mapped to the closest corner rather + # than the closest constellation point. + extra_layers = 1 + side = side + extra_layers*2 + # Calculate sector values + sector_values = [] + for real_x in range(side): + for imag_x in range(side): + sector = real_x * side + imag_x + # If this sector is a normal constellation sector then + # use the center point. + c = ((real_x-side/2.0+0.5)*width + + (imag_x-side/2.0+0.5)*width*1j) + if (real_x >= extra_layers and real_x < side-extra_layers + and imag_x >= extra_layers and imag_x < side-extra_layers): + # This is not an edge row/column. Find closest point. + index = find_closest_point(c, points) + else: + # This is an edge. Find closest corner point. + index = corner_indices[find_closest_point(c, corner_points)] + sector_values.append(index) + return sector_values + + # ///////////////////////////////////////////////////////////////////////////// # QAM modulator # ///////////////////////////////////////////////////////////////////////////// @@ -186,12 +269,19 @@ class qam_mod(generic_mod): The input is a byte stream (unsigned char) and the output is the complex modulated signal at baseband. - See generic_mod block for list of parameters. + Args: + constellation_points: Number of constellation points. + Must be a power of 4. + mod_code: Specifies an encoding to use (typically used to indicated + if we want gray coding, see digital.utils.mod_codes) + + See generic_mod block for list of additional parameters. """ - constellation = qam_constellation(constellation_points, differential, mod_code) - # We take care of the gray coding in the constellation generation so it doesn't - # need to be done in the block. + constellation = qam_constellation(constellation_points, differential, + mod_code) + # We take care of the gray coding in the constellation + # generation so it doesn't need to be done in the block. super(qam_mod, self).__init__(constellation, differential=differential, *args, **kwargs) @@ -205,6 +295,7 @@ class qam_demod(generic_demod): def __init__(self, constellation_points=_def_constellation_points, differential=_def_differential, mod_code=_def_mod_code, + large_ampls_to_corner = False, *args, **kwargs): """ @@ -213,11 +304,23 @@ class qam_demod(generic_demod): The input is a byte stream (unsigned char) and the output is the complex modulated signal at baseband. - See generic_demod block for list of parameters. + Args: + constellation_points: Number of constellation points. + Must be a power of 4. + mod_code: Specifies an encoding to use (typically used to indicated + if we want gray coding, see digital.utils.mod_codes) + large_ampls_to_corners: If this is set to True then when the + constellation is making decisions, points that are far outside + the constellation are mapped to the closest corner rather than + the closet constellation point. This can help with phase + locking. + + See generic_demod block for list of additional parameters. """ - constellation = qam_constellation(constellation_points, differential, mod_code) - # We take care of the gray coding in the constellation generation so it doesn't - # need to be done in the block. + constellation = qam_constellation(constellation_points, differential, + mod_code) + # We take care of the gray coding in the constellation + # generation so it doesn't need to be done in the block. super(qam_demod, self).__init__(constellation, differential=differential, *args, **kwargs) diff --git a/gr-digital/python/qamlike.py b/gr-digital/python/qamlike.py new file mode 100644 index 0000000000..2f8c855339 --- /dev/null +++ b/gr-digital/python/qamlike.py @@ -0,0 +1,75 @@ +# 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. +# + +""" +This file contains constellations that are similar to QAM, but are not perfect squares. +""" + +import digital_swig +from qam import large_ampls_to_corners_mapping + +def qam32_holeinside_constellation(large_ampls_to_corners=False): + # First make constellation for one quadrant. + # 0 1 2 + # 2 - 010 111 110 + # 1 - 011 101 100 + # 0 - 000 001 + + # Have put hole in the side rather than corner. + # Corner point is helpful for frequency locking. + + # It has an attempt at some gray-coding, but not + # a very good one. + + # Indices are (horizontal, vertical). + indices_and_numbers = ( + ((0, 0), 0b000), + ((0, 1), 0b011), + ((0, 2), 0b010), + ((1, 0), 0b001), + ((1, 1), 0b101), + ((1, 2), 0b111), + ((2, 1), 0b100), + ((2, 2), 0b110), + ) + points = [None]*32 + for indices, number in indices_and_numbers: + p_in_quadrant = 0.5+indices[0] + 1j*(0.5+indices[1]) + for quadrant in range(4): + index = number + 8 * quadrant + rotation = pow(1j, quadrant) + p = p_in_quadrant * rotation + points[index] = p + side = 6 + width = 1 + # Double number of boxes on side + # This is so that points in the 'hole' get assigned correctly. + side = 12 + width = 0.5 + pre_diff_code = [] + if not large_ampls_to_corners: + constellation = digital_swig.constellation_rect(points, pre_diff_code, 4, + side, side, width, width) + else: + sector_values = large_ampls_to_corners_mapping(side, points, width) + constellation = digital_swig.constellation_expl_rect( + points, pre_diff_code, 4, side, side, width, width, sector_values) + return constellation + diff --git a/gr-digital/python/utils/tagged_streams.py b/gr-digital/python/utils/tagged_streams.py new file mode 100644 index 0000000000..7e69aa20be --- /dev/null +++ b/gr-digital/python/utils/tagged_streams.py @@ -0,0 +1,112 @@ +from gnuradio import gr +try: import pmt +except: from gruel import pmt + +def make_lengthtags(lengths, offsets, tagname='length', vlen=1): + tags = [] + assert(len(offsets) == len(lengths)) + for offset, length in zip(offsets, lengths): + tag = gr.gr_tag_t() + tag.offset = offset/vlen + tag.key = pmt.pmt_string_to_symbol(tagname) + tag.value = pmt.pmt_from_long(length/vlen) + tags.append(tag) + return tags + +def string_to_vector(string): + v = [] + for s in string: + v.append(ord(s)) + return v + +def strings_to_vectors(strings, lengthtagname): + vs = [string_to_vector(string) for string in strings] + return packets_to_vectors(vs, lengthtagname) + +def vector_to_string(v): + s = [] + for d in v: + s.append(chr(d)) + return ''.join(s) + +def vectors_to_strings(data, tags, lengthtagname): + packets = vectors_to_packets(data, tags, lengthtagname) + return [vector_to_string(packet) for packet in packets] + +def count_bursts(data, tags, lengthtagname, vlen=1): + lengthtags = [t for t in tags + if pmt.pmt_symbol_to_string(t.key) == lengthtagname] + lengths = {} + for tag in lengthtags: + if tag.offset in lengths: + raise ValueError( + "More than one tags with key {0} with the same offset={1}." + .format(lengthtagname, tag.offset)) + lengths[tag.offset] = pmt.pmt_to_long(tag.value)*vlen + in_burst = False + in_packet = False + packet_length = None + packet_pos = None + burst_count = 0 + for pos in range(len(data)): + if pos in lengths: + if in_packet: + print("Got tag at pos {0} current packet_pos is {1}".format(pos, packet_pos)) + raise StandardError("Received packet tag while in packet.") + packet_pos = -1 + packet_length = lengths[pos] + in_packet = True + if not in_burst: + burst_count += 1 + in_burst = True + elif not in_packet: + in_burst = False + if in_packet: + packet_pos += 1 + if packet_pos == packet_length-1: + in_packet = False + packet_pos = None + return burst_count + +def vectors_to_packets(data, tags, lengthtagname, vlen=1): + lengthtags = [t for t in tags + if pmt.pmt_symbol_to_string(t.key) == lengthtagname] + lengths = {} + for tag in lengthtags: + if tag.offset in lengths: + raise ValueError( + "More than one tags with key {0} with the same offset={1}." + .format(lengthtagname, tag.offset)) + lengths[tag.offset] = pmt.pmt_to_long(tag.value)*vlen + if 0 not in lengths: + raise ValueError("There is no tag with key {0} and an offset of 0" + .format(lengthtagname)) + pos = 0 + packets = [] + while pos < len(data): + if pos not in lengths: + raise ValueError("There is no tag with key {0} and an offset of {1}." + "We were expecting one." + .format(lengthtagname, pos)) + length = lengths[pos] + if length == 0: + raise ValueError("Packets cannot have zero length.") + if pos+length > len(data): + raise ValueError("The final packet is incomplete.") + packets.append(data[pos: pos+length]) + pos += length + return packets + +def packets_to_vectors(packets, lengthtagname, vlen=1): + tags = [] + data = [] + offset = 0 + for packet in packets: + data.extend(packet) + tag = gr.gr_tag_t() + tag.offset = offset/vlen + tag.key = pmt.pmt_string_to_symbol(lengthtagname) + tag.value = pmt.pmt_from_long(len(packet)/vlen) + tags.append(tag) + offset = offset + len(packet) + return data, tags diff --git a/gr-digital/swig/CMakeLists.txt b/gr-digital/swig/CMakeLists.txt index 4107116bce..5e693af896 100644 --- a/gr-digital/swig/CMakeLists.txt +++ b/gr-digital/swig/CMakeLists.txt @@ -162,8 +162,8 @@ install( digital_map_bb.i digital_mpsk_receiver_cc.i digital_mpsk_snr_est_cc.i - digital_ofdm_cyclic_prefixer.i digital_ofdm_frame_acquisition.i + digital_ofdm_cyclic_prefixer.i digital_ofdm_frame_sink.i digital_ofdm_insert_preamble.i digital_ofdm_mapper_bcv.i diff --git a/gr-digital/swig/digital_constellation.i b/gr-digital/swig/digital_constellation.i index 248f900149..4c4f8aa01d 100644 --- a/gr-digital/swig/digital_constellation.i +++ b/gr-digital/swig/digital_constellation.i @@ -102,6 +102,33 @@ public: float width_real_sectors, float width_imag_sectors); }; +class digital_constellation_expl_rect; +typedef boost::shared_ptr<digital_constellation_expl_rect> digital_constellation_expl_rect_sptr; +%template(digital_constellation_expl_rect_sptr) boost::shared_ptr<digital_constellation_expl_rect>; +%rename(constellation_expl_rect) digital_make_constellation_expl_rect; +digital_constellation_expl_rect_sptr digital_make_constellation_expl_rect( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors, + std::vector<unsigned int> sector_values +); +%ignore digital_constellation_expl_rect; + +class digital_constellation_expl_rect : public digital_constellation_rect +{ +public: + digital_constellation_expl_rect ( + std::vector<gr_complex> constellation, + std::vector<unsigned int> pre_diff_code, + unsigned int rotational_symmetry, + unsigned int real_sectors, unsigned int imag_sectors, + float width_real_sectors, float width_imag_sectors, + std::vector<unsigned int> sector_values + ); +}; + class digital_constellation_psk; typedef boost::shared_ptr<digital_constellation_psk> digital_constellation_psk_sptr; %template(digital_constellation_psk_sptr) boost::shared_ptr<digital_constellation_psk>; @@ -198,6 +225,7 @@ public: digital_constellation_calcdist_sptr.__repr__ = lambda self: '<constellation calcdist (m=%s)>' % str(len(self.points())) digital_constellation_rect_sptr.__repr__ = lambda self: '<constellation rect (m=%s)>' % str(len(self.points())) +digital_constellation_expl_rect_sptr.__repr__ = lambda self: '<constellation expl_rect (m=%s)>' % str(len(self.points())) digital_constellation_psk_sptr.__repr__ = lambda self: '<constellation psk (m=%s)>' % str(len(self.points())) digital_constellation_bpsk_sptr.__repr__ = lambda self: '<constellation bpsk>' digital_constellation_qpsk_sptr.__repr__ = lambda self: '<constellation qpsk>' diff --git a/gr-digital/swig/digital_crc32_bb.i b/gr-digital/swig/digital_crc32_bb.i new file mode 100644 index 0000000000..45b240793d --- /dev/null +++ b/gr-digital/swig/digital_crc32_bb.i @@ -0,0 +1,32 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +GR_SWIG_BLOCK_MAGIC(digital, crc32_bb) + +digital_crc32_bb_sptr +digital_make_crc32_bb (bool check=false, const std::string& lengthtagname="packet_len"); + +class digital_crc32_bb : public gr_block +{ + private: + digital_crc32_bb(bool check, const std::string& lengthtagname); +}; + diff --git a/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i b/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i new file mode 100644 index 0000000000..1663a4de3d --- /dev/null +++ b/gr-digital/swig/digital_ofdm_carrier_allocator_cvc.i @@ -0,0 +1,37 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +GR_SWIG_BLOCK_MAGIC(digital, ofdm_carrier_allocator_cvc); + +digital_ofdm_carrier_allocator_cvc_sptr +digital_make_ofdm_carrier_allocator_cvc ( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + const std::string &len_tag_key = "packet_len"); + +class digital_ofdm_carrier_allocator_cvc : public gr_tagged_stream_block +{ + private: + digital_ofdm_carrier_allocator_cvc(int fft_len, const std::vector<std::vector<int> > &occupied_carriers, const std::vector<std::vector<int> > &pilot_carriers, const std::vector<std::vector<gr_complex> > &pilot_symbols, const std::string &len_tag_key); +}; + diff --git a/gr-digital/swig/digital_ofdm_chanest_vcvc.i b/gr-digital/swig/digital_ofdm_chanest_vcvc.i new file mode 100644 index 0000000000..aa6e79b5c2 --- /dev/null +++ b/gr-digital/swig/digital_ofdm_chanest_vcvc.i @@ -0,0 +1,40 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + +GR_SWIG_BLOCK_MAGIC(digital, ofdm_chanest_vcvc); + +digital_ofdm_chanest_vcvc_sptr +digital_make_ofdm_chanest_vcvc ( + const std::vector<gr_complex> &sync_symbol1, + const std::vector<gr_complex> &sync_symbol2, + int n_data_symbols, + int eq_noise_red_len=0, + int max_carr_offset=-1, + bool force_one_sync_symbol=false); + +class digital_ofdm_chanest_vcvc : public gr_block +{ + private: + digital_ofdm_chanest_vcvc(const std::vector<gr_complex> &sync_symbol1, const std::vector<gr_complex> &sync_symbol2, int n_data_symbols, int eq_noise_red_len, int max_carr_offset, bool force_one_sync_symbol); + + public: +}; + diff --git a/gr-digital/swig/digital_ofdm_cyclic_prefixer.i b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i index 56d1629a8a..19ffd6a12b 100644 --- a/gr-digital/swig/digital_ofdm_cyclic_prefixer.i +++ b/gr-digital/swig/digital_ofdm_cyclic_prefixer.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009,2011 Free Software Foundation, Inc. + * Copyright 2004-2006,2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,15 +20,16 @@ * Boston, MA 02110-1301, USA. */ -GR_SWIG_BLOCK_MAGIC(digital,ofdm_cyclic_prefixer) +GR_SWIG_BLOCK_MAGIC(digital,ofdm_cyclic_prefixer); -digital_ofdm_cyclic_prefixer_sptr -digital_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); +digital_ofdm_cyclic_prefixer_sptr +digital_make_ofdm_cyclic_prefixer (size_t input_size, + size_t output_size, + int rolloff_len=0, + const std::string &len_tag_key=""); -class digital_ofdm_cyclic_prefixer : public gr_sync_interpolator -{ - protected: - digital_ofdm_cyclic_prefixer (size_t input_size, size_t output_size); - public: +class digital_ofdm_cyclic_prefixer : public gr_tagged_stream_block +{ }; + diff --git a/gr-digital/swig/digital_ofdm_equalizer_base.i b/gr-digital/swig/digital_ofdm_equalizer_base.i new file mode 100644 index 0000000000..9de293f358 --- /dev/null +++ b/gr-digital/swig/digital_ofdm_equalizer_base.i @@ -0,0 +1,63 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + + + +class digital_ofdm_equalizer_base; +typedef boost::shared_ptr<digital_ofdm_equalizer_base> digital_ofdm_equalizer_base_sptr; +%template(digital_ofdm_equalizer_base_sptr) boost::shared_ptr<digital_ofdm_equalizer_base>; +%ignore digital_ofdm_equalizer_base; + +class digital_ofdm_equalizer_1d_pilots; +typedef boost::shared_ptr<digital_ofdm_equalizer_1d_pilots> digital_ofdm_equalizer_1d_pilots_sptr; +%template(digital_ofdm_equalizer_1d_pilots_sptr) boost::shared_ptr<digital_ofdm_equalizer_1d_pilots>; +%ignore digital_ofdm_equalizer_1d_pilots; + +class digital_ofdm_equalizer_base +{ + public: + digital_ofdm_equalizer_base(int fft_len); + + virtual void reset() = 0; + virtual void equalize( + gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()) = 0; + virtual void get_channel_state(std::vector<gr_complex> &taps) = 0; + digital_ofdm_equalizer_base_sptr base(); +}; + + +class digital_ofdm_equalizer_1d_pilots : public digital_ofdm_equalizer_base +{ + public: + digital_ofdm_equalizer_1d_pilots( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers, + const std::vector<std::vector<int> > &pilot_carriers, + const std::vector<std::vector<gr_complex> > &pilot_symbols, + int symbols_skipped, + bool input_is_shifted); + + void reset(); +}; + diff --git a/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i b/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i new file mode 100644 index 0000000000..b9a26e246f --- /dev/null +++ b/gr-digital/swig/digital_ofdm_equalizer_simpledfe.i @@ -0,0 +1,58 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + + +class digital_ofdm_equalizer_simpledfe; +typedef boost::shared_ptr<digital_ofdm_equalizer_simpledfe> digital_ofdm_equalizer_simpledfe_sptr; +%template(digital_ofdm_equalizer_simpledfe_sptr) boost::shared_ptr<digital_ofdm_equalizer_simpledfe>; +%rename(ofdm_equalizer_simpledfe) digital_make_ofdm_equalizer_simpledfe; +digital_ofdm_equalizer_simpledfe_sptr +digital_make_ofdm_equalizer_simpledfe( + int fft_len, + const digital_constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + float alpha = 0.1, + bool input_is_shifted = true); +%ignore digital_ofdm_equalizer_simpledfe; + +class digital_ofdm_equalizer_simpledfe : public digital_ofdm_equalizer_1d_pilots +{ + public: + digital_ofdm_equalizer_simpledfe( + int fft_len, + const digital_constellation_sptr &constellation, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + float alpha = 0.1, + bool input_is_shifted = true); + + void equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); + void get_channel_state(std::vector<gr_complex> &taps); +}; + diff --git a/gr-digital/swig/digital_ofdm_equalizer_static.i b/gr-digital/swig/digital_ofdm_equalizer_static.i new file mode 100644 index 0000000000..3e99403ff7 --- /dev/null +++ b/gr-digital/swig/digital_ofdm_equalizer_static.i @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* Copyright 2012 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. + */ + + +class digital_ofdm_equalizer_static; +typedef boost::shared_ptr<digital_ofdm_equalizer_static> digital_ofdm_equalizer_static_sptr; +%template(digital_ofdm_equalizer_static_sptr) boost::shared_ptr<digital_ofdm_equalizer_static>; +%rename(ofdm_equalizer_static) digital_make_ofdm_equalizer_static; +digital_ofdm_equalizer_static_sptr +digital_make_ofdm_equalizer_static( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + bool input_is_shifted = true); +%ignore digital_ofdm_equalizer_static; + +class digital_ofdm_equalizer_static : public digital_ofdm_equalizer_1d_pilots +{ + public: + digital_ofdm_equalizer_static( + int fft_len, + const std::vector<std::vector<int> > &occupied_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<int> > &pilot_carriers = std::vector<std::vector<int> >(), + const std::vector<std::vector<gr_complex> > &pilot_symbols = std::vector<std::vector<gr_complex> >(), + int symbols_skipped = 0, + bool input_is_shifted = true); + ~digital_ofdm_equalizer_static(); + + void equalize(gr_complex *frame, + int n_sym, + const std::vector<gr_complex> &initial_taps = std::vector<gr_complex>(), + const std::vector<gr_tag_t> &tags = std::vector<gr_tag_t>()); + void get_channel_state(std::vector<gr_complex> &taps); +}; + diff --git a/gr-digital/swig/digital_ofdm_sync_sc_cfb.i b/gr-digital/swig/digital_ofdm_sync_sc_cfb.i new file mode 100644 index 0000000000..e0298f8b8d --- /dev/null +++ b/gr-digital/swig/digital_ofdm_sync_sc_cfb.i @@ -0,0 +1,33 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +GR_SWIG_BLOCK_MAGIC(digital, ofdm_sync_sc_cfb) + +digital_ofdm_sync_sc_cfb_sptr +digital_make_ofdm_sync_sc_cfb (int fft_len, int cp_len, bool use_even_carriers=false); + +class digital_ofdm_sync_sc_cfb : public gr_hier_block2 +{ + private: + digital_ofdm_sync_sc_cfb(int fft_len, int cp_len, bool use_even_carriers); +}; + diff --git a/gr-digital/swig/digital_swig.i b/gr-digital/swig/digital_swig.i index a5f0251a43..2f36e13c8e 100644 --- a/gr-digital/swig/digital_swig.i +++ b/gr-digital/swig/digital_swig.i @@ -19,6 +19,8 @@ * Boston, MA 02110-1301, USA. */ +#define DIGITAL_API + %include "gnuradio.i" //load generated python docstrings @@ -81,6 +83,20 @@ enum snr_est_type_t { #include "digital_probe_mpsk_snr_est_c.h" #include "digital_scrambler_bb.h" #include "digital_simple_framer.h" +#include "digital_ofdm_sync_sc_cfb.h" +#include "digital_ofdm_chanest_vcvc.h" +#include "digital_crc32_bb.h" +#include "digital_ofdm_carrier_allocator_cvc.h" +#include "digital_ofdm_equalizer_base.h" +#include "digital_ofdm_equalizer_simpledfe.h" +#include "digital_ofdm_equalizer_static.h" +#include "digital/ofdm_frame_equalizer_vcvc.h" +#include "digital/packet_header_default.h" +#include "digital/packet_header_ofdm.h" +#include "digital/packet_headergenerator_bb.h" +#include "digital/ofdm_serializer_vcc.h" +#include "digital/packet_headerparser_b.h" +#include "digital/header_payload_demux.h" #include "digital_simple_correlator.h" %} @@ -126,4 +142,28 @@ enum snr_est_type_t { %include "digital_probe_mpsk_snr_est_c.i" %include "digital_scrambler_bb.i" %include "digital_simple_framer.i" +%include "digital_ofdm_sync_sc_cfb.i" +%include "digital_ofdm_chanest_vcvc.i" +%include "digital_crc32_bb.i" +%include "digital_ofdm_carrier_allocator_cvc.i" +%include "digital_ofdm_equalizer_base.i" +%include "digital_ofdm_equalizer_simpledfe.i" +%include "digital_ofdm_equalizer_static.i" +%include "digital/ofdm_frame_equalizer_vcvc.h" +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_frame_equalizer_vcvc); + +%include "digital/packet_header_default.h" +%include "digital/packet_header_ofdm.h" +%include "packet_header.i" + +%include "digital/packet_headergenerator_bb.h" +GR_SWIG_BLOCK_MAGIC2(digital, packet_headergenerator_bb); + +%include "digital/ofdm_serializer_vcc.h" +GR_SWIG_BLOCK_MAGIC2(digital, ofdm_serializer_vcc); + +%include "digital/packet_headerparser_b.h" +GR_SWIG_BLOCK_MAGIC2(digital, packet_headerparser_b); +%include "digital/header_payload_demux.h" +GR_SWIG_BLOCK_MAGIC2(digital, header_payload_demux); %include "digital_simple_correlator.i" diff --git a/gr-digital/swig/packet_header.i b/gr-digital/swig/packet_header.i new file mode 100644 index 0000000000..7c06d19f71 --- /dev/null +++ b/gr-digital/swig/packet_header.i @@ -0,0 +1,34 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 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. + */ + +%template(packet_header_default_sptr) boost::shared_ptr<gr::digital::packet_header_default>; +%pythoncode %{ +packet_header_default_sptr.__repr__ = lambda self: "<packet_header_default>" +packet_header_default = packet_header_default .make; +%} + +%template(packet_header_ofdm_sptr) boost::shared_ptr<gr::digital::packet_header_ofdm>; +%pythoncode %{ +packet_header_ofdm_sptr.__repr__ = lambda self: "<packet_header_ofdm>" +packet_header_ofdm = packet_header_ofdm .make; +%} + diff --git a/gr-fcd/grc/fcd_source_c.xml b/gr-fcd/grc/fcd_source_c.xml index f1726f88f2..b514c6126c 100644 --- a/gr-fcd/grc/fcd_source_c.xml +++ b/gr-fcd/grc/fcd_source_c.xml @@ -2,7 +2,7 @@ <block> <name>Funcube Dongle Source</name> <key>fcd_source_c</key> - <category>Sources</category> + <category>FCD</category> <throttle>1</throttle> <import>from gnuradio import fcd</import> <make>fcd.source_c($device_name) diff --git a/gr-fcd/include/fcd/fcd_source_c.h b/gr-fcd/include/fcd/fcd_source_c.h index 19c5890231..0fc7bb00d1 100644 --- a/gr-fcd/include/fcd/fcd_source_c.h +++ b/gr-fcd/include/fcd/fcd_source_c.h @@ -31,14 +31,18 @@ typedef boost::shared_ptr<fcd_source_c> fcd_source_c_sptr; /*! * \brief Return a shared_ptr to a new instance of fcd_source_c. * + * \details * This is effectively the public constructor. To avoid accidental use * of raw pointers, fcd_source_c's constructor is private. * fcd_make_source_c is the public interface for creating new instances. */ FCD_API fcd_source_c_sptr fcd_make_source_c(const std::string device_name = ""); -/*! \brief Funcube Dongle source block. +/*! + * \brief Funcube Dongle source block. + * \ingroup fcd_blk * + * \details * This class provides a Funcube Dongle soure block by wrapping the * USB audio interface and the USB HID control interface of the Funcube * Dongle into one convenient source block. diff --git a/gr-fcd/lib/CMakeLists.txt b/gr-fcd/lib/CMakeLists.txt index a5c95ceb7d..8e4afafdb1 100644 --- a/gr-fcd/lib/CMakeLists.txt +++ b/gr-fcd/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -36,6 +36,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -51,6 +54,18 @@ list(APPEND fcd_libs if (WIN32) list(APPEND fcd_libs setupapi) + + #Add Windows DLL resource file if using MSVC + if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-fcd.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fcd.rc + @ONLY) + + list(APPEND gr_fcd_sources ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fcd.rc) + endif(MSVC) endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") @@ -67,7 +82,7 @@ add_library(gnuradio-fcd SHARED ${gr_fcd_sources}) if (LINUX) list(APPEND fcd_libs rt) endif() -target_link_libraries(gnuradio-fcd ${fcd_libs}) +target_link_libraries(gnuradio-fcd ${fcd_libs} ${LOG4CPP_LIBRARIES}) GR_LIBRARY_FOO(gnuradio-fcd RUNTIME_COMPONENT "fcd_runtime" DEVEL_COMPONENT "fcd_devel") diff --git a/gr-fcd/lib/gnuradio-fcd.rc.in b/gr-fcd/lib/gnuradio-fcd.rc.in new file mode 100644 index 0000000000..01c502c4dd --- /dev/null +++ b/gr-fcd/lib/gnuradio-fcd.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-fcd" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-fcd.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-fcd.dll" + VALUE "ProductName", "gnuradio-fcd" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-fft/grc/fft_block_tree.xml b/gr-fft/grc/fft_block_tree.xml index 3bda77eae1..3a81ee76e9 100644 --- a/gr-fft/grc/fft_block_tree.xml +++ b/gr-fft/grc/fft_block_tree.xml @@ -29,7 +29,7 @@ <cat> <name></name> <!-- Blank for Root Name --> <cat> - <name>FFT</name> + <name>Fourier Analysis</name> <block>fft_vxx</block> <block>goertzel_fc</block> </cat> diff --git a/gr-fft/include/fft/fft_vcc.h b/gr-fft/include/fft/fft_vcc.h index cb07b166d2..2f5b5a23f0 100644 --- a/gr-fft/include/fft/fft_vcc.h +++ b/gr-fft/include/fft/fft_vcc.h @@ -29,6 +29,10 @@ namespace gr { namespace fft { + /*! + * \brief Compute forward or reverse FFT. complex vector in / complex vector out. + * \ingroup fourier_analysis_blk + */ class FFT_API fft_vcc : virtual public gr_sync_block { public: @@ -36,13 +40,9 @@ namespace gr { // gr::fft::fft_vcc::sptr typedef boost::shared_ptr<fft_vcc> sptr; - /*! - * \brief Compute forward or reverse FFT. complex vector in / complex vector out. - * \ingroup dft_blk - */ static sptr make(int fft_size, bool forward, - const std::vector<float> &window, - bool shift=false, int nthreads=1); + const std::vector<float> &window, + bool shift=false, int nthreads=1); virtual void set_nthreads(int n) = 0; diff --git a/gr-fft/include/fft/fft_vfc.h b/gr-fft/include/fft/fft_vfc.h index ec441d66a8..89491113b6 100644 --- a/gr-fft/include/fft/fft_vfc.h +++ b/gr-fft/include/fft/fft_vfc.h @@ -29,6 +29,10 @@ namespace gr { namespace fft { + /*! + * \brief Compute forward or reverse FFT. float vector in / complex vector out. + * \ingroup fourier_analysis_blk + */ class FFT_API fft_vfc : virtual public gr_sync_block { public: @@ -36,10 +40,6 @@ namespace gr { // gr::fft::fft_vfc::sptr typedef boost::shared_ptr<fft_vfc> sptr; - /*! - * \brief Compute forward or reverse FFT. float vector in / complex vector out. - * \ingroup dft_blk - */ static sptr make(int fft_size, bool forward, const std::vector<float> &window, int nthreads=1); diff --git a/gr-fft/include/fft/goertzel_fc.h b/gr-fft/include/fft/goertzel_fc.h index 5b3c8f1c49..26b0d0d11c 100644 --- a/gr-fft/include/fft/goertzel_fc.h +++ b/gr-fft/include/fft/goertzel_fc.h @@ -29,6 +29,10 @@ namespace gr { namespace fft { + /*! + * \brief Goertzel single-bin DFT calculation. + * \ingroup fourier_analysis_blk + */ class FFT_API goertzel_fc : virtual public gr_sync_decimator { public: @@ -36,10 +40,6 @@ namespace gr { // gr::fft::goertzel_fc::sptr typedef boost::shared_ptr<goertzel_fc> sptr; - /*! - * \brief Goertzel single-bin DFT calculation. - * \ingroup dft_blk - */ static sptr make(int rate, int len, float freq); virtual void set_freq (float freq) = 0; diff --git a/gr-fft/lib/CMakeLists.txt b/gr-fft/lib/CMakeLists.txt index 26fcaa7cde..9382a48c3b 100644 --- a/gr-fft/lib/CMakeLists.txt +++ b/gr-fft/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -50,6 +50,20 @@ list(APPEND fft_libs ${FFTW3F_LIBRARIES} ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-fft.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.rc + @ONLY) + + list(APPEND fft_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-fft.rc + ) +endif(MSVC) + if(FFTW3F_THREADS_LIBRARIES) list(APPEND fft_libs ${FFTW3F_THREADS_LIBRARIES}) add_definitions("-DFFTW3F_THREADS") diff --git a/gr-fft/lib/gnuradio-fft.rc.in b/gr-fft/lib/gnuradio-fft.rc.in new file mode 100644 index 0000000000..0c12bc91e7 --- /dev/null +++ b/gr-fft/lib/gnuradio-fft.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-fft" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-fft.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-fft.dll" + VALUE "ProductName", "gnuradio-fft" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-filter/grc/CMakeLists.txt b/gr-filter/grc/CMakeLists.txt index 2e3fef4f07..7d5e902dfc 100644 --- a/gr-filter/grc/CMakeLists.txt +++ b/gr-filter/grc/CMakeLists.txt @@ -24,6 +24,7 @@ install(FILES fir_filter_xxx.xml filter_delay_fc.xml fractional_interpolator_xx.xml + filter_fractional_resampler_xx.xml freq_xlating_fir_filter_xxx.xml hilbert_fc.xml iir_filter_ffd.xml diff --git a/gr-filter/grc/filter_block_tree.xml b/gr-filter/grc/filter_block_tree.xml index 711ce4059f..b2999806f9 100644 --- a/gr-filter/grc/filter_block_tree.xml +++ b/gr-filter/grc/filter_block_tree.xml @@ -34,18 +34,27 @@ <block>fft_filter_xxx</block> <block>fir_filter_xxx</block> <block>filter_delay_fc</block> - <block>fractional_interpolator_xx</block> - <block>freq_xlating_fir_filter_xxx</block> <block>hilbert_fc</block> <block>iir_filter_ffd</block> <block>interp_fir_filter_xxx</block> + <block>single_pole_iir_filter_xx</block> + </cat> + <cat> + <name>Resamplers</name> + <block>fractional_resampler_xx</block> <block>pfb_arb_resampler_xxx</block> + <block>rational_resampler_base_xxx</block> + </cat> + <cat> + <name>Channelizers</name> + <block>freq_xlating_fir_filter_xxx</block> <block>pfb_channelizer_ccf</block> <block>pfb_decimator_ccf</block> <block>pfb_interpolator_ccf</block> <block>pfb_synthesizer_ccf</block> - <block>rational_resampler_base_xxx</block> - <block>single_pole_iir_filter_xx</block> + </cat> + <cat> + <name>Channel Models</name> <block>channel_model</block> </cat> </cat> diff --git a/gr-filter/grc/filter_fractional_resampler_xx.xml b/gr-filter/grc/filter_fractional_resampler_xx.xml new file mode 100644 index 0000000000..48d624d432 --- /dev/null +++ b/gr-filter/grc/filter_fractional_resampler_xx.xml @@ -0,0 +1,46 @@ +<?xml version="1.0"?> +<!-- +################################################### +##Fractional Resampler +################################################### + --> +<block> + <name>Fractional Resampler</name> + <key>fractional_resampler_xx</key> + <import>from gnuradio import filter</import> + <make>filter.fractional_resampler_$(type.fcn)($phase_shift, $resamp_ratio)</make> + <callback>set_resamp_ratio($resamp_ratio)</callback> + <param> + <name>Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Complex</name> + <key>complex</key> + <opt>fcn:cc</opt> + </option> + <option> + <name>Float</name> + <key>float</key> + <opt>fcn:ff</opt> + </option> + </param> + <param> + <name>Phase Shift</name> + <key>phase_shift</key> + <type>real</type> + </param> + <param> + <name>Resampling Ratio</name> + <key>resamp_ratio</key> + <type>real</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/gr-filter/grc/pfb_arb_resampler.xml b/gr-filter/grc/pfb_arb_resampler.xml index 774cb91864..3166f038bd 100644 --- a/gr-filter/grc/pfb_arb_resampler.xml +++ b/gr-filter/grc/pfb_arb_resampler.xml @@ -18,7 +18,8 @@ #end if flt_size=$nfilts) </make> - <callback>set_taps($taps)</callback> + <callback>set_taps($taps)</callback> + <callback>set_rate($rrate)</callback> <param> <name>Type</name> <key>type</key> diff --git a/gr-filter/include/filter/CMakeLists.txt b/gr-filter/include/filter/CMakeLists.txt index 4c126fcbd3..8caab95349 100644 --- a/gr-filter/include/filter/CMakeLists.txt +++ b/gr-filter/include/filter/CMakeLists.txt @@ -99,6 +99,8 @@ install(FILES fft_filter_fff.h fractional_interpolator_cc.h fractional_interpolator_ff.h + fractional_resampler_cc.h + fractional_resampler_ff.h hilbert_fc.h iir_filter_ffd.h pfb_arb_resampler_ccf.h diff --git a/gr-filter/include/filter/adaptive_fir_ccc.h b/gr-filter/include/filter/adaptive_fir_ccc.h index 261259957f..e1eaf460ad 100644 --- a/gr-filter/include/filter/adaptive_fir_ccc.h +++ b/gr-filter/include/filter/adaptive_fir_ccc.h @@ -34,6 +34,7 @@ namespace gr { * \brief Adaptive FIR filter with gr_complex input, gr_complex output and gr_complex taps * \ingroup filter_blk * + * \details * This is a base class to implement an adaptive FIR * filter. Generally, another block will inherit from this one to * build a new type of adaptive filter such as an equalizer. diff --git a/gr-filter/include/filter/adaptive_fir_ccf.h b/gr-filter/include/filter/adaptive_fir_ccf.h index 0fd8d5746a..e296e42df1 100644 --- a/gr-filter/include/filter/adaptive_fir_ccf.h +++ b/gr-filter/include/filter/adaptive_fir_ccf.h @@ -33,6 +33,7 @@ namespace gr { * \brief Adaptive FIR filter with gr_complex input, gr_complex output and float taps * \ingroup filter_blk * + * \details * This is a base class to implement an adaptive FIR * filter. Generally, another block will inherit from this one to * build a new type of adaptive filter such as an equalizer. diff --git a/gr-filter/include/filter/channel_model.h b/gr-filter/include/filter/channel_model.h index 49c08181f7..47729ee5ab 100644 --- a/gr-filter/include/filter/channel_model.h +++ b/gr-filter/include/filter/channel_model.h @@ -32,8 +32,9 @@ namespace gr { /*! * \brief channel simulator - * \ingroup misc_blk + * \ingroup channel_models_blk * + * \details * This block implements a basic channel model simulator that can * be used to help evaluate, design, and test various signals, * waveforms, and algorithms. This model allows the user to set diff --git a/gr-filter/include/filter/dc_blocker_cc.h b/gr-filter/include/filter/dc_blocker_cc.h index df4c815d60..5ef75b48e4 100644 --- a/gr-filter/include/filter/dc_blocker_cc.h +++ b/gr-filter/include/filter/dc_blocker_cc.h @@ -29,6 +29,31 @@ namespace gr { namespace filter { + /*! + * \brief a computationally efficient controllable DC blocker + * \ingroup filter_blk + * + * \details + * This block implements a computationally efficient DC blocker that produces + * a tighter notch filter around DC for a smaller group delay than an + * equivalent FIR filter or using a single pole IIR filter (though the IIR + * filter is computationally cheaper). + * + * The block defaults to using a delay line of length 32 and the long form + * of the filter. Optionally, the delay line length can be changed to alter + * the width of the DC notch (longer lines will decrease the width). + * + * The long form of the filter produces a nearly flat response outside of + * the notch but at the cost of a group delay of 2D-2. + * + * The short form of the filter does not have as flat a response in the + * passband but has a group delay of only D-1 and is cheaper to compute. + * + * The theory behind this block can be found in the paper: + * + * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, + * Mar. 2008, pp 132-134.</EM></B> + */ class FILTER_API dc_blocker_cc : virtual public gr_sync_block { public: @@ -37,30 +62,7 @@ namespace gr { typedef boost::shared_ptr<dc_blocker_cc> sptr; /*! - * \class dc_blocker_cc - * \brief a computationally efficient controllable DC blocker - * - * \ingroup filter_blk - * - * This block implements a computationally efficient DC blocker that produces - * a tighter notch filter around DC for a smaller group delay than an - * equivalent FIR filter or using a single pole IIR filter (though the IIR - * filter is computationally cheaper). - * - * The block defaults to using a delay line of length 32 and the long form - * of the filter. Optionally, the delay line length can be changed to alter - * the width of the DC notch (longer lines will decrease the width). - * - * The long form of the filter produces a nearly flat response outside of - * the notch but at the cost of a group delay of 2D-2. - * - * The short form of the filter does not have as flat a response in the - * passband but has a group delay of only D-1 and is cheaper to compute. - * - * The theory behind this block can be found in the paper: - * - * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, - * Mar. 2008, pp 132-134.</EM></B> + * Make a DC blocker block. * * \param D (int) the length of the delay line * \param long_form (bool) whether to use long (true, default) or short form diff --git a/gr-filter/include/filter/dc_blocker_ff.h b/gr-filter/include/filter/dc_blocker_ff.h index 6ab4d5a3de..64f134e1ab 100644 --- a/gr-filter/include/filter/dc_blocker_ff.h +++ b/gr-filter/include/filter/dc_blocker_ff.h @@ -29,6 +29,34 @@ namespace gr { namespace filter { + /*! + * \brief a computationally efficient controllable DC blocker + * \ingroup filter_blk + * + * \details + * This block implements a computationally efficient DC blocker + * that produces a tighter notch filter around DC for a smaller + * group delay than an equivalent FIR filter or using a single + * pole IIR filter (though the IIR filter is computationally + * cheaper). + * + * The block defaults to using a delay line of length 32 and the + * long form of the filter. Optionally, the delay line length can + * be changed to alter the width of the DC notch (longer lines + * will decrease the width). + * + * The long form of the filter produces a nearly flat response + * outside of the notch but at the cost of a group delay of 2D-2. + * + * The short form of the filter does not have as flat a response + * in the passband but has a group delay of only D-1 and is + * cheaper to compute. + * + * The theory behind this block can be found in the paper: + * + * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, + * Mar. 2008, pp 132-134.</EM></B> + */ class FILTER_API dc_blocker_ff : virtual public gr_sync_block { public: @@ -37,30 +65,7 @@ namespace gr { typedef boost::shared_ptr<dc_blocker_ff> sptr; /*! - * \class dc_blocker_ff - * \brief a computationally efficient controllable DC blocker - * - * \ingroup filter_blk - * - * This block implements a computationally efficient DC blocker that produces - * a tighter notch filter around DC for a smaller group delay than an - * equivalent FIR filter or using a single pole IIR filter (though the IIR - * filter is computationally cheaper). - * - * The block defaults to using a delay line of length 32 and the long form - * of the filter. Optionally, the delay line length can be changed to alter - * the width of the DC notch (longer lines will decrease the width). - * - * The long form of the filter produces a nearly flat response outside of - * the notch but at the cost of a group delay of 2D-2. - * - * The short form of the filter does not have as flat a response in the - * passband but has a group delay of only D-1 and is cheaper to compute. - * - * The theory behind this block can be found in the paper: - * - * <B><EM>R. Yates, "DC Blocker Algorithms," IEEE Signal Processing Magazine, - * Mar. 2008, pp 132-134.</EM></B> + * Make a DC blocker block. * * \param D (int) the length of the delay line * \param long_form (bool) whether to use long (true, default) or short form diff --git a/gr-filter/include/filter/fft_filter.h b/gr-filter/include/filter/fft_filter.h index 8c7d6cf786..8bab289dac 100644 --- a/gr-filter/include/filter/fft_filter.h +++ b/gr-filter/include/filter/fft_filter.h @@ -31,6 +31,7 @@ namespace gr { namespace filter { namespace kernel { + /*! * \brief Fast FFT filter with float input, float output and float taps * \ingroup filter_blk diff --git a/gr-filter/include/filter/fft_filter_ccc.h b/gr-filter/include/filter/fft_filter_ccc.h index acec932775..38fef07f94 100644 --- a/gr-filter/include/filter/fft_filter_ccc.h +++ b/gr-filter/include/filter/fft_filter_ccc.h @@ -29,6 +29,29 @@ namespace gr { namespace filter { + /*! + * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps + * \ingroup filter_blk + * + * \details + * This block implements a complex decimating filter using the + * fast convolution method via an FFT. The decimation factor is an + * interger that is greater than or equal to 1. + * + * The filter takes a set of complex (or real) taps to use in the + * filtering operation. These taps can be defined as anything that + * satisfies the user's filtering needs. For standard filters such + * as lowpass, highpass, bandpass, etc., the filter.firdes and + * filter.optfir classes provide convenient generating methods. + * + * This filter is implemented by using the FFTW package to perform + * the required FFTs. An optional argument, nthreads, may be + * passed to the constructor (or set using the set_nthreads member + * function) to split the FFT among N number of threads. This can + * improve performance on very large FFTs (that is, if the number + * of taps used is very large) if you have enough threads/cores to + * support it. + */ class FILTER_API fft_filter_ccc : virtual public gr_sync_decimator { public: @@ -36,35 +59,15 @@ namespace gr { typedef boost::shared_ptr<fft_filter_ccc> sptr; /*! - * \brief Fast FFT filter with gr_complex input, gr_complex output and gr_complex taps - * \ingroup filter_blk - * - * This block implements a complex decimating filter using the - * fast convolution method via an FFT. The decimation factor is - * an interger that is greater than or equal to 1. - * - * The filter takes a set of complex (or real) taps to use in - * the filtering operation. These taps can be defined as - * anything that satisfies the user's filtering needs. For - * standard filters such as lowpass, highpass, bandpass, etc., - * the filter.firdes and filter.optfir classes provide - * convenient generating methods. - * - * This filter is implemented by using the FFTW package to - * perform the required FFTs. An optional argument, nthreads, - * may be passed to the constructor (or set using the - * set_nthreads member function) to split the FFT among N number - * of threads. This can improve performance on very large FFTs - * (that is, if the number of taps used is very large) if you - * have enough threads/cores to support it. + * Build an FFT filter blocks. * * \param decimation >= 1 * \param taps complex filter taps * \param nthreads number of threads for the FFT to use */ static sptr make(int decimation, - const std::vector<gr_complex> &taps, - int nthreads=1); + const std::vector<gr_complex> &taps, + int nthreads=1); virtual void set_taps(const std::vector<gr_complex> &taps) = 0; virtual std::vector<gr_complex> taps() const = 0; diff --git a/gr-filter/include/filter/fft_filter_fff.h b/gr-filter/include/filter/fft_filter_fff.h index d8140325f2..0183234380 100644 --- a/gr-filter/include/filter/fft_filter_fff.h +++ b/gr-filter/include/filter/fft_filter_fff.h @@ -29,6 +29,29 @@ namespace gr { namespace filter { + /*! + * \brief Fast FFT filter with float input, float output and float taps + * \ingroup filter_blk + * + * \details + * This block implements a real-value decimating filter using the + * fast convolution method via an FFT. The decimation factor is an + * interger that is greater than or equal to 1. + * + * The filter takes a set of real-valued taps to use in the + * filtering operation. These taps can be defined as anything that + * satisfies the user's filtering needs. For standard filters such + * as lowpass, highpass, bandpass, etc., the filter.firdes and + * filter.optfir classes provide convenient generating methods. + * + * This filter is implemented by using the FFTW package to perform + * the required FFTs. An optional argument, nthreads, may be + * passed to the constructor (or set using the set_nthreads member + * function) to split the FFT among N number of threads. This can + * improve performance on very large FFTs (that is, if the number + * of taps used is very large) if you have enough threads/cores to + * support it. + */ class FILTER_API fft_filter_fff : virtual public gr_sync_decimator { public: @@ -36,35 +59,15 @@ namespace gr { typedef boost::shared_ptr<fft_filter_fff> sptr; /*! - * \brief Fast FFT filter with float input, float output and float taps - * \ingroup filter_blk - * - * This block implements a real-value decimating filter using - * the fast convolution method via an FFT. The decimation factor - * is an interger that is greater than or equal to 1. - * - * The filter takes a set of real-valued taps to use in - * the filtering operation. These taps can be defined as - * anything that satisfies the user's filtering needs. For - * standard filters such as lowpass, highpass, bandpass, etc., - * the filter.firdes and filter.optfir classes provide - * convenient generating methods. - * - * This filter is implemented by using the FFTW package to - * perform the required FFTs. An optional argument, nthreads, - * may be passed to the constructor (or set using the - * set_nthreads member function) to split the FFT among N number - * of threads. This can improve performance on very large FFTs - * (that is, if the number of taps used is very large) if you - * have enough threads/cores to support it. + * Build an FFT filter block. * * \param decimation >= 1 * \param taps float filter taps * \param nthreads number of threads for the FFT to use */ static sptr make(int decimation, - const std::vector<float> &taps, - int nthreads=1); + const std::vector<float> &taps, + int nthreads=1); virtual void set_taps(const std::vector<float> &taps) = 0; virtual std::vector<float> taps() const = 0; diff --git a/gr-filter/include/filter/filter_delay_fc.h b/gr-filter/include/filter/filter_delay_fc.h index 8a84a6a0e5..1d2222a830 100644 --- a/gr-filter/include/filter/filter_delay_fc.h +++ b/gr-filter/include/filter/filter_delay_fc.h @@ -29,6 +29,26 @@ namespace gr { namespace filter { + /*! + * \brief Filter-Delay Combination Block. + * \ingroup filter_blk + * + * \details + * The block takes one or two float stream and outputs a complex + * stream. + * + * If only one float stream is input, the real output is a delayed + * version of this input and the imaginary output is the filtered + * output. + * + * If two floats are connected to the input, then the real output + * is the delayed version of the first input, and the imaginary + * output is the filtered output. + * + * The delay in the real path accounts for the group delay + * introduced by the filter in the imaginary path. The filter taps + * needs to be calculated before initializing this block. + */ class FILTER_API filter_delay_fc : virtual public gr_sync_block { public: @@ -37,24 +57,7 @@ namespace gr { typedef boost::shared_ptr<filter_delay_fc> sptr; /*! - * \brief Filter-Delay Combination Block. - * \ingroup filter_blk - * - * The block takes one or two float stream and outputs a complex - * stream. - * - * If only one float stream is input, the real output is a - * delayed version of this input and the imaginary output is the - * filtered output. - * - * If two floats are connected to the input, then the real - * output is the delayed version of the first input, and the - * imaginary output is the filtered output. - * - * The delay in the real path accounts for the group delay - * introduced by the filter in the imaginary path. The filter - * taps needs to be calculated before initializing this block. - * + * Build a filter with delay block. */ static sptr make(const std::vector<float> &taps); }; diff --git a/gr-filter/include/filter/fir_filter_XXX.h.t b/gr-filter/include/filter/fir_filter_XXX.h.t index 98e82f510d..0621bd978c 100644 --- a/gr-filter/include/filter/fir_filter_XXX.h.t +++ b/gr-filter/include/filter/fir_filter_XXX.h.t @@ -35,6 +35,7 @@ namespace gr { * \brief FIR filter with @I_TYPE@ input, @O_TYPE@ output, and @TAP_TYPE@ taps * \ingroup filter_blk * + * \details * The fir_filter_XXX blocks create finite impulse response * (FIR) filters that perform the convolution in the time * domain: @@ -53,7 +54,6 @@ namespace gr { * These versions of the filter can also act as down-samplers * (or decimators) by specifying an integer value for \p * decimation. - * */ class FILTER_API @BASE_NAME@ : virtual public gr_sync_decimator { @@ -64,13 +64,12 @@ namespace gr { /*! * \brief FIR filter with @I_TYPE@ input, @O_TYPE@ output, and @TAP_TYPE@ taps - * \ingroup filter_blk * * \param decimation set the integer decimation rate * \param taps a vector/list of taps of type @TAP_TYPE@ */ static sptr make(int decimation, - const std::vector<@TAP_TYPE@> &taps); + const std::vector<@TAP_TYPE@> &taps); virtual void set_taps(const std::vector<@TAP_TYPE@> &taps) = 0; virtual std::vector<@TAP_TYPE@> taps() const = 0; diff --git a/gr-filter/include/filter/fractional_interpolator_cc.h b/gr-filter/include/filter/fractional_interpolator_cc.h index bb0e18932e..90060817fc 100644 --- a/gr-filter/include/filter/fractional_interpolator_cc.h +++ b/gr-filter/include/filter/fractional_interpolator_cc.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief Interpolating MMSE filter with complex input, complex output - * \ingroup filter_blk + * \ingroup resamplers_blk */ class FILTER_API fractional_interpolator_cc : virtual public gr_block { diff --git a/gr-filter/include/filter/fractional_interpolator_ff.h b/gr-filter/include/filter/fractional_interpolator_ff.h index fc43c34570..131e9e541d 100644 --- a/gr-filter/include/filter/fractional_interpolator_ff.h +++ b/gr-filter/include/filter/fractional_interpolator_ff.h @@ -31,7 +31,7 @@ namespace gr { /*! * \brief Interpolating MMSE filter with float input, float output - * \ingroup filter_blk + * \ingroup resamplers_blk */ class FILTER_API fractional_interpolator_ff : virtual public gr_block { diff --git a/gr-filter/include/filter/fractional_resampler_cc.h b/gr-filter/include/filter/fractional_resampler_cc.h new file mode 100644 index 0000000000..ad4eee9494 --- /dev/null +++ b/gr-filter/include/filter/fractional_resampler_cc.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2012-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. + */ + +#ifndef INCLUDED_FRACTIONAL_RESAMPLER_CC_H +#define INCLUDED_FRACTIONAL_RESAMPLER_CC_H + +#include <filter/api.h> +#include <gr_block.h> + +namespace gr { + namespace filter { + + /*! + * \brief resampling MMSE filter with complex input, complex output + * \ingroup resamplers_blk + */ + class FILTER_API fractional_resampler_cc : virtual public gr_block + { + public: + // gr::filter::fractional_resampler_cc::sptr + typedef boost::shared_ptr<fractional_resampler_cc> sptr; + + /*! + * \brief Build the resampling MMSE filter (complex input, complex output) + * + * \param phase_shift The phase shift of the output signal to the input + * \param resamp_ratio The resampling ratio = input_rate / output_rate. + */ + static sptr make(float phase_shift, + float resamp_ratio); + + virtual float mu() const = 0; + virtual float resamp_ratio() const = 0; + virtual void set_mu (float mu) = 0; + virtual void set_resamp_ratio(float resamp_ratio) = 0; + }; + + } /* namespace filter */ +} /* namespace gr */ + +#endif /* INCLUDED_FRACTIONAL_RESAMPLER_FF_H */ diff --git a/gr-filter/include/filter/fractional_resampler_ff.h b/gr-filter/include/filter/fractional_resampler_ff.h new file mode 100644 index 0000000000..53fba9f029 --- /dev/null +++ b/gr-filter/include/filter/fractional_resampler_ff.h @@ -0,0 +1,60 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2012-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. + */ + +#ifndef INCLUDED_FRACTIONAL_RESAMPLER_FF_H +#define INCLUDED_FRACTIONAL_RESAMPLER_FF_H + +#include <filter/api.h> +#include <gr_block.h> + +namespace gr { + namespace filter { + + /*! + * \brief Resampling MMSE filter with float input, float output + * \ingroup resamplers_blk + */ + class FILTER_API fractional_resampler_ff : virtual public gr_block + { + public: + // gr::filter::fractional_resampler_ff::sptr + typedef boost::shared_ptr<fractional_resampler_ff> sptr; + + /*! + * \brief Build the resampling MMSE filter (float input, float output) + * + * \param phase_shift The phase shift of the output signal to the input + * \param resamp_ratio The resampling ratio = input_rate / output_rate. + */ + static sptr make(float phase_shift, + float resamp_ratio); + + virtual float mu() const = 0; + virtual float resamp_ratio() const = 0; + virtual void set_mu (float mu) = 0; + virtual void set_resamp_ratio(float resamp_ratio) = 0; + }; + + } /* namespace filter */ +} /* namespace gr */ + +#endif /* INCLUDED_FRACTIONAL_RESAMPLER_FF_H */ diff --git a/gr-filter/include/filter/freq_xlating_fir_filter_XXX.h.t b/gr-filter/include/filter/freq_xlating_fir_filter_XXX.h.t index 88e15f823d..7787db2b5c 100644 --- a/gr-filter/include/filter/freq_xlating_fir_filter_XXX.h.t +++ b/gr-filter/include/filter/freq_xlating_fir_filter_XXX.h.t @@ -40,7 +40,7 @@ namespace gr { * \brief FIR filter combined with frequency translation with * @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps * - * \ingroup filter_blk + * \ingroup channelizers_blk * * This class efficiently combines a frequency translation * (typically "down conversion") with a FIR filter (typically diff --git a/gr-filter/include/filter/hilbert_fc.h b/gr-filter/include/filter/hilbert_fc.h index de7cd82b69..c0973415f3 100644 --- a/gr-filter/include/filter/hilbert_fc.h +++ b/gr-filter/include/filter/hilbert_fc.h @@ -30,6 +30,15 @@ namespace gr { namespace filter { + /*! + * \brief Hilbert transformer. + * \ingroup filter_blk + * + * \details + * real output is input appropriately delayed. + * imaginary output is hilbert filtered (90 degree phase shift) + * version of input. + */ class FILTER_API hilbert_fc : virtual public gr_sync_block { public: @@ -37,12 +46,7 @@ namespace gr { typedef boost::shared_ptr<hilbert_fc> sptr; /*! - * \brief Hilbert transformer. - * \ingroup filter_blk - * - * real output is input appropriately delayed. - * imaginary output is hilbert filtered (90 degree phase shift) - * version of input. + * Build a Hilbert transformer filter block. */ static sptr make(unsigned int ntaps); }; diff --git a/gr-filter/include/filter/iir_filter_ffd.h b/gr-filter/include/filter/iir_filter_ffd.h index 04dd1e7767..ef5302038d 100644 --- a/gr-filter/include/filter/iir_filter_ffd.h +++ b/gr-filter/include/filter/iir_filter_ffd.h @@ -33,6 +33,7 @@ namespace gr { * \brief IIR filter with float input, float output and double taps * \ingroup filter_blk * + * \details * This filter uses the Direct Form I implementation, where * \p fftaps contains the feed-forward taps, and \p fbtaps the feedback ones. * @@ -70,7 +71,7 @@ namespace gr { typedef boost::shared_ptr<iir_filter_ffd> sptr; static sptr make(const std::vector<double> &fftaps, - const std::vector<double> &fbtaps); + const std::vector<double> &fbtaps); virtual void set_taps(const std::vector<double> &fftaps, const std::vector<double> &fbtaps) = 0; diff --git a/gr-filter/include/filter/interp_fir_filter_XXX.h.t b/gr-filter/include/filter/interp_fir_filter_XXX.h.t index b66c9f6439..7deb269e3a 100644 --- a/gr-filter/include/filter/interp_fir_filter_XXX.h.t +++ b/gr-filter/include/filter/interp_fir_filter_XXX.h.t @@ -35,6 +35,7 @@ namespace gr { * \brief Interpolating FIR filter with @I_TYPE@ input, @O_TYPE@ output and @TAP_TYPE@ taps * \ingroup filter_blk * + * \details * The fir_filter_XXX blocks create finite impulse response * (FIR) filters that perform the convolution in the time * domain: @@ -63,7 +64,6 @@ namespace gr { /*! * \brief Interpolating FIR filter with @I_TYPE@ input, @O_TYPE@ output, and @TAP_TYPE@ taps - * \ingroup filter_blk * * \param interpolation set the integer interpolation rate * \param taps a vector/list of taps of type @TAP_TYPE@ diff --git a/gr-filter/include/filter/mmse_fir_interpolator_cc.h b/gr-filter/include/filter/mmse_fir_interpolator_cc.h index 0436b4a0ff..0af52be552 100644 --- a/gr-filter/include/filter/mmse_fir_interpolator_cc.h +++ b/gr-filter/include/filter/mmse_fir_interpolator_cc.h @@ -34,6 +34,7 @@ namespace gr { * \brief Compute intermediate samples between signal samples x(k*Ts) * \ingroup filter_primitive * + * \details * This implements a Mininum Mean Squared Error interpolator with * 8 taps. It is suitable for signals where the bandwidth of * interest B = 1/(4*Ts) Where Ts is the time between samples. @@ -46,7 +47,6 @@ namespace gr { * \li gnuradio-core/src/gen_interpolator_taps/README * \li gnuradio-core/src/gen_interpolator_taps/praxis.txt */ - class FILTER_API mmse_fir_interpolator_cc { public: diff --git a/gr-filter/include/filter/mmse_fir_interpolator_ff.h b/gr-filter/include/filter/mmse_fir_interpolator_ff.h index 4353aa94f1..c10fad3be1 100644 --- a/gr-filter/include/filter/mmse_fir_interpolator_ff.h +++ b/gr-filter/include/filter/mmse_fir_interpolator_ff.h @@ -34,6 +34,7 @@ namespace gr { * \brief Compute intermediate samples between signal samples x(k*Ts) * \ingroup filter_primitive * + * \details * This implements a Mininum Mean Squared Error interpolator with * 8 taps. It is suitable for signals where the bandwidth of * interest B = 1/(4*Ts) Where Ts is the time between samples. diff --git a/gr-filter/include/filter/pfb_arb_resampler_ccf.h b/gr-filter/include/filter/pfb_arb_resampler_ccf.h index a154e055a0..1adf511a14 100644 --- a/gr-filter/include/filter/pfb_arb_resampler_ccf.h +++ b/gr-filter/include/filter/pfb_arb_resampler_ccf.h @@ -31,14 +31,11 @@ namespace gr { namespace filter { /*! - * \class pfb_arb_resampler_ccf - * * \brief Polyphase filterbank arbitrary resampler with * gr_complex input, gr_complex output and float taps + * \ingroup resamplers_blk * - * \ingroup filter_blk - * \ingroup pfb_blk - * + * \details * This block takes in a signal stream and performs arbitrary * resampling. The resampling rate can be any real number * <EM>r</EM>. The resampling is done by constructing <EM>N</EM> diff --git a/gr-filter/include/filter/pfb_arb_resampler_fff.h b/gr-filter/include/filter/pfb_arb_resampler_fff.h index 38dcc7132b..5e1be5c026 100644 --- a/gr-filter/include/filter/pfb_arb_resampler_fff.h +++ b/gr-filter/include/filter/pfb_arb_resampler_fff.h @@ -31,14 +31,11 @@ namespace gr { namespace filter { /*! - * \class pfb_arb_resampler_fff - * * \brief Polyphase filterbank arbitrary resampler with * float input, float output and float taps + * \ingroup resamplers_blk * - * \ingroup filter_blk - * \ingroup pfb_blk - * + * \details * This block takes in a signal stream and performs arbitrary * resampling. The resampling rate can be any real number * <EM>r</EM>. The resampling is done by constructing <EM>N</EM> diff --git a/gr-filter/include/filter/pfb_channelizer_ccf.h b/gr-filter/include/filter/pfb_channelizer_ccf.h index 2ff83b5e7e..d0f1b67ad7 100644 --- a/gr-filter/include/filter/pfb_channelizer_ccf.h +++ b/gr-filter/include/filter/pfb_channelizer_ccf.h @@ -31,14 +31,11 @@ namespace gr { namespace filter { /*! - * \class pfb_channelizer_ccf - * * \brief Polyphase filterbank channelizer with * gr_complex input, gr_complex output and float taps + * \ingroup channelizers_blk * - * \ingroup filter_blk - * \ingroup pfb_blk - * + * \details * This block takes in complex inputs and channelizes it to <EM>M</EM> * channels of equal bandwidth. Each of the resulting channels is * decimated to the new rate that is the input sampling rate diff --git a/gr-filter/include/filter/pfb_decimator_ccf.h b/gr-filter/include/filter/pfb_decimator_ccf.h index bf9d0d9508..604688b459 100644 --- a/gr-filter/include/filter/pfb_decimator_ccf.h +++ b/gr-filter/include/filter/pfb_decimator_ccf.h @@ -31,13 +31,11 @@ namespace gr { namespace filter { /*! - * \class pfb_decimator_ccf * \brief Polyphase filterbank bandpass decimator with gr_complex * input, gr_complex output and float taps + * \ingroup channelizers_blk * - * \ingroup filter_blk - * \ingroup pfb_blk - * + * \details * This block takes in a signal stream and performs interger down- * sampling (decimation) with a polyphase filterbank. The first * input is the integer specifying how much to decimate by. The diff --git a/gr-filter/include/filter/pfb_interpolator_ccf.h b/gr-filter/include/filter/pfb_interpolator_ccf.h index df28ab64d6..de1b2b85f4 100644 --- a/gr-filter/include/filter/pfb_interpolator_ccf.h +++ b/gr-filter/include/filter/pfb_interpolator_ccf.h @@ -31,14 +31,11 @@ namespace gr { namespace filter { /*! - * \class gr_pfb_interpolator_ccf - * * \brief Polyphase filterbank interpolator with gr_complex input, * gr_complex output and float taps + * \ingroup channelizers_blk * - * \ingroup filter_blk - * \ingroup pfb_blk - * + * \details * This block takes in a signal stream and performs interger up- * sampling (interpolation) with a polyphase filterbank. The first * input is the integer specifying how much to interpolate by. The diff --git a/gr-filter/include/filter/pfb_synthesizer_ccf.h b/gr-filter/include/filter/pfb_synthesizer_ccf.h index faa16990cc..d434776229 100644 --- a/gr-filter/include/filter/pfb_synthesizer_ccf.h +++ b/gr-filter/include/filter/pfb_synthesizer_ccf.h @@ -31,15 +31,10 @@ namespace gr { namespace filter { /*! - * \class pfb_synthesizer_ccf - * * \brief Polyphase synthesis filterbank with * gr_complex input, gr_complex output and float taps - * - * \ingroup filter_blk - * \ingroup pfb_blk + * \ingroup channelizers_blk */ - class FILTER_API pfb_synthesizer_ccf : virtual public gr_sync_interpolator { public: diff --git a/gr-filter/include/filter/pm_remez.h b/gr-filter/include/filter/pm_remez.h index a57e9e276d..71283eec1c 100644 --- a/gr-filter/include/filter/pm_remez.h +++ b/gr-filter/include/filter/pm_remez.h @@ -32,9 +32,9 @@ namespace gr { namespace filter { /*! * \brief Parks-McClellan FIR filter design using Remez algorithm. - * * \ingroup filter_design * + * \details * Calculates the optimal (in the Chebyshev/minimax sense) FIR * filter inpulse reponse given a set of band edges, the desired * reponse on those bands, and the weight given to the error in diff --git a/gr-filter/include/filter/polyphase_filterbank.h b/gr-filter/include/filter/polyphase_filterbank.h index 33e9522e17..7190f3689f 100644 --- a/gr-filter/include/filter/polyphase_filterbank.h +++ b/gr-filter/include/filter/polyphase_filterbank.h @@ -33,13 +33,11 @@ namespace gr { namespace kernel { /*! - * \class polyphase_filterbank - * * \brief Polyphase filterbank parent class - * * \ingroup filter_blk * \ingroup pfb_blk * + * \details * This block takes in complex inputs and channelizes it to * <EM>M</EM> channels of equal bandwidth. Each of the resulting * channels is decimated to the new rate that is the input diff --git a/gr-filter/include/filter/rational_resampler_base_XXX.h.t b/gr-filter/include/filter/rational_resampler_base_XXX.h.t index e47a16ec6d..18398bbfe7 100644 --- a/gr-filter/include/filter/rational_resampler_base_XXX.h.t +++ b/gr-filter/include/filter/rational_resampler_base_XXX.h.t @@ -35,8 +35,7 @@ namespace gr { /*! * \brief Rational Resampling Polyphase FIR filter with @I_TYPE@ * input, @O_TYPE@ output and @TAP_TYPE@ taps. - * - *\ingroup filter_blk + * \ingroup resamplers_blk */ class FILTER_API @NAME@ : virtual public gr_block { @@ -45,8 +44,8 @@ namespace gr { typedef boost::shared_ptr<@BASE_NAME@> sptr; static sptr make(unsigned interpolation, - unsigned decimation, - const std::vector<@TAP_TYPE@> &taps); + unsigned decimation, + const std::vector<@TAP_TYPE@> &taps); virtual unsigned interpolation() const = 0; virtual unsigned decimation() const = 0; diff --git a/gr-filter/include/filter/single_pole_iir_filter_cc.h b/gr-filter/include/filter/single_pole_iir_filter_cc.h index 82febe8ec4..fd6f107b65 100644 --- a/gr-filter/include/filter/single_pole_iir_filter_cc.h +++ b/gr-filter/include/filter/single_pole_iir_filter_cc.h @@ -35,6 +35,7 @@ namespace gr { * \brief single pole IIR filter with complex input, complex output * \ingroup filter_blk * + * \details * The input and output satisfy a difference equation of the form \htmlonly \f{ diff --git a/gr-filter/include/filter/single_pole_iir_filter_ff.h b/gr-filter/include/filter/single_pole_iir_filter_ff.h index d85688db84..ae4792f3d6 100644 --- a/gr-filter/include/filter/single_pole_iir_filter_ff.h +++ b/gr-filter/include/filter/single_pole_iir_filter_ff.h @@ -35,6 +35,7 @@ namespace gr { * \brief single pole IIR filter with float input, float output * \ingroup filter_blk * + * \details * The input and output satisfy a difference equation of the form \htmlonly \f{ diff --git a/gr-filter/lib/CMakeLists.txt b/gr-filter/lib/CMakeLists.txt index 626f5521f2..ae8b7ec845 100644 --- a/gr-filter/lib/CMakeLists.txt +++ b/gr-filter/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2012 Free Software Foundation, Inc. +# Copyright 2012-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -97,10 +97,14 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${VOLK_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) -link_directories(${Boost_LIBRARY_DIRS}) +link_directories( + ${Boost_LIBRARY_DIRS} + ${LOG4CPP_LIBRARIES} +) ######################################################################## # Setup library @@ -124,6 +128,8 @@ list(APPEND filter_sources fft_filter_fff_impl.cc fractional_interpolator_cc_impl.cc fractional_interpolator_ff_impl.cc + fractional_resampler_cc_impl.cc + fractional_resampler_ff_impl.cc hilbert_fc_impl.cc iir_filter_ffd_impl.cc pfb_arb_resampler_ccf_impl.cc @@ -137,6 +143,20 @@ list(APPEND filter_sources channel_model_impl.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-filter.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-filter.rc + @ONLY) + + list(APPEND filter_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-filter.rc + ) +endif(MSVC) + list(APPEND filter_libs gnuradio-core gnuradio-fft diff --git a/gr-filter/lib/fractional_resampler_cc_impl.cc b/gr-filter/lib/fractional_resampler_cc_impl.cc new file mode 100644 index 0000000000..965241fdb3 --- /dev/null +++ b/gr-filter/lib/fractional_resampler_cc_impl.cc @@ -0,0 +1,125 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2010,2012-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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "fractional_resampler_cc_impl.h" +#include <stdexcept> + +namespace gr { + namespace filter { + + fractional_resampler_cc::sptr + fractional_resampler_cc::make(float phase_shift, float resamp_ratio) + { + return gnuradio::get_initial_sptr + (new fractional_resampler_cc_impl(phase_shift, resamp_ratio)); + } + + fractional_resampler_cc_impl::fractional_resampler_cc_impl + (float phase_shift, float resamp_ratio) + : gr_block("fractional_resampler_cc", + gr_make_io_signature(1, 1, sizeof(gr_complex)), + gr_make_io_signature(1, 1, sizeof(gr_complex))), + d_mu(phase_shift), d_mu_inc(resamp_ratio), + d_resamp(new mmse_fir_interpolator_cc()) + { + if(resamp_ratio <= 0) + throw std::out_of_range("resampling ratio must be > 0"); + if(phase_shift < 0 || phase_shift > 1) + throw std::out_of_range("phase shift ratio must be > 0 and < 1"); + + set_relative_rate(1.0 / resamp_ratio); + } + + fractional_resampler_cc_impl::~fractional_resampler_cc_impl() + { + delete d_resamp; + } + + void + fractional_resampler_cc_impl::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + unsigned ninputs = ninput_items_required.size(); + for(unsigned i=0; i < ninputs; i++) { + ninput_items_required[i] = + (int)ceil((noutput_items * d_mu_inc) + d_resamp->ntaps()); + } + } + + int + fractional_resampler_cc_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const gr_complex *in = (const gr_complex*)input_items[0]; + gr_complex *out = (gr_complex*)output_items[0]; + + int ii = 0; // input index + int oo = 0; // output index + + while(oo < noutput_items) { + out[oo++] = d_resamp->interpolate(&in[ii], d_mu); + + double s = d_mu + d_mu_inc; + double f = floor(s); + int incr = (int)f; + d_mu = s - f; + ii += incr; + } + + consume_each(ii); + + return noutput_items; + } + + float + fractional_resampler_cc_impl::mu() const + { + return d_mu; + } + + float + fractional_resampler_cc_impl::resamp_ratio() const + { + return d_mu_inc; + } + + void + fractional_resampler_cc_impl::set_mu(float mu) + { + d_mu = mu; + } + + void + fractional_resampler_cc_impl::set_resamp_ratio(float resamp_ratio) + { + d_mu_inc = resamp_ratio; + } + + } /* namespace filter */ +} /* namespace gr */ diff --git a/gr-filter/lib/fractional_resampler_cc_impl.h b/gr-filter/lib/fractional_resampler_cc_impl.h new file mode 100644 index 0000000000..15f36f9bb9 --- /dev/null +++ b/gr-filter/lib/fractional_resampler_cc_impl.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2012-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. + */ + +#ifndef INCLUDED_FRACTIONAL_RESAMPLER_CC_IMPL_H +#define INCLUDED_FRACTIONAL_RESAMPLER_CC_IMPL_H + +#include <filter/fractional_resampler_cc.h> +#include <filter/mmse_fir_interpolator_cc.h> + +namespace gr { + namespace filter { + + class FILTER_API fractional_resampler_cc_impl + : public fractional_resampler_cc + { + private: + float d_mu; + float d_mu_inc; + mmse_fir_interpolator_cc *d_resamp; + + public: + fractional_resampler_cc_impl(float phase_shift, + float resamp_ratio); + ~fractional_resampler_cc_impl(); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + float mu() const; + float resamp_ratio() const; + void set_mu(float mu); + void set_resamp_ratio(float resamp_ratio); + }; + + } /* namespace filter */ +} /* namespace gr */ + +#endif /* INCLUDED_FRACTIONAL_RESAMPLER_CC_IMPL_H */ diff --git a/gr-filter/lib/fractional_resampler_ff_impl.cc b/gr-filter/lib/fractional_resampler_ff_impl.cc new file mode 100644 index 0000000000..cf7a9f462f --- /dev/null +++ b/gr-filter/lib/fractional_resampler_ff_impl.cc @@ -0,0 +1,125 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2010,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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_io_signature.h> +#include "fractional_resampler_ff_impl.h" +#include <stdexcept> + +namespace gr { + namespace filter { + + fractional_resampler_ff::sptr + fractional_resampler_ff::make(float phase_shift, float resamp_ratio) + { + return gnuradio::get_initial_sptr + (new fractional_resampler_ff_impl(phase_shift, resamp_ratio)); + } + + fractional_resampler_ff_impl::fractional_resampler_ff_impl + (float phase_shift, float resamp_ratio) + : gr_block("fractional_resampler_ff", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(float))), + d_mu (phase_shift), d_mu_inc (resamp_ratio), + d_resamp(new mmse_fir_interpolator_ff()) + { + if(resamp_ratio <= 0) + throw std::out_of_range("resampling ratio must be > 0"); + if(phase_shift < 0 || phase_shift > 1) + throw std::out_of_range("phase shift ratio must be > 0 and < 1"); + + set_relative_rate(1.0 / resamp_ratio); + } + + fractional_resampler_ff_impl::~fractional_resampler_ff_impl() + { + delete d_resamp; + } + + void + fractional_resampler_ff_impl::forecast(int noutput_items, + gr_vector_int &ninput_items_required) + { + unsigned ninputs = ninput_items_required.size(); + for(unsigned i=0; i < ninputs; i++) { + ninput_items_required[i] = + (int)ceil((noutput_items * d_mu_inc) + d_resamp->ntaps()); + } + } + + int + fractional_resampler_ff_impl::general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float*)input_items[0]; + float *out = (float*)output_items[0]; + + int ii = 0; // input index + int oo = 0; // output index + + while(oo < noutput_items) { + out[oo++] = d_resamp->interpolate(&in[ii], d_mu); + + double s = d_mu + d_mu_inc; + double f = floor(s); + int incr = (int)f; + d_mu = s - f; + ii += incr; + } + + consume_each(ii); + + return noutput_items; + } + + float + fractional_resampler_ff_impl::mu() const + { + return d_mu; + } + + float + fractional_resampler_ff_impl::resamp_ratio() const + { + return d_mu_inc; + } + + void + fractional_resampler_ff_impl::set_mu(float mu) + { + d_mu = mu; + } + + void + fractional_resampler_ff_impl::set_resamp_ratio(float resamp_ratio) + { + d_mu_inc = resamp_ratio; + } + + } /* namespace filter */ +} /* namespace gr */ diff --git a/gr-filter/lib/fractional_resampler_ff_impl.h b/gr-filter/lib/fractional_resampler_ff_impl.h new file mode 100644 index 0000000000..053a3ca040 --- /dev/null +++ b/gr-filter/lib/fractional_resampler_ff_impl.h @@ -0,0 +1,61 @@ +/* -*- c++ -*- */ +/* + * Copyright 2004,2007,2012-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. + */ + +#ifndef INCLUDED_FRACTIONAL_RESAMPLER_FF_IMPL_H +#define INCLUDED_FRACTIONAL_RESAMPLER_FF_IMPL_H + +#include <filter/fractional_resampler_ff.h> +#include <filter/mmse_fir_interpolator_ff.h> + +namespace gr { + namespace filter { + + class FILTER_API fractional_resampler_ff_impl + : public fractional_resampler_ff + { + private: + float d_mu; + float d_mu_inc; + mmse_fir_interpolator_ff *d_resamp; + + public: + fractional_resampler_ff_impl(float phase_shift, + float resamp_ratio); + ~fractional_resampler_ff_impl(); + + void forecast(int noutput_items, + gr_vector_int &ninput_items_required); + int general_work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + + float mu() const; + float resamp_ratio() const; + void set_mu(float mu); + void set_resamp_ratio(float resamp_ratio); + }; + + } /* namespace filter */ +} /* namespace gr */ + +#endif /* INCLUDED_FRACTIONAL_RESAMPLER_FF_IMPL_H */ diff --git a/gr-filter/lib/gnuradio-filter.rc.in b/gr-filter/lib/gnuradio-filter.rc.in new file mode 100644 index 0000000000..8fae9746e9 --- /dev/null +++ b/gr-filter/lib/gnuradio-filter.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-filter" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-filter.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-filter.dll" + VALUE "ProductName", "gnuradio-filter" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-filter/python/qa_fractional_resampler.py b/gr-filter/python/qa_fractional_resampler.py new file mode 100644 index 0000000000..35de2631f3 --- /dev/null +++ b/gr-filter/python/qa_fractional_resampler.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# +# Copyright 2007,2010,2012,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. +# + +from gnuradio import gr, gr_unittest +import filter_swig as filter +import math + +def sig_source_f(samp_rate, freq, amp, N): + t = map(lambda x: float(x)/samp_rate, xrange(N)) + y = map(lambda x: math.sin(2.*math.pi*freq*x), t) + return y + +def sig_source_c(samp_rate, freq, amp, N): + t = map(lambda x: float(x)/samp_rate, xrange(N)) + y = map(lambda x: math.cos(2.*math.pi*freq*x) + \ + 1j*math.sin(2.*math.pi*freq*x), t) + return y + +class test_fractional_resampler(gr_unittest.TestCase): + + def setUp(self): + self.tb = gr.top_block() + + def tearDown(self): + self.tb = None + + def test_001_ff(self): + N = 10000 # number of samples to use + fs = 1000 # baseband sampling rate + rrate = 1.123 # resampling rate + + freq = 10 + data = sig_source_f(fs, freq, 1, N) + signal = gr.vector_source_f(data) + op = filter.fractional_resampler_ff(0, rrate) + snk = gr.vector_sink_f() + + self.tb.connect(signal, op, snk) + self.tb.run() + + Ntest = 5000 + L = len(snk.data()) + t = map(lambda x: float(x)/(fs/rrate), xrange(L)) + + phase = 0.1884 + expected_data = map(lambda x: math.sin(2.*math.pi*freq*x+phase), t) + + dst_data = snk.data() + + self.assertFloatTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 3) + + + def test_002_cc(self): + N = 10000 # number of samples to use + fs = 1000 # baseband sampling rate + rrate = 1.123 # resampling rate + + freq = 10 + data = sig_source_c(fs, freq, 1, N) + signal = gr.vector_source_c(data) + op = filter.fractional_resampler_cc(0.0, rrate) + snk = gr.vector_sink_c() + + self.tb.connect(signal, op, snk) + self.tb.run() + + Ntest = 5000 + L = len(snk.data()) + t = map(lambda x: float(x)/(fs/rrate), xrange(L)) + + phase = 0.1884 + expected_data = map(lambda x: math.cos(2.*math.pi*freq*x+phase) + \ + 1j*math.sin(2.*math.pi*freq*x+phase), t) + + dst_data = snk.data() + + self.assertComplexTuplesAlmostEqual(expected_data[-Ntest:], dst_data[-Ntest:], 3) + + +if __name__ == '__main__': + gr_unittest.run(test_fractional_resampler, "test_fractional_resampler.xml") diff --git a/gr-filter/swig/filter_swig.i b/gr-filter/swig/filter_swig.i index 05b84d4d69..1fb3941c86 100644 --- a/gr-filter/swig/filter_swig.i +++ b/gr-filter/swig/filter_swig.i @@ -45,6 +45,8 @@ #include "filter/fft_filter_fff.h" #include "filter/fractional_interpolator_cc.h" #include "filter/fractional_interpolator_ff.h" +#include "filter/fractional_resampler_cc.h" +#include "filter/fractional_resampler_ff.h" #include "filter/freq_xlating_fir_filter_ccc.h" #include "filter/freq_xlating_fir_filter_ccf.h" #include "filter/freq_xlating_fir_filter_fcc.h" @@ -93,6 +95,8 @@ %include "filter/fft_filter_fff.h" %include "filter/fractional_interpolator_cc.h" %include "filter/fractional_interpolator_ff.h" +%include "filter/fractional_resampler_cc.h" +%include "filter/fractional_resampler_ff.h" %include "filter/freq_xlating_fir_filter_ccc.h" %include "filter/freq_xlating_fir_filter_ccf.h" %include "filter/freq_xlating_fir_filter_fcc.h" @@ -138,6 +142,8 @@ GR_SWIG_BLOCK_MAGIC2(filter, fft_filter_ccc); GR_SWIG_BLOCK_MAGIC2(filter, fft_filter_fff); GR_SWIG_BLOCK_MAGIC2(filter, fractional_interpolator_cc); GR_SWIG_BLOCK_MAGIC2(filter, fractional_interpolator_ff); +GR_SWIG_BLOCK_MAGIC2(filter, fractional_resampler_cc); +GR_SWIG_BLOCK_MAGIC2(filter, fractional_resampler_ff); GR_SWIG_BLOCK_MAGIC2(filter, freq_xlating_fir_filter_ccc); GR_SWIG_BLOCK_MAGIC2(filter, freq_xlating_fir_filter_ccf); GR_SWIG_BLOCK_MAGIC2(filter, freq_xlating_fir_filter_fcc); diff --git a/gr-howto-write-a-block/CMakeLists.txt b/gr-howto-write-a-block/CMakeLists.txt index 02b13c6b69..1a9f403dd2 100644 --- a/gr-howto-write-a-block/CMakeLists.txt +++ b/gr-howto-write-a-block/CMakeLists.txt @@ -94,6 +94,10 @@ if(NOT GNURADIO_CORE_FOUND) message(FATAL_ERROR "GnuRadio Core required to compile howto") endif() +# Handle gr_log enable/disable +include(GrMiscUtils) #define LIB_SUFFIX +GR_LOGGING() + ######################################################################## # Setup the include and linker paths ######################################################################## @@ -101,12 +105,14 @@ include_directories( ${CMAKE_SOURCE_DIR}/include ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ) link_directories( ${GNURADIO_CORE_LIBRARY_DIRS} ${GRUEL_LIBRARY_DIRS} + ${LOG4CPP_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ) diff --git a/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake b/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake new file mode 100644 index 0000000000..0b7208630f --- /dev/null +++ b/gr-howto-write-a-block/cmake/Modules/FindLog4cpp.cmake @@ -0,0 +1,58 @@ +# - Find Log4cpp +# Find the native LOG4CPP includes and library +# +# LOG4CPP_INCLUDE_DIR - where to find LOG4CPP.h, etc. +# LOG4CPP_LIBRARIES - List of libraries when using LOG4CPP. +# LOG4CPP_FOUND - True if LOG4CPP found. + + +if (LOG4CPP_INCLUDE_DIR) + # Already in cache, be silent + set(LOG4CPP_FIND_QUIETLY TRUE) +endif () + +find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh + /opt/local/include + /usr/local/include + /usr/include +) + +set(LOG4CPP_NAMES log4cpp) +find_library(LOG4CPP_LIBRARY + NAMES ${LOG4CPP_NAMES} + PATHS /usr/lib /usr/local/lib /opt/local/lib +) + +message("#####################") +message("LOG INCLEUDE :${LOG4CPP_INCLUDE_DIR}") +message("LOG LIBRARY :${LOG4CPP_LIBRARY}") + + +message("#####################") + +if (LOG4CPP_INCLUDE_DIR AND LOG4CPP_LIBRARY) + set(LOG4CPP_FOUND TRUE) + set(LOG4CPP_LIBRARIES ${LOG4CPP_LIBRARY} ) +else () + set(LOG4CPP_FOUND FALSE) + set(LOG4CPP_LIBRARIES ) +endif () + +if (LOG4CPP_FOUND) + if (NOT LOG4CPP_FIND_QUIETLY) + message(STATUS "Found LOG4CPP: ${LOG4CPP_LIBRARIES}") + endif () +else () + if (LOG4CPP_FIND_REQUIRED) + message(STATUS "Looked for LOG4CPP libraries named ${LOG4CPPS_NAMES}.") + message(FATAL_ERROR "Could NOT find LOG4CPP library") + endif () +endif () + +message("internal libs: ${LOG4CPP_LIBRARIES}") + +mark_as_advanced( + LOG4CPP_LIBRARY + LOG4CPP_LIBRARIES + LOG4CPP_INCLUDE_DIR + ) diff --git a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake index 9331d5debc..876e71687f 100644 --- a/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake +++ b/gr-howto-write-a-block/cmake/Modules/GrMiscUtils.cmake @@ -208,3 +208,46 @@ function(GR_GEN_TARGET_DEPS name var) set(${var} "DEPENDS;${name};COMMAND;${name}" PARENT_SCOPE) endif() endfunction(GR_GEN_TARGET_DEPS) + + +######################################################################## +# Control use of gr_logger +# Usage: +# GR_LOGGING() +# +# Will set ENABLE_GR_LOG to 1 by default. +# Can manually set with -DENABLE_GR_LOG=0|1 +######################################################################## +function(GR_LOGGING) + find_package(Log4cpp) + + OPTION(ENABLE_GR_LOG "Use gr_logger" ON) + if(ENABLE_GR_LOG) + # If gr_logger is enabled, make it usable + add_definitions( -DENABLE_GR_LOG ) + + # also test LOG4CPP; if we have it, use this version of the logger + # otherwise, default to the stdout/stderr model. + if(LOG4CPP_FOUND) + SET(HAVE_LOG4CPP True) + add_definitions( -DHAVE_LOG4CPP ) + else(LOG4CPP_FOUND) + SET(HAVE_LOG4CPP False) + SET(LOG4CPP_INCLUDE_DIRS "") + SET(LOG4CPP_LIBRARY_DIRS "") + SET(LOG4CPP_LIBRARIES "") + endif(LOG4CPP_FOUND) + + SET(ENABLE_GR_LOG ${ENABLE_GR_LOG} CACHE INTERNAL "" FORCE) + + else(ENABLE_GR_LOG) + SET(HAVE_LOG4CPP False) + SET(LOG4CPP_INCLUDE_DIRS) + SET(LOG4CPP_LIBRARY_DIRS) + SET(LOG4CPP_LIBRARIES) + endif(ENABLE_GR_LOG) + + message(STATUS "ENABLE_GR_LOG set to ${ENABLE_GR_LOG}.") + message(STATUS "HAVE_LOG4CPP set to ${HAVE_LOG4CPP}.") + +endfunction(GR_LOGGING) diff --git a/gr-howto-write-a-block/lib/CMakeLists.txt b/gr-howto-write-a-block/lib/CMakeLists.txt index 835ae02d60..dee02f08c7 100644 --- a/gr-howto-write-a-block/lib/CMakeLists.txt +++ b/gr-howto-write-a-block/lib/CMakeLists.txt @@ -23,7 +23,11 @@ include(GrPlatform) #define LIB_SUFFIX add_library(gnuradio-howto SHARED howto_square_ff.cc howto_square2_ff.cc) -target_link_libraries(gnuradio-howto ${Boost_LIBRARIES} ${GRUEL_LIBRARIES} ${GNURADIO_CORE_LIBRARIES}) +target_link_libraries(gnuradio-howto + ${Boost_LIBRARIES} + ${GRUEL_LIBRARIES} + ${GNURADIO_CORE_LIBRARIES} + ${LOG4CPP_LIBRARIES}) set_target_properties(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS") ######################################################################## diff --git a/gr-noaa/lib/CMakeLists.txt b/gr-noaa/lib/CMakeLists.txt index 3f369f8aff..4830fe4f95 100644 --- a/gr-noaa/lib/CMakeLists.txt +++ b/gr-noaa/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,6 +29,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -38,9 +41,24 @@ list(APPEND gr_noaa_sources noaa_hrpt_pll_cf.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-noaa.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-noaa.rc + @ONLY) + + list(APPEND gr_noaa_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-noaa.rc + ) +endif(MSVC) + list(APPEND noaa_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-noaa SHARED ${gr_noaa_sources}) diff --git a/gr-noaa/lib/gnuradio-noaa.rc.in b/gr-noaa/lib/gnuradio-noaa.rc.in new file mode 100644 index 0000000000..2f19f110b7 --- /dev/null +++ b/gr-noaa/lib/gnuradio-noaa.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-noaa" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-noaa.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-noaa.dll" + VALUE "ProductName", "gnuradio-noaa" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-noaa/lib/noaa_hrpt_decoder.h b/gr-noaa/lib/noaa_hrpt_decoder.h index 3b3214b721..27c6184b54 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.h +++ b/gr-noaa/lib/noaa_hrpt_decoder.h @@ -32,6 +32,10 @@ typedef boost::shared_ptr<noaa_hrpt_decoder> noaa_hrpt_decoder_sptr; NOAA_API noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(bool verbose, bool output_files); +/*! + * \brief NOAA HRPT Decoder + * \ingroup noaa_blk + */ class NOAA_API noaa_hrpt_decoder : public gr_sync_block { friend NOAA_API noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(bool verbose, bool output_files); diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h index 475ad90f61..68e3ab5fac 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.h +++ b/gr-noaa/lib/noaa_hrpt_deframer.h @@ -32,6 +32,10 @@ typedef boost::shared_ptr<noaa_hrpt_deframer> noaa_hrpt_deframer_sptr; NOAA_API noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer(); +/*! + * \brief NOAA HRPT Deframer + * \ingroup noaa_blk + */ class NOAA_API noaa_hrpt_deframer : public gr_block { friend NOAA_API noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer(); diff --git a/gr-noaa/lib/noaa_hrpt_pll_cf.h b/gr-noaa/lib/noaa_hrpt_pll_cf.h index 178dccfb33..aff1602319 100644 --- a/gr-noaa/lib/noaa_hrpt_pll_cf.h +++ b/gr-noaa/lib/noaa_hrpt_pll_cf.h @@ -29,6 +29,10 @@ class noaa_hrpt_pll_cf; typedef boost::shared_ptr<noaa_hrpt_pll_cf> noaa_hrpt_pll_cf_sptr; +/*! + * \brief NOAA HRPT PLL + * \ingroup noaa_blk + */ NOAA_API noaa_hrpt_pll_cf_sptr noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset); diff --git a/gr-pager/lib/CMakeLists.txt b/gr-pager/lib/CMakeLists.txt index cb62bcc752..68c60ed16d 100644 --- a/gr-pager/lib/CMakeLists.txt +++ b/gr-pager/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,6 +29,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -43,9 +46,24 @@ list(APPEND gr_pager_sources pageri_util.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-pager.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-pager.rc + @ONLY) + + list(APPEND gr_pager_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-pager.rc + ) +endif(MSVC) + list(APPEND pager_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-pager SHARED ${gr_pager_sources}) diff --git a/gr-pager/lib/gnuradio-pager.rc.in b/gr-pager/lib/gnuradio-pager.rc.in new file mode 100644 index 0000000000..cf9d85b24f --- /dev/null +++ b/gr-pager/lib/gnuradio-pager.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-pager" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-pager.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-pager.dll" + VALUE "ProductName", "gnuradio-pager" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-pager/lib/pager_flex_deinterleave.h b/gr-pager/lib/pager_flex_deinterleave.h index c702da23d7..d565167391 100644 --- a/gr-pager/lib/pager_flex_deinterleave.h +++ b/gr-pager/lib/pager_flex_deinterleave.h @@ -34,7 +34,6 @@ PAGER_API pager_flex_deinterleave_sptr pager_make_flex_deinterleave(); * \brief flex deinterleave description * \ingroup pager_blk */ - class PAGER_API pager_flex_deinterleave : public gr_sync_decimator { private: diff --git a/gr-pager/lib/pager_flex_frame.h b/gr-pager/lib/pager_flex_frame.h index 61973f7229..a2e8f23835 100644 --- a/gr-pager/lib/pager_flex_frame.h +++ b/gr-pager/lib/pager_flex_frame.h @@ -34,6 +34,7 @@ PAGER_API pager_flex_frame_sptr pager_make_flex_frame(); /*! * \brief flex_frame. + * \ingroup pager_blk */ class PAGER_API pager_flex_frame { // Constructor is private to force use of shared_ptr diff --git a/gr-pager/lib/pager_flex_sync.h b/gr-pager/lib/pager_flex_sync.h index b53737d121..bdb6fb0399 100644 --- a/gr-pager/lib/pager_flex_sync.h +++ b/gr-pager/lib/pager_flex_sync.h @@ -35,7 +35,6 @@ PAGER_API pager_flex_sync_sptr pager_make_flex_sync(); * \brief flex sync description * \ingroup pager_blk */ - class PAGER_API pager_flex_sync : public gr_block { private: diff --git a/gr-qtgui/grc/qtgui_check_box.xml b/gr-qtgui/grc/qtgui_check_box.xml index 95f4f968a6..3ac7cae134 100644 --- a/gr-qtgui/grc/qtgui_check_box.xml +++ b/gr-qtgui/grc/qtgui_check_box.xml @@ -8,7 +8,7 @@ <block> <name>QT GUI Check Box</name> <key>variable_qtgui_check_box</key> - <category>QT GUI Widgets</category> + <category>GUI Widgets/QT</category> <import>from PyQt4 import Qt</import> <var_make>self.$(id) = $(id) = $value</var_make> <make>#set $win = '_%s_check_box'%$id diff --git a/gr-qtgui/grc/qtgui_chooser.xml b/gr-qtgui/grc/qtgui_chooser.xml index cb50902897..98c94b5e5b 100644 --- a/gr-qtgui/grc/qtgui_chooser.xml +++ b/gr-qtgui/grc/qtgui_chooser.xml @@ -8,7 +8,7 @@ <block> <name>QT GUI Chooser</name> <key>variable_qtgui_chooser</key> - <category>QT GUI Widgets</category> + <category>GUI Widgets/QT</category> <import>from PyQt4 import Qt</import> <var_make>self.$(id) = $(id) = $value</var_make> <make>#slurp diff --git a/gr-qtgui/grc/qtgui_entry.xml b/gr-qtgui/grc/qtgui_entry.xml index 1a98402a0f..e27f260efe 100644 --- a/gr-qtgui/grc/qtgui_entry.xml +++ b/gr-qtgui/grc/qtgui_entry.xml @@ -8,7 +8,7 @@ <block> <name>QT GUI Entry</name> <key>variable_qtgui_entry</key> - <category>QT GUI Widgets</category> + <category>GUI Widgets/QT</category> <import>from PyQt4 import Qt</import> <import>from gnuradio import eng_notation</import> <var_make>self.$(id) = $(id) = $value</var_make> diff --git a/gr-qtgui/grc/qtgui_label.xml b/gr-qtgui/grc/qtgui_label.xml index 5049118c47..3c127edb96 100644 --- a/gr-qtgui/grc/qtgui_label.xml +++ b/gr-qtgui/grc/qtgui_label.xml @@ -8,7 +8,7 @@ <block> <name>QT GUI Label</name> <key>variable_qtgui_label</key> - <category>QT GUI Widgets</category> + <category>GUI Widgets/QT</category> <import>from PyQt4 import Qt</import> <import>from gnuradio import eng_notation</import> <var_make>self.$(id) = $(id) = $value</var_make> diff --git a/gr-qtgui/grc/qtgui_range.xml b/gr-qtgui/grc/qtgui_range.xml index 6b0555f98e..bc1c09cdea 100644 --- a/gr-qtgui/grc/qtgui_range.xml +++ b/gr-qtgui/grc/qtgui_range.xml @@ -8,7 +8,7 @@ <block> <name>QT GUI Range</name> <key>variable_qtgui_range</key> - <category>QT GUI Widgets</category> + <category>GUI Widgets/QT</category> <import>from PyQt4 import Qt</import> <import>import PyQt4.Qwt5 as Qwt</import> <var_make>self.$(id) = $(id) = $value</var_make> diff --git a/gr-qtgui/grc/qtgui_sink_x.xml b/gr-qtgui/grc/qtgui_sink_x.xml index 6488ac04cd..7a03205f5d 100644 --- a/gr-qtgui/grc/qtgui_sink_x.xml +++ b/gr-qtgui/grc/qtgui_sink_x.xml @@ -7,7 +7,7 @@ <block> <name>QT GUI Sink</name> <key>qtgui_sink_x</key> - <category>QT GUI Widgets</category> + <category>Instrumentation/QT</category> <import>from PyQt4 import Qt</import> <import>from gnuradio.qtgui import qtgui</import> <import>from gnuradio.gr import firdes</import> diff --git a/gr-qtgui/grc/qtgui_tab_widget.xml b/gr-qtgui/grc/qtgui_tab_widget.xml index f900541093..f9de310c96 100644 --- a/gr-qtgui/grc/qtgui_tab_widget.xml +++ b/gr-qtgui/grc/qtgui_tab_widget.xml @@ -7,7 +7,7 @@ <block> <name>QT GUI Tab Widget</name> <key>qtgui_tab_widget</key> - <category>QT GUI Widgets</category> + <category>GUI Widgets/QT</category> <import>from PyQt4 import Qt</import> <make>#set $win = 'self.%s'%$id Qt.QTabWidget() diff --git a/gr-qtgui/grc/qtgui_time_sink_x.xml b/gr-qtgui/grc/qtgui_time_sink_x.xml index 9c8da6fbcf..33e58425ca 100644 --- a/gr-qtgui/grc/qtgui_time_sink_x.xml +++ b/gr-qtgui/grc/qtgui_time_sink_x.xml @@ -7,7 +7,7 @@ <block> <name>QT GUI Time Sink</name> <key>qtgui_time_sink_x</key> - <category>QT GUI Widgets</category> + <category>Instrumentation/QT</category> <import>from PyQt4 import Qt</import> <import>from gnuradio.qtgui import qtgui</import> <import>from gnuradio.gr import firdes</import> diff --git a/gr-qtgui/include/qtgui_sink_c.h b/gr-qtgui/include/qtgui_sink_c.h index 68fff368a9..120c1c5c44 100644 --- a/gr-qtgui/include/qtgui_sink_c.h +++ b/gr-qtgui/include/qtgui_sink_c.h @@ -44,8 +44,10 @@ GR_QTGUI_API qtgui_sink_c_sptr qtgui_make_sink_c (int fftsize, int wintype, /*! * \brief A graphical sink to display freq, spec, time, and const plots. + * \ingroup instrumentation_blk * \ingroup qtgui_blk * + * \details * This is a QT-based graphical sink the takes a complex stream and * plots it. The default action is to plot the signal as a PSD (FFT), * spectrogram (waterfall), time domain I&Q, and constellation (I diff --git a/gr-qtgui/include/qtgui_sink_f.h b/gr-qtgui/include/qtgui_sink_f.h index 709f02a2f5..5f5a14a093 100644 --- a/gr-qtgui/include/qtgui_sink_f.h +++ b/gr-qtgui/include/qtgui_sink_f.h @@ -43,8 +43,10 @@ GR_QTGUI_API qtgui_sink_f_sptr qtgui_make_sink_f (int fftsize, int wintype, /*! * \brief A graphical sink to display freq, spec, and time. + * \ingroup instrumentation_blk * \ingroup qtgui_blk * + * \details * This is a QT-based graphical sink the takes a float stream and * plots it. The default action is to plot the signal as a PSD (FFT), * spectrogram (waterfall), and time domain plots. The plots may be diff --git a/gr-qtgui/include/qtgui_time_sink_c.h b/gr-qtgui/include/qtgui_time_sink_c.h index 561d796cfa..c440ba0984 100644 --- a/gr-qtgui/include/qtgui_time_sink_c.h +++ b/gr-qtgui/include/qtgui_time_sink_c.h @@ -41,8 +41,10 @@ GR_QTGUI_API qtgui_time_sink_c_sptr qtgui_make_time_sink_c(int size, double bw, /*! * \brief A graphical sink to display multiple signals in time. + * \ingroup instrumentation_blk * \ingroup qtgui_blk * + * \details * This is a QT-based graphical sink the takes set of a complex * streams and plots them in the time domain. For each signal, both * the signal's I and Q parts are plotted, and they are all plotted diff --git a/gr-qtgui/include/qtgui_time_sink_f.h b/gr-qtgui/include/qtgui_time_sink_f.h index 993e0556cf..cd7bd75a00 100644 --- a/gr-qtgui/include/qtgui_time_sink_f.h +++ b/gr-qtgui/include/qtgui_time_sink_f.h @@ -41,8 +41,10 @@ GR_QTGUI_API qtgui_time_sink_f_sptr qtgui_make_time_sink_f(int size, double bw, /*! * \brief A graphical sink to display multiple signals in time. + * \ingroup instrumentation_blk * \ingroup qtgui_blk * + * \details * This is a QT-based graphical sink the takes set of a float streams * and plots them in the time domain. Each signal is plotted with a * different color, and the \a set_title and \a set_color functions diff --git a/gr-qtgui/lib/CMakeLists.txt b/gr-qtgui/lib/CMakeLists.txt index 49fa525d7e..955db49e72 100644 --- a/gr-qtgui/lib/CMakeLists.txt +++ b/gr-qtgui/lib/CMakeLists.txt @@ -58,6 +58,20 @@ set(qtgui_srcs qtgui_util.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-qtgui.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-qtgui.rc + @ONLY) + + list(APPEND qtgui_srcs + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-qtgui.rc + ) +endif(MSVC) + ######################################################################## # Setup the include and linker paths ######################################################################## @@ -67,12 +81,14 @@ include_directories( ${GRUEL_INCLUDE_DIRS} ${QWT_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} ) link_directories( ${QWT_LIBRARY_DIRS} + ${LOG4CPP_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ) @@ -86,6 +102,7 @@ list(APPEND qtgui_libs ${QWT_LIBRARIES} ${QT_LIBRARIES} ${PYTHON_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_definitions(-DQWT_DLL) #setup QWT library linkage diff --git a/gr-qtgui/lib/gnuradio-qtgui.rc.in b/gr-qtgui/lib/gnuradio-qtgui.rc.in new file mode 100644 index 0000000000..1e1e0725e1 --- /dev/null +++ b/gr-qtgui/lib/gnuradio-qtgui.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-qtgui" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-qtgui.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-qtgui.dll" + VALUE "ProductName", "gnuradio-qtgui" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-shd/lib/CMakeLists.txt b/gr-shd/lib/CMakeLists.txt index 38154755c1..bb98d8ce8b 100644 --- a/gr-shd/lib/CMakeLists.txt +++ b/gr-shd/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -31,6 +31,9 @@ include_directories( link_directories(${SHD_LIBRARY_DIRS}) link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -39,10 +42,25 @@ list(APPEND gr_shd_sources gr_shd_smini_sink.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-shd.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-shd.rc + @ONLY) + + list(APPEND gr_shd_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-shd.rc + ) +endif(MSVC) + list(APPEND shd_libs gnuradio-core ${Boost_LIBRARIES} ${SHD_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-shd SHARED ${gr_shd_sources}) diff --git a/gr-shd/lib/gnuradio-shd.rc.in b/gr-shd/lib/gnuradio-shd.rc.in new file mode 100644 index 0000000000..4a3313b0ff --- /dev/null +++ b/gr-shd/lib/gnuradio-shd.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-shd" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-shd.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-shd.dll" + VALUE "ProductName", "gnuradio-shd" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-trellis/grc/trellis_encoder_xx.xml b/gr-trellis/grc/trellis_encoder_xx.xml index 639e948ec5..fe9c38f22c 100644 --- a/gr-trellis/grc/trellis_encoder_xx.xml +++ b/gr-trellis/grc/trellis_encoder_xx.xml @@ -8,7 +8,7 @@ <block> <name>Trellis Encoder</name> <key>trellis_encoder_xx</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.encoder_$(type)(trellis.fsm($fsm_args), $init_state)</make> <param> diff --git a/gr-trellis/grc/trellis_metrics_x.xml b/gr-trellis/grc/trellis_metrics_x.xml index 0bc349514b..f551bc1521 100644 --- a/gr-trellis/grc/trellis_metrics_x.xml +++ b/gr-trellis/grc/trellis_metrics_x.xml @@ -9,7 +9,7 @@ <block> <name>Trellis Metrics</name> <key>trellis_metrics_x</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis, digital</import> <make>trellis.metrics_$(type)($card, $dim, $table, $metric_type)</make> <callback>set_TABLE($table)</callback> diff --git a/gr-trellis/grc/trellis_pccc_decoder_combined_xx.xml b/gr-trellis/grc/trellis_pccc_decoder_combined_xx.xml index 005a88d668..2583f0858b 100644 --- a/gr-trellis/grc/trellis_pccc_decoder_combined_xx.xml +++ b/gr-trellis/grc/trellis_pccc_decoder_combined_xx.xml @@ -9,7 +9,7 @@ <block> <name>PCCC Decoder Combo</name> <key>trellis_pccc_decoder_combined_xx</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis, digital</import> <make>trellis.pccc_decoder_combined_$(type)$(out_type)( trellis.fsm($o_fsm_args), $o_init_state, $o_final_state, diff --git a/gr-trellis/grc/trellis_pccc_decoder_x.xml b/gr-trellis/grc/trellis_pccc_decoder_x.xml index c794478260..046731547b 100644 --- a/gr-trellis/grc/trellis_pccc_decoder_x.xml +++ b/gr-trellis/grc/trellis_pccc_decoder_x.xml @@ -9,7 +9,7 @@ <block> <name>PCCC Decoder</name> <key>trellis_pccc_decoder_x</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.pccc_decoder_$(out_type)( trellis.fsm($o_fsm_args), $o_init_state, $o_final_state, diff --git a/gr-trellis/grc/trellis_pccc_encoder_xx.xml b/gr-trellis/grc/trellis_pccc_encoder_xx.xml index 6774f18d21..7441ba8fc9 100644 --- a/gr-trellis/grc/trellis_pccc_encoder_xx.xml +++ b/gr-trellis/grc/trellis_pccc_encoder_xx.xml @@ -8,7 +8,7 @@ <block> <name>PCCC Encoder</name> <key>trellis_pccc_encoder_xx</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.pccc_encoder_$(type)(trellis.fsm($o_fsm_args), $o_init_state, trellis.fsm($i_fsm_args), $i_init_state, trellis.interleaver($interleaver_args), $bl)</make> <param> diff --git a/gr-trellis/grc/trellis_permutation.xml b/gr-trellis/grc/trellis_permutation.xml index 2126933110..bf6fc3ff15 100644 --- a/gr-trellis/grc/trellis_permutation.xml +++ b/gr-trellis/grc/trellis_permutation.xml @@ -9,7 +9,7 @@ <block> <name>Trellis Permutation</name> <key>trellis_permutation</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.permutation($interleaver_size, $table, $syms_per_block, $type.size*$vlen)</make> <param> diff --git a/gr-trellis/grc/trellis_sccc_decoder_combined_xx.xml b/gr-trellis/grc/trellis_sccc_decoder_combined_xx.xml index 324f06e7f4..eee4e2b9e4 100644 --- a/gr-trellis/grc/trellis_sccc_decoder_combined_xx.xml +++ b/gr-trellis/grc/trellis_sccc_decoder_combined_xx.xml @@ -9,7 +9,7 @@ <block> <name>SCCC Decoder Combo</name> <key>trellis_sccc_decoder_combined_xx</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis, digital</import> <make>trellis.sccc_decoder_combined_$(type)$(out_type)( trellis.fsm($o_fsm_args), $o_init_state, $o_final_state, diff --git a/gr-trellis/grc/trellis_sccc_decoder_x.xml b/gr-trellis/grc/trellis_sccc_decoder_x.xml index 4bf8d26d56..ac65a6a49d 100644 --- a/gr-trellis/grc/trellis_sccc_decoder_x.xml +++ b/gr-trellis/grc/trellis_sccc_decoder_x.xml @@ -9,7 +9,7 @@ <block> <name>SCCC Decoder</name> <key>trellis_sccc_decoder_x</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.sccc_decoder_$(out_type)( trellis.fsm($o_fsm_args), $o_init_state, $o_final_state, diff --git a/gr-trellis/grc/trellis_sccc_encoder_xx.xml b/gr-trellis/grc/trellis_sccc_encoder_xx.xml index 54d9c1e014..f1054bf795 100644 --- a/gr-trellis/grc/trellis_sccc_encoder_xx.xml +++ b/gr-trellis/grc/trellis_sccc_encoder_xx.xml @@ -8,7 +8,7 @@ <block> <name>SCCC Encoder</name> <key>trellis_sccc_encoder_xx</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.sccc_encoder_$(type)(trellis.fsm($o_fsm_args), $o_init_state, trellis.fsm($i_fsm_args), $i_init_state, trellis.interleaver($interleaver_args), $bl)</make> <param> diff --git a/gr-trellis/grc/trellis_siso_combined_f.xml b/gr-trellis/grc/trellis_siso_combined_f.xml index a39986a86c..95eceeea31 100644 --- a/gr-trellis/grc/trellis_siso_combined_f.xml +++ b/gr-trellis/grc/trellis_siso_combined_f.xml @@ -9,7 +9,7 @@ <block> <name>SISO Combo</name> <key>trellis_siso_combined_f</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.siso_combined_f(trellis.fsm($fsm_args), $block_size, $init_state, $final_state, $a_post_in, $a_post_out, $siso_type, $dim, $table, $metric_type)</make> <param> diff --git a/gr-trellis/grc/trellis_siso_f.xml b/gr-trellis/grc/trellis_siso_f.xml index e3fb502b3c..523e6a3aac 100644 --- a/gr-trellis/grc/trellis_siso_f.xml +++ b/gr-trellis/grc/trellis_siso_f.xml @@ -9,7 +9,7 @@ <block> <name>SISO</name> <key>trellis_siso_f</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.siso_f(trellis.fsm($fsm_args), $block_size, $init_state, $final_state, $a_post_in, $a_post_out, $siso_type)</make> <param> diff --git a/gr-trellis/grc/trellis_viterbi_combined_xx.xml b/gr-trellis/grc/trellis_viterbi_combined_xx.xml index 85128714c6..7faf735fe1 100644 --- a/gr-trellis/grc/trellis_viterbi_combined_xx.xml +++ b/gr-trellis/grc/trellis_viterbi_combined_xx.xml @@ -9,7 +9,7 @@ <block> <name>Viterbi Combo</name> <key>trellis_viterbi_combined_xx</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis, digital</import> <make>trellis.viterbi_combined_$(type)$(out_type)(trellis.fsm($fsm_args), $block_size, $init_state, $final_state, $dim, $table, $metric_type)</make> <callback>set_TABLE($table)</callback> diff --git a/gr-trellis/grc/trellis_viterbi_x.xml b/gr-trellis/grc/trellis_viterbi_x.xml index d97e6707af..861b23f124 100644 --- a/gr-trellis/grc/trellis_viterbi_x.xml +++ b/gr-trellis/grc/trellis_viterbi_x.xml @@ -9,7 +9,7 @@ <block> <name>Viterbi</name> <key>trellis_viterbi_x</key> - <category>Error Correction/Trellis</category> + <category>Trellis Coding</category> <import>from gnuradio import trellis</import> <make>trellis.viterbi_$(type)(trellis.fsm($fsm_args), $block_size, $init_state, $final_state)</make> <param> diff --git a/gr-trellis/src/lib/CMakeLists.txt b/gr-trellis/src/lib/CMakeLists.txt index e2abf0238f..05f54b9bd8 100644 --- a/gr-trellis/src/lib/CMakeLists.txt +++ b/gr-trellis/src/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011 Free Software Foundation, Inc. +# Copyright 2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -32,6 +32,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # generate the python helper script which calls into the build utils ######################################################################## @@ -103,6 +106,10 @@ expand_h_cc_i(trellis_sccc_decoder_combined_XX fb fs fi cb cs ci) expand_h_cc_i(trellis_pccc_decoder_X b s i) expand_h_cc_i(trellis_pccc_decoder_combined_XX fb fs fi cb cs ci) +add_custom_target(trellis_generated_includes DEPENDS + ${generated_trellis_includes} +) + ######################################################################## # Create the master trellis swig include files ######################################################################## @@ -147,9 +154,24 @@ list(APPEND gr_trellis_sources ${generated_trellis_sources} ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-trellis.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-trellis.rc + @ONLY) + + list(APPEND gr_trellis_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-trellis.rc + ) +endif(MSVC) + list(APPEND trellis_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-trellis SHARED ${gr_trellis_sources}) diff --git a/gr-trellis/src/lib/fsm.h b/gr-trellis/src/lib/fsm.h index 47e467898a..99a5cce778 100644 --- a/gr-trellis/src/lib/fsm.h +++ b/gr-trellis/src/lib/fsm.h @@ -29,6 +29,7 @@ /*! * \brief Finite State Machine Specification class. + * \ingroup trellis_coding_blk * * An instance of this class represents a finite state machine specification (FSMS) * rather than the FSM itself. It particular the state of the FSM diff --git a/gr-trellis/src/lib/gnuradio-trellis.rc.in b/gr-trellis/src/lib/gnuradio-trellis.rc.in new file mode 100644 index 0000000000..db9f187947 --- /dev/null +++ b/gr-trellis/src/lib/gnuradio-trellis.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-trellis" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-trellis.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-trellis.dll" + VALUE "ProductName", "gnuradio-trellis" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-trellis/src/lib/interleaver.h b/gr-trellis/src/lib/interleaver.h index fbd378d621..21735bd639 100644 --- a/gr-trellis/src/lib/interleaver.h +++ b/gr-trellis/src/lib/interleaver.h @@ -28,6 +28,7 @@ /*! * \brief INTERLEAVER class + * \ingroup trellis_coding_blk */ class TRELLIS_API interleaver { private: diff --git a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h index 2c2070522c..b799b5cc6d 100644 --- a/gr-trellis/src/lib/trellis_constellation_metrics_cf.h +++ b/gr-trellis/src/lib/trellis_constellation_metrics_cf.h @@ -35,7 +35,7 @@ TRELLIS_API trellis_constellation_metrics_cf_sptr trellis_make_constellation_met /*! * \brief Evaluate metrics for use by the Viterbi algorithm. - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API trellis_constellation_metrics_cf : public gr_block { diff --git a/gr-trellis/src/lib/trellis_encoder_XX.h.t b/gr-trellis/src/lib/trellis_encoder_XX.h.t index 7c4250a929..d94ad80652 100644 --- a/gr-trellis/src/lib/trellis_encoder_XX.h.t +++ b/gr-trellis/src/lib/trellis_encoder_XX.h.t @@ -36,7 +36,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST); /*! * \brief Convolutional encoder. - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_sync_block { diff --git a/gr-trellis/src/lib/trellis_metrics_X.h.t b/gr-trellis/src/lib/trellis_metrics_X.h.t index ab406c51ea..1bf61dd957 100644 --- a/gr-trellis/src/lib/trellis_metrics_X.h.t +++ b/gr-trellis/src/lib/trellis_metrics_X.h.t @@ -36,7 +36,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vect /*! * \brief Evaluate metrics for use by the Viterbi algorithm. - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_block { diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t b/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t index e9bc946818..3561bb5504 100644 --- a/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t +++ b/gr-trellis/src/lib/trellis_pccc_decoder_X.h.t @@ -46,7 +46,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( /*! - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_block { diff --git a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t index 6e45ea10ac..82216a0917 100644 --- a/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t +++ b/gr-trellis/src/lib/trellis_pccc_decoder_combined_XX.h.t @@ -51,7 +51,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( /*! - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_block { diff --git a/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t b/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t index 75a22b829c..e4682558e2 100644 --- a/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t +++ b/gr-trellis/src/lib/trellis_pccc_encoder_XX.h.t @@ -43,7 +43,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( /*! * \brief SCCC encoder. - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_sync_block { diff --git a/gr-trellis/src/lib/trellis_permutation.h b/gr-trellis/src/lib/trellis_permutation.h index cc40518c2c..5669fdd4dd 100644 --- a/gr-trellis/src/lib/trellis_permutation.h +++ b/gr-trellis/src/lib/trellis_permutation.h @@ -35,7 +35,7 @@ TRELLIS_API trellis_permutation_sptr trellis_make_permutation (int K, const std: /*! * \brief Permutation. - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API trellis_permutation : public gr_sync_block { diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t b/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t index d6fb72f682..b0b0cd37a6 100644 --- a/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t +++ b/gr-trellis/src/lib/trellis_sccc_decoder_X.h.t @@ -46,7 +46,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( /*! - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_block { diff --git a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t index 3fdc53c624..9b56e7167a 100644 --- a/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t +++ b/gr-trellis/src/lib/trellis_sccc_decoder_combined_XX.h.t @@ -51,7 +51,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( /*! - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_block { diff --git a/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t b/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t index b16d7ffca9..655f2d1ee2 100644 --- a/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t +++ b/gr-trellis/src/lib/trellis_sccc_encoder_XX.h.t @@ -43,7 +43,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( /*! * \brief SCCC encoder. - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_sync_block { diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.h b/gr-trellis/src/lib/trellis_siso_combined_f.h index 4b28e8de4a..d3b3b64189 100644 --- a/gr-trellis/src/lib/trellis_siso_combined_f.h +++ b/gr-trellis/src/lib/trellis_siso_combined_f.h @@ -47,7 +47,7 @@ TRELLIS_API trellis_siso_combined_f_sptr trellis_make_siso_combined_f ( ); /*! - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API trellis_siso_combined_f : public gr_block { diff --git a/gr-trellis/src/lib/trellis_siso_f.h b/gr-trellis/src/lib/trellis_siso_f.h index 9341f24683..52e6bf3eb0 100644 --- a/gr-trellis/src/lib/trellis_siso_f.h +++ b/gr-trellis/src/lib/trellis_siso_f.h @@ -44,7 +44,7 @@ TRELLIS_API trellis_siso_f_sptr trellis_make_siso_f ( /*! - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API trellis_siso_f : public gr_block { diff --git a/gr-trellis/src/lib/trellis_viterbi_X.h.t b/gr-trellis/src/lib/trellis_viterbi_X.h.t index c0400d3410..b2d5ee6495 100644 --- a/gr-trellis/src/lib/trellis_viterbi_X.h.t +++ b/gr-trellis/src/lib/trellis_viterbi_X.h.t @@ -42,7 +42,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( /*! - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_block { diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t index c7e468e73b..07175bff7e 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t +++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.h.t @@ -45,7 +45,7 @@ TRELLIS_API @SPTR_NAME@ trellis_make_@BASE_NAME@ ( /*! - * \ingroup coding_blk + * \ingroup trellis_coding_blk */ class TRELLIS_API @NAME@ : public gr_block { diff --git a/gr-uhd/examples/python/usrp_spectrum_sense.py b/gr-uhd/examples/python/usrp_spectrum_sense.py index 32980adbfa..a7830204e6 100755 --- a/gr-uhd/examples/python/usrp_spectrum_sense.py +++ b/gr-uhd/examples/python/usrp_spectrum_sense.py @@ -29,6 +29,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") @@ -64,6 +65,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: @@ -100,13 +107,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", - help="time to dwell (in seconds) at a given frequncy [default=%default]") - parser.add_option("-F", "--fft-size", type="int", default=256, - help="specify number of FFT bins [default=%default]") + default=0.25, metavar="SECS", + help="time to dwell (in seconds) at a given frequency [default=%default]") + 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("-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") @@ -115,6 +131,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]) @@ -122,8 +140,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 - if not options.real_time: realtime = False else: @@ -146,15 +162,23 @@ class my_top_block(gr.top_block): # Set the antenna if(options.antenna): self.u.set_antenna(options.antenna, 0) - - usrp_rate = options.samp_rate - self.u.set_samp_rate(usrp_rate) - dev_rate = self.u.get_samp_rate() - - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) + + self.u.set_samp_rate(options.samp_rate) + self.usrp_rate = usrp_rate = self.u.get_samp_rate() + + self.lo_offset = options.lo_offset + + 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 = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) mywindow = window.blackmanharris(self.fft_size) - fft = gr.fft_vcc(self.fft_size, True, mywindow) + fft = gr.fft_vcc(self.fft_size, True, mywindow, True) power = 0 for tap in mywindow: power += tap*tap @@ -162,14 +186,14 @@ class my_top_block(gr.top_block): c2mag = gr.complex_to_mag_squared(self.fft_size) # FIXME the log10 primitive is dog slow - log = gr.nlog10_ff(10, self.fft_size, - -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) + #log = gr.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) @@ -178,15 +202,15 @@ 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 = gr.bin_statistics_f(self.fft_size, self.msgq, self._tune_callback, tune_delay, dwell_delay) # FIXME leave out the log10 until we speed it up - #self.connect(self.u, s2v, fft, c2mag, log, stats) - self.connect(self.u, s2v, fft, c2mag, stats) + #self.connect(self.u, s2v, fft, c2mag, log, stats) + self.connect(self.u, s2v, fft, c2mag, stats) if options.gain is None: # if no gain was specified, use the mid-point in dB @@ -194,7 +218,7 @@ class my_top_block(gr.top_block): options.gain = float(g.start()+g.stop())/2.0 self.set_gain(options.gain) - print "gain =", options.gain + print "gain =", options.gain def set_next_freq(self): target_freq = self.next_freq @@ -216,7 +240,8 @@ class my_top_block(gr.top_block): @param 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 @@ -224,26 +249,45 @@ class my_top_block(gr.top_block): def set_gain(self, gain): self.u.set_gain(gain) - + + 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) + (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 - - # 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): + + 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/gr_uhd_usrp_sink.h b/gr-uhd/include/gr_uhd_usrp_sink.h index eaf60fb777..9cea6f3e28 100644 --- a/gr-uhd/include/gr_uhd_usrp_sink.h +++ b/gr-uhd/include/gr_uhd_usrp_sink.h @@ -290,6 +290,20 @@ public: 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/gr_uhd_usrp_source.h b/gr-uhd/include/gr_uhd_usrp_source.h index 1243ddcc2f..4d15bf1606 100644 --- a/gr-uhd/include/gr_uhd_usrp_source.h +++ b/gr-uhd/include/gr_uhd_usrp_source.h @@ -300,6 +300,20 @@ public: 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/CMakeLists.txt b/gr-uhd/lib/CMakeLists.txt index c494fddad5..15ba1e7f1c 100644 --- a/gr-uhd/lib/CMakeLists.txt +++ b/gr-uhd/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011-2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -34,6 +34,9 @@ link_directories( ${Boost_LIBRARY_DIRS} ) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -43,10 +46,25 @@ list(APPEND gr_uhd_sources gr_uhd_amsg_source.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-uhd.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-uhd.rc + @ONLY) + + list(APPEND gr_uhd_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-uhd.rc + ) +endif(MSVC) + list(APPEND uhd_libs gnuradio-core ${Boost_LIBRARIES} ${UHD_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-uhd SHARED ${gr_uhd_sources}) diff --git a/gr-uhd/lib/gnuradio-uhd.rc.in b/gr-uhd/lib/gnuradio-uhd.rc.in new file mode 100644 index 0000000000..80fb29b9fb --- /dev/null +++ b/gr-uhd/lib/gnuradio-uhd.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-uhd" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-uhd.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-uhd.dll" + VALUE "ProductName", "gnuradio-uhd" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-uhd/lib/gr_uhd_usrp_sink.cc b/gr-uhd/lib/gr_uhd_usrp_sink.cc index 6216c94a83..99d8e03c33 100644 --- a/gr-uhd/lib/gr_uhd_usrp_sink.cc +++ b/gr-uhd/lib/gr_uhd_usrp_sink.cc @@ -157,6 +157,14 @@ public: return _dev->set_tx_bandwidth(bandwidth, chan); } + double get_bandwidth(size_t chan){ + return _dev->get_tx_bandwidth(chan); + } + + uhd::freq_range_t get_bandwidth_range(size_t chan){ + return _dev->get_tx_bandwidth_range(chan); + } + void set_dc_offset(const std::complex<double> &offset, size_t chan){ #ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API return _dev->set_tx_dc_offset(offset, chan); diff --git a/gr-uhd/lib/gr_uhd_usrp_source.cc b/gr-uhd/lib/gr_uhd_usrp_source.cc index 3813673b4b..c6c82d56cf 100644 --- a/gr-uhd/lib/gr_uhd_usrp_source.cc +++ b/gr-uhd/lib/gr_uhd_usrp_source.cc @@ -168,6 +168,14 @@ public: return _dev->set_rx_bandwidth(bandwidth, chan); } + double get_bandwidth(size_t chan){ + return _dev->get_rx_bandwidth(chan); + } + + uhd::freq_range_t get_bandwidth_range(size_t chan){ + return _dev->get_rx_bandwidth_range(chan); + } + void set_auto_dc_offset(const bool enable, size_t chan){ #ifdef UHD_USRP_MULTI_USRP_FRONTEND_CAL_API return _dev->set_rx_dc_offset(enable, chan); diff --git a/gr-utils/src/python/modtool/code_generator.py b/gr-utils/src/python/modtool/code_generator.py index 525b3d1e9a..fbe9aa92c2 100644 --- a/gr-utils/src/python/modtool/code_generator.py +++ b/gr-utils/src/python/modtool/code_generator.py @@ -37,6 +37,7 @@ class GRMTemplate(Cheetah.Template.Template): 'decimator': 'gr_sync_decimator', 'interpolator': 'gr_sync_interpolator', 'general': 'gr_block', + 'tagged_stream': 'gr_tagged_stream_block', 'hier': 'gr_hier_block2', 'noblock': ''} searchList['str_to_fancyc_comment'] = str_to_fancyc_comment diff --git a/gr-utils/src/python/modtool/gr-newmod/CMakeLists.txt b/gr-utils/src/python/modtool/gr-newmod/CMakeLists.txt index deea791f80..2ad81710b8 100644 --- a/gr-utils/src/python/modtool/gr-newmod/CMakeLists.txt +++ b/gr-utils/src/python/modtool/gr-newmod/CMakeLists.txt @@ -87,6 +87,14 @@ find_package(Gruel) find_package(GnuradioCore) 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 CORE BLOCKS FILTER ...) +# find_package(Gnuradio "version") + if(NOT GRUEL_FOUND) message(FATAL_ERROR "Gruel required to compile howto") endif() diff --git a/gr-utils/src/python/modtool/modtool_add.py b/gr-utils/src/python/modtool/modtool_add.py index e1d61cf0fb..81103e460d 100644 --- a/gr-utils/src/python/modtool/modtool_add.py +++ b/gr-utils/src/python/modtool/modtool_add.py @@ -37,7 +37,7 @@ class ModToolAdd(ModTool): name = 'add' aliases = ('insert',) _block_types = ('sink', 'source', 'sync', 'decimator', 'interpolator', - 'general', 'hier', 'noblock') + 'general', 'tagged_stream', 'hier', 'noblock') def __init__(self): ModTool.__init__(self) self._add_cc_qa = False @@ -208,7 +208,7 @@ class ModToolAdd(ModTool): fname_h = self._info['blockname'] + '.h' fname_cc = self._info['blockname'] + '.cc' if self._info['blocktype'] in ('source', 'sink', 'sync', 'decimator', - 'interpolator', 'general', 'hier'): + 'interpolator', 'general', 'hier', 'tagged_stream'): fname_cc = self._info['blockname'] + '_impl.cc' self._write_tpl('block_impl_h', 'lib', self._info['blockname'] + '_impl.h') self._write_tpl('block_impl_cpp', 'lib', fname_cc) diff --git a/gr-utils/src/python/modtool/templates.py b/gr-utils/src/python/modtool/templates.py index 878baaadf9..0e5fba25cc 100644 --- a/gr-utils/src/python/modtool/templates.py +++ b/gr-utils/src/python/modtool/templates.py @@ -57,25 +57,34 @@ namespace gr { class ${blockname}_impl : public ${blockname} { - private: + private: // Nothing to declare in this block. - public: +#if $blocktype == 'tagged_stream' + protected: + int calculate_output_stream_length(const gr_vector_int &ninput_items); + +#end if + public: ${blockname}_impl(${strip_default_values($arglist)}); ~${blockname}_impl(); + // Where all the action really happens #if $blocktype == 'general' void forecast (int noutput_items, gr_vector_int &ninput_items_required); - // Where all the action really happens int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); +#else if $blocktype == 'tagged_stream' + int work(int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); #else if $blocktype == 'hier' #silent pass #else - // Where all the action really happens int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); @@ -125,6 +134,8 @@ namespace gr { #set $decimation = ', <+decimation+>' #else if $blocktype == 'interpolator' #set $decimation = ', <+interpolation+>' +#else if $blocktype == 'tagged_stream' +#set $decimation = ', <+len_tag_key+>' #else #set $decimation = '' #end if @@ -186,6 +197,28 @@ namespace gr { // Tell runtime system how many output items we produced. return noutput_items; } +#else if $blocktype == 'tagged_stream' + int + ${blockname}_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) + { + int noutput_items = /* <+set this+> */; + return noutput_items ; + } + + int + ${blockname}_impl::work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + { + const float *in = (const float *) input_items[0]; + float *out = (float *) output_items[0]; + + // Do <+signal processing+> + + // Tell runtime system how many output items we produced. + return noutput_items; + } #else if $blocktype == 'hier' #silent pass #else @@ -231,8 +264,8 @@ namespace gr { class ${modname.upper()}_API $blockname { public: - ${blockname}(${arglist}); - ~${blockname}(); + ${blockname}(${arglist}); + ~${blockname}(); private: }; #else @@ -243,18 +276,18 @@ namespace gr { */ class ${modname.upper()}_API ${blockname} : virtual public $grblocktype { - public: - typedef boost::shared_ptr<${blockname}> sptr; - - /*! - * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}. - * - * To avoid accidental use of raw pointers, ${modname}::${blockname}'s - * constructor is in a private implementation - * class. ${modname}::${blockname}::make is the public interface for - * creating new instances. - */ - static sptr make($arglist); + public: + typedef boost::shared_ptr<${blockname}> sptr; + + /*! + * \\brief Return a shared_ptr to a new instance of ${modname}::${blockname}. + * + * To avoid accidental use of raw pointers, ${modname}::${blockname}'s + * constructor is in a private implementation + * class. ${modname}::${blockname}::make is the public interface for + * creating new instances. + */ + static sptr make($arglist); }; #end if diff --git a/gr-video-sdl/src/CMakeLists.txt b/gr-video-sdl/src/CMakeLists.txt index 3050926bd7..8053182239 100644 --- a/gr-video-sdl/src/CMakeLists.txt +++ b/gr-video-sdl/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2011-2012 Free Software Foundation, Inc. +# Copyright 2011-2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -25,6 +25,7 @@ include_directories( ${GNURADIO_CORE_INCLUDE_DIRS} ${GRUEL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} + ${LOG4CPP_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ) @@ -38,10 +39,25 @@ list(APPEND gr_video_sdl_sources video_sdl_sink_s.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-video-sdl.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-video-sdl.rc + @ONLY) + + list(APPEND gr_uhd_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-video-sdl.rc + ) +endif(MSVC) + list(APPEND video_sdl_libs gnuradio-core ${Boost_LIBRARIES} ${SDL_LIBRARY} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-video-sdl SHARED ${gr_video_sdl_sources}) diff --git a/gr-video-sdl/src/gnuradio-video-sdl.rc.in b/gr-video-sdl/src/gnuradio-video-sdl.rc.in new file mode 100644 index 0000000000..c876b0f08a --- /dev/null +++ b/gr-video-sdl/src/gnuradio-video-sdl.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-video-sdl" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-video-sdl.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-video-sdl.dll" + VALUE "ProductName", "gnuradio-video-sdl" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-vocoder/doc/vocoder.dox b/gr-vocoder/doc/vocoder.dox index ff1c4b9ddb..3973ca56fc 100644 --- a/gr-vocoder/doc/vocoder.dox +++ b/gr-vocoder/doc/vocoder.dox @@ -11,8 +11,7 @@ normally imported as: \endcode See the Doxygen documentation for details about the blocks available -in this package. The relevant blocks are listed in the \ref -vocoder_blk group. +in this package. A quick listing of the details can be found in Python after importing by using: diff --git a/gr-vocoder/grc/vocoder_alaw_encode_sb.xml b/gr-vocoder/grc/vocoder_alaw_encode_sb.xml index 0ad8eca124..728158eec7 100644 --- a/gr-vocoder/grc/vocoder_alaw_encode_sb.xml +++ b/gr-vocoder/grc/vocoder_alaw_encode_sb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>g711 alaw Audio Encoder</name> + <name>g711 Alaw Audio Encoder</name> <key>vocoder_alaw_encode_sb</key> <import>from gnuradio import vocoder</import> <make>vocoder.alaw_encode_sb()</make> diff --git a/gr-vocoder/grc/vocoder_block_tree.xml b/gr-vocoder/grc/vocoder_block_tree.xml index ed3338d441..c96a5cc687 100644 --- a/gr-vocoder/grc/vocoder_block_tree.xml +++ b/gr-vocoder/grc/vocoder_block_tree.xml @@ -29,7 +29,7 @@ <cat> <name></name> <!-- Blank for Root Name --> <cat> - <name>Vocoders</name> + <name>Audio</name> <block>vocoder_alaw_decode_bs</block> <block>vocoder_alaw_encode_sb</block> <block>vocoder_codec2_decode_ps</block> diff --git a/gr-vocoder/grc/vocoder_ulaw_decode_bs.xml b/gr-vocoder/grc/vocoder_ulaw_decode_bs.xml index 5a7ccbb0e3..ca3c535c18 100644 --- a/gr-vocoder/grc/vocoder_ulaw_decode_bs.xml +++ b/gr-vocoder/grc/vocoder_ulaw_decode_bs.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Ulaw Audio Decoder</name> + <name>ulaw Audio Decoder</name> <key>vocoder_ulaw_decode_bs</key> <import>from gnuradio import vocoder</import> <make>vocoder.ulaw_decode_bs()</make> diff --git a/gr-vocoder/include/vocoder_alaw_decode_bs.h b/gr-vocoder/include/vocoder_alaw_decode_bs.h index 083be21000..935caef649 100644 --- a/gr-vocoder/include/vocoder_alaw_decode_bs.h +++ b/gr-vocoder/include/vocoder_alaw_decode_bs.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_alaw_decode_bs_sptr vocoder_make_alaw_decode_bs(); /*! * \brief This block performs alaw audio decoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_alaw_decode_bs : public gr_sync_block diff --git a/gr-vocoder/include/vocoder_alaw_encode_sb.h b/gr-vocoder/include/vocoder_alaw_encode_sb.h index c2609a95c6..7d3a8d7779 100644 --- a/gr-vocoder/include/vocoder_alaw_encode_sb.h +++ b/gr-vocoder/include/vocoder_alaw_encode_sb.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_alaw_encode_sb_sptr vocoder_make_alaw_encode_sb(); /*! * \brief This block performs g.711 alaw audio encoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_alaw_encode_sb : public gr_sync_block { diff --git a/gr-vocoder/include/vocoder_codec2_decode_ps.h b/gr-vocoder/include/vocoder_codec2_decode_ps.h index 9ceef79214..8ed3b15c9d 100644 --- a/gr-vocoder/include/vocoder_codec2_decode_ps.h +++ b/gr-vocoder/include/vocoder_codec2_decode_ps.h @@ -32,7 +32,7 @@ VOCODER_API vocoder_codec2_decode_ps_sptr vocoder_make_codec2_decode_ps (); /*! * \brief CODEC2 Vocoder Decoder - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_codec2_decode_ps : public gr_sync_interpolator { void *d_codec2; diff --git a/gr-vocoder/include/vocoder_codec2_encode_sp.h b/gr-vocoder/include/vocoder_codec2_encode_sp.h index c24aca1c48..a8333ea342 100644 --- a/gr-vocoder/include/vocoder_codec2_encode_sp.h +++ b/gr-vocoder/include/vocoder_codec2_encode_sp.h @@ -32,7 +32,7 @@ VOCODER_API vocoder_codec2_encode_sp_sptr vocoder_make_codec2_encode_sp (); /*! * \brief CODEC2 Vocoder Encoder - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_codec2_encode_sp : public gr_sync_decimator { void *d_codec2; diff --git a/gr-vocoder/include/vocoder_cvsd_decode_bs.h b/gr-vocoder/include/vocoder_cvsd_decode_bs.h index ebafeeb4ea..40deabe91b 100644 --- a/gr-vocoder/include/vocoder_cvsd_decode_bs.h +++ b/gr-vocoder/include/vocoder_cvsd_decode_bs.h @@ -35,7 +35,7 @@ typedef boost::shared_ptr<vocoder_cvsd_decode_bs> vocoder_cvsd_decode_bs_sptr; * values are modeled after the Bluetooth standard and should not be changed, * except by an advanced user * - * \ingroup vocoder_blk + * \ingroup audio_blk * * \param min_step Minimum step size used to update the internal reference. Default: "10" * \param max_step Maximum step size used to update the internal reference. Default: "1280" @@ -61,7 +61,7 @@ VOCODER_API vocoder_cvsd_decode_bs_sptr vocoder_make_cvsd_decode_bs (short min_s * is modeled after the CVSD encoder/decoder specifications defined in the * Bluetooth standard. * - * \ingroup vocoder_blk + * \ingroup audio_blk * * CVSD is a method for encoding speech that seeks to reduce the * bandwidth required for digital voice transmission. CVSD takes diff --git a/gr-vocoder/include/vocoder_cvsd_encode_sb.h b/gr-vocoder/include/vocoder_cvsd_encode_sb.h index 876fd96de4..11bce25514 100644 --- a/gr-vocoder/include/vocoder_cvsd_encode_sb.h +++ b/gr-vocoder/include/vocoder_cvsd_encode_sb.h @@ -34,7 +34,7 @@ typedef boost::shared_ptr<vocoder_cvsd_encode_sb> vocoder_cvsd_encode_sb_sptr; * default values are modeled after the Bluetooth standard and should * not be changed except by an advanced user * - * \ingroup vocoder_blk + * \ingroup audio_blk * * \param min_step Minimum step size used to update the internal reference. Default: "10" * \param max_step Maximum step size used to update the internal reference. Default: "1280" @@ -61,7 +61,7 @@ VOCODER_API vocoder_cvsd_encode_sb_sptr vocoder_make_cvsd_encode_sb(short min_st * is modeled after the CVSD encoder/decoder specifications defined in the * Bluetooth standard. * - * \ingroup vocoder_blk + * \ingroup audio_blk * * CVSD is a method for encoding speech that seeks to reduce the * bandwidth required for digital voice transmission. CVSD takes diff --git a/gr-vocoder/include/vocoder_g721_decode_bs.h b/gr-vocoder/include/vocoder_g721_decode_bs.h index 61a386ffca..0e74645f90 100644 --- a/gr-vocoder/include/vocoder_g721_decode_bs.h +++ b/gr-vocoder/include/vocoder_g721_decode_bs.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_g721_decode_bs_sptr vocoder_make_g721_decode_bs(); /*! * \brief This block performs g721 audio decoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_g721_decode_bs : virtual public gr_sync_block diff --git a/gr-vocoder/include/vocoder_g721_encode_sb.h b/gr-vocoder/include/vocoder_g721_encode_sb.h index 694da92d6d..aa657da2fe 100644 --- a/gr-vocoder/include/vocoder_g721_encode_sb.h +++ b/gr-vocoder/include/vocoder_g721_encode_sb.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_g721_encode_sb_sptr vocoder_make_g721_encode_sb(); /*! * \brief This block performs g721 audio encoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_g721_encode_sb : virtual public gr_sync_block diff --git a/gr-vocoder/include/vocoder_g723_24_decode_bs.h b/gr-vocoder/include/vocoder_g723_24_decode_bs.h index 6c0f09838f..0693c1a258 100644 --- a/gr-vocoder/include/vocoder_g723_24_decode_bs.h +++ b/gr-vocoder/include/vocoder_g723_24_decode_bs.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_g723_24_decode_bs_sptr vocoder_make_g723_24_decode_bs(); /*! * \brief This block performs g723_24 audio decoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_g723_24_decode_bs : virtual public gr_sync_block diff --git a/gr-vocoder/include/vocoder_g723_24_encode_sb.h b/gr-vocoder/include/vocoder_g723_24_encode_sb.h index 105897583f..70e9496971 100644 --- a/gr-vocoder/include/vocoder_g723_24_encode_sb.h +++ b/gr-vocoder/include/vocoder_g723_24_encode_sb.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_g723_24_encode_sb_sptr vocoder_make_g723_24_encode_sb(); /*! * \brief This block performs g723_24 audio encoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_g723_24_encode_sb : virtual public gr_sync_block diff --git a/gr-vocoder/include/vocoder_g723_40_decode_bs.h b/gr-vocoder/include/vocoder_g723_40_decode_bs.h index ce320a5266..29c8e2a712 100644 --- a/gr-vocoder/include/vocoder_g723_40_decode_bs.h +++ b/gr-vocoder/include/vocoder_g723_40_decode_bs.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_g723_40_decode_bs_sptr vocoder_make_g723_40_decode_bs(); /*! * \brief This block performs g723_40 audio decoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_g723_40_decode_bs : virtual public gr_sync_block diff --git a/gr-vocoder/include/vocoder_g723_40_encode_sb.h b/gr-vocoder/include/vocoder_g723_40_encode_sb.h index eb732e73e2..d9a2427691 100644 --- a/gr-vocoder/include/vocoder_g723_40_encode_sb.h +++ b/gr-vocoder/include/vocoder_g723_40_encode_sb.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_g723_40_encode_sb_sptr vocoder_make_g723_40_encode_sb(); /*! * \brief This block performs g723_40 audio encoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_g723_40_encode_sb : virtual public gr_sync_block diff --git a/gr-vocoder/include/vocoder_gsm_fr_decode_ps.h b/gr-vocoder/include/vocoder_gsm_fr_decode_ps.h index 3af249436c..64e8ca5765 100644 --- a/gr-vocoder/include/vocoder_gsm_fr_decode_ps.h +++ b/gr-vocoder/include/vocoder_gsm_fr_decode_ps.h @@ -33,7 +33,7 @@ VOCODER_API vocoder_gsm_fr_decode_ps_sptr vocoder_make_gsm_fr_decode_ps (); /*! * \brief GSM 06.10 Full Rate Vocoder Decoder - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_gsm_fr_decode_ps : public gr_sync_interpolator { struct gsm_state *d_gsm; diff --git a/gr-vocoder/include/vocoder_gsm_fr_encode_sp.h b/gr-vocoder/include/vocoder_gsm_fr_encode_sp.h index 2b65b5b44e..7d12a4778a 100644 --- a/gr-vocoder/include/vocoder_gsm_fr_encode_sp.h +++ b/gr-vocoder/include/vocoder_gsm_fr_encode_sp.h @@ -33,7 +33,7 @@ VOCODER_API vocoder_gsm_fr_encode_sp_sptr vocoder_make_gsm_fr_encode_sp (); /*! * \brief GSM 06.10 Full Rate Vocoder Encoder - * \ingroup vocoder_blk + * \ingroup audio_blk * * shorts in; 33 byte packets out */ diff --git a/gr-vocoder/include/vocoder_ulaw_decode_bs.h b/gr-vocoder/include/vocoder_ulaw_decode_bs.h index e25e9cdcf5..b6d41af28b 100644 --- a/gr-vocoder/include/vocoder_ulaw_decode_bs.h +++ b/gr-vocoder/include/vocoder_ulaw_decode_bs.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_ulaw_decode_bs_sptr vocoder_make_ulaw_decode_bs(); /*! * \brief This block performs ulaw audio decoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_ulaw_decode_bs : public gr_sync_block diff --git a/gr-vocoder/include/vocoder_ulaw_encode_sb.h b/gr-vocoder/include/vocoder_ulaw_encode_sb.h index 702017d42a..3a4422a384 100644 --- a/gr-vocoder/include/vocoder_ulaw_encode_sb.h +++ b/gr-vocoder/include/vocoder_ulaw_encode_sb.h @@ -35,7 +35,7 @@ VOCODER_API vocoder_ulaw_encode_sb_sptr vocoder_make_ulaw_encode_sb(); /*! * \brief This block performs g.711 ulaw audio encoding. * - * \ingroup vocoder_blk + * \ingroup audio_blk */ class VOCODER_API vocoder_ulaw_encode_sb : public gr_sync_block { diff --git a/gr-vocoder/lib/CMakeLists.txt b/gr-vocoder/lib/CMakeLists.txt index 43a4156d06..e00fd09b8b 100644 --- a/gr-vocoder/lib/CMakeLists.txt +++ b/gr-vocoder/lib/CMakeLists.txt @@ -29,6 +29,9 @@ include_directories( link_directories(${Boost_LIBRARY_DIRS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -51,6 +54,20 @@ list(APPEND gr_vocoder_sources vocoder_ulaw_encode_sb.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-vocoder.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-vocoder.rc + @ONLY) + + list(APPEND gr_uhd_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-vocoder.rc + ) +endif(MSVC) + ######################################################################## # Include subdirs rather to populate to the sources lists. ######################################################################## @@ -61,6 +78,7 @@ GR_INCLUDE_SUBDIRECTORY(gsm) list(APPEND vocoder_libs gnuradio-core ${Boost_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-vocoder SHARED ${gr_vocoder_sources}) diff --git a/gr-vocoder/lib/gnuradio-vocoder.rc.in b/gr-vocoder/lib/gnuradio-vocoder.rc.in new file mode 100644 index 0000000000..c80be446e3 --- /dev/null +++ b/gr-vocoder/lib/gnuradio-vocoder.rc.in @@ -0,0 +1,33 @@ +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-vocoder" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-vocoder.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-vocoder.dll" + VALUE "ProductName", "gnuradio-vocoder" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-wavelet/lib/CMakeLists.txt b/gr-wavelet/lib/CMakeLists.txt index f446adb9c2..2b5ce093d4 100644 --- a/gr-wavelet/lib/CMakeLists.txt +++ b/gr-wavelet/lib/CMakeLists.txt @@ -35,6 +35,9 @@ link_directories(${Boost_LIBRARY_DIRS}) link_directories(${GSL_LIBRARY_DIRS}) add_definitions(${GSL_DEFINITIONS}) +include_directories(${LOG4CPP_INCLUDE_DIRS}) +link_directories(${LOG4CPP_LIBRARY_DIRS}) + ######################################################################## # Setup library ######################################################################## @@ -44,11 +47,26 @@ list(APPEND gr_wavelet_sources wavelet_wvps_ff_impl.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gnuradio-wavelet.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wavelet.rc + @ONLY) + + list(APPEND gr_wavelet_sources + ${CMAKE_CURRENT_BINARY_DIR}/gnuradio-wavelet.rc + ) +endif(MSVC) + list(APPEND wavelet_libs gnuradio-core ${Boost_LIBRARIES} ${WAVELET_LIBRARIES} ${GSL_LIBRARIES} + ${LOG4CPP_LIBRARIES} ) add_library(gnuradio-wavelet SHARED ${gr_wavelet_sources}) diff --git a/gr-wavelet/lib/gnuradio-wavelet.rc.in b/gr-wavelet/lib/gnuradio-wavelet.rc.in new file mode 100644 index 0000000000..7c3c0674f9 --- /dev/null +++ b/gr-wavelet/lib/gnuradio-wavelet.rc.in @@ -0,0 +1,33 @@ +#include <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gnuradio-wavelet" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gnuradio-wavelet.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gnuradio-wavelet.dll" + VALUE "ProductName", "gnuradio-wavelet" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gr-wxgui/grc/notebook.xml b/gr-wxgui/grc/notebook.xml index bb3de51cb3..5f30c06201 100644 --- a/gr-wxgui/grc/notebook.xml +++ b/gr-wxgui/grc/notebook.xml @@ -7,7 +7,7 @@ <block> <name>WX GUI Notebook</name> <key>notebook</key> - <category>WX GUI Widgets</category> + <category>GUI Widgets/WX</category> <import>from grc_gnuradio import wxgui as grc_wxgui</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' self.$(id) = wx.Notebook($(parent).GetWin(), style=$style) diff --git a/gr-wxgui/grc/variable_check_box.xml b/gr-wxgui/grc/variable_check_box.xml index 0c7bd10815..75dae78215 100644 --- a/gr-wxgui/grc/variable_check_box.xml +++ b/gr-wxgui/grc/variable_check_box.xml @@ -8,7 +8,7 @@ <block> <name>WX GUI Check Box</name> <key>variable_check_box</key> - <category>WX GUI Widgets</category> + <category>GUI Widgets/WX</category> <import>from gnuradio.wxgui import forms</import> <var_make>self.$(id) = $(id) = $value</var_make> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' diff --git a/gr-wxgui/grc/variable_chooser.xml b/gr-wxgui/grc/variable_chooser.xml index e16e88c5da..ef75a04337 100644 --- a/gr-wxgui/grc/variable_chooser.xml +++ b/gr-wxgui/grc/variable_chooser.xml @@ -9,7 +9,7 @@ <block> <name>WX GUI Chooser</name> <key>variable_chooser</key> - <category>WX GUI Widgets</category> + <category>GUI Widgets/WX</category> <import>from gnuradio.wxgui import forms</import> <var_make>self.$(id) = $(id) = $value</var_make> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' diff --git a/gr-wxgui/grc/variable_slider.xml b/gr-wxgui/grc/variable_slider.xml index 5e3c175aa4..96c0b5ec70 100644 --- a/gr-wxgui/grc/variable_slider.xml +++ b/gr-wxgui/grc/variable_slider.xml @@ -8,7 +8,7 @@ <block> <name>WX GUI Slider</name> <key>variable_slider</key> - <category>WX GUI Widgets</category> + <category>GUI Widgets/WX</category> <import>from gnuradio.wxgui import forms</import> <var_make>self.$(id) = $(id) = $value</var_make> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' diff --git a/gr-wxgui/grc/variable_static_text.xml b/gr-wxgui/grc/variable_static_text.xml index cd122e76a1..d68b00a1dd 100644 --- a/gr-wxgui/grc/variable_static_text.xml +++ b/gr-wxgui/grc/variable_static_text.xml @@ -8,7 +8,7 @@ <block> <name>WX GUI Static Text</name> <key>variable_static_text</key> - <category>WX GUI Widgets</category> + <category>GUI Widgets/WX</category> <import>from gnuradio.wxgui import forms</import> <var_make>self.$(id) = $(id) = $value</var_make> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' diff --git a/gr-wxgui/grc/variable_text_box.xml b/gr-wxgui/grc/variable_text_box.xml index afff839cfd..a2cf1a8220 100644 --- a/gr-wxgui/grc/variable_text_box.xml +++ b/gr-wxgui/grc/variable_text_box.xml @@ -8,7 +8,7 @@ <block> <name>WX GUI Text Box</name> <key>variable_text_box</key> - <category>WX GUI Widgets</category> + <category>GUI Widgets/WX</category> <import>from gnuradio.wxgui import forms</import> <var_make>self.$(id) = $(id) = $value</var_make> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' diff --git a/gr-wxgui/grc/wxgui_constellationsink2.xml b/gr-wxgui/grc/wxgui_constellationsink2.xml index f9df9d4acd..62cadfc9a2 100644 --- a/gr-wxgui/grc/wxgui_constellationsink2.xml +++ b/gr-wxgui/grc/wxgui_constellationsink2.xml @@ -7,7 +7,7 @@ <block> <name>WX GUI Constellation Sink</name> <key>wxgui_constellationsink2</key> - <category>WX GUI Widgets</category> + <category>Instrumentation/WX</category> <import>from gnuradio.wxgui import constsink_gl</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' constsink_gl.const_sink_c( diff --git a/gr-wxgui/grc/wxgui_fftsink2.xml b/gr-wxgui/grc/wxgui_fftsink2.xml index 74ee5b173e..4a6237143b 100644 --- a/gr-wxgui/grc/wxgui_fftsink2.xml +++ b/gr-wxgui/grc/wxgui_fftsink2.xml @@ -7,7 +7,7 @@ <block> <name>WX GUI FFT Sink</name> <key>wxgui_fftsink2</key> - <category>WX GUI Widgets</category> + <category>Instrumentation/WX</category> <import>from gnuradio import window</import> <import>from gnuradio.wxgui import fftsink2</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' diff --git a/gr-wxgui/grc/wxgui_histosink2.xml b/gr-wxgui/grc/wxgui_histosink2.xml index f4f6a29597..aed7781798 100644 --- a/gr-wxgui/grc/wxgui_histosink2.xml +++ b/gr-wxgui/grc/wxgui_histosink2.xml @@ -7,7 +7,7 @@ <block> <name>WX GUI Histo Sink</name> <key>wxgui_histosink2</key> - <category>WX GUI Widgets</category> + <category>Instrumentation/WX</category> <import>from gnuradio.wxgui import histosink_gl</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' histosink_gl.histo_sink_f( diff --git a/gr-wxgui/grc/wxgui_numbersink2.xml b/gr-wxgui/grc/wxgui_numbersink2.xml index 2559266101..6f93714dba 100644 --- a/gr-wxgui/grc/wxgui_numbersink2.xml +++ b/gr-wxgui/grc/wxgui_numbersink2.xml @@ -7,7 +7,7 @@ <block> <name>WX GUI Number Sink</name> <key>wxgui_numbersink2</key> - <category>WX GUI Widgets</category> + <category>Instrumentation/WX</category> <import>from gnuradio.wxgui import numbersink2</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' numbersink2.$(type.fcn)( diff --git a/gr-wxgui/grc/wxgui_scopesink2.xml b/gr-wxgui/grc/wxgui_scopesink2.xml index dbf983e112..64db47a055 100644 --- a/gr-wxgui/grc/wxgui_scopesink2.xml +++ b/gr-wxgui/grc/wxgui_scopesink2.xml @@ -7,7 +7,7 @@ <block> <name>WX GUI Scope Sink</name> <key>wxgui_scopesink2</key> - <category>WX GUI Widgets</category> + <category>Instrumentation/WX</category> <import>from gnuradio.wxgui import scopesink2</import> <import>from gnuradio import gr</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' diff --git a/gr-wxgui/grc/wxgui_termsink.xml b/gr-wxgui/grc/wxgui_termsink.xml index 3e35c75788..2a7623d9d7 100644 --- a/gr-wxgui/grc/wxgui_termsink.xml +++ b/gr-wxgui/grc/wxgui_termsink.xml @@ -7,7 +7,7 @@ <block> <name>WX GUI Terminal Sink</name> <key>wxgui_termsink</key> - <category>WX GUI Widgets</category> + <category>Instrumentation/WX</category> <import>from gnuradio.wxgui import termsink</import> diff --git a/gr-wxgui/grc/wxgui_waterfallsink2.xml b/gr-wxgui/grc/wxgui_waterfallsink2.xml index 8921e87f9a..94de667e02 100644 --- a/gr-wxgui/grc/wxgui_waterfallsink2.xml +++ b/gr-wxgui/grc/wxgui_waterfallsink2.xml @@ -7,7 +7,7 @@ <block> <name>WX GUI Waterfall Sink</name> <key>wxgui_waterfallsink2</key> - <category>WX GUI Widgets</category> + <category>Instrumentation/WX</category> <import>from gnuradio import window</import> <import>from gnuradio.wxgui import waterfallsink2</import> <make>#set $parent = $notebook() and 'self.%s.GetPage(%s)'%$notebook() or 'self' diff --git a/gr-wxgui/src/python/fftsink_nongl.py b/gr-wxgui/src/python/fftsink_nongl.py index c38abbb22e..473cc424c4 100644 --- a/gr-wxgui/src/python/fftsink_nongl.py +++ b/gr-wxgui/src/python/fftsink_nongl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2003,2004,2005,2006,2007,2009,2010 Free Software Foundation, Inc. +# Copyright 2003-2007,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -99,6 +99,8 @@ class fft_sink_base(object): def _set_n(self): self.one_in_n.set_n(max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + def set_callback(self, callb): + return class fft_sink_f(gr.hier_block2, fft_sink_base): def __init__(self, parent, baseband_freq=0, ref_scale=2.0, diff --git a/gr-wxgui/src/python/waterfallsink_nongl.py b/gr-wxgui/src/python/waterfallsink_nongl.py index 213415c82c..bf77b4b131 100644 --- a/gr-wxgui/src/python/waterfallsink_nongl.py +++ b/gr-wxgui/src/python/waterfallsink_nongl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2003,2004,2005,2007,2008 Free Software Foundation, Inc. +# Copyright 2003-2005,2007,2008 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -71,6 +71,9 @@ class waterfall_sink_base(object): def _set_n(self): self.one_in_n.set_n(max(1, int(self.sample_rate/self.fft_size/self.fft_rate))) + def set_callback(self, callb): + return + class waterfall_sink_f(gr.hier_block2, waterfall_sink_base): def __init__(self, parent, baseband_freq=0, y_per_div=10, ref_level=50, sample_rate=1, fft_size=512, diff --git a/gr_config.h.in b/gr_config.h.in new file mode 100644 index 0000000000..2a2141b3d5 --- /dev/null +++ b/gr_config.h.in @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#ifndef GNURADIO_CONFIG_H +#define GNURADIO_CONFIG_H +#ifndef TRY_SHM_VMCIRCBUF +#cmakedefine TRY_SHM_VMCIRCBUF +#endif +#ifndef GR_PERFORMANCE_COUNTERS +#cmakedefine GR_PERFORMANCE_COUNTERS +#endif +#ifndef ENABLE_GR_LOG +#cmakedefine ENABLE_GR_LOG +#endif +#ifndef HAVE_LOG4CPP +#cmakedefine HAVE_LOG4CPP +#endif + +#endif /* GNURADIO_CONFIG_H */ diff --git a/grc/blocks/blks2_pfb_arb_resampler.xml b/grc/blocks/blks2_pfb_arb_resampler.xml index b58e70f1cb..aef83dd91a 100644 --- a/grc/blocks/blks2_pfb_arb_resampler.xml +++ b/grc/blocks/blks2_pfb_arb_resampler.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Polyphase Resampler</name> + <name>Polyphase Resampler (old)</name> <key>blks2_pfb_arb_resampler_ccf</key> <import>from gnuradio import blks2</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/blks2_pfb_channelizer.xml b/grc/blocks/blks2_pfb_channelizer.xml index 5a93c08664..6184749cd0 100644 --- a/grc/blocks/blks2_pfb_channelizer.xml +++ b/grc/blocks/blks2_pfb_channelizer.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Polyphase Channelizer</name> + <name>Polyphase Channelizer (old)</name> <key>blks2_pfb_channelizer_ccf</key> <import>from gnuradio import blks2</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index dcd6c54483..897e4a14c2 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -7,168 +7,6 @@ <cat> <name></name> <!-- Blank for Root Name --> <cat> - <name>Sources</name> - <block>const_source_x</block> - <block>gr_sig_source_x</block> - <block>gr_noise_source_x</block> - <block>gr_vector_source_x</block> - <block>random_source_x</block> - <block>gr_glfsr_source_x</block> - <block>gr_null_source</block> - <block>gr_file_source</block> - <block>blks2_tcp_source</block> - <block>gr_udp_source</block> - <block>gr_wavfile_source</block> - <block>gr_message_source</block> - <block>gr_message_burst_source</block> - <block>pad_source</block> - <block>virtual_source</block> - </cat> - <cat> - <name>Sinks</name> - <block>gr_vector_sink_x</block> - <block>gr_null_sink</block> - <block>gr_file_sink</block> - <block>blks2_tcp_sink</block> - <block>gr_udp_sink</block> - <block>gr_wavfile_sink</block> - <block>gr_message_sink</block> - <block>pad_sink</block> - <block>virtual_sink</block> - <block>gr_tag_debug</block> - </cat> - <cat> - <name>Message Tools</name> - <block>gr_message_debug</block> - <block>gr_message_strobe</block> - <block>gr_pdu_to_tagged_stream</block> - <block>gr_tagged_stream_to_pdu</block> - <block>gr_tuntap_pdu</block> - <block>gr_socket_pdu</block> - <block>gr_random_pdu</block> - </cat> - <cat> - <name>Operators</name> - <block>gr_add_xx</block> - <block>gr_sub_xx</block> - <block>gr_multiply_xx</block> - <block>gr_divide_xx</block> - <block>gr_nlog10_ff</block> - <block>gr_transcendental</block> - <block>gr_add_const_vxx</block> - <block>gr_multiply_const_vxx</block> - <block>gr_and_const_xx</block> - - <block>gr_not_xx</block> - <block>gr_and_xx</block> - <block>gr_or_xx</block> - <block>gr_xor_xx</block> - - <block>gr_max_xx</block> - <block>gr_argmax_xx</block> - <block>gr_rms_xx</block> - <block>gr_integrate_xx</block> - - <block>gr_conjugate_cc</block> - - <block>gr_fft_vxx</block> - <block>blks2_logpwrfft_x</block> - <block>gr_vector_insert_x</block> - - <block>gr_endian_swap</block> - </cat> - <cat> - <name>Type Conversions</name> - <block>gr_complex_to_arg</block> - <block>gr_complex_to_mag</block> - <block>gr_complex_to_mag_squared</block> - <block>gr_complex_to_real</block> - <block>gr_complex_to_imag</block> - - <block>gr_complex_to_float</block> - <block>gr_float_to_complex</block> - - <block>gr_float_to_int</block> - <block>gr_float_to_short</block> - <block>gr_short_to_float</block> - <block>gr_short_to_char</block> - - <block>gr_int_to_float</block> - - <block>gr_float_to_char</block> - <block>gr_char_to_float</block> - <block>gr_char_to_short</block> - - <block>gr_float_to_uchar</block> - <block>gr_uchar_to_float</block> - - <block>gr_complex_to_interleaved_short</block> - <block>gr_interleaved_short_to_complex</block> - </cat> - <cat> - <name>Stream Conversions</name> - <block>gr_interleave</block> - <block>gr_deinterleave</block> - - <block>gr_streams_to_stream</block> - <block>gr_stream_to_streams</block> - - <block>gr_streams_to_vector</block> - <block>gr_vector_to_streams</block> - - <block>gr_stream_to_vector</block> - <block>gr_vector_to_stream</block> - - <block>blks2_stream_to_vector_decimator</block> - - <block>gr_stream_mux</block> - <block>gr_burst_tagger</block> - </cat> - <cat> - <name>Misc Conversions</name> - <block>gr_unpacked_to_packed_xx</block> - <block>gr_packed_to_unpacked_xx</block> - <block>gr_unpack_k_bits_bb</block> - <block>gr_pack_k_bits_bb</block> - <block>gr_chunks_to_symbols_xx</block> - <block>gr_map_bb</block> - </cat> - <cat> - <name>Synchronizers</name> - <block>gr_pfb_clock_sync_xxx</block> - - <block>gr_mpsk_sync_cc</block> - - <block>gr_pll_carriertracking_cc</block> - <block>gr_pll_freqdet_cf</block> - <block>gr_pll_refout_cc</block> - - <block>gr_pn_correlator_cc</block> - <block>gr_simple_correlator</block> - <block>gr_simple_framer</block> - - <block>blks2_packet_decoder</block> - <block>blks2_packet_encoder</block> - </cat> - <cat> - <name>Level Controls</name> - <block>gr_dpll_bb</block> - <block>gr_peak_detector_xb</block> - <block>gr_peak_detector2_fb</block> - <block>gr_sample_and_hold_xx</block> - - <block>gr_agc_xx</block> - <block>gr_agc2_xx</block> - <block>gr_feedforward_agc_cc</block> - - <block>gr_mute_xx</block> - <block>gr_simple_squelch_cc</block> - <block>blks2_standard_squelch</block> - <block>gr_pwr_squelch_xx</block> - <block>gr_ctcss_squelch_ff</block> - <block>gr_threshold_ff</block> - </cat> - <cat> <name>Filters</name> <!-- FIR convenience filters --> <block>low_pass_filter</block> @@ -176,47 +14,49 @@ <block>band_pass_filter</block> <block>band_reject_filter</block> <block>root_raised_cosine_filter</block> - <!-- Filters that take taps as arguments --> - <block>gr_fir_filter_xxx</block> - <block>gr_interp_fir_filter_xxx</block> - <block>gr_fft_filter_xxx</block> - <block>gr_freq_xlating_fir_filter_xxx</block> - <block>gr_iir_filter_ffd</block> - <block>gr_filter_delay_fc</block> - <block>gr_channel_model</block> <!-- Filter banks --> <block>blks2_synthesis_filterbank</block> <block>blks2_analysis_filterbank</block> - <!-- Polyphase filters --> - <block>blks2_pfb_arb_resampler_ccf</block> - <block>blks2_pfb_channelizer_ccf</block> - <block>gr_pfb_synthesizer_ccf</block> <!-- Other filters --> - <block>gr_single_pole_iir_filter_xx</block> - <block>gr_hilbert_fc</block> - <block>gr_goertzel_fc</block> - <block>gr_rational_resampler_base_xxx</block> <block>blks2_rational_resampler_xxx</block> - <block>gr_fractional_interpolator_xx</block> - <block>gr_keep_one_in_n</block> - <block>gr_keep_m_in_n</block> - <block>gr_moving_average_xx</block> <block>gr_iqcomp_cc</block> - <block>gr_dc_blocker</block> </cat> <cat> - <name>Modulators</name> - <block>gr_vco_f</block> - <block>gr_frequency_modulator_fc</block> - <block>gr_phase_modulator_fc</block> - <block>gr_quadrature_demod_cf</block> - <block>gr_cpfsk_bc</block> + <name>Error Coding</name> + <block>gr_encode_ccsds_27_bb</block> + <block>gr_decode_ccsds_27_fb</block> + </cat> + <cat> + <name>Fourier Analysis</name> + <block>blks2_logpwrfft_x</block> + </cat> + <cat> + <name>Level Controllers</name> + <block>blks2_standard_squelch</block> + </cat> + <cat> + <name>Message Tools</name> + <block>gr_random_pdu</block> + </cat> + <cat> + <name>Misc</name> + <block>pad_source</block> + <block>pad_sink</block> + <block>virtual_source</block> + <block>virtual_sink</block> - <block>gr_diff_phasor_cc</block> + <block>note</block> + <block>import</block> - <block>gr_diff_encoder_bb</block> - <block>gr_diff_decoder_bb</block> + <block>blks2_selector</block> + <block>blks2_valve</block> + <block>blks2_error_rate</block> + <block>xmlrpc_server</block> + <block>xmlrpc_client</block> + </cat> + <cat> + <name>Modulators</name> <block>blks2_wfm_tx</block> <block>blks2_wfm_rcv</block> <block>blks2_wfm_rcv_pll</block> @@ -230,25 +70,23 @@ <block>blks2_fm_preemph</block> </cat> <cat> - <name>Error Correction</name> - <cat> - <name>Trellis</name> - </cat> - - <block>gr_encode_ccsds_27_bb</block> - <block>gr_decode_ccsds_27_fb</block> + <name>Networking Tools</name> + <block>blks2_tcp_source</block> + <block>blks2_tcp_sink</block> </cat> <cat> - <name>Line Coding</name> - <block>gr_scrambler_bb</block> - <block>gr_descrambler_bb</block> - <block>gr_additive_scrambler_bb</block> + <name>Synchronizers</name> + <block>blks2_packet_decoder</block> + <block>blks2_packet_encoder</block> </cat> <cat> - <name>Probes</name> - <block>gr_probe_avg_mag_sqrd_x</block> - <block>gr_probe_density_b</block> - <block>gr_probe_signal_f</block> + <name>Type Converters</name> + <block>blks2_stream_to_vector_decimator</block> + </cat> + <cat> + <name>Waveform Generators</name> + <block>const_source_x</block> + <block>random_source_x</block> </cat> <cat> <name>Variables</name> @@ -257,27 +95,4 @@ <block>variable_function_probe</block> <block>parameter</block> </cat> - <cat> - <name>Misc</name> - <block>note</block> - <block>import</block> - - <block>gr_throttle</block> - <block>gr_delay</block> - <block>gr_repeat</block> - - <block>blks2_selector</block> - <block>blks2_valve</block> - <block>blks2_error_rate</block> - - <block>gr_head</block> - <block>gr_skiphead</block> - - <block>gr_kludge_copy</block> - <block>gr_copy</block> - <block>gr_nop</block> - - <block>xmlrpc_server</block> - <block>xmlrpc_client</block> - </cat> </cat> diff --git a/grc/blocks/gr_add_const_vxx.xml b/grc/blocks/gr_add_const_vxx.xml index 9f1c545ab8..360433cd7b 100644 --- a/grc/blocks/gr_add_const_vxx.xml +++ b/grc/blocks/gr_add_const_vxx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Add Const</name> + <name>Add Const (old)</name> <key>gr_add_const_vxx</key> <import>from gnuradio import gr</import> <make>gr.add_const_v$(type.fcn)($const)</make> diff --git a/grc/blocks/gr_add_xx.xml b/grc/blocks/gr_add_xx.xml index 97ed9283c2..14b8ad16a5 100644 --- a/grc/blocks/gr_add_xx.xml +++ b/grc/blocks/gr_add_xx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Add</name> + <name>Add (old)</name> <key>gr_add_xx</key> <import>from gnuradio import gr</import> <make>gr.add_v$(type.fcn)($vlen)</make> diff --git a/grc/blocks/gr_additive_scrambler_bb.xml b/grc/blocks/gr_additive_scrambler_bb.xml index a15d6eefbe..754303f881 100644 --- a/grc/blocks/gr_additive_scrambler_bb.xml +++ b/grc/blocks/gr_additive_scrambler_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Additive Scrambler</name> + <name>Additive Scrambler (old)</name> <key>gr_additive_scrambler_bb</key> <import>from gnuradio import gr</import> <make>gr.additive_scrambler_bb($mask, $seed, $len, $count)</make> diff --git a/grc/blocks/gr_agc2_xx.xml b/grc/blocks/gr_agc2_xx.xml index 55b20d4e82..54b0f80e8e 100644 --- a/grc/blocks/gr_agc2_xx.xml +++ b/grc/blocks/gr_agc2_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>AGC2</name> + <name>AGC2 (old)</name> <key>gr_agc2_xx</key> <import>from gnuradio import gr</import> <make>gr.agc2_$(type.fcn)($attack_rate, $decay_rate, $reference, $gain, $max_gain)</make> diff --git a/grc/blocks/gr_agc_xx.xml b/grc/blocks/gr_agc_xx.xml index c87d239edd..a63ce5890b 100644 --- a/grc/blocks/gr_agc_xx.xml +++ b/grc/blocks/gr_agc_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>AGC</name> + <name>AGC (old)</name> <key>gr_agc_xx</key> <import>from gnuradio import gr</import> <make>gr.agc_$(type.fcn)($rate, $reference, $gain, $max_gain)</make> diff --git a/grc/blocks/gr_and_const_xx.xml b/grc/blocks/gr_and_const_xx.xml index dc96493111..1e7e6a1c43 100644 --- a/grc/blocks/gr_and_const_xx.xml +++ b/grc/blocks/gr_and_const_xx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>And Const</name> + <name>And Const (old)</name> <key>gr_and_const_xx</key> <import>from gnuradio import gr</import> <make>gr.and_const_$(type.fcn)($const)</make> diff --git a/grc/blocks/gr_and_xx.xml b/grc/blocks/gr_and_xx.xml index 9ed0060906..ffeb872038 100644 --- a/grc/blocks/gr_and_xx.xml +++ b/grc/blocks/gr_and_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>And</name> + <name>And (old)</name> <key>gr_and_xx</key> <import>from gnuradio import gr</import> <make>gr.and_$(type.fcn)()</make> diff --git a/grc/blocks/gr_argmax_xx.xml b/grc/blocks/gr_argmax_xx.xml index 95269292e7..8c6a7ad7a9 100644 --- a/grc/blocks/gr_argmax_xx.xml +++ b/grc/blocks/gr_argmax_xx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Argmax</name> + <name>Argmax (old)</name> <key>gr_argmax_xx</key> <import>from gnuradio import gr</import> <make>gr.argmax_$(type.fcn)($vlen)</make> diff --git a/grc/blocks/gr_burst_tagger.xml b/grc/blocks/gr_burst_tagger.xml index 58c909999a..349b56ac9d 100644 --- a/grc/blocks/gr_burst_tagger.xml +++ b/grc/blocks/gr_burst_tagger.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Burst Tagger</name> + <name>Burst Tagger (old)</name> <key>gr_burst_tagger</key> <import>from gnuradio import gr</import> <make>gr.burst_tagger($type.size) diff --git a/grc/blocks/gr_channel_model.xml b/grc/blocks/gr_channel_model.xml index d0d178d345..d0d5889f56 100644 --- a/grc/blocks/gr_channel_model.xml +++ b/grc/blocks/gr_channel_model.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Channel Model</name> + <name>Channel Model (old)</name> <key>gr_channel_model</key> <import>from gnuradio import gr</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/gr_char_to_float.xml b/grc/blocks/gr_char_to_float.xml index 838b6a203d..282fbd23b2 100644 --- a/grc/blocks/gr_char_to_float.xml +++ b/grc/blocks/gr_char_to_float.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Char To Float</name> + <name>Char To Float (old)</name> <key>gr_char_to_float</key> <import>from gnuradio import gr</import> <make>gr.char_to_float($vlen, $scale)</make> diff --git a/grc/blocks/gr_char_to_short.xml b/grc/blocks/gr_char_to_short.xml index 57261e0845..27b89b0780 100644 --- a/grc/blocks/gr_char_to_short.xml +++ b/grc/blocks/gr_char_to_short.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Char To Short</name> + <name>Char To Short (old)</name> <key>gr_char_to_short</key> <import>from gnuradio import gr</import> <make>gr.char_to_short($vlen)</make> diff --git a/grc/blocks/gr_chunks_to_symbols.xml b/grc/blocks/gr_chunks_to_symbols.xml index e9da38e9a5..60528f7cde 100644 --- a/grc/blocks/gr_chunks_to_symbols.xml +++ b/grc/blocks/gr_chunks_to_symbols.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Chunks to Symbols</name> + <name>Chunks to Symbols (old)</name> <key>gr_chunks_to_symbols_xx</key> <import>from gnuradio import gr</import> <make>gr.chunks_to_symbols_$(in_type.fcn)$(out_type.fcn)($symbol_table, $dimension)</make> diff --git a/grc/blocks/gr_complex_to_arg.xml b/grc/blocks/gr_complex_to_arg.xml index a7bbacd74f..e740ecd3e7 100644 --- a/grc/blocks/gr_complex_to_arg.xml +++ b/grc/blocks/gr_complex_to_arg.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Complex to Arg</name> + <name>Complex to Arg (old)</name> <key>gr_complex_to_arg</key> <import>from gnuradio import gr</import> <make>gr.complex_to_arg($vlen)</make> diff --git a/grc/blocks/gr_complex_to_float.xml b/grc/blocks/gr_complex_to_float.xml index 05681b0b90..4d9ae13610 100644 --- a/grc/blocks/gr_complex_to_float.xml +++ b/grc/blocks/gr_complex_to_float.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Complex To Float</name> + <name>Complex To Float (old)</name> <key>gr_complex_to_float</key> <import>from gnuradio import gr</import> <make>gr.complex_to_float($vlen)</make> diff --git a/grc/blocks/gr_complex_to_imag.xml b/grc/blocks/gr_complex_to_imag.xml index 7c120eedda..1ea5b2ce99 100644 --- a/grc/blocks/gr_complex_to_imag.xml +++ b/grc/blocks/gr_complex_to_imag.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Complex to Imag</name> + <name>Complex to Imag (old)</name> <key>gr_complex_to_imag</key> <import>from gnuradio import gr</import> <make>gr.complex_to_imag($vlen)</make> diff --git a/grc/blocks/gr_complex_to_interleaved_short.xml b/grc/blocks/gr_complex_to_interleaved_short.xml index 5e999599ac..28a503b8b0 100644 --- a/grc/blocks/gr_complex_to_interleaved_short.xml +++ b/grc/blocks/gr_complex_to_interleaved_short.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Complex To IShort</name> + <name>Complex To IShort (old)</name> <key>gr_complex_to_interleaved_short</key> <import>from gnuradio import gr</import> <make>gr.complex_to_interleaved_short()</make> diff --git a/grc/blocks/gr_complex_to_mag.xml b/grc/blocks/gr_complex_to_mag.xml index adc95f2075..d4308cf166 100644 --- a/grc/blocks/gr_complex_to_mag.xml +++ b/grc/blocks/gr_complex_to_mag.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Complex to Mag</name> + <name>Complex to Mag (old)</name> <key>gr_complex_to_mag</key> <import>from gnuradio import gr</import> <make>gr.complex_to_mag($vlen)</make> diff --git a/grc/blocks/gr_complex_to_mag_squared.xml b/grc/blocks/gr_complex_to_mag_squared.xml index cd23bfb5c5..ac8110bac9 100644 --- a/grc/blocks/gr_complex_to_mag_squared.xml +++ b/grc/blocks/gr_complex_to_mag_squared.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Complex to Mag^2</name> + <name>Complex to Mag^2 (old)</name> <key>gr_complex_to_mag_squared</key> <import>from gnuradio import gr</import> <make>gr.complex_to_mag_squared($vlen)</make> diff --git a/grc/blocks/gr_complex_to_real.xml b/grc/blocks/gr_complex_to_real.xml index ae9ec7b142..b0955516c6 100644 --- a/grc/blocks/gr_complex_to_real.xml +++ b/grc/blocks/gr_complex_to_real.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Complex to Real</name> + <name>Complex to Real (old)</name> <key>gr_complex_to_real</key> <import>from gnuradio import gr</import> <make>gr.complex_to_real($vlen)</make> diff --git a/grc/blocks/gr_conjugate_cc.xml b/grc/blocks/gr_conjugate_cc.xml index 0b4deb3472..0f7ded3c69 100644 --- a/grc/blocks/gr_conjugate_cc.xml +++ b/grc/blocks/gr_conjugate_cc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Complex Conjugate</name> + <name>Complex Conjugate (old)</name> <key>gr_conjugate_cc</key> <import>from gnuradio import gr</import> <make>gr.conjugate_cc()</make> diff --git a/grc/blocks/gr_copy.xml b/grc/blocks/gr_copy.xml index 8b12eaca78..fda3e14fca 100644 --- a/grc/blocks/gr_copy.xml +++ b/grc/blocks/gr_copy.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Copy</name> + <name>Copy (old)</name> <key>gr_copy</key> <import>from gnuradio import gr</import> <make>gr.copy($type.size*$vlen) diff --git a/grc/blocks/gr_cpfsk_bc.xml b/grc/blocks/gr_cpfsk_bc.xml index d5549d933f..d4692eaf98 100644 --- a/grc/blocks/gr_cpfsk_bc.xml +++ b/grc/blocks/gr_cpfsk_bc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>CPFSK</name> + <name>CPFSK (old)</name> <key>gr_cpfsk_bc</key> <import>from gnuradio import gr</import> <make>gr.cpfsk_bc($k, $amplitude, $samples_per_symbol)</make> diff --git a/grc/blocks/gr_ctcss_squelch_ff.xml b/grc/blocks/gr_ctcss_squelch_ff.xml index a34c75374c..d248c19993 100644 --- a/grc/blocks/gr_ctcss_squelch_ff.xml +++ b/grc/blocks/gr_ctcss_squelch_ff.xml @@ -27,7 +27,7 @@ ################################################### --> <block> - <name>CTCSS Squelch</name> + <name>CTCSS Squelch (old)</name> <key>gr_ctcss_squelch_ff</key> <import>from gnuradio import gr</import> <make>gr.ctcss_squelch_ff($rate, $freq, $level, $len, $ramp, $gate)</make> diff --git a/grc/blocks/gr_dc_blocker.xml b/grc/blocks/gr_dc_blocker.xml index 05c3420747..a710c1ea08 100644 --- a/grc/blocks/gr_dc_blocker.xml +++ b/grc/blocks/gr_dc_blocker.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>DC Blocker</name> + <name>DC Blocker (old)</name> <key>gr_dc_blocker</key> <import>from gnuradio import gr</import> <make>gr.dc_blocker_$(type)($length, $long_form)</make> diff --git a/grc/blocks/gr_deinterleave.xml b/grc/blocks/gr_deinterleave.xml index a7482978c0..b600cf0262 100644 --- a/grc/blocks/gr_deinterleave.xml +++ b/grc/blocks/gr_deinterleave.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Deinterleave</name> + <name>Deinterleave (old)</name> <key>gr_deinterleave</key> <import>from gnuradio import gr</import> <make>gr.deinterleave($type.size*$vlen)</make> diff --git a/grc/blocks/gr_delay.xml b/grc/blocks/gr_delay.xml index 5cc411a782..fa6715df11 100644 --- a/grc/blocks/gr_delay.xml +++ b/grc/blocks/gr_delay.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Delay</name> + <name>Delay (old)</name> <key>gr_delay</key> <import>from gnuradio import gr</import> <make>gr.delay($type.size*$vlen, $delay)</make> diff --git a/grc/blocks/gr_descrambler_bb.xml b/grc/blocks/gr_descrambler_bb.xml index 5cfbcc203e..cd14b234df 100644 --- a/grc/blocks/gr_descrambler_bb.xml +++ b/grc/blocks/gr_descrambler_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Descrambler</name> + <name>Descrambler (old)</name> <key>gr_descrambler_bb</key> <import>from gnuradio import gr</import> <make>gr.descrambler_bb($mask, $seed, $len)</make> diff --git a/grc/blocks/gr_diff_decoder_bb.xml b/grc/blocks/gr_diff_decoder_bb.xml index ea7cf17343..bfb6e3e120 100644 --- a/grc/blocks/gr_diff_decoder_bb.xml +++ b/grc/blocks/gr_diff_decoder_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Differential Decoder</name> + <name>Differential Decoder (old)</name> <key>gr_diff_decoder_bb</key> <import>from gnuradio import gr</import> <make>gr.diff_decoder_bb($modulus)</make> diff --git a/grc/blocks/gr_diff_encoder_bb.xml b/grc/blocks/gr_diff_encoder_bb.xml index 21241eac22..b589f31361 100644 --- a/grc/blocks/gr_diff_encoder_bb.xml +++ b/grc/blocks/gr_diff_encoder_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Differential Encoder</name> + <name>Differential Encoder (old)</name> <key>gr_diff_encoder_bb</key> <import>from gnuradio import gr</import> <make>gr.diff_encoder_bb($modulus)</make> diff --git a/grc/blocks/gr_diff_phasor_cc.xml b/grc/blocks/gr_diff_phasor_cc.xml index 2b2d7e372c..d7a3445b6c 100644 --- a/grc/blocks/gr_diff_phasor_cc.xml +++ b/grc/blocks/gr_diff_phasor_cc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Differential Phasor</name> + <name>Differential Phasor (old)</name> <key>gr_diff_phasor_cc</key> <import>from gnuradio import gr</import> <make>gr.diff_phasor_cc()</make> diff --git a/grc/blocks/gr_divide_xx.xml b/grc/blocks/gr_divide_xx.xml index 04667bc2ac..5f95515e4b 100644 --- a/grc/blocks/gr_divide_xx.xml +++ b/grc/blocks/gr_divide_xx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Divide</name> + <name>Divide (old)</name> <key>gr_divide_xx</key> <import>from gnuradio import gr</import> <make>gr.divide_$(type.fcn)($vlen)</make> diff --git a/grc/blocks/gr_dpll_bb.xml b/grc/blocks/gr_dpll_bb.xml index 044d398ff1..add6e31930 100644 --- a/grc/blocks/gr_dpll_bb.xml +++ b/grc/blocks/gr_dpll_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Detect Peak</name> + <name>Detect Peak (old)</name> <key>gr_dpll_bb</key> <import>from gnuradio import gr</import> <make>gr.dpll_bb($period, $gain)</make> diff --git a/grc/blocks/gr_endian_swap.xml b/grc/blocks/gr_endian_swap.xml index aa564026cd..f826d42d44 100644 --- a/grc/blocks/gr_endian_swap.xml +++ b/grc/blocks/gr_endian_swap.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Endian Swap</name> + <name>Endian Swap (old)</name> <key>gr_endian_swap</key> <import>from gnuradio import gr</import> <make>gr.endian_swap($type.size)</make> diff --git a/grc/blocks/gr_feedforward_agc_cc.xml b/grc/blocks/gr_feedforward_agc_cc.xml index 24e80953f4..7af013cebb 100644 --- a/grc/blocks/gr_feedforward_agc_cc.xml +++ b/grc/blocks/gr_feedforward_agc_cc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Feed Forward AGC</name> + <name>Feed Forward AGC (old)</name> <key>gr_feedforward_agc_cc</key> <import>from gnuradio import gr</import> <make>gr.feedforward_agc_cc($num_samples, $reference)</make> diff --git a/grc/blocks/gr_fft_filter_xxx.xml b/grc/blocks/gr_fft_filter_xxx.xml index 5b4cd83cca..1147fc099d 100644 --- a/grc/blocks/gr_fft_filter_xxx.xml +++ b/grc/blocks/gr_fft_filter_xxx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>FFT Filter</name> + <name>FFT Filter (old)</name> <key>gr_fft_filter_xxx</key> <import>from gnuradio import gr</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/gr_fft_vxx.xml b/grc/blocks/gr_fft_vxx.xml index 565354e415..3bf7b4f1e1 100644 --- a/grc/blocks/gr_fft_vxx.xml +++ b/grc/blocks/gr_fft_vxx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>FFT</name> + <name>FFT (old)</name> <key>gr_fft_vxx</key> <import>from gnuradio import gr</import> <import>from gnuradio import window</import> diff --git a/grc/blocks/gr_file_sink.xml b/grc/blocks/gr_file_sink.xml index d0a693900f..7399192f1d 100644 --- a/grc/blocks/gr_file_sink.xml +++ b/grc/blocks/gr_file_sink.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>File Sink</name> + <name>File Sink (old)</name> <key>gr_file_sink</key> <import>from gnuradio import gr</import> <make>gr.file_sink($type.size*$vlen, $file) diff --git a/grc/blocks/gr_file_source.xml b/grc/blocks/gr_file_source.xml index 5f0e16b279..0eb2b37b11 100644 --- a/grc/blocks/gr_file_source.xml +++ b/grc/blocks/gr_file_source.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>File Source</name> + <name>File Source (old)</name> <key>gr_file_source</key> <import>from gnuradio import gr</import> <make>gr.file_source($type.size*$vlen, $file, $repeat)</make> diff --git a/grc/blocks/gr_filter_delay_fc.xml b/grc/blocks/gr_filter_delay_fc.xml index 30d65bf825..731eaf395c 100644 --- a/grc/blocks/gr_filter_delay_fc.xml +++ b/grc/blocks/gr_filter_delay_fc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Filter Delay</name> + <name>Filter Delay (old)</name> <key>gr_filter_delay_fc</key> <import>from gnuradio import gr</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/gr_fir_filter_xxx.xml b/grc/blocks/gr_fir_filter_xxx.xml index c4de8f539d..f2dad1dd46 100644 --- a/grc/blocks/gr_fir_filter_xxx.xml +++ b/grc/blocks/gr_fir_filter_xxx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Decimating FIR Filter</name> + <name>Decimating FIR Filter (old)</name> <key>gr_fir_filter_xxx</key> <import>from gnuradio import gr</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/gr_float_to_char.xml b/grc/blocks/gr_float_to_char.xml index 1fa500e3cf..68b12f3847 100644 --- a/grc/blocks/gr_float_to_char.xml +++ b/grc/blocks/gr_float_to_char.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Float To Char</name> + <name>Float To Char (old)</name> <key>gr_float_to_char</key> <import>from gnuradio import gr</import> <make>gr.float_to_char($vlen, $scale)</make> diff --git a/grc/blocks/gr_float_to_complex.xml b/grc/blocks/gr_float_to_complex.xml index a42cff3589..30bc1cd379 100644 --- a/grc/blocks/gr_float_to_complex.xml +++ b/grc/blocks/gr_float_to_complex.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Float To Complex</name> + <name>Float To Complex (old)</name> <key>gr_float_to_complex</key> <import>from gnuradio import gr</import> <make>gr.float_to_complex($vlen)</make> diff --git a/grc/blocks/gr_float_to_int.xml b/grc/blocks/gr_float_to_int.xml index b43c208a5a..3999cab6a7 100644 --- a/grc/blocks/gr_float_to_int.xml +++ b/grc/blocks/gr_float_to_int.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Float To Int</name> + <name>Float To Int (old)</name> <key>gr_float_to_int</key> <import>from gnuradio import gr</import> <make>gr.float_to_int($vlen, $scale)</make> diff --git a/grc/blocks/gr_float_to_short.xml b/grc/blocks/gr_float_to_short.xml index 4f76b8f580..14e4dd2cb3 100644 --- a/grc/blocks/gr_float_to_short.xml +++ b/grc/blocks/gr_float_to_short.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Float To Short</name> + <name>Float To Short (old)</name> <key>gr_float_to_short</key> <import>from gnuradio import gr</import> <make>gr.float_to_short($vlen, $scale)</make> diff --git a/grc/blocks/gr_float_to_uchar.xml b/grc/blocks/gr_float_to_uchar.xml index aa804d7d93..0ff345f0d3 100644 --- a/grc/blocks/gr_float_to_uchar.xml +++ b/grc/blocks/gr_float_to_uchar.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Float To UChar</name> + <name>Float To UChar (old)</name> <key>gr_float_to_uchar</key> <import>from gnuradio import gr</import> <make>gr.float_to_uchar()</make> diff --git a/grc/blocks/gr_fractional_interpolator_xx.xml b/grc/blocks/gr_fractional_interpolator_xx.xml index 8d65ff8bfc..022dcc6a69 100644 --- a/grc/blocks/gr_fractional_interpolator_xx.xml +++ b/grc/blocks/gr_fractional_interpolator_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Fractional Interpolator</name> + <name>Fractional Interpolator (old)</name> <key>gr_fractional_interpolator_xx</key> <import>from gnuradio import gr</import> <make>gr.fractional_interpolator_$(type.fcn)($phase_shift, $interp_ratio)</make> diff --git a/grc/blocks/gr_freq_xlating_fir_filter_xxx.xml b/grc/blocks/gr_freq_xlating_fir_filter_xxx.xml index e3ee66977d..ddbc69ec0d 100644 --- a/grc/blocks/gr_freq_xlating_fir_filter_xxx.xml +++ b/grc/blocks/gr_freq_xlating_fir_filter_xxx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Frequency Xlating FIR Filter</name> + <name>Frequency Xlating FIR Filter (old)</name> <key>gr_freq_xlating_fir_filter_xxx</key> <import>from gnuradio import gr</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/gr_frequency_modulator_fc.xml b/grc/blocks/gr_frequency_modulator_fc.xml index d5f8fcfe35..d8da95b29f 100644 --- a/grc/blocks/gr_frequency_modulator_fc.xml +++ b/grc/blocks/gr_frequency_modulator_fc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Frequency Mod</name> + <name>Frequency Mod (old)</name> <key>gr_frequency_modulator_fc</key> <import>from gnuradio import gr</import> <make>gr.frequency_modulator_fc($sensitivity)</make> diff --git a/grc/blocks/gr_glfsr_source_x.xml b/grc/blocks/gr_glfsr_source_x.xml index 88fb66797b..4aa4b5d774 100644 --- a/grc/blocks/gr_glfsr_source_x.xml +++ b/grc/blocks/gr_glfsr_source_x.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>GLFSR Source</name> + <name>GLFSR Source (old)</name> <key>gr_glfsr_source_x</key> <import>from gnuradio import gr</import> <make>gr.glfsr_source_$(type.fcn)($degree, $repeat, $mask, $seed)</make> diff --git a/grc/blocks/gr_goertzel_fc.xml b/grc/blocks/gr_goertzel_fc.xml index f27d9582ea..5907bd0304 100644 --- a/grc/blocks/gr_goertzel_fc.xml +++ b/grc/blocks/gr_goertzel_fc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Goertzel</name> + <name>Goertzel (old)</name> <key>gr_goertzel_fc</key> <import>from gnuradio import gr</import> <make>gr.goertzel_fc($rate, $len, $freq)</make> diff --git a/grc/blocks/gr_head.xml b/grc/blocks/gr_head.xml index e5ff7f6aad..cb93071676 100644 --- a/grc/blocks/gr_head.xml +++ b/grc/blocks/gr_head.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Head</name> + <name>Head (old)</name> <key>gr_head</key> <import>from gnuradio import gr</import> <make>gr.head($type.size*$vlen, $num_items)</make> diff --git a/grc/blocks/gr_hilbert_fc.xml b/grc/blocks/gr_hilbert_fc.xml index 165e8da237..08dbe6386f 100644 --- a/grc/blocks/gr_hilbert_fc.xml +++ b/grc/blocks/gr_hilbert_fc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Hilbert</name> + <name>Hilbert (old)</name> <key>gr_hilbert_fc</key> <import>from gnuradio import gr</import> <make>gr.hilbert_fc($num_taps)</make> diff --git a/grc/blocks/gr_iir_filter_ffd.xml b/grc/blocks/gr_iir_filter_ffd.xml index 9799150e80..ffad5be165 100644 --- a/grc/blocks/gr_iir_filter_ffd.xml +++ b/grc/blocks/gr_iir_filter_ffd.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>IIR Filter</name> + <name>IIR Filter (old)</name> <key>gr_iir_filter_ffd</key> <import>from gnuradio import gr</import> <make>gr.iir_filter_ffd($fftaps, $fbtaps)</make> diff --git a/grc/blocks/gr_int_to_float.xml b/grc/blocks/gr_int_to_float.xml index 7430fec728..3a68282c40 100644 --- a/grc/blocks/gr_int_to_float.xml +++ b/grc/blocks/gr_int_to_float.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Int To Float</name> + <name>Int To Float (old)</name> <key>gr_int_to_float</key> <import>from gnuradio import gr</import> <make>gr.int_to_float($vlen, $scale)</make> diff --git a/grc/blocks/gr_integrate_xx.xml b/grc/blocks/gr_integrate_xx.xml index d0ebd42e2d..e3adb1d976 100644 --- a/grc/blocks/gr_integrate_xx.xml +++ b/grc/blocks/gr_integrate_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Integrate</name> + <name>Integrate (old)</name> <key>gr_integrate_xx</key> <import>from gnuradio import gr</import> <make>gr.integrate_$(type.fcn)($decim)</make> diff --git a/grc/blocks/gr_interleave.xml b/grc/blocks/gr_interleave.xml index 3db16ab552..6d3920d685 100644 --- a/grc/blocks/gr_interleave.xml +++ b/grc/blocks/gr_interleave.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Interleave</name> + <name>Interleave (old)</name> <key>gr_interleave</key> <import>from gnuradio import gr</import> <make>gr.interleave($type.size*$vlen)</make> diff --git a/grc/blocks/gr_interleaved_short_to_complex.xml b/grc/blocks/gr_interleaved_short_to_complex.xml index e3023e499d..edfe82f120 100644 --- a/grc/blocks/gr_interleaved_short_to_complex.xml +++ b/grc/blocks/gr_interleaved_short_to_complex.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>IShort To Complex</name> + <name>IShort To Complex (old)</name> <key>gr_interleaved_short_to_complex</key> <import>from gnuradio import gr</import> <make>gr.interleaved_short_to_complex()</make> diff --git a/grc/blocks/gr_interp_fir_filter_xxx.xml b/grc/blocks/gr_interp_fir_filter_xxx.xml index 55375ae021..66046d6081 100644 --- a/grc/blocks/gr_interp_fir_filter_xxx.xml +++ b/grc/blocks/gr_interp_fir_filter_xxx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Interpolating FIR Filter</name> + <name>Interpolating FIR Filter (old)</name> <key>gr_interp_fir_filter_xxx</key> <import>from gnuradio import gr</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/gr_keep_m_in_n.xml b/grc/blocks/gr_keep_m_in_n.xml index 35a1561764..34717cf5dc 100644 --- a/grc/blocks/gr_keep_m_in_n.xml +++ b/grc/blocks/gr_keep_m_in_n.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Keep M in N</name> + <name>Keep M in N (old)</name> <key>gr_keep_m_in_n</key> <import>from gnuradio import gr</import> <make>gr.keep_m_in_n($type.size, $m, $n, $offset)</make> diff --git a/grc/blocks/gr_keep_one_in_n.xml b/grc/blocks/gr_keep_one_in_n.xml index 21595b7559..dc382c30ef 100644 --- a/grc/blocks/gr_keep_one_in_n.xml +++ b/grc/blocks/gr_keep_one_in_n.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Keep 1 in N</name> + <name>Keep 1 in N (old)</name> <key>gr_keep_one_in_n</key> <import>from gnuradio import gr</import> <make>gr.keep_one_in_n($type.size*$vlen, $n)</make> diff --git a/grc/blocks/gr_kludge_copy.xml b/grc/blocks/gr_kludge_copy.xml index 8058b082db..fca60fcca0 100644 --- a/grc/blocks/gr_kludge_copy.xml +++ b/grc/blocks/gr_kludge_copy.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Kludge Copy</name> + <name>Kludge Copy (old)</name> <key>gr_kludge_copy</key> <import>from gnuradio import gr</import> <make>gr.kludge_copy($type.size*$vlen)</make> diff --git a/grc/blocks/gr_map_bb.xml b/grc/blocks/gr_map_bb.xml index 20d6bd2b44..a9964bff34 100644 --- a/grc/blocks/gr_map_bb.xml +++ b/grc/blocks/gr_map_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Map</name> + <name>Map (old)</name> <key>gr_map_bb</key> <import>from gnuradio import gr</import> <make>gr.map_bb($map)</make> diff --git a/grc/blocks/gr_max_xx.xml b/grc/blocks/gr_max_xx.xml index 9dbbe60e56..5718e8b5ba 100644 --- a/grc/blocks/gr_max_xx.xml +++ b/grc/blocks/gr_max_xx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Max</name> + <name>Max (old)</name> <key>gr_max_xx</key> <import>from gnuradio import gr</import> <make>gr.max_$(type.fcn)($vlen)</make> diff --git a/grc/blocks/gr_message_burst_source.xml b/grc/blocks/gr_message_burst_source.xml index e835d2a2ce..0ec3adee14 100644 --- a/grc/blocks/gr_message_burst_source.xml +++ b/grc/blocks/gr_message_burst_source.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Message Burst Source</name> + <name>Message Burst Source (old)</name> <key>gr_message_burst_source</key> <import>from gnuradio import gr</import> <make>gr.message_burst_source($type.size*$vlen, $(id)_msgq_in)</make> diff --git a/grc/blocks/gr_message_debug.xml b/grc/blocks/gr_message_debug.xml index 964f957569..5aec5d0683 100644 --- a/grc/blocks/gr_message_debug.xml +++ b/grc/blocks/gr_message_debug.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Message Debug</name> + <name>Message Debug (old)</name> <key>gr_message_debug</key> <import>from gnuradio import gr</import> <make>gr.message_debug()</make> diff --git a/grc/blocks/gr_message_sink.xml b/grc/blocks/gr_message_sink.xml index 18e92adb97..3929d5a66d 100644 --- a/grc/blocks/gr_message_sink.xml +++ b/grc/blocks/gr_message_sink.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Message Sink</name> + <name>Message Sink (old)</name> <key>gr_message_sink</key> <import>from gnuradio import gr</import> <make>gr.message_sink($type.size*$vlen, $(id)_msgq_out, $dont_block)</make> diff --git a/grc/blocks/gr_message_source.xml b/grc/blocks/gr_message_source.xml index 72367b21b0..b54e83c1c2 100644 --- a/grc/blocks/gr_message_source.xml +++ b/grc/blocks/gr_message_source.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Message Source</name> + <name>Message Source (old)</name> <key>gr_message_source</key> <import>from gnuradio import gr</import> <make>gr.message_source($type.size*$vlen, $(id)_msgq_in)</make> diff --git a/grc/blocks/gr_message_strobe.xml b/grc/blocks/gr_message_strobe.xml index 60a7724dfc..596f84d8ba 100644 --- a/grc/blocks/gr_message_strobe.xml +++ b/grc/blocks/gr_message_strobe.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Message Strobe</name> + <name>Message Strobe (old)</name> <key>gr_message_strobe</key> <import>from gnuradio import gr</import> <import>from gruel import pmt</import> diff --git a/grc/blocks/gr_moving_average_xx.xml b/grc/blocks/gr_moving_average_xx.xml index b70943c785..6334f53c56 100644 --- a/grc/blocks/gr_moving_average_xx.xml +++ b/grc/blocks/gr_moving_average_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Moving Average</name> + <name>Moving Average (old)</name> <key>gr_moving_average_xx</key> <import>from gnuradio import gr</import> <make>gr.moving_average_$(type.fcn)($length, $scale, $max_iter)</make> diff --git a/grc/blocks/gr_mpsk_sync_cc.xml b/grc/blocks/gr_mpsk_sync_cc.xml deleted file mode 100644 index fd08f8340b..0000000000 --- a/grc/blocks/gr_mpsk_sync_cc.xml +++ /dev/null @@ -1,69 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##MPSK Sync -################################################### - --> -<block> - <name>MPSK Sync</name> - <key>gr_mpsk_sync_cc</key> - <import>from gnuradio import gr</import> - <make>gr.mpsk_sync_cc($alpha, $beta, $max_freq, $min_freq, $ref_phase, $omega, $gain_omega, $mu, $gain_mu)</make> - <callback>set_mu($mu)</callback> - <callback>set_gain_mu($gain_mu)</callback> - <callback>set_omega($omega)</callback> - <callback>set_gain_omega($gain_omega)</callback> - <param> - <name>Alpha</name> - <key>alpha</key> - <type>real</type> - </param> - <param> - <name>Beta</name> - <key>beta</key> - <type>real</type> - </param> - <param> - <name>Max Freq</name> - <key>max_freq</key> - <type>real</type> - </param> - <param> - <name>Min Freq</name> - <key>min_freq</key> - <type>real</type> - </param> - <param> - <name>Reference Phase</name> - <key>ref_phase</key> - <type>real</type> - </param> - <param> - <name>Omega</name> - <key>omega</key> - <type>real</type> - </param> - <param> - <name>Gain Omega</name> - <key>gain_omega</key> - <type>real</type> - </param> - <param> - <name>Mu</name> - <key>mu</key> - <type>real</type> - </param> - <param> - <name>Gain Mu</name> - <key>gain_mu</key> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_multiply_const_vxx.xml b/grc/blocks/gr_multiply_const_vxx.xml index 1309d75cde..98c69fa31a 100644 --- a/grc/blocks/gr_multiply_const_vxx.xml +++ b/grc/blocks/gr_multiply_const_vxx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Multiply Const</name> + <name>Multiply Const (old)</name> <key>gr_multiply_const_vxx</key> <import>from gnuradio import gr</import> <make>gr.multiply_const_v$(type.fcn)($const)</make> diff --git a/grc/blocks/gr_multiply_xx.xml b/grc/blocks/gr_multiply_xx.xml index 60f65c2745..4ff9e1c5ef 100644 --- a/grc/blocks/gr_multiply_xx.xml +++ b/grc/blocks/gr_multiply_xx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Multiply</name> + <name>Multiply (old)</name> <key>gr_multiply_xx</key> <import>from gnuradio import gr</import> <make>gr.multiply_v$(type.fcn)($vlen)</make> diff --git a/grc/blocks/gr_mute_xx.xml b/grc/blocks/gr_mute_xx.xml index a9a857c6a1..0ca593b854 100644 --- a/grc/blocks/gr_mute_xx.xml +++ b/grc/blocks/gr_mute_xx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Mute</name> + <name>Mute (old)</name> <key>gr_mute_xx</key> <import>from gnuradio import gr</import> <make>gr.mute_$(type.fcn)(bool($mute))</make> diff --git a/grc/blocks/gr_nlog10_ff.xml b/grc/blocks/gr_nlog10_ff.xml index 9350782368..4d4efe4ce9 100644 --- a/grc/blocks/gr_nlog10_ff.xml +++ b/grc/blocks/gr_nlog10_ff.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Log10</name> + <name>Log10 (old)</name> <key>gr_nlog10_ff</key> <import>from gnuradio import gr</import> <make>gr.nlog10_ff($n, $vlen, $k)</make> diff --git a/grc/blocks/gr_noise_source_x.xml b/grc/blocks/gr_noise_source_x.xml index 72daaaa209..c37127977b 100644 --- a/grc/blocks/gr_noise_source_x.xml +++ b/grc/blocks/gr_noise_source_x.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Noise Source</name> + <name>Noise Source (old)</name> <key>gr_noise_source_x</key> <import>from gnuradio import gr</import> <make>gr.noise_source_$(type.fcn)($noise_type, $amp, $seed)</make> diff --git a/grc/blocks/gr_nop.xml b/grc/blocks/gr_nop.xml index bd884d6b8b..65f24b0ade 100644 --- a/grc/blocks/gr_nop.xml +++ b/grc/blocks/gr_nop.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Nop</name> + <name>Nop (old)</name> <key>gr_nop</key> <import>from gnuradio import gr</import> <make>gr.nop($type.size*$vlen)</make> diff --git a/grc/blocks/gr_not_xx.xml b/grc/blocks/gr_not_xx.xml index 1c2bb87096..0dcbbf8e6c 100644 --- a/grc/blocks/gr_not_xx.xml +++ b/grc/blocks/gr_not_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Not</name> + <name>Not (old)</name> <key>gr_not_xx</key> <import>from gnuradio import gr</import> <make>gr.not_$(type.fcn)()</make> diff --git a/grc/blocks/gr_null_sink.xml b/grc/blocks/gr_null_sink.xml index ed106b4950..497f3a85ab 100644 --- a/grc/blocks/gr_null_sink.xml +++ b/grc/blocks/gr_null_sink.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Null Sink</name> + <name>Null Sink (old)</name> <key>gr_null_sink</key> <import>from gnuradio import gr</import> <make>gr.null_sink($type.size*$vlen)</make> diff --git a/grc/blocks/gr_null_source.xml b/grc/blocks/gr_null_source.xml index 6132eae3cb..42d5b2edbb 100644 --- a/grc/blocks/gr_null_source.xml +++ b/grc/blocks/gr_null_source.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Null Source</name> + <name>Null Source (old)</name> <key>gr_null_source</key> <import>from gnuradio import gr</import> <make>gr.null_source($type.size*$vlen)</make> diff --git a/grc/blocks/gr_or_xx.xml b/grc/blocks/gr_or_xx.xml index b374aa22ab..4d29dc1495 100644 --- a/grc/blocks/gr_or_xx.xml +++ b/grc/blocks/gr_or_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Or</name> + <name>Or (old)</name> <key>gr_or_xx</key> <import>from gnuradio import gr</import> <make>gr.or_$(type.fcn)()</make> diff --git a/grc/blocks/gr_pack_k_bits_bb.xml b/grc/blocks/gr_pack_k_bits_bb.xml index 34e64a5d96..958e308c6a 100644 --- a/grc/blocks/gr_pack_k_bits_bb.xml +++ b/grc/blocks/gr_pack_k_bits_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Pack K Bits</name> + <name>Pack K Bits (old)</name> <key>gr_pack_k_bits_bb</key> <import>from gnuradio import gr</import> <make>gr.pack_k_bits_bb($k)</make> diff --git a/grc/blocks/gr_packed_to_unpacked_xx.xml b/grc/blocks/gr_packed_to_unpacked_xx.xml index c1477dd9ca..ffba71cce3 100644 --- a/grc/blocks/gr_packed_to_unpacked_xx.xml +++ b/grc/blocks/gr_packed_to_unpacked_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Packed to Unpacked</name> + <name>Packed to Unpacked (old)</name> <key>gr_packed_to_unpacked_xx</key> <import>from gnuradio import gr</import> <make>gr.packed_to_unpacked_$(type.fcn)($bits_per_chunk, $endianness)</make> diff --git a/grc/blocks/gr_pdu_to_tagged_stream.xml b/grc/blocks/gr_pdu_to_tagged_stream.xml index 6d2fea97e7..2d4a517129 100644 --- a/grc/blocks/gr_pdu_to_tagged_stream.xml +++ b/grc/blocks/gr_pdu_to_tagged_stream.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>PDU to Tagged Stream</name> + <name>PDU to Tagged Stream (old)</name> <key>gr_pdu_to_tagged_stream</key> <import>from gnuradio import gr</import> <make>gr.pdu_to_tagged_stream($type.tv)</make> diff --git a/grc/blocks/gr_peak_detector2_fb.xml b/grc/blocks/gr_peak_detector2_fb.xml index 128c6244f7..998d97a9d2 100644 --- a/grc/blocks/gr_peak_detector2_fb.xml +++ b/grc/blocks/gr_peak_detector2_fb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Peak Detector2</name> + <name>Peak Detector2 (old)</name> <key>gr_peak_detector2_fb</key> <import>from gnuradio import gr</import> <make>gr.peak_detector2_fb($threshold_factor_rise, $look_ahead, $alpha)</make> diff --git a/grc/blocks/gr_peak_detector_xb.xml b/grc/blocks/gr_peak_detector_xb.xml index 394b0697f8..a789b372b9 100644 --- a/grc/blocks/gr_peak_detector_xb.xml +++ b/grc/blocks/gr_peak_detector_xb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Peak Detector</name> + <name>Peak Detector (old)</name> <key>gr_peak_detector_xb</key> <import>from gnuradio import gr</import> <make>gr.peak_detector_$(type.fcn)b($threshold_factor_rise, $threshold_factor_fall, $look_ahead, $alpha)</make> diff --git a/grc/blocks/gr_pfb_clock_sync.xml b/grc/blocks/gr_pfb_clock_sync.xml index 3e5e65d127..d469e065d6 100644 --- a/grc/blocks/gr_pfb_clock_sync.xml +++ b/grc/blocks/gr_pfb_clock_sync.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Polyphase Clock Sync</name> + <name>Polyphase Clock Sync (old)</name> <key>gr_pfb_clock_sync_xxx</key> <import>from gnuradio import gr</import> <make>gr.pfb_clock_sync_$(type)($sps, $alpha, $taps, $filter_size, $init_phase, $max_dev, $osps) diff --git a/grc/blocks/gr_pfb_synthesizer.xml b/grc/blocks/gr_pfb_synthesizer.xml index 49e5cb0321..b78d345586 100644 --- a/grc/blocks/gr_pfb_synthesizer.xml +++ b/grc/blocks/gr_pfb_synthesizer.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Polyphase Synthesizer</name> + <name>Polyphase Synthesizer (old)</name> <key>gr_pfb_synthesizer_ccf</key> <import>from gnuradio import gr</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/gr_phase_modulator_fc.xml b/grc/blocks/gr_phase_modulator_fc.xml index 758c50863b..bcde45a635 100644 --- a/grc/blocks/gr_phase_modulator_fc.xml +++ b/grc/blocks/gr_phase_modulator_fc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Phase Mod</name> + <name>Phase Mod (old)</name> <key>gr_phase_modulator_fc</key> <import>from gnuradio import gr</import> <make>gr.phase_modulator_fc($sensitivity)</make> diff --git a/grc/blocks/gr_pll_carriertracking_cc.xml b/grc/blocks/gr_pll_carriertracking_cc.xml index 27e6732482..cb90b197d6 100644 --- a/grc/blocks/gr_pll_carriertracking_cc.xml +++ b/grc/blocks/gr_pll_carriertracking_cc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>PLL Carrier Tracking</name> + <name>PLL Carrier Tracking (old)</name> <key>gr_pll_carriertracking_cc</key> <import>from gnuradio import gr</import> <make>gr.pll_carriertracking_cc($w, $max_freq, $min_freq)</make> diff --git a/grc/blocks/gr_pll_freqdet_cf.xml b/grc/blocks/gr_pll_freqdet_cf.xml index d6e4694f00..b73cd6ff10 100644 --- a/grc/blocks/gr_pll_freqdet_cf.xml +++ b/grc/blocks/gr_pll_freqdet_cf.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>PLL Freq Det</name> + <name>PLL Freq Det (old)</name> <key>gr_pll_freqdet_cf</key> <import>from gnuradio import gr</import> <make>gr.pll_freqdet_cf($w, $max_freq, $min_freq)</make> diff --git a/grc/blocks/gr_pll_refout_cc.xml b/grc/blocks/gr_pll_refout_cc.xml index b231ddd19a..a92bf2c3ed 100644 --- a/grc/blocks/gr_pll_refout_cc.xml +++ b/grc/blocks/gr_pll_refout_cc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>PLL Ref Out</name> + <name>PLL Ref Out (old)</name> <key>gr_pll_refout_cc</key> <import>from gnuradio import gr</import> <make>gr.pll_refout_cc($w, $max_freq, $min_freq)</make> diff --git a/grc/blocks/gr_pn_correlator_cc.xml b/grc/blocks/gr_pn_correlator_cc.xml index 094f46cdfd..54d512a28b 100644 --- a/grc/blocks/gr_pn_correlator_cc.xml +++ b/grc/blocks/gr_pn_correlator_cc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>PN Correlator</name> + <name>PN Correlator (old)</name> <key>gr_pn_correlator_cc</key> <import>from gnuradio import gr</import> <make>gr.pn_correlator_cc($degree, $mask, $seed)</make> diff --git a/grc/blocks/gr_probe_avg_mag_sqrd_x.xml b/grc/blocks/gr_probe_avg_mag_sqrd_x.xml index 6bf706ae1c..65fd0e763b 100644 --- a/grc/blocks/gr_probe_avg_mag_sqrd_x.xml +++ b/grc/blocks/gr_probe_avg_mag_sqrd_x.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Probe Avg Mag^2</name> + <name>Probe Avg Mag^2 (old)</name> <key>gr_probe_avg_mag_sqrd_x</key> <import>from gnuradio import gr</import> <make>gr.probe_avg_mag_sqrd_$(type)($threshold, $alpha)</make> diff --git a/grc/blocks/gr_probe_density_b.xml b/grc/blocks/gr_probe_density_b.xml index 3a91256aa5..84dec814a5 100644 --- a/grc/blocks/gr_probe_density_b.xml +++ b/grc/blocks/gr_probe_density_b.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Probe Density</name> + <name>Probe Density (old)</name> <key>gr_probe_density_b</key> <import>from gnuradio import gr</import> <make>gr.probe_density_b($alpha)</make> diff --git a/grc/blocks/gr_probe_signal_f.xml b/grc/blocks/gr_probe_signal_f.xml index 5c38e816f0..731da6f49b 100644 --- a/grc/blocks/gr_probe_signal_f.xml +++ b/grc/blocks/gr_probe_signal_f.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Probe Signal</name> + <name>Probe Signal (old)</name> <key>gr_probe_signal_f</key> <import>from gnuradio import gr</import> <make>gr.probe_signal_f()</make> diff --git a/grc/blocks/gr_pwr_squelch_xx.xml b/grc/blocks/gr_pwr_squelch_xx.xml index 08d6211770..12bd337ebd 100644 --- a/grc/blocks/gr_pwr_squelch_xx.xml +++ b/grc/blocks/gr_pwr_squelch_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Power Squelch</name> + <name>Power Squelch (old)</name> <key>gr_pwr_squelch_xx</key> <import>from gnuradio import gr</import> <make>gr.pwr_squelch_$(type.fcn)($threshold, $alpha, $ramp, $gate)</make> diff --git a/grc/blocks/gr_quadrature_demod_cf.xml b/grc/blocks/gr_quadrature_demod_cf.xml index fad0b3879c..ed0f326a4b 100644 --- a/grc/blocks/gr_quadrature_demod_cf.xml +++ b/grc/blocks/gr_quadrature_demod_cf.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Quadrature Demod</name> + <name>Quadrature Demod (old)</name> <key>gr_quadrature_demod_cf</key> <import>from gnuradio import gr</import> <make>gr.quadrature_demod_cf($gain)</make> diff --git a/grc/blocks/gr_rational_resampler_base_xxx.xml b/grc/blocks/gr_rational_resampler_base_xxx.xml index 4b7720173c..7bdf0577e0 100644 --- a/grc/blocks/gr_rational_resampler_base_xxx.xml +++ b/grc/blocks/gr_rational_resampler_base_xxx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Rational Resampler Base</name> + <name>Rational Resampler Base (old)</name> <key>gr_rational_resampler_base_xxx</key> <import>from gnuradio import gr</import> <import>from gnuradio.gr import firdes</import> diff --git a/grc/blocks/gr_repeat.xml b/grc/blocks/gr_repeat.xml index ba652a4d79..6555e391fa 100644 --- a/grc/blocks/gr_repeat.xml +++ b/grc/blocks/gr_repeat.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Repeat</name> + <name>Repeat (old)</name> <key>gr_repeat</key> <import>from gnuradio import gr</import> <make>gr.repeat($type.size*$vlen, $interp)</make> diff --git a/grc/blocks/gr_rms_xx.xml b/grc/blocks/gr_rms_xx.xml index 1e0947192b..e878871e8e 100644 --- a/grc/blocks/gr_rms_xx.xml +++ b/grc/blocks/gr_rms_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>RMS</name> + <name>RMS (old)</name> <key>gr_rms_xx</key> <import>from gnuradio import gr</import> <make>gr.rms_$(type.fcn)f($alpha)</make> diff --git a/grc/blocks/gr_sample_and_hold_xx.xml b/grc/blocks/gr_sample_and_hold_xx.xml index 2a036c3fdb..82400cf84e 100644 --- a/grc/blocks/gr_sample_and_hold_xx.xml +++ b/grc/blocks/gr_sample_and_hold_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Sample and Hold</name> + <name>Sample and Hold (old)</name> <key>gr_sample_and_hold_xx</key> <import>from gnuradio import gr</import> <make>gr.sample_and_hold_$(type.fcn)()</make> diff --git a/grc/blocks/gr_scrambler_bb.xml b/grc/blocks/gr_scrambler_bb.xml index d079c4015f..17270eafc1 100644 --- a/grc/blocks/gr_scrambler_bb.xml +++ b/grc/blocks/gr_scrambler_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Scrambler</name> + <name>Scrambler (old)</name> <key>gr_scrambler_bb</key> <import>from gnuradio import gr</import> <make>gr.scrambler_bb($mask, $seed, $len)</make> diff --git a/grc/blocks/gr_short_to_char.xml b/grc/blocks/gr_short_to_char.xml index 9c41da84ef..2021eaf838 100644 --- a/grc/blocks/gr_short_to_char.xml +++ b/grc/blocks/gr_short_to_char.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Short To Char</name> + <name>Short To Char (old)</name> <key>gr_short_to_char</key> <import>from gnuradio import gr</import> <make>gr.short_to_char($vlen)</make> diff --git a/grc/blocks/gr_short_to_float.xml b/grc/blocks/gr_short_to_float.xml index 529f8c78cb..bf3657b638 100644 --- a/grc/blocks/gr_short_to_float.xml +++ b/grc/blocks/gr_short_to_float.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Short To Float</name> + <name>Short To Float (old)</name> <key>gr_short_to_float</key> <import>from gnuradio import gr</import> <make>gr.short_to_float($vlen, $scale)</make> diff --git a/grc/blocks/gr_sig_source_x.xml b/grc/blocks/gr_sig_source_x.xml index 644cf52d0c..fcb36b9a1c 100644 --- a/grc/blocks/gr_sig_source_x.xml +++ b/grc/blocks/gr_sig_source_x.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Signal Source</name> + <name>Signal Source (old)</name> <key>gr_sig_source_x</key> <import>from gnuradio import gr</import> <make>gr.sig_source_$(type.fcn)($samp_rate, $waveform, $freq, $amp, $offset)</make> diff --git a/grc/blocks/gr_simple_correlator.xml b/grc/blocks/gr_simple_correlator.xml index 820523a644..c6c076b8be 100644 --- a/grc/blocks/gr_simple_correlator.xml +++ b/grc/blocks/gr_simple_correlator.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Simple Correlator</name> + <name>Simple Correlator (old)</name> <key>gr_simple_correlator</key> <import>from gnuradio import gr</import> <make>gr.simple_correlator($payload_bytesize)</make> diff --git a/grc/blocks/gr_simple_framer.xml b/grc/blocks/gr_simple_framer.xml index 2a0295c417..aa194d7ab2 100644 --- a/grc/blocks/gr_simple_framer.xml +++ b/grc/blocks/gr_simple_framer.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Simple Framer</name> + <name>Simple Framer (old)</name> <key>gr_simple_framer</key> <import>from gnuradio import gr</import> <make>gr.simple_framer($payload_bytesize)</make> diff --git a/grc/blocks/gr_simple_squelch_cc.xml b/grc/blocks/gr_simple_squelch_cc.xml index 5c0727f5f8..1be4b662e6 100644 --- a/grc/blocks/gr_simple_squelch_cc.xml +++ b/grc/blocks/gr_simple_squelch_cc.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Simple Squelch</name> + <name>Simple Squelch (old)</name> <key>gr_simple_squelch_cc</key> <import>from gnuradio import gr</import> <make>gr.simple_squelch_cc($threshold, $alpha)</make> diff --git a/grc/blocks/gr_single_pole_iir_filter_xx.xml b/grc/blocks/gr_single_pole_iir_filter_xx.xml index 50cf4a82d8..8d8b455a46 100644 --- a/grc/blocks/gr_single_pole_iir_filter_xx.xml +++ b/grc/blocks/gr_single_pole_iir_filter_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Single Pole IIR Filter</name> + <name>Single Pole IIR Filter (old)</name> <key>gr_single_pole_iir_filter_xx</key> <import>from gnuradio import gr</import> <make>gr.single_pole_iir_filter_$(type.fcn)($alpha, $vlen)</make> diff --git a/grc/blocks/gr_skiphead.xml b/grc/blocks/gr_skiphead.xml index 0849ad2981..be1c0c7655 100644 --- a/grc/blocks/gr_skiphead.xml +++ b/grc/blocks/gr_skiphead.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Skip Head</name> + <name>Skip Head (old)</name> <key>gr_skiphead</key> <import>from gnuradio import gr</import> <make>gr.skiphead($type.size*$vlen, $num_items)</make> diff --git a/grc/blocks/gr_socket_pdu.xml b/grc/blocks/gr_socket_pdu.xml index a175c36991..020958d739 100644 --- a/grc/blocks/gr_socket_pdu.xml +++ b/grc/blocks/gr_socket_pdu.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Socket PDU</name> + <name>Socket PDU (old)</name> <key>gr_socket_pdu</key> <import>from gnuradio import gr</import> <make>gr.socket_pdu($type, $host, $port, $mtu)</make> diff --git a/grc/blocks/gr_stream_mux.xml b/grc/blocks/gr_stream_mux.xml index 8efe7b6555..53ce31bc96 100644 --- a/grc/blocks/gr_stream_mux.xml +++ b/grc/blocks/gr_stream_mux.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Stream Mux</name> + <name>Stream Mux (old)</name> <key>gr_stream_mux</key> <import>from gnuradio import gr</import> <make>gr.stream_mux($type.size*$vlen, $lengths)</make> diff --git a/grc/blocks/gr_stream_to_streams.xml b/grc/blocks/gr_stream_to_streams.xml index 82542b8d44..7f99aae1b6 100644 --- a/grc/blocks/gr_stream_to_streams.xml +++ b/grc/blocks/gr_stream_to_streams.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Stream to Streams</name> + <name>Stream to Streams (old)</name> <key>gr_stream_to_streams</key> <import>from gnuradio import gr</import> <make>gr.stream_to_streams($type.size*$vlen, $num_streams)</make> diff --git a/grc/blocks/gr_stream_to_vector.xml b/grc/blocks/gr_stream_to_vector.xml index 296d786f8c..83d20607cc 100644 --- a/grc/blocks/gr_stream_to_vector.xml +++ b/grc/blocks/gr_stream_to_vector.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Stream to Vector</name> + <name>Stream to Vector (old)</name> <key>gr_stream_to_vector</key> <import>from gnuradio import gr</import> <make>gr.stream_to_vector($type.size*$vlen, $num_items)</make> diff --git a/grc/blocks/gr_streams_to_stream.xml b/grc/blocks/gr_streams_to_stream.xml index 7aadd7eef2..eed8be6d37 100644 --- a/grc/blocks/gr_streams_to_stream.xml +++ b/grc/blocks/gr_streams_to_stream.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Streams to Stream</name> + <name>Streams to Stream (old)</name> <key>gr_streams_to_stream</key> <import>from gnuradio import gr</import> <make>gr.streams_to_stream($type.size*$vlen, $num_streams)</make> diff --git a/grc/blocks/gr_streams_to_vector.xml b/grc/blocks/gr_streams_to_vector.xml index 4ecdcb2d41..944a511996 100644 --- a/grc/blocks/gr_streams_to_vector.xml +++ b/grc/blocks/gr_streams_to_vector.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Streams to Vector</name> + <name>Streams to Vector (old)</name> <key>gr_streams_to_vector</key> <import>from gnuradio import gr</import> <make>gr.streams_to_vector($type.size*$vlen, $num_streams)</make> diff --git a/grc/blocks/gr_sub_xx.xml b/grc/blocks/gr_sub_xx.xml index c677747da9..54c7883aff 100644 --- a/grc/blocks/gr_sub_xx.xml +++ b/grc/blocks/gr_sub_xx.xml @@ -6,7 +6,7 @@ ################################################### --> <block> - <name>Subtract</name> + <name>Subtract (old)</name> <key>gr_sub_xx</key> <import>from gnuradio import gr</import> <make>gr.sub_$(type.fcn)($vlen)</make> diff --git a/grc/blocks/gr_tag_debug.xml b/grc/blocks/gr_tag_debug.xml index 4af7729be9..c3ac63735c 100644 --- a/grc/blocks/gr_tag_debug.xml +++ b/grc/blocks/gr_tag_debug.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Tag Debug</name> + <name>Tag Debug (old)</name> <key>gr_tag_debug</key> <import>from gnuradio import gr</import> <make>gr.tag_debug($type.size*$vlen, $name)</make> diff --git a/grc/blocks/gr_tagged_stream_to_pdu.xml b/grc/blocks/gr_tagged_stream_to_pdu.xml index e2f754c9eb..75b4ab5d1f 100644 --- a/grc/blocks/gr_tagged_stream_to_pdu.xml +++ b/grc/blocks/gr_tagged_stream_to_pdu.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Tagged Stream to PDU</name> + <name>Tagged Stream to PDU (old)</name> <key>gr_tagged_stream_to_pdu</key> <import>from gnuradio import gr</import> <make>gr.tagged_stream_to_pdu($type.tv)</make> diff --git a/grc/blocks/gr_threshold_ff.xml b/grc/blocks/gr_threshold_ff.xml index 740ce5794c..12650297a7 100644 --- a/grc/blocks/gr_threshold_ff.xml +++ b/grc/blocks/gr_threshold_ff.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Threshold</name> + <name>Threshold (old)</name> <key>gr_threshold_ff</key> <import>from gnuradio import gr</import> <make>gr.threshold_ff($low, $high, $init)</make> diff --git a/grc/blocks/gr_throttle.xml b/grc/blocks/gr_throttle.xml index e3a5a2ba19..978aa29662 100644 --- a/grc/blocks/gr_throttle.xml +++ b/grc/blocks/gr_throttle.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Throttle</name> + <name>Throttle (old)</name> <key>gr_throttle</key> <throttle>1</throttle> <import>from gnuradio import gr</import> diff --git a/grc/blocks/gr_transcendental.xml b/grc/blocks/gr_transcendental.xml index eede447f98..2862fb17e6 100644 --- a/grc/blocks/gr_transcendental.xml +++ b/grc/blocks/gr_transcendental.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Transcendental</name> + <name>Transcendental (old)</name> <key>gr_transcendental</key> <import>from gnuradio import gr</import> <make>gr.transcendental($name, "$type")</make> diff --git a/grc/blocks/gr_tuntap_pdu.xml b/grc/blocks/gr_tuntap_pdu.xml index f169345afa..eff31219fb 100644 --- a/grc/blocks/gr_tuntap_pdu.xml +++ b/grc/blocks/gr_tuntap_pdu.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>TunTap PDU</name> + <name>TunTap PDU (old)</name> <key>gr_tuntap_pdu</key> <import>from gnuradio import gr</import> <make>gr.tuntap_pdu($ifn, $mtu)</make> diff --git a/grc/blocks/gr_uchar_to_float.xml b/grc/blocks/gr_uchar_to_float.xml index 0a5f7f96a5..8e270681e0 100644 --- a/grc/blocks/gr_uchar_to_float.xml +++ b/grc/blocks/gr_uchar_to_float.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>UChar To Float</name> + <name>UChar To Float (old)</name> <key>gr_uchar_to_float</key> <import>from gnuradio import gr</import> <make>gr.uchar_to_float()</make> diff --git a/grc/blocks/gr_udp_sink.xml b/grc/blocks/gr_udp_sink.xml index 45f81075f0..006848048a 100644 --- a/grc/blocks/gr_udp_sink.xml +++ b/grc/blocks/gr_udp_sink.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>UDP Sink</name> + <name>UDP Sink (old)</name> <key>gr_udp_sink</key> <import>from gnuradio import gr</import> <make>gr.udp_sink($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make> diff --git a/grc/blocks/gr_udp_source.xml b/grc/blocks/gr_udp_source.xml index a1b961651f..f74d58e74e 100644 --- a/grc/blocks/gr_udp_source.xml +++ b/grc/blocks/gr_udp_source.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>UDP Source</name> + <name>UDP Source (old)</name> <key>gr_udp_source</key> <import>from gnuradio import gr</import> <make>gr.udp_source($type.size*$vlen, $ipaddr, $port, $psize, $eof, $wait)</make> diff --git a/grc/blocks/gr_unpack_k_bits_bb.xml b/grc/blocks/gr_unpack_k_bits_bb.xml index 9917644ab5..ce6f19b072 100644 --- a/grc/blocks/gr_unpack_k_bits_bb.xml +++ b/grc/blocks/gr_unpack_k_bits_bb.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Unpack K Bits</name> + <name>Unpack K Bits (old)</name> <key>gr_unpack_k_bits_bb</key> <import>from gnuradio import gr</import> <make>gr.unpack_k_bits_bb($k)</make> diff --git a/grc/blocks/gr_unpacked_to_packed_xx.xml b/grc/blocks/gr_unpacked_to_packed_xx.xml index 427c800824..3366d65055 100644 --- a/grc/blocks/gr_unpacked_to_packed_xx.xml +++ b/grc/blocks/gr_unpacked_to_packed_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Unpacked to Packed</name> + <name>Unpacked to Packed (old)</name> <key>gr_unpacked_to_packed_xx</key> <import>from gnuradio import gr</import> <make>gr.unpacked_to_packed_$(type.fcn)($bits_per_chunk, $endianness)</make> diff --git a/grc/blocks/gr_vco_f.xml b/grc/blocks/gr_vco_f.xml index e49c539651..196f56a2d0 100644 --- a/grc/blocks/gr_vco_f.xml +++ b/grc/blocks/gr_vco_f.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>VCO</name> + <name>VCO (old)</name> <key>gr_vco_f</key> <import>from gnuradio import gr</import> <make>gr.vco_f($samp_rate, $sensitivity, $amplitude)</make> diff --git a/grc/blocks/gr_vector_insert_x.xml b/grc/blocks/gr_vector_insert_x.xml index f9ce1f6544..8d8e869381 100644 --- a/grc/blocks/gr_vector_insert_x.xml +++ b/grc/blocks/gr_vector_insert_x.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Vector Insert</name> + <name>Vector Insert (old)</name> <key>gr_vector_insert_x</key> <import>from gnuradio import gr</import> <make>gr.vector_insert_$(type.fcn)($vector, $period, $offset)</make> diff --git a/grc/blocks/gr_vector_sink_x.xml b/grc/blocks/gr_vector_sink_x.xml index 3bd998698f..e71480565f 100644 --- a/grc/blocks/gr_vector_sink_x.xml +++ b/grc/blocks/gr_vector_sink_x.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Vector Sink</name> + <name>Vector Sink (old)</name> <key>gr_vector_sink_x</key> <import>from gnuradio import gr</import> <make>gr.vector_sink_$(type.fcn)($vlen)</make> diff --git a/grc/blocks/gr_vector_source_x.xml b/grc/blocks/gr_vector_source_x.xml index 7a6a3aeff8..7d00feb16a 100644 --- a/grc/blocks/gr_vector_source_x.xml +++ b/grc/blocks/gr_vector_source_x.xml @@ -5,10 +5,11 @@ ################################################### --> <block> - <name>Vector Source</name> + <name>Vector Source (old)</name> <key>gr_vector_source_x</key> <import>from gnuradio import gr</import> - <make>gr.vector_source_$(type.fcn)($vector, $repeat, $vlen)</make> + <make>gr.vector_source_$(type.fcn)($vector, $repeat, $vlen, $tags) + </make> <param> <name>Output Type</name> <key>type</key> @@ -47,8 +48,14 @@ <param> <name>Vector</name> <key>vector</key> - <value>0, 0, 0</value> - <type>$type.vec_type</type> + <value>[0, 0, 0]</value> + <type>raw</type> + </param> + <param> + <name>Tags</name> + <key>tags</key> + <value>[]</value> + <type>raw</type> </param> <param> <name>Repeat</name> diff --git a/grc/blocks/gr_vector_to_stream.xml b/grc/blocks/gr_vector_to_stream.xml index d56d340677..1091116fab 100644 --- a/grc/blocks/gr_vector_to_stream.xml +++ b/grc/blocks/gr_vector_to_stream.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Vector to Stream</name> + <name>Vector to Stream (old)</name> <key>gr_vector_to_stream</key> <import>from gnuradio import gr</import> <make>gr.vector_to_stream($type.size*$vlen, $num_items)</make> diff --git a/grc/blocks/gr_vector_to_streams.xml b/grc/blocks/gr_vector_to_streams.xml index 86cb56813c..29ee2d1321 100644 --- a/grc/blocks/gr_vector_to_streams.xml +++ b/grc/blocks/gr_vector_to_streams.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Vector to Streams</name> + <name>Vector to Streams (old)</name> <key>gr_vector_to_streams</key> <import>from gnuradio import gr</import> <make>gr.vector_to_streams($type.size*$vlen, $num_streams)</make> diff --git a/grc/blocks/gr_wavfile_sink.xml b/grc/blocks/gr_wavfile_sink.xml index 651e16cb6b..a1c002a3f9 100644 --- a/grc/blocks/gr_wavfile_sink.xml +++ b/grc/blocks/gr_wavfile_sink.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Wav File Sink</name> + <name>Wav File Sink (old)</name> <key>gr_wavfile_sink</key> <import>from gnuradio import gr</import> <make>gr.wavfile_sink($file, $nchan, $samp_rate, $bits_per_sample)</make> diff --git a/grc/blocks/gr_wavfile_source.xml b/grc/blocks/gr_wavfile_source.xml index 433bb0af21..80c864e12a 100644 --- a/grc/blocks/gr_wavfile_source.xml +++ b/grc/blocks/gr_wavfile_source.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Wav File Source</name> + <name>Wav File Source (old)</name> <key>gr_wavfile_source</key> <import>from gnuradio import gr</import> <make>gr.wavfile_source($file, $repeat)</make> diff --git a/grc/blocks/gr_xor_xx.xml b/grc/blocks/gr_xor_xx.xml index c014cbe577..79d97b0f5b 100644 --- a/grc/blocks/gr_xor_xx.xml +++ b/grc/blocks/gr_xor_xx.xml @@ -5,7 +5,7 @@ ################################################### --> <block> - <name>Xor</name> + <name>Xor (old)</name> <key>gr_xor_xx</key> <import>from gnuradio import gr</import> <make>gr.xor_$(type.fcn)()</make> diff --git a/grc/gui/BlockTreeWindow.py b/grc/gui/BlockTreeWindow.py index 62afb62056..945be10a50 100644 --- a/grc/gui/BlockTreeWindow.py +++ b/grc/gui/BlockTreeWindow.py @@ -70,6 +70,8 @@ class BlockTreeWindow(gtk.VBox): #try to enable the tooltips (available in pygtk 2.12 and above) try: self.treeview.set_tooltip_column(DOC_INDEX) except: pass + #setup sort order + column.set_sort_column_id(0) #setup drag and drop self.treeview.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, DND_TARGETS, gtk.gdk.ACTION_COPY) self.treeview.connect('drag-data-get', self._handle_drag_get_data) diff --git a/grc/python/Param.py b/grc/python/Param.py index 2caca48024..3236441a86 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -94,8 +94,8 @@ class Param(_Param, _GUIParam): def get_types(self): return ( 'raw', 'enum', - 'complex', 'real', 'int', - 'complex_vector', 'real_vector', 'int_vector', + 'complex', 'real', 'float', 'int', + 'complex_vector', 'real_vector', 'float_vector', 'int_vector', 'hex', 'string', 'bool', 'file_open', 'file_save', 'id', 'stream_id', @@ -174,10 +174,12 @@ class Param(_Param, _GUIParam): #number types 'complex': Constants.COMPLEX_COLOR_SPEC, 'real': Constants.FLOAT_COLOR_SPEC, + 'float': Constants.FLOAT_COLOR_SPEC, 'int': Constants.INT_COLOR_SPEC, #vector types 'complex_vector': Constants.COMPLEX_VECTOR_COLOR_SPEC, 'real_vector': Constants.FLOAT_VECTOR_COLOR_SPEC, + 'float_vector': Constants.FLOAT_VECTOR_COLOR_SPEC, 'int_vector': Constants.INT_VECTOR_COLOR_SPEC, #special 'bool': Constants.INT_COLOR_SPEC, @@ -257,7 +259,7 @@ class Param(_Param, _GUIParam): ######################### # Numeric Types ######################### - elif t in ('raw', 'complex', 'real', 'int', 'hex', 'bool'): + elif t in ('raw', 'complex', 'real', 'float', 'int', 'hex', 'bool'): #raise exception if python cannot evaluate this value try: e = self.get_parent().get_parent().evaluate(v) except Exception, e: raise Exception, 'Value "%s" cannot be evaluated:\n%s'%(v, e) @@ -267,9 +269,9 @@ class Param(_Param, _GUIParam): if not isinstance(e, COMPLEX_TYPES): raise Exception, 'Expression "%s" is invalid for type complex.'%str(e) return e - elif t == 'real': + elif t == 'real' or t == 'float': if not isinstance(e, REAL_TYPES): - raise Exception, 'Expression "%s" is invalid for type real.'%str(e) + raise Exception, 'Expression "%s" is invalid for type float.'%str(e) return e elif t == 'int': if not isinstance(e, INT_TYPES): @@ -284,7 +286,7 @@ class Param(_Param, _GUIParam): ######################### # Numeric Vector Types ######################### - elif t in ('complex_vector', 'real_vector', 'int_vector'): + elif t in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): if not v: v = '()' #turn a blank string into an empty list, so it will eval #raise exception if python cannot evaluate this value try: e = self.get_parent().get_parent().evaluate(v) @@ -297,12 +299,12 @@ class Param(_Param, _GUIParam): if not all([isinstance(ei, COMPLEX_TYPES) for ei in e]): raise Exception, 'Expression "%s" is invalid for type complex vector.'%str(e) return e - elif t == 'real_vector': + elif t == 'real_vector' or t == 'float_vector': if not isinstance(e, VECTOR_TYPES): self._lisitify_flag = True e = [e] if not all([isinstance(ei, REAL_TYPES) for ei in e]): - raise Exception, 'Expression "%s" is invalid for type real vector.'%str(e) + raise Exception, 'Expression "%s" is invalid for type float vector.'%str(e) return e elif t == 'int_vector': if not isinstance(e, VECTOR_TYPES): @@ -443,7 +445,7 @@ class Param(_Param, _GUIParam): if not self._init: self.evaluate() if self._stringify_flag: return '"%s"'%v.replace('"', '\"') else: return v - elif t in ('complex_vector', 'real_vector', 'int_vector'): #vector types + elif t in ('complex_vector', 'real_vector', 'float_vector', 'int_vector'): #vector types if not self._init: self.evaluate() if self._lisitify_flag: return '(%s, )'%v else: return '(%s)'%v diff --git a/gruel/src/lib/CMakeLists.txt b/gruel/src/lib/CMakeLists.txt index 717d566601..a08e67d99a 100644 --- a/gruel/src/lib/CMakeLists.txt +++ b/gruel/src/lib/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2010-2011 Free Software Foundation, Inc. +# Copyright 2010-2011,2013 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -81,6 +81,20 @@ list(APPEND gruel_sources thread_group.cc ) +#Add Windows DLL resource file if using MSVC +if(MSVC) + include(${CMAKE_SOURCE_DIR}/cmake/Modules/GrVersion.cmake) + + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/gruel.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/gruel.rc + @ONLY) + + list(APPEND gruel_sources + ${CMAKE_CURRENT_BINARY_DIR}/gruel.rc + ) +endif(MSVC) + list(APPEND gruel_libs ${Boost_LIBRARIES}) if(HAVE_PTHREAD_SETSCHEDPARAM) diff --git a/gruel/src/lib/gruel.rc.in b/gruel/src/lib/gruel.rc.in new file mode 100644 index 0000000000..906b7d61c2 --- /dev/null +++ b/gruel/src/lib/gruel.rc.in @@ -0,0 +1,55 @@ +/* -*- c++ -*- */ +/* + * 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 <afxres.h> + +VS_VERSION_INFO VERSIONINFO + FILEVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + PRODUCTVERSION @MAJOR_VERSION@,@API_COMPAT@,@RC_MINOR_VERSION@,@RC_MAINT_VERSION@ + FILEFLAGSMASK 0x3fL +#ifndef NDEBUG + FILEFLAGS 0x0L +#else + FILEFLAGS 0x1L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE VFT2_DRV_INSTALLABLE + BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "gruel" + VALUE "FileVersion", "@VERSION@" + VALUE "InternalName", "gruel.dll" + VALUE "LegalCopyright", "Licensed under GPLv3 or any later version" + VALUE "OriginalFilename", "gruel.dll" + VALUE "ProductName", "gruel" + VALUE "ProductVersion", "@VERSION@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END + END diff --git a/gruel/src/lib/pmt/CMakeLists.txt b/gruel/src/lib/pmt/CMakeLists.txt index 6ea616e107..04a0983106 100644 --- a/gruel/src/lib/pmt/CMakeLists.txt +++ b/gruel/src/lib/pmt/CMakeLists.txt @@ -53,8 +53,6 @@ ADD_FILE_DEPENDENCIES( ${PMT_SERIAL_TAGS_H} ) -add_custom_target(pmt_generated DEPENDS ${PMT_SERIAL_TAGS_H}) - ######################################################################## # Generate other pmt stuff ######################################################################## @@ -87,3 +85,6 @@ list(APPEND test_gruel_sources ${CMAKE_CURRENT_SOURCE_DIR}/qa_pmt_prims.cc ${CMAKE_CURRENT_SOURCE_DIR}/qa_pmt.cc ) + +add_custom_target(pmt_generated + DEPENDS ${PMT_SERIAL_TAGS_H} ${CMAKE_CURRENT_BINARY_DIR}/pmt_unv_int.h) |